github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/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")/.integration-daemon-start" 18 source "$(dirname "$BASH_SOURCE")/.detect-daemon-osarch" 19 20 : ${DOCKER_RELEASE_DIR:=$DEST} 21 : ${GPG_KEYID:=releasedocker} 22 APTDIR=$DOCKER_RELEASE_DIR/apt/repo 23 24 # setup the apt repo (if it does not exist) 25 mkdir -p "$APTDIR/conf" "$APTDIR/db" "$APTDIR/dists" 26 27 # supported arches/sections 28 arches=( amd64 i386 ) 29 30 # Preserve existing components but don't add any non-existing ones 31 for component in main testing experimental ; do 32 exists=$(find "$APTDIR/dists" -mindepth 2 -maxdepth 2 -type d -name "$component" -print -quit) 33 if [ -n "$exists" ] ; then 34 components+=( $component ) 35 fi 36 done 37 38 # set the component for the version being released 39 component="main" 40 41 if [[ "$VERSION" == *-rc* ]]; then 42 component="testing" 43 fi 44 45 if [ "$DOCKER_EXPERIMENTAL" ] || [[ "$VERSION" == *-dev ]] || [ -n "$(git status --porcelain)" ]; then 46 component="experimental" 47 fi 48 49 # Make sure our component is in the list of components 50 if [[ ! "${components[*]}" =~ $component ]] ; then 51 components+=( $component ) 52 fi 53 54 # create apt-ftparchive file on every run. This is essential to avoid 55 # using stale versions of the config file that could cause unnecessary 56 # refreshing of bits for EOL-ed releases. 57 cat <<-EOF > "$APTDIR/conf/apt-ftparchive.conf" 58 Dir { 59 ArchiveDir "${APTDIR}"; 60 CacheDir "${APTDIR}/db"; 61 }; 62 63 Default { 64 Packages::Compress ". gzip bzip2"; 65 Sources::Compress ". gzip bzip2"; 66 Contents::Compress ". gzip bzip2"; 67 }; 68 69 TreeDefault { 70 BinCacheDB "packages-\$(SECTION)-\$(ARCH).db"; 71 Directory "pool/\$(SECTION)"; 72 Packages "\$(DIST)/\$(SECTION)/binary-\$(ARCH)/Packages"; 73 SrcDirectory "pool/\$(SECTION)"; 74 Sources "\$(DIST)/\$(SECTION)/source/Sources"; 75 Contents "\$(DIST)/\$(SECTION)/Contents-\$(ARCH)"; 76 FileList "$APTDIR/\$(DIST)/\$(SECTION)/filelist"; 77 }; 78 EOF 79 80 for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do 81 version="$(basename "$dir")" 82 suite="${version//debootstrap-}" 83 84 cat <<-EOF 85 Tree "dists/${suite}" { 86 Sections "${components[*]}"; 87 Architectures "${arches[*]}"; 88 } 89 90 EOF 91 done >> "$APTDIR/conf/apt-ftparchive.conf" 92 93 cat <<-EOF > "$APTDIR/conf/docker-engine-release.conf" 94 APT::FTPArchive::Release::Origin "Docker"; 95 APT::FTPArchive::Release::Components "${components[*]}"; 96 APT::FTPArchive::Release::Label "Docker APT Repository"; 97 APT::FTPArchive::Release::Architectures "${arches[*]}"; 98 EOF 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 tempdir="$(mktemp -d /tmp/tmp-docker-release-deb.XXXXXXXX)" 106 DEBFILE=( "bundles/$VERSION/build-deb/$version/docker-engine"*.deb ) 107 108 # add the deb for each component for the distro version into the 109 # pool (if it is not there already) 110 mkdir -p "$APTDIR/pool/$component/d/docker-engine/" 111 for deb in ${DEBFILE[@]}; do 112 d=$(basename "$deb") 113 # We do not want to generate a new deb if it has already been 114 # copied into the APTDIR 115 if [ ! -f "$APTDIR/pool/$component/d/docker-engine/$d" ]; then 116 cp "$deb" "$tempdir/" 117 # if we have a $GPG_PASSPHRASE we may as well 118 # dpkg-sign before copying the deb into the pool 119 if [ ! -z "$GPG_PASSPHRASE" ]; then 120 dpkg-sig -g "--no-tty --passphrase '$GPG_PASSPHRASE'" \ 121 -k "$GPG_KEYID" --sign builder "$tempdir/$d" 122 fi 123 mv "$tempdir/$d" "$APTDIR/pool/$component/d/docker-engine/" 124 fi 125 done 126 127 rm -rf "$tempdir" 128 129 # build the right directory structure, needed for apt-ftparchive 130 for arch in "${arches[@]}"; do 131 mkdir -p "$APTDIR/dists/$codename/$component/binary-$arch" 132 done 133 134 # update the filelist for this codename/component 135 find "$APTDIR/pool/$component" \ 136 -name *~${codename#*-}*.deb > "$APTDIR/dists/$codename/$component/filelist" 137 done 138 139 # run the apt-ftparchive commands so we can have pinning 140 apt-ftparchive generate "$APTDIR/conf/apt-ftparchive.conf" 141 142 for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do 143 version="$(basename "$dir")" 144 codename="${version//debootstrap-}" 145 146 apt-ftparchive \ 147 -c "$APTDIR/conf/docker-engine-release.conf" \ 148 -o "APT::FTPArchive::Release::Codename=$codename" \ 149 -o "APT::FTPArchive::Release::Suite=$codename" \ 150 release \ 151 "$APTDIR/dists/$codename" > "$APTDIR/dists/$codename/Release" 152 153 for arch in "${arches[@]}"; do 154 apt-ftparchive \ 155 -c "$APTDIR/conf/docker-engine-release.conf" \ 156 -o "APT::FTPArchive::Release::Codename=$codename" \ 157 -o "APT::FTPArchive::Release::Suite=$codename" \ 158 -o "APT::FTPArchive::Release::Components=$component" \ 159 -o "APT::FTPArchive::Release::Architecture=$arch" \ 160 release \ 161 "$APTDIR/dists/$codename/$component/binary-$arch" > "$APTDIR/dists/$codename/$component/binary-$arch/Release" 162 done 163 done