release-deb 5.1 KB

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