#!/bin/sh # This script builds various binary artifacts from a checkout of the docker source code. # # Requirements: # - The current directory should be a checkout of the docker source code (http://github.com/dotcloud/docker). Whatever version is checked out will be built. # - The script is intented to be run as part of a docker build, as defined in the Dockerfile at the root of the source. # - If you don't call this script from the official Dockerfile, or a container built by the official Dockerfile, you're probably doing it wrong. # set -e set -x VERSION=`cat ./VERSION` GIT_COMMIT=$(git rev-parse --short HEAD) GIT_CHANGES=$(test -n "`git status --porcelain`" && echo "+CHANGES" || true) # "bundles" indicate the different types of build artifacts: static binary, ubuntu package, etc. # Build docker as a static binary file bundle_binary() { mkdir -p bundles/$VERSION/binary go build -o bundles/$VERSION/binary/docker-$VERSION -ldflags "-X main.GITCOMMIT $GIT_COMMIT$GIT_CHANGES -X main.VERSION $VERSION -d -w" ./docker } # Build docker's test suite as a collection of binary files (one per sub-package to test) bundle_test() { mkdir -p bundles/$VERSION/test for test_dir in `find_test_dirs`; do test_binary=` cd $test_dir go test -c -v -ldflags "-X main.GITCOMMIT $GIT_COMMIT$GIT_CHANGES -X main.VERSION $VERSION -d -w" >&2 find . -maxdepth 1 -type f -name '*.test' -executable ` cp $test_dir/$test_binary bundles/$VERSION/test/ done } # 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=$(mktemp -d) # Generate an upstart config file (ubuntu-specific) mkdir -p $DIR/etc/init cat > $DIR/etc/init/docker.conf < $APTDIR/conf/distributions <