Chris@2116: #!/bin/bash Chris@2116: # Chris@2116: # Docker required Chris@2116: Chris@2116: set -eu Chris@2116: Chris@2116: current=$(hg id | awk '{ print $1; }') Chris@2116: release=$(perl -p -e 's/^[^"]*"([^"]*)".*$/$1/' version.h) Chris@2116: Chris@2116: case "$current" in Chris@2116: *+) 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@2116: *);; Chris@2116: esac Chris@2116: Chris@2116: echo Chris@2116: echo "Building Debian deb archive from revision $current..." Chris@2116: Chris@2116: dockerdir=deploy/linux/docker Chris@2116: Chris@2116: cat "$dockerdir"/Dockerfile_deb.in | \ Chris@2116: perl -p -e "s/\[\[REVISION\]\]/$current/g" | \ Chris@2116: perl -p -e "s/\[\[RELEASE\]\]/$release/g" > \ Chris@2116: "$dockerdir"/Dockerfile_deb.gen Chris@2116: Chris@2116: cat "$dockerdir"/Dockerfile_test_deb.in | \ Chris@2116: perl -p -e "s/\[\[REVISION\]\]/$current/g" | \ Chris@2116: perl -p -e "s/\[\[RELEASE\]\]/$release/g" > \ Chris@2116: "$dockerdir"/Dockerfile_test_deb.gen Chris@2116: Chris@2353: fgrep 'hg.sr.ht' ~/.ssh/known_hosts > "$dockerdir"/known_hosts Chris@2353: cp ~/.ssh/id_rsa_build "$dockerdir"/id_rsa_build Chris@2353: chmod 600 "$dockerdir"/known_hosts "$dockerdir"/id_rsa_build Chris@2353: trap "rm $dockerdir/known_hosts $dockerdir/id_rsa_build" 0 Chris@2144: Chris@2116: dockertag="cannam/sonic-visualiser-deb-$current" Chris@2116: Chris@2116: sudo docker build -t "$dockertag" -f "$dockerdir"/Dockerfile_deb.gen "$dockerdir" Chris@2116: Chris@2116: outdir="$dockerdir/output" Chris@2116: mkdir -p "$outdir" Chris@2116: Chris@2116: container=$(sudo docker create "$dockertag") Chris@2116: Chris@2116: sudo docker cp "$container":output-deb.tar "$outdir" Chris@2116: sudo docker rm "$container" Chris@2116: Chris@2116: ( cd "$outdir" ; tar xf output-deb.tar && rm -f output-deb.tar ) Chris@2116: Chris@2116: sudo docker build -f "$dockerdir"/Dockerfile_test_deb.gen "$dockerdir"