Admin/Release/build
author wenzelm
Fri Apr 25 23:47:39 2014 +0200 (2014-04-25)
changeset 56734 6ca87a061740
parent 51064 9c425ed4a52c
child 56902 f901a08c5653
permissions -rwxr-xr-x
suppress potential dangerous option (see 1baa5d19ac44);
wenzelm@50899
     1
#!/usr/bin/env bash
wenzelm@50899
     2
#
wenzelm@50899
     3
# Author: Makarius
wenzelm@50899
     4
#
wenzelm@50899
     5
# build full Isabelle distribution from repository
wenzelm@50899
     6
wenzelm@50899
     7
THIS="$(cd "$(dirname "$0")"; pwd)"
wenzelm@50899
     8
PRG="$(basename "$0")"
wenzelm@50899
     9
wenzelm@50899
    10
wenzelm@50899
    11
## diagnostics
wenzelm@50899
    12
wenzelm@50899
    13
PRG="$(basename "$0")"
wenzelm@50899
    14
wenzelm@50899
    15
function usage()
wenzelm@50899
    16
{
wenzelm@50899
    17
  echo
wenzelm@50899
    18
  echo "Usage: isabelle $PRG [OPTIONS] DIR [VERSION]"
wenzelm@50899
    19
  echo
wenzelm@50899
    20
  echo "  Options are:"
wenzelm@50899
    21
  echo "    -j INT       maximum number of parallel jobs (default 1)"
wenzelm@50899
    22
  echo "    -r RELEASE   proper release with name"
wenzelm@50899
    23
  echo
wenzelm@50899
    24
  echo "  Make Isabelle distribution DIR, using the local repository clone."
wenzelm@50899
    25
  echo
wenzelm@50899
    26
  echo "  VERSION identifies the snapshot, using usual Mercurial terminology;"
wenzelm@50899
    27
  echo "  the default is RELEASE if given, otherwise \"tip\"."
wenzelm@50899
    28
  echo
wenzelm@50899
    29
  exit 1
wenzelm@50899
    30
}
wenzelm@50899
    31
wenzelm@50899
    32
function fail()
wenzelm@50899
    33
{
wenzelm@50899
    34
  echo "$1" >&2
wenzelm@50899
    35
  exit 2
wenzelm@50899
    36
}
wenzelm@50899
    37
wenzelm@50899
    38
function check_number()
wenzelm@50899
    39
{
wenzelm@50899
    40
  [ -n "$1" -a -z "$(echo "$1" | tr -d '[0-9]')" ] || fail "Bad number: \"$1\""
wenzelm@50899
    41
}
wenzelm@50899
    42
wenzelm@50899
    43
wenzelm@50899
    44
## process command line
wenzelm@50899
    45
wenzelm@50899
    46
# options
wenzelm@50899
    47
wenzelm@50899
    48
JOBS=""
wenzelm@50899
    49
RELEASE=""
wenzelm@50899
    50
wenzelm@50899
    51
while getopts "j:r:" OPT
wenzelm@50899
    52
do
wenzelm@50899
    53
  case "$OPT" in
wenzelm@50899
    54
    j)
wenzelm@50899
    55
      check_number "$OPTARG"
wenzelm@50899
    56
      JOBS="-j $OPTARG"
wenzelm@50899
    57
      ;;
wenzelm@50899
    58
    r)
wenzelm@50899
    59
      RELEASE="$OPTARG"
wenzelm@50899
    60
      ;;
wenzelm@50899
    61
    \?)
wenzelm@50899
    62
      usage
wenzelm@50899
    63
      ;;
wenzelm@50899
    64
  esac
wenzelm@50899
    65
done
wenzelm@50899
    66
wenzelm@50899
    67
shift $(($OPTIND - 1))
wenzelm@50899
    68
wenzelm@50899
    69
wenzelm@50899
    70
# args
wenzelm@50899
    71
wenzelm@50899
    72
BASE_DIR=""
wenzelm@50899
    73
[ "$#" -gt 0 ] && { BASE_DIR="$1"; shift; }
wenzelm@50899
    74
[ -z "$BASE_DIR" ] && usage
wenzelm@50899
    75
wenzelm@50899
    76
VERSION=""
wenzelm@50899
    77
[ "$#" -gt 0 ] && { VERSION="$1"; shift; }
wenzelm@50899
    78
[ -z "$VERSION" ] && VERSION="$RELEASE"
wenzelm@50899
    79
[ -z "$VERSION" ] && VERSION="tip"
wenzelm@50899
    80
wenzelm@50899
    81
[ "$#" -gt 0 ] && usage
wenzelm@50899
    82
wenzelm@50899
    83
wenzelm@50899
    84
## Isabelle settings
wenzelm@50899
    85
wenzelm@50899
    86
ISABELLE_TOOL="$THIS/../../bin/isabelle"
wenzelm@50899
    87
ISABELLE_PLATFORM_FAMILY="$("$ISABELLE_TOOL" getenv -b ISABELLE_PLATFORM_FAMILY)"
wenzelm@50899
    88
wenzelm@50899
    89
wenzelm@50899
    90
## main
wenzelm@50899
    91
wenzelm@50899
    92
if [ -z "$RELEASE" ]; then
wenzelm@50899
    93
  DISTNAME="Isabelle_$(env LC_ALL=C date "+%d-%b-%Y")"
wenzelm@50899
    94
  "$ISABELLE_TOOL" makedist -d "$BASE_DIR" $JOBS
wenzelm@50899
    95
else
wenzelm@50899
    96
  DISTNAME="$RELEASE"
wenzelm@50899
    97
  "$ISABELLE_TOOL" makedist -d "$BASE_DIR" $JOBS -r "$RELEASE"
wenzelm@50899
    98
fi
wenzelm@50899
    99
[ "$?" = 0 ] || exit "$?"
wenzelm@50899
   100
wenzelm@50899
   101
DISTBASE="$BASE_DIR/dist-${DISTNAME}"
wenzelm@50899
   102
wenzelm@51064
   103
wenzelm@51064
   104
for PLATFORM_FAMILY in linux macos windows
wenzelm@51064
   105
do
wenzelm@51064
   106
wenzelm@51064
   107
echo
wenzelm@51064
   108
echo "*** $PLATFORM_FAMILY ***"
wenzelm@51064
   109
wenzelm@51064
   110
"$ISABELLE_TOOL" makedist_bundle "$DISTBASE/${DISTNAME}.tar.gz" "$PLATFORM_FAMILY"
wenzelm@50899
   111
[ "$?" = 0 ] || exit "$?"
wenzelm@50899
   112
wenzelm@51064
   113
done
wenzelm@51064
   114
wenzelm@50899
   115
"$THIS/build_library" $JOBS "$DISTBASE/${DISTNAME}_${ISABELLE_PLATFORM_FAMILY}.tar.gz"
wenzelm@50899
   116