+
+ echo "=================================================="
+ echo "Install image ready in $img_dmg"
+ echo "You may publish it by running e.g."
+ echo "rsync -av $img_dmg root@build.onelab.eu:/build/sface"
+ echo "=================================================="
+
+}
+
+########################################
+# either provide a build dir and tags file
+# or sface-GITPATH sfa-GITPATH
+function usage () {
+ echo "$COMMAND -b <build-dir> -t <tags-file>"
+ echo " or"
+ echo "$COMMAND -c <sface-GITPATH> -s <sfa-GITPATH>"
+ echo ""
+ echo "Common options"
+ echo " -i : interactive : let you align icons properly in the image before it gets wrapped"
+ echo " -f : force download of the skeleton package"
+ echo " -F : force overwrite if output already exists"
+ echo " -a leopard|snow-leopard"
+ echo " -A : run on all known archs"
+ echo " -n : dry-run"
+ echo " -v : verbose"
+ echo " -h : this help"
+}
+
+DEFAULT_BUILD_DIR=$HOME/git/build
+DEFAULT_TAGS_FILE=onelab-k32-tags.mk
+
+function main () {
+ while getopts "b:t:c:s:ifFa:Anvh" opt ; do
+ case $opt in
+ b) BUILD_DIR=$OPTARG;;
+ t) TAGS_FILE=$OPTARG;;
+ c) sface_GITPATH=$OPTARG;;
+ s) sfa_GITPATH=$OPTARG;;
+ i) INTERACTIVE=true;;
+ f) FORCE_DOWNLOAD=true;;
+ F) FORCE_REWRITE=true ;;
+ a) ARCHS="$ARCHS $OPTARG";;
+ A) ARCHS="leopard snow-leopard";;
+ n) dry_run=true;;
+ v) set -x;;
+ h) usage; exit 1 ;;
+ esac
+ done
+ shift $(($OPTIND - 1))
+
+ [ -z "$BUILD_DIR" ] && BUILD_DIR=$DEFAULT_BUILD_DIR
+ [ -z "$TAGS_FILE" ] && TAGS_FILE=$DEFAULT_TAGS_FILE
+ [ -z "$ARCHS" ] && ARCHS=$DEFAULT_ARCH
+ [[ -n "$@" ]] && { usage ; exit 1; }
+ if [ -z "$sface_GITPATH" ] ; then
+ sface_GITPATH=$(make -C $BUILD_DIR stage1=true PLDISTROTAGS=$TAGS_FILE +sface-GITPATH 2> /dev/null)
+ echo "Retrieved from $BUILD_DIR/$TAGS_FILE.."
+ echo " sface_GITPATH=$sface_GITPATH"
+ fi
+ if [ -z "$sfa_GITPATH" ] ; then
+ sfa_GITPATH=$(make -C $BUILD_DIR stage1=true PLDISTROTAGS=$TAGS_FILE +sfa-GITPATH 2> /dev/null)
+ echo "Retrieved from $BUILD_DIR/$TAGS_FILE.."
+ echo " sfa_GITPATH=$sfa_GITPATH"
+ fi
+ for ARCH in $ARCHS; do
+ if [ -z "$dry_run" ] ; then
+ package $sface_GITPATH $sfa_GITPATH $ARCH
+ else
+ echo "Would run package $sface_GITPATH $sfa_GITPATH $ARCH"
+ fi
+ done
+