release-deb 5.0 KB

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