Admin/makebin
author wenzelm
Mon Jul 14 19:59:58 2008 +0200 (2008-07-14)
changeset 27587 6f469a8aff10
parent 27030 8c558af86e21
child 27588 0dd8d4c558f9
permissions -rwxr-xr-x
added HOL-Nominal image;
     1 #!/usr/bin/env bash
     2 #
     3 # $Id$
     4 #
     5 # makebin -- make Isabelle logic images for current platform.
     6 
     7 
     8 ## global settings
     9 
    10 TMP="/var/tmp/isabelle-makebin$$"
    11 
    12 TAR=tar
    13 type -path gtar >/dev/null && TAR=gtar
    14 
    15 export THIS_IS_ISABELLE_MAKEBIN=true
    16 
    17 
    18 ## diagnostics
    19 
    20 PRG=$(basename "$0")
    21 
    22 function usage()
    23 {
    24   echo
    25   echo "Usage: $PRG [OPTIONS] ARCHIVE"
    26   echo
    27   echo "  Options are:"
    28   echo "    -l           produce library"
    29   echo "    -n           dry run"
    30   echo
    31   echo "  Precompile Isabelle for the current platform."
    32   echo
    33   exit 1
    34 }
    35 
    36 function fail()
    37 {
    38   echo "$1" >&2
    39   exit 2
    40 }
    41 
    42 
    43 ## process command line
    44 
    45 # options
    46 
    47 DO_LIBRARY=""
    48 DRY_RUN=""
    49 
    50 while getopts "ln" OPT
    51 do
    52   case "$OPT" in
    53     l)
    54       DO_LIBRARY=true
    55       ;;
    56     n)
    57       DRY_RUN=true
    58       ;;
    59     \?)
    60       usage
    61       ;;
    62   esac
    63 done
    64 
    65 shift $(($OPTIND - 1))
    66 
    67 
    68 # args
    69 
    70 [ "$#" -gt 1 ] && usage
    71 
    72 ARCHIVE="$1"; shift
    73 
    74 
    75 ## main
    76 
    77 [ ! -f "$ARCHIVE" ] && fail "Bad archive file $ARCHIVE"
    78 ARCHIVE_BASE=$(basename "$ARCHIVE")
    79 ARCHIVE_DIR=$(cd $(dirname "$ARCHIVE"); echo "$PWD")
    80 ARCHIVE_FULL="$ARCHIVE_DIR/$ARCHIVE_BASE"
    81 
    82 ISABELLE_NAME=$(basename "$ARCHIVE_BASE" .tar.gz)
    83 ISABELLE_HOME="$TMP/$ISABELLE_NAME"
    84 
    85 
    86 # build logics
    87 
    88 mkdir "$TMP" || fail "Cannot create directory $TMP"
    89 
    90 cd "$TMP"
    91 "$TAR" xzf "$ARCHIVE_FULL"
    92 cd "$ISABELLE_NAME"
    93 
    94 perl -pi \
    95   -e 's:^ISABELLE_USEDIR_OPTIONS=.*$:ISABELLE_USEDIR_OPTIONS="-p 1":;' \
    96   -e 's:^HOL_USEDIR_OPTIONS=.*$:HOL_USEDIR_OPTIONS="-p 2":;' \
    97   etc/settings
    98 
    99 if [ -n "$DO_LIBRARY" ]; then
   100   perl -pi -e 's:^ISABELLE_USEDIR_OPTIONS=.*$:ISABELLE_USEDIR_OPTIONS="-p 1 -i true -d pdf -V outline=/proof,/ML":;' \
   101     etc/settings
   102 fi
   103 
   104 ISABELLE_HOME_USER=$(./bin/isatool getenv -b ISABELLE_HOME_USER)
   105 [ -f "$ISABELLE_HOME_USER/etc/settings" ] && \
   106   echo "### WARNING!  Personal Isabelle settings present. " >&2
   107 
   108 COMPILER=$(./bin/isatool getenv -b ML_IDENTIFIER)
   109 PLATFORM=$(./bin/isatool getenv -b ML_PLATFORM)
   110 
   111 if [ -n "$DRY_RUN" ]; then
   112   mkdir -p "heaps/$COMPILER/log"
   113   touch "heaps/$COMPILER/HOL"
   114   touch "heaps/$COMPILER/log/HOL.gz"
   115   touch "heaps/$COMPILER/HOL-Complex"
   116   touch "heaps/$COMPILER/log/HOL-Complex.gz"
   117   touch "heaps/$COMPILER/HOL-Nominal"
   118   touch "heaps/$COMPILER/log/HOL-Nominal.gz"
   119   touch "heaps/$COMPILER/ZF"
   120   touch "heaps/$COMPILER/log/ZF.gz"
   121   mkdir browser_info
   122 elif [ -n "$DO_LIBRARY" ]; then
   123   ./build -bait
   124 else
   125   ./build -b -m HOL-Complex HOL
   126   ./build -b -m HOL-Nominal HOL
   127   ./build -b ZF
   128   rm -f "heaps/$COMPILER/Pure" "heaps/$COMPILER/FOL"
   129 fi
   130 
   131 
   132 # prepare result
   133 
   134 cd "$TMP"
   135 
   136 chmod -R g=o "$TMP"
   137 chgrp -R isabelle "$TMP"
   138 
   139 if [ -n "$DO_LIBRARY" ]; then
   140   "$TAR" cf "${ISABELLE_NAME}_library.tar" $ISABELLE_NAME/browser_info && \
   141     gzip -f "${ISABELLE_NAME}_library.tar"
   142     cp -f "${ISABELLE_NAME}_library.tar.gz" "$ARCHIVE_DIR"
   143 else
   144   for IMG in HOL HOL-Complex HOL-Nominal ZF
   145   do
   146     "$TAR" cf "${IMG}_$PLATFORM.tar" \
   147       "$ISABELLE_NAME/heaps/$COMPILER/$IMG" \
   148       "$ISABELLE_NAME/heaps/$COMPILER/log/$IMG.gz"
   149     gzip -f "${IMG}_$PLATFORM.tar"
   150     cp -f "${IMG}_$PLATFORM.tar.gz" "$ARCHIVE_DIR"
   151   done
   152 fi
   153 
   154 
   155 # clean up
   156 cd /tmp
   157 rm -rf "$TMP"