Admin/makebundle
author blanchet
Wed, 28 Apr 2010 17:56:07 +0200
changeset 36549 d29617bcc1fb
parent 33907 473f859e1c29
child 37315 af2adf0ae97d
permissions -rwxr-xr-x
properly extract SPASS proof
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33907
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
     1
#!/usr/bin/env bash
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
     2
#
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
     3
# makebundle -- re-package with add-on components
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
     4
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
     5
## global settings
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
     6
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
     7
TMP="/var/tmp/isabelle-makebundle$$"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
     8
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
     9
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    10
## diagnostics
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    11
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    12
PRG=$(basename "$0")
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    13
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    14
function usage()
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    15
{
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    16
  echo
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    17
  echo "Usage: $PRG ARCHIVE COMPONENTS"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    18
  echo
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    19
  echo "  Re-package Isabelle distribution with add-on components."
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    20
  echo
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    21
  exit 1
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    22
}
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    23
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    24
function fail()
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    25
{
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    26
  echo "$1" >&2
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    27
  exit 2
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    28
}
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    29
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    30
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    31
## process command line
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    32
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    33
[ "$#" -lt 1 ] && usage
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    34
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    35
ARCHIVE="$1"; shift
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    36
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    37
declare -a COMPONENTS
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    38
COMPONENTS=("$@")
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    39
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    40
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    41
## main
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    42
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    43
mkdir "$TMP" || fail "Cannot create directory $TMP"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    44
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    45
ARCHIVE_DIR="$(cd $(dirname "$ARCHIVE"); echo "$PWD")"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    46
ISABELLE_NAME="$(basename "$ARCHIVE" .tar.gz)"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    47
ISABELLE_HOME="$TMP/$ISABELLE_NAME"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    48
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    49
[ ! -f "$ARCHIVE" ] && fail "Bad archive file $ARCHIVE"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    50
tar -C "$TMP" -x -z -f "$ARCHIVE"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    51
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    52
echo "#bundled components" >> "$ISABELLE_HOME/etc/components"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    53
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    54
for COMPONENT in "${COMPONENTS[@]}"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    55
do
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    56
  tar -C "$ISABELLE_HOME/contrib" -x -z -f "$COMPONENT"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    57
  NAME="$(basename "$COMPONENT" .tar.gz)"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    58
  [ -d "$ISABELLE_HOME/contrib/$NAME" ] || fail "Bad archive content $COMPONENT"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    59
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    60
  if [ -e "$ISABELLE_HOME/contrib/$NAME/etc/settings" ]; then
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    61
    echo "component $NAME"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    62
    echo "contrib/$NAME" >> "$ISABELLE_HOME/etc/components"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    63
  else
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    64
    echo "package $NAME"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    65
  fi
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    66
done
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    67
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    68
tar -C "$TMP" -c -z \
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    69
  -f "${ARCHIVE_DIR}/${ISABELLE_NAME}_bundle.tar.gz" \
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    70
  Isabelle "$ISABELLE_NAME"
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    71
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    72
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    73
# clean up
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    74
cd /tmp
473f859e1c29 re-package Isabelle distribution with add-on components;
wenzelm
parents:
diff changeset
    75
rm -rf "$TMP"