github.com/ojongerius/docker@v1.11.2/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"
    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  	if ls "$APTDIR/dists/*/$component" >/dev/null 2>&1 ; then
    33  		components+=( $component )
    34  	fi
    35  done
    36  
    37  # set the component for the version being released
    38  component="main"
    39  
    40  if [[ "$VERSION" == *-rc* ]]; then
    41  	component="testing"
    42  fi
    43  
    44  if [ "$DOCKER_EXPERIMENTAL" ] || [[ "$VERSION" == *-dev ]] || [ -n "$(git status --porcelain)" ]; then
    45  	component="experimental"
    46  fi
    47  
    48  # Make sure our component is in the list of components
    49  if [[ ! "${components[*]}" =~ $component ]] ; then
    50  	components+=( $component )
    51  fi
    52  
    53  # create apt-ftparchive file on every run. This is essential to avoid
    54  # using stale versions of the config file that could cause unnecessary
    55  # refreshing of bits for EOL-ed releases.
    56  cat <<-EOF > "$APTDIR/conf/apt-ftparchive.conf"
    57  Dir {
    58  	ArchiveDir "${APTDIR}";
    59  	CacheDir "${APTDIR}/db";
    60  };
    61  
    62  Default {
    63  	Packages::Compress ". gzip bzip2";
    64  	Sources::Compress ". gzip bzip2";
    65  	Contents::Compress ". gzip bzip2";
    66  };
    67  
    68  TreeDefault {
    69  	BinCacheDB "packages-\$(SECTION)-\$(ARCH).db";
    70  	Directory "pool/\$(SECTION)";
    71  	Packages "\$(DIST)/\$(SECTION)/binary-\$(ARCH)/Packages";
    72  	SrcDirectory "pool/\$(SECTION)";
    73  	Sources "\$(DIST)/\$(SECTION)/source/Sources";
    74  	Contents "\$(DIST)/\$(SECTION)/Contents-\$(ARCH)";
    75  	FileList "$APTDIR/\$(DIST)/\$(SECTION)/filelist";
    76  };
    77  EOF
    78  
    79  for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do
    80  	version="$(basename "$dir")"
    81  	suite="${version//debootstrap-}"
    82  
    83  	cat <<-EOF
    84  	Tree "dists/${suite}" {
    85  		Sections "${components[*]}";
    86  		Architectures "${arches[*]}";
    87  	}
    88  
    89  	EOF
    90  done >> "$APTDIR/conf/apt-ftparchive.conf"
    91  
    92  if [ ! -f "$APTDIR/conf/docker-engine-release.conf" ]; then
    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  fi
   100  
   101  # release the debs
   102  for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do
   103  	version="$(basename "$dir")"
   104  	codename="${version//debootstrap-}"
   105  
   106  	DEBFILE=( "bundles/$VERSION/build-deb/$version/docker-engine"*.deb )
   107  
   108  	# if we have a $GPG_PASSPHRASE we may as well
   109  	# dpkg-sign before copying the deb into the pool
   110  	if [ ! -z "$GPG_PASSPHRASE" ]; then
   111  		dpkg-sig -g "--no-tty --passphrase '$GPG_PASSPHRASE'" \
   112  			-k "$GPG_KEYID" --sign builder "${DEBFILE[@]}"
   113  	fi
   114  
   115  	# add the deb for each component for the distro version into the pool
   116  	mkdir -p "$APTDIR/pool/$component/d/docker-engine/"
   117  	cp "${DEBFILE[@]}" "$APTDIR/pool/$component/d/docker-engine/"
   118  
   119  	# update the filelist for this codename/component
   120  	mkdir -p "$APTDIR/dists/$codename/$component"
   121  	find "$APTDIR/pool/$component" \
   122  		-name *~${codename#*-}*.deb > "$APTDIR/dists/$codename/$component/filelist"
   123  done
   124  
   125  # run the apt-ftparchive commands so we can have pinning
   126  apt-ftparchive generate "$APTDIR/conf/apt-ftparchive.conf"
   127  
   128  for dir in contrib/builder/deb/${PACKAGE_ARCH}/*/; do
   129  	version="$(basename "$dir")"
   130  	codename="${version//debootstrap-}"
   131  
   132  	apt-ftparchive \
   133  		-o "APT::FTPArchive::Release::Codename=$codename" \
   134  		-o "APT::FTPArchive::Release::Suite=$codename" \
   135  		-c "$APTDIR/conf/docker-engine-release.conf" \
   136  		release \
   137  		"$APTDIR/dists/$codename" > "$APTDIR/dists/$codename/Release"
   138  
   139  	for arch in "${arches[@]}"; do
   140  		mkdir -p "$APTDIR/dists/$codename/$component/binary-$arch"
   141  		apt-ftparchive \
   142  			-o "APT::FTPArchive::Release::Codename=$codename" \
   143  			-o "APT::FTPArchive::Release::Suite=$codename" \
   144  			-o "APT::FTPArchive::Release::Component=$component" \
   145  			-o "APT::FTPArchive::Release::Architecture=$arch" \
   146  			-c "$APTDIR/conf/docker-engine-release.conf" \
   147  			release \
   148  			"$APTDIR/dists/$codename/$component/binary-$arch" > "$APTDIR/dists/$codename/$component/binary-$arch/Release"
   149  	done
   150  done