github.com/hustcat/docker@v1.3.3-0.20160314103604-901c67a8eeab/hack/make/release-deb (about) 1 #!/bin/bash 2 set -e 3 4 # This script creates the apt repos for the .deb files generated by hack/make/build-deb 5 # 6 # The following can then be used as apt sources: 7 # deb http://apt.dockerproject.org/repo $distro-$release $version 8 # 9 # For example: 10 # deb http://apt.dockerproject.org/repo ubuntu-trusty main 11 # deb http://apt.dockerproject.org/repo ubuntu-trusty testing 12 # deb http://apt.dockerproject.org/repo debian-wheezy experimental 13 # deb http://apt.dockerproject.org/repo debian-jessie main 14 # 15 # ... and so on and so forth for the builds created by hack/make/build-deb 16 17 source "$(dirname "$BASH_SOURCE")/.detect-daemon-osarch" 18 19 : ${DOCKER_RELEASE_DIR:=$DEST} 20 : ${GPG_KEYID:=releasedocker} 21 APTDIR=$DOCKER_RELEASE_DIR/apt/repo 22 23 # setup the apt repo (if it does not exist) 24 mkdir -p "$APTDIR/conf" "$APTDIR/db" 25 26 # supported arches/sections 27 arches=( amd64 i386 ) 28 29 # Preserve existing components but don't add any non-existing ones 30 for component in main testing experimental ; do 31 if ls "$APTDIR/dists/*/$component" >/dev/null 2>&1 ; then 32 components+=( $component ) 33 fi 34 done 35 36 # set the component for the version being released 37 component="main" 38 39 if [[ "$VERSION" == *-rc* ]]; then 40 component="testing" 41 fi 42 43 if [ "$DOCKER_EXPERIMENTAL" ] || [[ "$VERSION" == *-dev ]] || [ -n "$(git status --porcelain)" ]; then 44 component="experimental" 45 fi 46 47 # Make sure our component is in the list of components 48 if [[ ! "${components[*]}" =~ $component ]] ; then 49 components+=( $component ) 50 fi 51 52 # create apt-ftparchive file on every run. This is essential to avoid 53 # using stale versions of the config file that could cause unnecessary 54 # refreshing of bits for EOL-ed releases. 55 cat <<-EOF > "$APTDIR/conf/apt-ftparchive.conf" 56 Dir { 57 ArchiveDir "${APTDIR}"; 58 CacheDir "${APTDIR}/db"; 59 }; 60 61 Default { 62 Packages::Compress ". gzip bzip2"; 63 Sources::Compress ". gzip bzip2"; 64 Contents::Compress ". gzip bzip2"; 65 }; 66 67 TreeDefault { 68 BinCacheDB "packages-\$(SECTION)-\$(ARCH).db"; 69 Directory "pool/\$(SECTION)"; 70 Packages "\$(DIST)/\$(SECTION)/binary-\$(ARCH)/Packages"; 71 SrcDirectory "pool/\$(SECTION)"; 72 Sources "\$(DIST)/\$(SECTION)/source/Sources"; 73 Contents "\$(DIST)/\$(SECTION)/Contents-\$(ARCH)"; 74 FileList "$APTDIR/\$(DIST)/\$(SECTION)/filelist"; 75 }; 76 EOF 77 78 for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do 79 version="$(basename "$dir")" 80 suite="${version//debootstrap-}" 81 82 cat <<-EOF 83 Tree "dists/${suite}" { 84 Sections "${components[*]}"; 85 Architectures "${arches[*]}"; 86 } 87 88 EOF 89 done >> "$APTDIR/conf/apt-ftparchive.conf" 90 91 if [ ! -f "$APTDIR/conf/docker-engine-release.conf" ]; then 92 cat <<-EOF > "$APTDIR/conf/docker-engine-release.conf" 93 APT::FTPArchive::Release::Origin "Docker"; 94 APT::FTPArchive::Release::Components "${components[*]}"; 95 APT::FTPArchive::Release::Label "Docker APT Repository"; 96 APT::FTPArchive::Release::Architectures "${arches[*]}"; 97 EOF 98 fi 99 100 # release the debs 101 for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do 102 version="$(basename "$dir")" 103 codename="${version//debootstrap-}" 104 105 DEBFILE=( "bundles/$VERSION/build-deb/$version/docker-engine"*.deb ) 106 107 # if we have a $GPG_PASSPHRASE we may as well 108 # dpkg-sign before copying the deb into the pool 109 if [ ! -z "$GPG_PASSPHRASE" ]; then 110 dpkg-sig -g "--no-tty --passphrase '$GPG_PASSPHRASE'" \ 111 -k "$GPG_KEYID" --sign builder "${DEBFILE[@]}" 112 fi 113 114 # add the deb for each component for the distro version into the pool 115 mkdir -p "$APTDIR/pool/$component/d/docker-engine/" 116 cp "${DEBFILE[@]}" "$APTDIR/pool/$component/d/docker-engine/" 117 118 # update the filelist for this codename/component 119 mkdir -p "$APTDIR/dists/$codename/$component" 120 find "$APTDIR/pool/$component" \ 121 -name *~${codename#*-}*.deb > "$APTDIR/dists/$codename/$component/filelist" 122 done 123 124 # run the apt-ftparchive commands so we can have pinning 125 apt-ftparchive generate "$APTDIR/conf/apt-ftparchive.conf" 126 127 for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do 128 version="$(basename "$dir")" 129 codename="${version//debootstrap-}" 130 131 apt-ftparchive \ 132 -o "APT::FTPArchive::Release::Codename=$codename" \ 133 -o "APT::FTPArchive::Release::Suite=$codename" \ 134 -c "$APTDIR/conf/docker-engine-release.conf" \ 135 release \ 136 "$APTDIR/dists/$codename" > "$APTDIR/dists/$codename/Release" 137 138 for arch in "${arches[@]}"; do 139 mkdir -p "$APTDIR/dists/$codename/$component/binary-$arch" 140 apt-ftparchive \ 141 -o "APT::FTPArchive::Release::Codename=$codename" \ 142 -o "APT::FTPArchive::Release::Suite=$codename" \ 143 -o "APT::FTPArchive::Release::Component=$component" \ 144 -o "APT::FTPArchive::Release::Architecture=$arch" \ 145 -c "$APTDIR/conf/docker-engine-release.conf" \ 146 release \ 147 "$APTDIR/dists/$codename/$component/binary-$arch" > "$APTDIR/dists/$codename/$component/binary-$arch/Release" 148 done 149 done