re-package Isabelle distribution with add-on components;
authorwenzelm
Fri Nov 27 00:11:56 2009 +0100 (2009-11-27)
changeset 33907473f859e1c29
parent 33906 1eebf19b773e
child 33908 7c473c4d42f4
re-package Isabelle distribution with add-on components;
Admin/makebundle
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Admin/makebundle	Fri Nov 27 00:11:56 2009 +0100
     1.3 @@ -0,0 +1,75 @@
     1.4 +#!/usr/bin/env bash
     1.5 +#
     1.6 +# makebundle -- re-package with add-on components
     1.7 +
     1.8 +## global settings
     1.9 +
    1.10 +TMP="/var/tmp/isabelle-makebundle$$"
    1.11 +
    1.12 +
    1.13 +## diagnostics
    1.14 +
    1.15 +PRG=$(basename "$0")
    1.16 +
    1.17 +function usage()
    1.18 +{
    1.19 +  echo
    1.20 +  echo "Usage: $PRG ARCHIVE COMPONENTS"
    1.21 +  echo
    1.22 +  echo "  Re-package Isabelle distribution with add-on components."
    1.23 +  echo
    1.24 +  exit 1
    1.25 +}
    1.26 +
    1.27 +function fail()
    1.28 +{
    1.29 +  echo "$1" >&2
    1.30 +  exit 2
    1.31 +}
    1.32 +
    1.33 +
    1.34 +## process command line
    1.35 +
    1.36 +[ "$#" -lt 1 ] && usage
    1.37 +
    1.38 +ARCHIVE="$1"; shift
    1.39 +
    1.40 +declare -a COMPONENTS
    1.41 +COMPONENTS=("$@")
    1.42 +
    1.43 +
    1.44 +## main
    1.45 +
    1.46 +mkdir "$TMP" || fail "Cannot create directory $TMP"
    1.47 +
    1.48 +ARCHIVE_DIR="$(cd $(dirname "$ARCHIVE"); echo "$PWD")"
    1.49 +ISABELLE_NAME="$(basename "$ARCHIVE" .tar.gz)"
    1.50 +ISABELLE_HOME="$TMP/$ISABELLE_NAME"
    1.51 +
    1.52 +[ ! -f "$ARCHIVE" ] && fail "Bad archive file $ARCHIVE"
    1.53 +tar -C "$TMP" -x -z -f "$ARCHIVE"
    1.54 +
    1.55 +echo "#bundled components" >> "$ISABELLE_HOME/etc/components"
    1.56 +
    1.57 +for COMPONENT in "${COMPONENTS[@]}"
    1.58 +do
    1.59 +  tar -C "$ISABELLE_HOME/contrib" -x -z -f "$COMPONENT"
    1.60 +  NAME="$(basename "$COMPONENT" .tar.gz)"
    1.61 +  [ -d "$ISABELLE_HOME/contrib/$NAME" ] || fail "Bad archive content $COMPONENT"
    1.62 +
    1.63 +  if [ -e "$ISABELLE_HOME/contrib/$NAME/etc/settings" ]; then
    1.64 +    echo "component $NAME"
    1.65 +    echo "contrib/$NAME" >> "$ISABELLE_HOME/etc/components"
    1.66 +  else
    1.67 +    echo "package $NAME"
    1.68 +  fi
    1.69 +done
    1.70 +
    1.71 +tar -C "$TMP" -c -z \
    1.72 +  -f "${ARCHIVE_DIR}/${ISABELLE_NAME}_bundle.tar.gz" \
    1.73 +  Isabelle "$ISABELLE_NAME"
    1.74 +
    1.75 +
    1.76 +# clean up
    1.77 +cd /tmp
    1.78 +rm -rf "$TMP"