Admin/makebin
author wenzelm
Wed May 30 23:31:57 2007 +0200 (2007-05-30)
changeset 23137 ae4110f7f88f
parent 17660 94bbe14c088e
child 25183 261d6791952c
permissions -rwxr-xr-x
removed HOL4 image, which seldom works;
     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_BUILD=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/ZF"
   118   touch "heaps/$COMPILER/log/ZF.gz"
   119   mkdir browser_info
   120 elif [ -n "$DO_LIBRARY" ]; then
   121   ./build -bait
   122 else
   123   ./build -b -m HOL-Complex HOL
   124   ./build -b ZF
   125   rm -f "heaps/$COMPILER/Pure" "heaps/$COMPILER/FOL"
   126 fi
   127 
   128 
   129 # prepare result
   130 
   131 cd "$TMP"
   132 
   133 chmod -R g=o "$TMP"
   134 chgrp -R isabelle "$TMP"
   135 
   136 if [ -n "$DO_LIBRARY" ]; then
   137   "$TAR" cf "${ISABELLE_NAME}_library.tar" $ISABELLE_NAME/browser_info && \
   138     gzip -f "${ISABELLE_NAME}_library.tar"
   139     cp -f "${ISABELLE_NAME}_library.tar.gz" "$ARCHIVE_DIR"
   140 else
   141   for IMG in HOL HOL-Complex ZF
   142   do
   143     "$TAR" cf "${IMG}_$PLATFORM.tar" \
   144       "$ISABELLE_NAME/heaps/$COMPILER/$IMG" \
   145       "$ISABELLE_NAME/heaps/$COMPILER/log/$IMG.gz"
   146     gzip -f "${IMG}_$PLATFORM.tar"
   147     cp -f "${IMG}_$PLATFORM.tar.gz" "$ARCHIVE_DIR"
   148   done
   149 fi
   150 
   151 
   152 # clean up
   153 cd /tmp
   154 rm -rf "$TMP"