github.com/jogo/docker@v1.7.0-rc1/hack/make/ubuntu (about) 1 #!/bin/bash 2 3 DEST=$1 4 5 PKGVERSION="${VERSION//-/'~'}" 6 # if we have a "-dev" suffix or have change in Git, let's make this package version more complex so it works better 7 if [[ "$VERSION" == *-dev ]] || [ -n "$(git status --porcelain)" ]; then 8 GIT_UNIX="$(git log -1 --pretty='%at')" 9 GIT_DATE="$(date --date "@$GIT_UNIX" +'%Y%m%d.%H%M%S')" 10 GIT_COMMIT="$(git log -1 --pretty='%h')" 11 GIT_VERSION="git${GIT_DATE}.0.${GIT_COMMIT}" 12 # GIT_VERSION is now something like 'git20150128.112847.0.17e840a' 13 PKGVERSION="$PKGVERSION~$GIT_VERSION" 14 fi 15 16 # $ dpkg --compare-versions 1.5.0 gt 1.5.0~rc1 && echo true || echo false 17 # true 18 # $ dpkg --compare-versions 1.5.0~rc1 gt 1.5.0~git20150128.112847.17e840a && echo true || echo false 19 # true 20 # $ dpkg --compare-versions 1.5.0~git20150128.112847.17e840a gt 1.5.0~dev~git20150128.112847.17e840a && echo true || echo false 21 # true 22 23 # ie, 1.5.0 > 1.5.0~rc1 > 1.5.0~git20150128.112847.17e840a > 1.5.0~dev~git20150128.112847.17e840a 24 25 PACKAGE_ARCHITECTURE="$(dpkg-architecture -qDEB_HOST_ARCH)" 26 PACKAGE_URL="https://www.docker.com/" 27 PACKAGE_MAINTAINER="support@docker.com" 28 PACKAGE_DESCRIPTION="Linux container runtime 29 Docker complements LXC with a high-level API which operates at the process 30 level. It runs unix processes with strong guarantees of isolation and 31 repeatability across servers. 32 Docker is a great building block for automating distributed systems: 33 large-scale web deployments, database clusters, continuous deployment systems, 34 private PaaS, service-oriented architectures, etc." 35 PACKAGE_LICENSE="Apache-2.0" 36 37 # Build docker as an ubuntu package using FPM and REPREPRO (sue me). 38 # bundle_binary must be called first. 39 bundle_ubuntu() { 40 DIR=$DEST/build 41 42 # Include our udev rules 43 mkdir -p "$DIR/etc/udev/rules.d" 44 cp contrib/udev/80-docker.rules "$DIR/etc/udev/rules.d/" 45 46 # Include our init scripts 47 mkdir -p "$DIR/etc/init" 48 cp contrib/init/upstart/docker.conf "$DIR/etc/init/" 49 mkdir -p "$DIR/etc/init.d" 50 cp contrib/init/sysvinit-debian/docker "$DIR/etc/init.d/" 51 mkdir -p "$DIR/etc/default" 52 cp contrib/init/sysvinit-debian/docker.default "$DIR/etc/default/docker" 53 mkdir -p "$DIR/lib/systemd/system" 54 cp contrib/init/systemd/docker.{service,socket} "$DIR/lib/systemd/system/" 55 56 # Include contributed completions 57 mkdir -p "$DIR/etc/bash_completion.d" 58 cp contrib/completion/bash/docker "$DIR/etc/bash_completion.d/" 59 mkdir -p "$DIR/usr/share/zsh/vendor-completions" 60 cp contrib/completion/zsh/_docker "$DIR/usr/share/zsh/vendor-completions/" 61 mkdir -p "$DIR/etc/fish/completions" 62 cp contrib/completion/fish/docker.fish "$DIR/etc/fish/completions/" 63 64 # Include contributed man pages 65 docs/man/md2man-all.sh -q 66 manRoot="$DIR/usr/share/man" 67 mkdir -p "$manRoot" 68 for manDir in docs/man/man?; do 69 manBase="$(basename "$manDir")" # "man1" 70 for manFile in "$manDir"/*; do 71 manName="$(basename "$manFile")" # "docker-build.1" 72 mkdir -p "$manRoot/$manBase" 73 gzip -c "$manFile" > "$manRoot/$manBase/$manName.gz" 74 done 75 done 76 77 # Copy the binary 78 # This will fail if the binary bundle hasn't been built 79 mkdir -p "$DIR/usr/bin" 80 cp "$DEST/../binary/docker-$VERSION" "$DIR/usr/bin/docker" 81 82 # Generate postinst/prerm/postrm scripts 83 cat > "$DEST/postinst" <<'EOF' 84 #!/bin/sh 85 set -e 86 set -u 87 88 if [ "$1" = 'configure' ] && [ -z "$2" ]; then 89 if ! getent group docker > /dev/null; then 90 groupadd --system docker 91 fi 92 fi 93 94 if ! { [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; }; then 95 # we only need to do this if upstart isn't in charge 96 update-rc.d docker defaults > /dev/null || true 97 fi 98 if [ -n "$2" ]; then 99 _dh_action=restart 100 else 101 _dh_action=start 102 fi 103 service docker $_dh_action 2>/dev/null || true 104 105 #DEBHELPER# 106 EOF 107 cat > "$DEST/prerm" <<'EOF' 108 #!/bin/sh 109 set -e 110 set -u 111 112 service docker stop 2>/dev/null || true 113 114 #DEBHELPER# 115 EOF 116 cat > "$DEST/postrm" <<'EOF' 117 #!/bin/sh 118 set -e 119 set -u 120 121 if [ "$1" = "purge" ] ; then 122 update-rc.d docker remove > /dev/null || true 123 fi 124 125 # In case this system is running systemd, we make systemd reload the unit files 126 # to pick up changes. 127 if [ -d /run/systemd/system ] ; then 128 systemctl --system daemon-reload > /dev/null || true 129 fi 130 131 #DEBHELPER# 132 EOF 133 # 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 134 chmod +x "$DEST/postinst" "$DEST/prerm" "$DEST/postrm" 135 136 ( 137 # switch directories so we create *.deb in the right folder 138 cd "$DEST" 139 140 # create lxc-docker-VERSION package 141 fpm -s dir -C "$DIR" \ 142 --name "lxc-docker-$VERSION" --version "$PKGVERSION" \ 143 --after-install "$DEST/postinst" \ 144 --before-remove "$DEST/prerm" \ 145 --after-remove "$DEST/postrm" \ 146 --architecture "$PACKAGE_ARCHITECTURE" \ 147 --prefix / \ 148 --depends iptables \ 149 --deb-recommends aufs-tools \ 150 --deb-recommends ca-certificates \ 151 --deb-recommends git \ 152 --deb-recommends xz-utils \ 153 --deb-recommends 'cgroupfs-mount | cgroup-lite' \ 154 --description "$PACKAGE_DESCRIPTION" \ 155 --maintainer "$PACKAGE_MAINTAINER" \ 156 --conflicts docker \ 157 --conflicts docker.io \ 158 --conflicts lxc-docker-virtual-package \ 159 --provides lxc-docker \ 160 --provides lxc-docker-virtual-package \ 161 --replaces lxc-docker \ 162 --replaces lxc-docker-virtual-package \ 163 --url "$PACKAGE_URL" \ 164 --license "$PACKAGE_LICENSE" \ 165 --config-files /etc/udev/rules.d/80-docker.rules \ 166 --config-files /etc/init/docker.conf \ 167 --config-files /etc/init.d/docker \ 168 --config-files /etc/default/docker \ 169 --deb-compression gz \ 170 -t deb . 171 # TODO replace "Suggests: cgroup-lite" with "Recommends: cgroupfs-mount | cgroup-lite" once cgroupfs-mount is available 172 173 # create empty lxc-docker wrapper package 174 fpm -s empty \ 175 --name lxc-docker --version "$PKGVERSION" \ 176 --architecture "$PACKAGE_ARCHITECTURE" \ 177 --depends lxc-docker-$VERSION \ 178 --description "$PACKAGE_DESCRIPTION" \ 179 --maintainer "$PACKAGE_MAINTAINER" \ 180 --url "$PACKAGE_URL" \ 181 --license "$PACKAGE_LICENSE" \ 182 --deb-compression gz \ 183 -t deb 184 ) 185 186 # clean up after ourselves so we have a clean output directory 187 rm "$DEST/postinst" "$DEST/prerm" "$DEST/postrm" 188 rm -r "$DIR" 189 } 190 191 bundle_ubuntu