2013-12-03 02:48:26 +04:00
#!/bin/bash
2013-09-10 05:45:40 +04:00
DEST=$1
PKGVERSION="$VERSION"
2013-10-18 09:36:28 +04:00
if [ -n "$(git status --porcelain)" ]; then
2013-09-10 05:45:40 +04:00
PKGVERSION="$PKGVERSION-$(date +%Y%m%d%H%M%S)-$GITCOMMIT"
fi
PACKAGE_ARCHITECTURE="$(dpkg-architecture -qDEB_HOST_ARCH)"
PACKAGE_URL="http://www.docker.io/"
PACKAGE_MAINTAINER="docker@dotcloud.com"
2013-11-09 02:41:45 +04:00
PACKAGE_DESCRIPTION="Linux container runtime
2013-09-10 05:45:40 +04:00
Docker complements LXC with a high-level API which operates at the process
level. It runs unix processes with strong guarantees of isolation and
repeatability across servers.
Docker is a great building block for automating distributed systems:
large-scale web deployments, database clusters, continuous deployment systems,
private PaaS, service-oriented architectures, etc."
2013-12-28 17:35:00 +04:00
PACKAGE_LICENSE="Apache-2.0"
2013-09-10 05:45:40 +04:00
# Build docker as an ubuntu package using FPM and REPREPRO (sue me).
# bundle_binary must be called first.
bundle_ubuntu() {
DIR=$DEST/build
2014-01-20 01:07:18 +04:00
# Include our udev rules
mkdir -p $DIR/etc/udev/rules.d
cp contrib/udev/80-docker.rules $DIR/etc/udev/rules.d/
2013-10-15 19:38:02 +04:00
# Include our init scripts
2014-03-10 09:16:42 +04:00
mkdir -p $DIR/etc/init
cp contrib/init/upstart/docker.conf $DIR/etc/init/
mkdir -p $DIR/etc/init.d
cp contrib/init/sysvinit-debian/docker $DIR/etc/init.d/
2014-01-02 09:34:22 +04:00
mkdir -p $DIR/etc/default
2014-03-10 09:16:42 +04:00
cp contrib/init/sysvinit-debian/docker.default $DIR/etc/default/docker
mkdir -p $DIR/lib/systemd/system
cp contrib/init/systemd/docker.service $DIR/lib/systemd/system/
2014-01-02 09:34:22 +04:00
2014-03-26 00:29:58 +04:00
# Include contributed completions
mkdir -p $DIR/etc/bash_completion.d
cp contrib/completion/bash/docker $DIR/etc/bash_completion.d/
mkdir -p $DIR/usr/share/zsh/vendor-completions
cp contrib/completion/zsh/_docker $DIR/usr/share/zsh/vendor-completions/
mkdir -p $DIR/etc/fish/completions
cp contrib/completion/fish/docker.fish $DIR/etc/fish/completions/
2013-09-10 05:45:40 +04:00
# Copy the binary
# This will fail if the binary bundle hasn't been built
mkdir -p $DIR/usr/bin
cp $DEST/../binary/docker-$VERSION $DIR/usr/bin/docker
2013-11-09 02:41:45 +04:00
# Generate postinst/prerm/postrm scripts
2014-03-10 09:16:42 +04:00
cat > $DEST/postinst <<'EOF'
2013-09-10 05:45:40 +04:00
#!/bin/sh
2013-11-09 02:41:45 +04:00
set -e
set -u
2014-03-10 09:16:42 +04:00
if [ "$1" = 'configure' ] && [ -z "$2" ]; then
if ! getent group docker > /dev/null; then
groupadd --system docker
fi
fi
2013-11-09 02:41:45 +04:00
2014-03-10 09:16:42 +04:00
if ! { [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | grep -q upstart; }; then
# we only need to do this if upstart isn't in charge
update-rc.d docker defaults > /dev/null || true
fi
2013-11-09 02:41:45 +04:00
if [ -n "$2" ]; then
_dh_action=restart
else
_dh_action=start
fi
service docker $_dh_action 2>/dev/null || true
#DEBHELPER#
2013-09-10 05:45:40 +04:00
EOF
2014-03-10 09:16:42 +04:00
cat > $DEST/prerm <<'EOF'
2013-09-10 05:45:40 +04:00
#!/bin/sh
2013-11-09 02:41:45 +04:00
set -e
set -u
service docker stop 2>/dev/null || true
#DEBHELPER#
2013-09-10 05:45:40 +04:00
EOF
2014-03-10 09:16:42 +04:00
cat > $DEST/postrm <<'EOF'
2013-11-09 02:41:45 +04:00
#!/bin/sh
set -e
set -u
if [ "$1" = "purge" ] ; then
update-rc.d docker remove > /dev/null || true
fi
# In case this system is running systemd, we make systemd reload the unit files
# to pick up changes.
if [ -d /run/systemd/system ] ; then
systemctl --system daemon-reload > /dev/null || true
fi
#DEBHELPER#
EOF
# 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
2014-03-10 09:16:42 +04:00
chmod +x $DEST/postinst $DEST/prerm $DEST/postrm
2013-09-10 05:45:40 +04:00
(
2014-03-10 09:16:42 +04:00
# switch directories so we create *.deb in the right folder
2013-09-10 05:45:40 +04:00
cd $DEST
2014-03-10 09:16:42 +04:00
# create lxc-docker-VERSION package
2013-09-10 05:45:40 +04:00
fpm -s dir -C $DIR \
2014-03-10 09:16:42 +04:00
--name lxc-docker-$VERSION --version $PKGVERSION \
--after-install $DEST/postinst \
--before-remove $DEST/prerm \
--after-remove $DEST/postrm \
--architecture "$PACKAGE_ARCHITECTURE" \
--prefix / \
--depends iptables \
--deb-recommends aufs-tools \
--deb-recommends ca-certificates \
--deb-recommends git \
--deb-recommends xz-utils \
--deb-suggests cgroup-lite \
--description "$PACKAGE_DESCRIPTION" \
--maintainer "$PACKAGE_MAINTAINER" \
--conflicts docker \
--conflicts docker.io \
--conflicts lxc-docker-virtual-package \
--provides lxc-docker \
--provides lxc-docker-virtual-package \
--replaces lxc-docker \
--replaces lxc-docker-virtual-package \
--url "$PACKAGE_URL" \
--license "$PACKAGE_LICENSE" \
--config-files /etc/udev/rules.d/80-docker.rules \
--config-files /etc/init/docker.conf \
--config-files /etc/init.d/docker \
--config-files /etc/default/docker \
--deb-compression gz \
-t deb .
# TODO replace "Suggests: cgroup-lite" with "Recommends: cgroupfs-mount | cgroup-lite" once cgroupfs-mount is available
# create empty lxc-docker wrapper package
2014-01-11 00:08:28 +04:00
fpm -s empty \
2014-03-10 09:16:42 +04:00
--name lxc-docker --version $PKGVERSION \
--architecture "$PACKAGE_ARCHITECTURE" \
--depends lxc-docker-$VERSION \
--description "$PACKAGE_DESCRIPTION" \
--maintainer "$PACKAGE_MAINTAINER" \
--url "$PACKAGE_URL" \
--license "$PACKAGE_LICENSE" \
--deb-compression gz \
-t deb
2013-09-10 05:45:40 +04:00
)
2014-03-10 09:16:42 +04:00
# clean up after ourselves so we have a clean output directory
rm $DEST/postinst $DEST/prerm $DEST/postrm
rm -r $DIR
2013-09-10 05:45:40 +04:00
}
bundle_ubuntu