ubuntu 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/bin/bash
  2. DEST=$1
  3. PKGVERSION="$VERSION"
  4. if [ -n "$(git status --porcelain)" ]; then
  5. PKGVERSION="$PKGVERSION-$(date +%Y%m%d%H%M%S)-$GITCOMMIT"
  6. fi
  7. PACKAGE_ARCHITECTURE="$(dpkg-architecture -qDEB_HOST_ARCH)"
  8. PACKAGE_URL="http://www.docker.io/"
  9. PACKAGE_MAINTAINER="docker@dotcloud.com"
  10. PACKAGE_DESCRIPTION="Linux container runtime
  11. Docker complements LXC with a high-level API which operates at the process
  12. level. It runs unix processes with strong guarantees of isolation and
  13. repeatability across servers.
  14. Docker is a great building block for automating distributed systems:
  15. large-scale web deployments, database clusters, continuous deployment systems,
  16. private PaaS, service-oriented architectures, etc."
  17. PACKAGE_LICENSE="Apache-2.0"
  18. # Build docker as an ubuntu package using FPM and REPREPRO (sue me).
  19. # bundle_binary must be called first.
  20. bundle_ubuntu() {
  21. DIR=$DEST/build
  22. # Include our init scripts
  23. mkdir -p $DIR/etc
  24. cp -R contrib/init/upstart $DIR/etc/init
  25. cp -R contrib/init/sysvinit $DIR/etc/init.d
  26. mkdir -p $DIR/lib/systemd
  27. cp -R contrib/init/systemd $DIR/lib/systemd/system
  28. mkdir -p $DIR/etc/default
  29. cat > $DIR/etc/default/docker <<'EOF'
  30. # Docker Upstart and SysVinit configuration file
  31. # Customize location of Docker binary (especially for development testing).
  32. #DOCKER="/usr/local/bin/docker"
  33. # Use DOCKER_OPTS to modify the daemon startup options.
  34. #DOCKER_OPTS="-dns 8.8.8.8"
  35. # If you need Docker to use an HTTP proxy, it can also be specified here.
  36. #export http_proxy=http://127.0.0.1:3128/
  37. EOF
  38. # Copy the binary
  39. # This will fail if the binary bundle hasn't been built
  40. mkdir -p $DIR/usr/bin
  41. # Copy the binary
  42. # This will fail if the binary bundle hasn't been built
  43. cp $DEST/../binary/docker-$VERSION $DIR/usr/bin/docker
  44. # Generate postinst/prerm/postrm scripts
  45. cat > /tmp/postinst <<'EOF'
  46. #!/bin/sh
  47. set -e
  48. set -u
  49. getent group docker > /dev/null || groupadd --system docker || true
  50. update-rc.d docker defaults > /dev/null || true
  51. if [ -n "$2" ]; then
  52. _dh_action=restart
  53. else
  54. _dh_action=start
  55. fi
  56. service docker $_dh_action 2>/dev/null || true
  57. #DEBHELPER#
  58. EOF
  59. cat > /tmp/prerm <<'EOF'
  60. #!/bin/sh
  61. set -e
  62. set -u
  63. service docker stop 2>/dev/null || true
  64. #DEBHELPER#
  65. EOF
  66. cat > /tmp/postrm <<'EOF'
  67. #!/bin/sh
  68. set -e
  69. set -u
  70. if [ "$1" = "purge" ] ; then
  71. update-rc.d docker remove > /dev/null || true
  72. fi
  73. # In case this system is running systemd, we make systemd reload the unit files
  74. # to pick up changes.
  75. if [ -d /run/systemd/system ] ; then
  76. systemctl --system daemon-reload > /dev/null || true
  77. fi
  78. #DEBHELPER#
  79. EOF
  80. # TODO swaths of these were borrowed from debhelper's auto-inserted stuff, because we're still using fpm - we need to use debhelper instead, and somehow reconcile Ubuntu that way
  81. chmod +x /tmp/postinst /tmp/prerm
  82. (
  83. cd $DEST
  84. fpm -s dir -C $DIR \
  85. --name lxc-docker-$VERSION --version $PKGVERSION \
  86. --after-install /tmp/postinst \
  87. --before-remove /tmp/prerm \
  88. --after-remove /tmp/postrm \
  89. --architecture "$PACKAGE_ARCHITECTURE" \
  90. --prefix / \
  91. --depends lxc \
  92. --depends aufs-tools \
  93. --depends iptables \
  94. --deb-recommends ca-certificates \
  95. --description "$PACKAGE_DESCRIPTION" \
  96. --maintainer "$PACKAGE_MAINTAINER" \
  97. --conflicts lxc-docker-virtual-package \
  98. --provides lxc-docker \
  99. --provides lxc-docker-virtual-package \
  100. --replaces lxc-docker \
  101. --replaces lxc-docker-virtual-package \
  102. --url "$PACKAGE_URL" \
  103. --license "$PACKAGE_LICENSE" \
  104. --config-files /etc/init/docker.conf \
  105. --config-files /etc/init.d/docker \
  106. --config-files /etc/default/docker \
  107. --deb-compression gz \
  108. -t deb .
  109. fpm -s empty \
  110. --name lxc-docker --version $PKGVERSION \
  111. --architecture "$PACKAGE_ARCHITECTURE" \
  112. --depends lxc-docker-$VERSION \
  113. --description "$PACKAGE_DESCRIPTION" \
  114. --maintainer "$PACKAGE_MAINTAINER" \
  115. --url "$PACKAGE_URL" \
  116. --license "$PACKAGE_LICENSE" \
  117. --deb-compression gz \
  118. -t deb
  119. )
  120. }
  121. bundle_ubuntu