#!/bin/sh set -e proc usage { echo "Usage: -o file" exit 1 } test $Argc = 0 && usage while [ $# -gt 0 ] { setvar flag = "$1" match $flag { with -o test $Argc -eq 1 && usage setvar out = "$2" mkdir -p $(dirname $2) shift with * echo "Unknown option $1" exit 1 } shift } test -z $out && usage setvar package = $(basename "$out") setvar dir = ""/src"" # untar input tar xf - -C $dir shell { cd $dir opam config exec -- mirage configure -o $out -t unix opam config exec -- make depend opam config exec -- make mv $(readlink $out) $out } > /src/logs 2>&1 cd $dir && tar -cf - $out exit 0