Admin/makebundle
author blanchet
Tue Dec 07 11:56:53 2010 +0100 (2010-12-07)
changeset 41052 3db267a01c1d
parent 37357 b7a55231065a
child 41555 178fdd4cca46
permissions -rwxr-xr-x
remove the "fin_fun" optimization in Nitpick -- it was always a hack and didn't help much
     1 #!/usr/bin/env bash
     2 #
     3 # makebundle -- re-package with add-on components
     4 
     5 ## diagnostics
     6 
     7 PRG=$(basename "$0")
     8 
     9 function usage()
    10 {
    11   echo
    12   echo "Usage: $PRG ARCHIVE PLATFORM"
    13   echo
    14   echo "  Re-package Isabelle source distribution with add-on components"
    15   echo "  and heap images"
    16   echo
    17   exit 1
    18 }
    19 
    20 function fail()
    21 {
    22   echo "$1" >&2
    23   exit 2
    24 }
    25 
    26 
    27 ## implicit and explicit arguments
    28 
    29 TMP="/var/tmp/isabelle-makebundle$$"
    30 mkdir "$TMP" || fail "Cannot create directory $TMP"
    31 
    32 [ "$#" -ne 2 ] && usage
    33 
    34 ARCHIVE="$1"; shift
    35 PLATFORM="$1"; shift
    36 
    37 [ -f "$ARCHIVE" ] || fail "Bad source archive: $ARCHIVE"
    38 
    39 
    40 ## main
    41 
    42 ARCHIVE_DIR="$(cd $(dirname "$ARCHIVE"); echo "$PWD")"
    43 ISABELLE_NAME="$(basename "$ARCHIVE" .tar.gz)"
    44 ISABELLE_HOME="$TMP/$ISABELLE_NAME"
    45 
    46 tar -C "$TMP" -x -z -f "$ARCHIVE"
    47 
    48 
    49 echo "#bundled components" >> "$ISABELLE_HOME/etc/components"
    50 
    51 for CONTRIB in "$ARCHIVE_DIR"/contrib/*.tar.gz
    52 do
    53   tar -C "$ISABELLE_HOME/contrib" -x -z -f "$CONTRIB"
    54   NAME="$(basename "$CONTRIB" .tar.gz)"
    55   [ -d "$ISABELLE_HOME/contrib/$NAME" ] || fail "Bad archive content $CONTRIB"
    56 
    57   if [ -e "$ISABELLE_HOME/contrib/$NAME/etc/settings" ]; then
    58     echo "component $NAME"
    59     echo "contrib/$NAME" >> "$ISABELLE_HOME/etc/components"
    60   else
    61     echo "package $NAME"
    62   fi
    63 done
    64 
    65 
    66 HEAPS_ARCHIVE="$ARCHIVE_DIR/${ISABELLE_NAME}_heaps_${PLATFORM}.tar.gz"
    67 [ -f "$HEAPS_ARCHIVE" ] || fail "Bad heaps archive: $HEAPS_ARCHIVE"
    68 echo "heaps"
    69 tar -C "$TMP" -x -z -f "$HEAPS_ARCHIVE"
    70 
    71 
    72 BUNDLE_ARCHIVE="${ARCHIVE_DIR}/${ISABELLE_NAME}_bundle_${PLATFORM}.tar.gz"
    73 
    74 echo "$(basename "$BUNDLE_ARCHIVE")"
    75 tar -C "$TMP" -c -z -f "$BUNDLE_ARCHIVE" Isabelle "$ISABELLE_NAME"
    76 
    77 
    78 # clean up
    79 cd /tmp
    80 rm -rf "$TMP"