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