#!/bin/sh set -e proc usage { echo "Usage: -o file" exit 1 } test $Argc = 0 && usage while [ $# -gt 0 ] { setglobal flag = $1 match $flag { with -o test $Argc -eq 1 && usage setglobal out = $2 mkdir -p $[dirname $2] shift with * echo "Unknown option $1" exit 1 } shift } test -z $out && usage setglobal package = $[basename $out] setglobal 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