github.com/rightscale/docker@v1.9.1/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-trusy main
    11  #	deb http://apt.dockerproject.org/repo ubuntu-vivid 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  : ${DOCKER_RELEASE_DIR:=$DEST}
    18  : ${GPG_KEYID:=releasedocker}
    19  APTDIR=$DOCKER_RELEASE_DIR/apt/repo
    20  
    21  # setup the apt repo (if it does not exist)
    22  mkdir -p "$APTDIR/conf" "$APTDIR/db"
    23  
    24  # supported arches/sections
    25  arches=( amd64 i386 )
    26  components=( main testing experimental )
    27  
    28  # create/update apt-ftparchive file
    29  if [ ! -f "$APTDIR/conf/apt-ftparchive.conf" ]; then
    30  	cat <<-EOF > "$APTDIR/conf/apt-ftparchive.conf"
    31  	Dir {
    32  		ArchiveDir "${APTDIR}";
    33  		CacheDir "${APTDIR}/db";
    34  	};
    35  
    36  	Default {
    37  		Packages::Compress ". gzip bzip2";
    38  		Sources::Compress ". gzip bzip2";
    39  		Contents::Compress ". gzip bzip2";
    40  	};
    41  
    42  	TreeDefault {
    43  		BinCacheDB "packages-\$(SECTION)-\$(ARCH).db";
    44  		Directory "pool/\$(SECTION)";
    45  		Packages "\$(DIST)/\$(SECTION)/binary-\$(ARCH)/Packages";
    46  		SrcDirectory "pool/\$(SECTION)";
    47  		Sources "\$(DIST)/\$(SECTION)/source/Sources";
    48  		Contents "\$(DIST)/\$(SECTION)/Contents-\$(ARCH)";
    49  		FileList "$APTDIR/\$(DIST)/\$(SECTION)/filelist";
    50  	};
    51  	EOF
    52  
    53  	for suite in $(exec contrib/reprepro/suites.sh); do
    54  		cat <<-EOF
    55  		Tree "dists/${suite}" {
    56  			Sections "main testing experimental";
    57  			Architectures "${arches[*]}";
    58  		}
    59  
    60  		EOF
    61  	done >> "$APTDIR/conf/apt-ftparchive.conf"
    62  fi
    63  
    64  if [ ! -f "$APTDIR/conf/docker-engine-release.conf" ]; then
    65  	cat <<-EOF > "$APTDIR/conf/docker-engine-release.conf"
    66  	APT::FTPArchive::Release::Origin "Docker";
    67  	APT::FTPArchive::Release::Components "${components[*]}";
    68  	APT::FTPArchive::Release::Label "Docker APT Repository";
    69  	APT::FTPArchive::Release::Architectures "${arches[*]}";
    70  	EOF
    71  fi
    72  
    73  # set the component for the version being released
    74  component="main"
    75  
    76  if [[ "$VERSION" == *-rc* ]]; then
    77  	component="testing"
    78  fi
    79  
    80  if [ $DOCKER_EXPERIMENTAL ] || [[ "$VERSION" == *-dev ]] || [ -n "$(git status --porcelain)" ]; then
    81  	component="experimental"
    82  fi
    83  
    84  # release the debs
    85  for dir in contrib/builder/deb/*/; do
    86  	version="$(basename "$dir")"
    87  	codename="${version//debootstrap-}"
    88  
    89  	DEBFILE=( "bundles/$VERSION/build-deb/$version/docker-engine"*.deb )
    90  
    91  	# if we have a $GPG_PASSPHRASE we may as well
    92  	# dpkg-sign before copying the deb into the pool
    93  	if [ ! -z "$GPG_PASSPHRASE" ]; then
    94  		dpkg-sig -g "--passphrase $GPG_PASSPHRASE" \
    95  			-k "$GPG_KEYID" --sign builder "${DEBFILE[@]}"
    96  	fi
    97  
    98  	# add the deb for each component for the distro version into the pool
    99  	mkdir -p "$APTDIR/pool/$component/d/docker-engine/"
   100  	cp "${DEBFILE[@]}" "$APTDIR/pool/$component/d/docker-engine/"
   101  
   102  	# update the filelist for this codename/component
   103  	find "$APTDIR/pool/$component" \
   104  		-name *~${codename#*-}*.deb > "$APTDIR/dists/$codename/$component/filelist"
   105  done
   106  
   107  
   108  # run the apt-ftparchive commands so we can have pinning
   109  apt-ftparchive generate "$APTDIR/conf/apt-ftparchive.conf"
   110  
   111  for dir in contrib/builder/deb/*/; do
   112  	version="$(basename "$dir")"
   113  	codename="${version//debootstrap-}"
   114  
   115  	apt-ftparchive \
   116  		-o "APT::FTPArchive::Release::Codename=$codename" \
   117  		-o "APT::FTPArchive::Release::Suite=$codename" \
   118  		-c "$APTDIR/conf/docker-engine-release.conf" \
   119  		release \
   120  		"$APTDIR/dists/$codename" > "$APTDIR/dists/$codename/Release"
   121  
   122  	for arch in "${arches[@]}"; do
   123  		apt-ftparchive \
   124  			-o "APT::FTPArchive::Release::Codename=$codename" \
   125  			-o "APT::FTPArchive::Release::Suite=$codename" \
   126  			-o "APT::FTPArchive::Release::Component=$component" \
   127  			-o "APT::FTPArchive::Release::Architecture=$arch" \
   128  			-c "$APTDIR/conf/docker-engine-release.conf" \
   129  			release \
   130  			"$APTDIR/dists/$codename/$component/binary-$arch" > "$APTDIR/dists/$codename/$component/binary-$arch/Release"
   131  	done
   132  done