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