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