This repository has been archived by the owner on Nov 10, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from hypriot/add-create-debian-package
Add creating of debian package
- Loading branch information
Showing
10 changed files
with
107 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,19 +3,71 @@ set -e | |
|
||
# set env var | ||
DOCKER_VERSION=$1 | ||
ARCH_VERSION=armv6hf | ||
TAR_FILE=docker-$DOCKER_VERSION-linux-$ARCH_VERSION.tar.gz | ||
DEB_FILE=docker-$DOCKER_VERSION-linux-$ARCH_VERSION.deb | ||
BUILD_REVISION=$2 | ||
|
||
# compile Docker | ||
# debian package versions | ||
PACKAGE_NAME=docker-hypriot | ||
PACKAGE_VERSION=$DOCKER_VERSION | ||
PACKAGE_REVISION=$BUILD_REVISION | ||
PACKAGE_ARCH=armhf | ||
PACKAGE_ROOT=/pkg-debian | ||
DEB_FILE=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_REVISION}_${PACKAGE_ARCH}.deb | ||
TAR_FILE=${PACKAGE_NAME}-${DOCKER_VERSION}-${PACKAGE_REVISION}-${PACKAGE_ARCH}.tar.gz | ||
|
||
# compile Docker from source | ||
cd /src/docker | ||
git checkout v$DOCKER_VERSION | ||
export AUTO_GOPATH=1 | ||
GOARM=6 ./hack/make.sh dynbinary | ||
|
||
# Create Debian package | ||
cd / | ||
tar czf $TAR_FILE -C /src/docker/bundles/$DOCKER_VERSION/dynbinary/ . | ||
# create tarball with Docker binaries | ||
tar czf /$TAR_FILE -C /src/docker/bundles/$DOCKER_VERSION/dynbinary/ . | ||
|
||
# create debian package | ||
# --copy docker files | ||
mkdir -p $PACKAGE_ROOT/etc/default/ | ||
cp /src/docker/contrib/init/sysvinit-debian/docker.default $PACKAGE_ROOT/etc/default/docker | ||
mkdir -p $PACKAGE_ROOT/etc/init.d/ | ||
cp /src/docker/contrib/init/sysvinit-debian/docker $PACKAGE_ROOT/etc/init.d/docker | ||
mkdir -p $PACKAGE_ROOT/lib/systemd/system/ | ||
cp /src/docker/contrib/init/systemd/docker.service $PACKAGE_ROOT/lib/systemd/system/ | ||
cp /src/docker/contrib/init/systemd/docker.socket $PACKAGE_ROOT/lib/systemd/system/ | ||
mkdir -p $PACKAGE_ROOT/usr/bin/ | ||
cp /src/docker/bundles/$DOCKER_VERSION/dynbinary/docker-$DOCKER_VERSION $PACKAGE_ROOT/usr/bin/docker | ||
mkdir -p $PACKAGE_ROOT/usr/lib/docker/ | ||
cp /src/docker/bundles/$DOCKER_VERSION/dynbinary/dockerinit-$DOCKER_VERSION $PACKAGE_ROOT/usr/lib/docker/dockerinit | ||
|
||
# --enable overlayfs by default | ||
sed -i '/#DOCKER_OPTS/a \ | ||
DOCKER_OPTS="--storage-driver=overlay -D"' $PACKAGE_ROOT/etc/default/docker | ||
|
||
# --get the total size of all package files | ||
filesize=`du -sk /pkg-debian/ | cut -f1` | ||
echo "Package size (uncompressed): $filesize kByte" | ||
|
||
# --create control file | ||
cat << EOF > /pkg-debian/DEBIAN/control | ||
Package: $PACKAGE_NAME | ||
Version: $PACKAGE_VERSION$PACKAGE_REVISION | ||
Architecture: $PACKAGE_ARCH | ||
Maintainer: Dieter Reuter <[email protected]> | ||
Installed-Size: $filesize | ||
Depends: adduser, iptables | ||
Conflicts: docker.io | ||
Replaces: docker.io | ||
Recommends: ca-certificates, cgroupfs-mount | cgroup-lite, git, xz-utils | ||
Section: admin | ||
Priority: optional | ||
Homepage: https://github.com/docker/docker | ||
Description: Docker for ARM devices, compiled and packaged by http://blog.hypriot.com | ||
EOF | ||
|
||
# --regenerate MD5 checksums for all files | ||
(cd /pkg-debian; find . -type f ! -regex '.*.hg.*' ! -regex '.*?debian-binary.*' ! -regex '.*?DEBIAN.*' -printf '%P ' | xargs md5sum > DEBIAN/md5sums) | ||
|
||
# --use fakeroot to set owner/group to 0/0 (root/root) | ||
fakeroot dpkg -b /pkg-debian/ /$DEB_FILE | ||
|
||
# Upload to S3 (using AWS CLI) | ||
aws s3 cp $TAR_FILE s3://$AWS_BUCKET_NAME/docker/v$DOCKER_VERSION/ | ||
aws s3 cp /$TAR_FILE s3://$AWS_BUCKET_NAME/docker/bin/ | ||
aws s3 cp /$DEB_FILE s3://$AWS_BUCKET_NAME/docker/deb/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
etc/default/docker |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#!/bin/sh | ||
set -e | ||
|
||
case "$1" in | ||
configure) | ||
if [ -z "$2" ]; then | ||
if ! getent group docker > /dev/null 2>&1; then | ||
addgroup --system --quiet docker | ||
fi | ||
fi | ||
;; | ||
abort-*) | ||
# How'd we get here?? | ||
exit 1 | ||
;; | ||
*) | ||
;; | ||
esac | ||
|
||
if [ -x "/etc/init.d/docker" ]; then | ||
update-rc.d docker defaults >/dev/null | ||
invoke-rc.d docker start || exit $? | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
set -e | ||
if [ "$1" = "purge" ] ; then | ||
update-rc.d docker remove >/dev/null | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
set -e | ||
if [ -x "/etc/init.d/docker" ]; then | ||
invoke-rc.d docker stop >/dev/null 2>&1 || exit 0 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#!/bin/sh | ||
set -e | ||
if [ -x "/etc/init.d/docker" ]; then | ||
invoke-rc.d docker stop || exit $? | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
#!/bin/sh -x | ||
docker run --rm=true --env-file=.env hypriot/rpi-docker-builder /builder.sh 1.5.0 | ||
docker run --rm=true --env-file=.env -v $(pwd)/builder.sh:/builder.sh -v $(pwd)/pkg-debian:/pkg-debian hypriot/rpi-docker-builder /builder.sh 1.5.0 -7 |