From 3d39336a46a0d7f411467d29eb6328dc1ab3e900 Mon Sep 17 00:00:00 2001 From: Solomon Hykes Date: Mon, 9 Sep 2013 18:45:40 -0700 Subject: [PATCH] Break down hack/make.sh into small scripts, one per 'bundle': test, binary, ubuntu etc. --- hack/make.sh | 153 +++++++++----------------------------------- hack/make/README.md | 17 +++++ hack/make/binary | 4 ++ hack/make/test | 27 ++++++++ hack/make/ubuntu | 94 +++++++++++++++++++++++++++ 5 files changed, 174 insertions(+), 121 deletions(-) create mode 100644 hack/make/README.md create mode 100644 hack/make/binary create mode 100644 hack/make/test create mode 100644 hack/make/ubuntu diff --git a/hack/make.sh b/hack/make.sh index 1d79ed7396..9910882e20 100755 --- a/hack/make.sh +++ b/hack/make.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # This script builds various binary artifacts from a checkout of the docker # source code. @@ -34,139 +34,50 @@ grep -q "$RESOLVCONF" /proc/mounts || { exit 1 } +# List of bundles to create when no argument is passed +DEFAULT_BUNDLES=( + test + binary + ubuntu +) + VERSION=$(cat ./VERSION) -PKGVERSION="$VERSION" GITCOMMIT=$(git rev-parse --short HEAD) if test -n "$(git status --porcelain)" then GITCOMMIT="$GITCOMMIT-dirty" - PKGVERSION="$PKGVERSION-$(date +%Y%m%d%H%M%S)-$GITCOMMIT" fi # Use these flags when compiling the tests and final binary LDFLAGS="-X main.GITCOMMIT $GITCOMMIT -X main.VERSION $VERSION -d -w" -PACKAGE_ARCHITECTURE="$(dpkg-architecture -qDEB_HOST_ARCH)" -PACKAGE_URL="http://www.docker.io/" -PACKAGE_MAINTAINER="docker@dotcloud.com" -PACKAGE_DESCRIPTION="lxc-docker is a Linux container runtime -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." -UPSTART_SCRIPT='description "Docker daemon" - -start on filesystem and started lxc-net -stop on runlevel [!2345] - -respawn - -script - /usr/bin/docker -d -end script -' - -# Each "bundle" is a different type of build artefact: static binary, Ubuntu -# package, etc. - -# Run Docker's test suite, including sub-packages, and store their output as a bundle -bundle_test() { - mkdir -p bundles/$VERSION/test - { - date - for test_dir in $(find_test_dirs); do ( - set -x - cd $test_dir - go test -v -ldflags "$LDFLAGS" - ) done - } 2>&1 | tee bundles/$VERSION/test/test.log +bundle() { + bundlescript=$1 + bundle=$(basename $bundlescript) + echo "---> Making bundle: $bundle" + mkdir -p bundles/$VERSION/$bundle + source $bundlescript $(pwd)/bundles/$VERSION/$bundle } - -# This helper function walks the current directory looking for directories -# holding Go test files, and prints their paths on standard output, one per -# line. -find_test_dirs() { - find . -name '*_test.go' | grep -v '^./vendor' | - { while read f; do dirname $f; done; } | - sort -u -} - -# Build Docker as a static binary file -bundle_binary() { - mkdir -p bundles/$VERSION/binary - go build -o bundles/$VERSION/binary/docker-$VERSION \ - -ldflags "$LDFLAGS" \ - ./docker -} - -# Build docker as an ubuntu package using FPM and REPREPRO (sue me). -# bundle_binary must be called first. -bundle_ubuntu() { - mkdir -p bundles/$VERSION/ubuntu - - DIR=$(pwd)/bundles/$VERSION/ubuntu/build - - # Generate an upstart config file (ubuntu-specific) - mkdir -p $DIR/etc/init - echo "$UPSTART_SCRIPT" > $DIR/etc/init/docker.conf - - # Copy the binary - mkdir -p $DIR/usr/bin - cp bundles/$VERSION/binary/docker-$VERSION $DIR/usr/bin/docker - - # Generate postinstall/prerm scripts - cat >/tmp/postinstall </tmp/prerm <&1 | tee $DEST/test.log +} + + +# This helper function walks the current directory looking for directories +# holding Go test files, and prints their paths on standard output, one per +# line. +find_test_dirs() { + find . -name '*_test.go' | grep -v '^./vendor' | + { while read f; do dirname $f; done; } | + sort -u +} + +bundle_test diff --git a/hack/make/ubuntu b/hack/make/ubuntu new file mode 100644 index 0000000000..dde11ae81e --- /dev/null +++ b/hack/make/ubuntu @@ -0,0 +1,94 @@ +#!/bin/sh + +DEST=$1 + +PKGVERSION="$VERSION" +if test -n "$(git status --porcelain)" +then + 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" +PACKAGE_DESCRIPTION="lxc-docker is a Linux container runtime +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." + +UPSTART_SCRIPT='description "Docker daemon" + +start on filesystem and started lxc-net +stop on runlevel [!2345] + +respawn + +script + /usr/bin/docker -d +end script +' + +# Build docker as an ubuntu package using FPM and REPREPRO (sue me). +# bundle_binary must be called first. +bundle_ubuntu() { + DIR=$DEST/build + + # Generate an upstart config file (ubuntu-specific) + mkdir -p $DIR/etc/init + echo "$UPSTART_SCRIPT" > $DIR/etc/init/docker.conf + + # Copy the binary + # This will fail if the binary bundle hasn't been built + mkdir -p $DIR/usr/bin + # Copy the binary + # This will fail if the binary bundle hasn't been built + cp $DEST/../binary/docker-$VERSION $DIR/usr/bin/docker + + # Generate postinstall/prerm scripts + cat >/tmp/postinstall </tmp/prerm <