github.com/sijibomii/docker@v0.0.0-20231230191044-5cf6ca554647/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 # Copy the binary 76 # This will fail if the binary bundle hasn't been built 77 mkdir -p "$DIR/usr/bin" 78 cp "$DEST/../binary/docker-$VERSION" "$DIR/usr/bin/docker" 79 80 # Generate postinst/prerm/postrm scripts 81 cat > "$DEST/postinst" <<'EOF' 82 #!/bin/sh 83 set -e 84 set -u 85 86 if [ "$1" = 'configure' ] && [ -z "$2" ]; then 87 if ! getent group docker > /dev/null; then 88 groupadd --system docker 89 fi 90 fi 91 92 if ! { [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; }; then 93 # we only need to do this if upstart isn't in charge 94 update-rc.d docker defaults > /dev/null || true 95 fi 96 if [ -n "$2" ]; then 97 _dh_action=restart 98 else 99 _dh_action=start 100 fi 101 service docker $_dh_action 2>/dev/null || true 102 103 #DEBHELPER# 104 EOF 105 cat > "$DEST/prerm" <<'EOF' 106 #!/bin/sh 107 set -e 108 set -u 109 110 service docker stop 2>/dev/null || true 111 112 #DEBHELPER# 113 EOF 114 cat > "$DEST/postrm" <<'EOF' 115 #!/bin/sh 116 set -e 117 set -u 118 119 if [ "$1" = "purge" ] ; then 120 update-rc.d docker remove > /dev/null || true 121 fi 122 123 # In case this system is running systemd, we make systemd reload the unit files 124 # to pick up changes. 125 if [ -d /run/systemd/system ] ; then 126 systemctl --system daemon-reload > /dev/null || true 127 fi 128 129 #DEBHELPER# 130 EOF 131 # 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 132 chmod +x "$DEST/postinst" "$DEST/prerm" "$DEST/postrm" 133 134 ( 135 # switch directories so we create *.deb in the right folder 136 cd "$DEST" 137 138 # create lxc-docker-VERSION package 139 fpm -s dir -C "$DIR" \ 140 --name "lxc-docker-$VERSION" --version "$PKGVERSION" \ 141 --after-install "$ABS_DEST/postinst" \ 142 --before-remove "$ABS_DEST/prerm" \ 143 --after-remove "$ABS_DEST/postrm" \ 144 --architecture "$PACKAGE_ARCHITECTURE" \ 145 --prefix / \ 146 --depends iptables \ 147 --deb-recommends aufs-tools \ 148 --deb-recommends ca-certificates \ 149 --deb-recommends git \ 150 --deb-recommends xz-utils \ 151 --deb-recommends 'cgroupfs-mount | cgroup-lite' \ 152 --deb-suggests apparmor \ 153 --description "$PACKAGE_DESCRIPTION" \ 154 --maintainer "$PACKAGE_MAINTAINER" \ 155 --conflicts docker \ 156 --conflicts docker.io \ 157 --conflicts lxc-docker-virtual-package \ 158 --provides lxc-docker \ 159 --provides lxc-docker-virtual-package \ 160 --replaces lxc-docker \ 161 --replaces lxc-docker-virtual-package \ 162 --url "$PACKAGE_URL" \ 163 --license "$PACKAGE_LICENSE" \ 164 --config-files /etc/udev/rules.d/80-docker.rules \ 165 --config-files /etc/init/docker.conf \ 166 --config-files /etc/init.d/docker \ 167 --config-files /etc/default/docker \ 168 --deb-compression gz \ 169 -t deb . 170 # TODO replace "Suggests: cgroup-lite" with "Recommends: cgroupfs-mount | cgroup-lite" once cgroupfs-mount is available 171 172 # create empty lxc-docker wrapper package 173 fpm -s empty \ 174 --name lxc-docker --version "$PKGVERSION" \ 175 --architecture "$PACKAGE_ARCHITECTURE" \ 176 --depends lxc-docker-$VERSION \ 177 --description "$PACKAGE_DESCRIPTION" \ 178 --maintainer "$PACKAGE_MAINTAINER" \ 179 --url "$PACKAGE_URL" \ 180 --license "$PACKAGE_LICENSE" \ 181 --deb-compression gz \ 182 -t deb 183 ) 184 185 # clean up after ourselves so we have a clean output directory 186 rm "$DEST/postinst" "$DEST/prerm" "$DEST/postrm" 187 rm -r "$DIR" 188 } 189 190 bundle_ubuntu