diff deploy/linux/build-and-test-appimage.sh @ 371:a0ff34e9e86b

First cut at Linux AppImage
author Chris Cannam
date Fri, 05 Jun 2020 11:08:37 +0100
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/linux/build-and-test-appimage.sh	Fri Jun 05 11:08:37 2020 +0100
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# Docker required
+
+set -eu
+
+current=$(hg id | awk '{ print $1; }')
+
+case "$current" in
+    *+) 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;;
+    *);;
+esac
+
+echo
+echo "Building appimage from revision $current..."
+
+dockerdir=deploy/linux/docker
+
+cat "$dockerdir"/Dockerfile_appimage.in | \
+    perl -p -e "s/\[\[REVISION\]\]/$current/g" > \
+         "$dockerdir"/Dockerfile_appimage.gen
+
+cat "$dockerdir"/Dockerfile_test_appimage.in | \
+    perl -p -e "s/\[\[REVISION\]\]/$current/g" > \
+         "$dockerdir"/Dockerfile_test_appimage.gen
+
+fgrep 'hg.sr.ht' ~/.ssh/known_hosts > "$dockerdir"/known_hosts
+cp ~/.ssh/id_rsa_build "$dockerdir"/id_rsa_build
+chmod 600 "$dockerdir"/known_hosts "$dockerdir"/id_rsa_build
+trap "rm $dockerdir/known_hosts $dockerdir/id_rsa_build" 0
+
+dockertag="cannam/sonic-annotator-appimage-$current"
+
+sudo docker build -t "$dockertag" -f "$dockerdir"/Dockerfile_appimage.gen "$dockerdir"
+
+outdir="$dockerdir/output"
+mkdir -p "$outdir"
+
+container=$(sudo docker create "$dockertag")
+
+sudo docker cp "$container":output-appimage.tar "$outdir"
+sudo docker rm "$container"
+
+( cd "$outdir" ; tar xf output-appimage.tar && rm -f output-appimage.tar )
+
+sudo docker build -f "$dockerdir"/Dockerfile_test_appimage.gen "$dockerdir"