Chris@706: #!/bin/bash Chris@706: # Chris@706: # Docker required Chris@706: Chris@706: set -eu Chris@706: Chris@706: current=$(hg id | awk '{ print $1; }') Chris@706: release=$(perl -p -e 's/^[^"]*"([^"]*)".*$/$1/' src/version.h) Chris@706: Chris@706: case "$current" in Chris@706: *+) echo "ERROR: Current working copy has been modified - unmodified copy required so we know we can check it out separately and obtain the same contents"; exit 2;; Chris@706: *);; Chris@706: esac Chris@706: Chris@706: echo Chris@706: echo "Building Debian deb archive from revision $current..." Chris@706: Chris@706: dockerdir=deploy/linux/docker Chris@706: Chris@706: cat "$dockerdir"/Dockerfile_deb.in | \ Chris@706: perl -p -e "s/\[\[REVISION\]\]/$current/g" | \ Chris@706: perl -p -e "s/\[\[RELEASE\]\]/$release/g" > \ Chris@706: "$dockerdir"/Dockerfile_deb.gen Chris@706: Chris@706: cat "$dockerdir"/Dockerfile_test_deb.in | \ Chris@706: perl -p -e "s/\[\[REVISION\]\]/$current/g" | \ Chris@706: perl -p -e "s/\[\[RELEASE\]\]/$release/g" > \ Chris@706: "$dockerdir"/Dockerfile_test_deb.gen Chris@706: Chris@706: grep '^bitbucket.org' ~/.ssh/known_hosts > "$dockerdir"/known_hosts Chris@706: cp ~/.ssh/id_dsa_build "$dockerdir"/id_dsa_build Chris@706: chmod 600 "$dockerdir"/known_hosts "$dockerdir"/id_dsa_build Chris@706: trap "rm $dockerdir/known_hosts $dockerdir/id_dsa_build" 0 Chris@706: Chris@706: dockertag="cannam/easymercurial-deb-$current" Chris@706: Chris@706: sudo docker build -t "$dockertag" -f "$dockerdir"/Dockerfile_deb.gen "$dockerdir" Chris@706: Chris@706: outdir="$dockerdir/output" Chris@706: mkdir -p "$outdir" Chris@706: Chris@706: container=$(sudo docker create "$dockertag") Chris@706: Chris@706: sudo docker cp "$container":output-deb.tar "$outdir" Chris@706: sudo docker rm "$container" Chris@706: Chris@706: ( cd "$outdir" ; tar xf output-deb.tar && rm -f output-deb.tar ) Chris@706: Chris@706: sudo docker build -t "$dockertag"-test -f "$dockerdir"/Dockerfile_test_deb.gen "$dockerdir"