Admin/makedist
author haftmann
Mon Jul 11 18:44:58 2011 +0200 (2011-07-11)
changeset 43764 366d5726de09
parent 43357 07889e32bc58
child 44152 a07748619f53
permissions -rwxr-xr-x
explicit code equation for equality
wenzelm@28932
     1
#!/usr/bin/env bash
wenzelm@28932
     2
#
wenzelm@28932
     3
# makedist -- make Isabelle source distribution
wenzelm@28932
     4
wenzelm@28932
     5
## global settings
wenzelm@28932
     6
wenzelm@41665
     7
REPOS_NAME="isabelle"
wenzelm@33909
     8
REPOS="http://isabelle.in.tum.de/repos/${REPOS_NAME}"
wenzelm@28932
     9
wenzelm@28932
    10
DISTPREFIX=${DISTPREFIX:-~/tmp/isadist}
wenzelm@28932
    11
wenzelm@28932
    12
umask 022
wenzelm@28932
    13
wenzelm@28932
    14
wenzelm@28932
    15
## diagnostics
wenzelm@28932
    16
wenzelm@30885
    17
PRG="$(basename "$0")"
wenzelm@30885
    18
THIS="$(cd $(dirname "$0"); echo "$PWD")"
wenzelm@28932
    19
wenzelm@28932
    20
function usage()
wenzelm@28932
    21
{
wenzelm@28932
    22
  cat <<EOF
wenzelm@28932
    23
wenzelm@28932
    24
Usage: $PRG [OPTIONS] [VERSION]
wenzelm@28932
    25
wenzelm@28932
    26
  Options are:
wenzelm@43357
    27
    -j JEDIT_BUILD     build Isabelle/jEdit via given jedit_build component
wenzelm@28932
    28
    -r RELEASE         proper release with name"
wenzelm@28932
    29
wenzelm@28932
    30
  Make Isabelle distribution from the main Mercurial repository at TUM.
wenzelm@28932
    31
wenzelm@28932
    32
  VERSION identifies the snapshot, using usual Mercurial terminology;
wenzelm@28932
    33
  the default is RELEASE if given, otherwise "tip".
wenzelm@28932
    34
wenzelm@28932
    35
EOF
wenzelm@28932
    36
  exit 1
wenzelm@28932
    37
}
wenzelm@28932
    38
wenzelm@28932
    39
function fail()
wenzelm@28932
    40
{
wenzelm@28932
    41
  echo "$1" >&2
wenzelm@28932
    42
  exit 2
wenzelm@28932
    43
}
wenzelm@28932
    44
wenzelm@28932
    45
wenzelm@28932
    46
## process command line
wenzelm@28932
    47
wenzelm@28932
    48
# options
wenzelm@28932
    49
wenzelm@28932
    50
RELEASE=""
wenzelm@43357
    51
ISABELLE_JEDIT_BUILD_HOME=""
wenzelm@28932
    52
wenzelm@43357
    53
while getopts "j:r:" OPT
wenzelm@28932
    54
do
wenzelm@28932
    55
  case "$OPT" in
wenzelm@43357
    56
    j)
wenzelm@43357
    57
      ISABELLE_JEDIT_BUILD_HOME="$OPTARG"
wenzelm@43357
    58
      ;;
wenzelm@28932
    59
    r)
wenzelm@28932
    60
      RELEASE="$OPTARG"
wenzelm@28932
    61
      ;;
wenzelm@28932
    62
    \?)
wenzelm@28932
    63
      usage
wenzelm@28932
    64
      ;;
wenzelm@28932
    65
  esac
wenzelm@28932
    66
done
wenzelm@28932
    67
wenzelm@28932
    68
shift $(($OPTIND - 1))
wenzelm@28932
    69
wenzelm@28932
    70
wenzelm@28932
    71
# args
wenzelm@28932
    72
wenzelm@28932
    73
VERSION=""
wenzelm@28932
    74
[ "$#" -gt 0 ] && { VERSION="$1"; shift; }
wenzelm@28932
    75
[ -z "$VERSION" ] && VERSION="$RELEASE"
wenzelm@28932
    76
[ -z "$VERSION" ] && VERSION="tip"
wenzelm@28932
    77
wenzelm@28932
    78
[ "$#" -gt 0 ] && usage
wenzelm@28932
    79
wenzelm@28932
    80
wenzelm@28932
    81
## main
wenzelm@28932
    82
wenzelm@28932
    83
# tmp
wenzelm@28932
    84
wenzelm@28932
    85
TMP="tmp-$USER$$"
wenzelm@28932
    86
function purge_tmp () { rm -rf "$DISTPREFIX/$TMP"; }
wenzelm@28932
    87
wenzelm@28932
    88
wenzelm@28932
    89
# retrieve archive and resolve version identifier
wenzelm@28932
    90
wenzelm@28932
    91
mkdir "$DISTPREFIX/$TMP" || fail "Failed to create fresh directory"
wenzelm@28932
    92
cd "$DISTPREFIX/$TMP"
wenzelm@28932
    93
wenzelm@28932
    94
echo "###"
wenzelm@28932
    95
echo "### Retrieving Mercurial repository $VERSION"
wenzelm@28932
    96
echo "###"
wenzelm@28932
    97
wenzelm@28932
    98
{ wget -q "$REPOS/archive/${VERSION}.tar.gz" -O- | tar -xzf -; } || \
wenzelm@28932
    99
  fail "Failed to retrieve $VERSION"
wenzelm@28932
   100
wenzelm@33910
   101
IDENT=$(echo * | sed "s/${REPOS_NAME}-//")
wenzelm@28932
   102
wenzelm@33909
   103
rm -f "${REPOS_NAME}-${IDENT}/.hg_archival.txt"
wenzelm@33909
   104
rm -f "${REPOS_NAME}-${IDENT}/.hgtags"
wenzelm@33909
   105
rm -f "${REPOS_NAME}-${IDENT}/.hgignore"
wenzelm@33909
   106
rm -f "${REPOS_NAME}-${IDENT}/README_REPOSITORY"
wenzelm@28932
   107
wenzelm@28932
   108
wenzelm@28932
   109
# dist name
wenzelm@28932
   110
wenzelm@28932
   111
DATE=$(env LC_ALL=C date "+%d-%b-%Y")
wenzelm@28932
   112
DISTDATE=$(env LC_ALL=C date "+%B %Y")
wenzelm@28932
   113
wenzelm@28932
   114
if [ -z "$RELEASE" ]; then
wenzelm@28932
   115
  DISTNAME="Isabelle_$DATE"
wenzelm@40573
   116
  DISTVERSION="Isabelle repository snapshot $IDENT $DATE"
wenzelm@28932
   117
else
wenzelm@28932
   118
  DISTNAME="$RELEASE"
wenzelm@28932
   119
  DISTVERSION="$DISTNAME: $DISTDATE"
wenzelm@28932
   120
fi
wenzelm@28932
   121
wenzelm@28932
   122
DISTBASE="$DISTPREFIX/dist-$DISTNAME"
wenzelm@28932
   123
mkdir -p "$DISTBASE" || { purge_tmp; fail "Unable to create distribution base dir $DISTBASE!"; }
wenzelm@28932
   124
[ -e "$DISTBASE/$DISTNAME" ] && { purge_tmp; fail "$DISTBASE/$DISTNAME already exists!"; }
wenzelm@28932
   125
wenzelm@28932
   126
cd "$DISTBASE"
wenzelm@33909
   127
mv "$DISTPREFIX/$TMP/${REPOS_NAME}-${IDENT}" "$DISTNAME"
wenzelm@28932
   128
purge_tmp
wenzelm@28932
   129
wenzelm@28932
   130
cd "$DISTNAME" || fail "No dist directory: $DISTBASE/$DISTNAME"
wenzelm@28932
   131
wenzelm@28932
   132
wenzelm@28932
   133
# prepare dist for release
wenzelm@28932
   134
wenzelm@28932
   135
echo "###"
wenzelm@28932
   136
echo "### Preparing distribution $DISTNAME"
wenzelm@28932
   137
echo "###"
wenzelm@28932
   138
wenzelm@30885
   139
rm -f .hgignore
wenzelm@30287
   140
find . "(" -name \*.thy -o -name \*.ML ")" -perm +111 -print | xargs chmod -f -x
wenzelm@30885
   141
find . -print | xargs chmod -f u+rw
wenzelm@28932
   142
wenzelm@28932
   143
./Admin/build all || fail "Failed to build distribution"
wenzelm@43357
   144
wenzelm@43357
   145
if [ -n "$ISABELLE_JEDIT_BUILD_HOME" ]; then
wenzelm@43357
   146
  [ -d "$ISABELLE_JEDIT_BUILD_HOME" ] || fail "Bad jedit_build component directory: \"$ISABELLE_JEDIT_BUILD_HOME\""
wenzelm@43357
   147
  eval "$(fgrep ISABELLE_JEDIT_BUILD_VERSION "$ISABELLE_JEDIT_BUILD_HOME/etc/settings")"
wenzelm@43357
   148
  [ -n "$ISABELLE_JEDIT_BUILD_VERSION" ] || fail "Bad ISABELLE_JEDIT_BUILD_VERSION"
wenzelm@43357
   149
  export ISABELLE_JEDIT_BUILD_HOME ISABELLE_JEDIT_BUILD_VERSION
wenzelm@43357
   150
  ./bin/isabelle jedit -b || fail "Failed to build Isabelle/jEdit"
wenzelm@43357
   151
fi
wenzelm@43357
   152
wenzelm@28932
   153
rm -rf Admin
wenzelm@28932
   154
wenzelm@28932
   155
MOVE=$(find doc-src \( -type f -a -not -type l -a -not -name isabelle_isar.pdf -a -not -name pghead.pdf -a \( -name \*.dvi -o -name \*.eps -o -name \*.ps -o -name \*.pdf \) -a -print \) | grep -v 'gfx/.*pdf')
wenzelm@28932
   156
mv -f $MOVE doc
wenzelm@28932
   157
rm doc/Isa-logics.eps
wenzelm@31842
   158
rm doc/adaptation.dvi doc/adaptation.pdf doc/architecture.dvi doc/architecture.pdf
wenzelm@28932
   159
rm -rf doc-src
wenzelm@28932
   160
wenzelm@30140
   161
mkdir -p contrib
wenzelm@37369
   162
cat >contrib/README <<EOF
wenzelm@37369
   163
This directory contains add-on components that contribute to the main
wenzelm@37369
   164
Isabelle distribution.  Separate licensing conditions apply, see each
wenzelm@37369
   165
directory individually.
wenzelm@37369
   166
EOF
wenzelm@28932
   167
wenzelm@28932
   168
cp doc/isabelle*.eps lib/logo
wenzelm@28932
   169
wenzelm@28932
   170
if [ -z "$RELEASE" ]; then
wenzelm@28932
   171
  {
wenzelm@28932
   172
    echo
wenzelm@28932
   173
    echo "IMPORTANT NOTE"
wenzelm@28932
   174
    echo "=============="
wenzelm@28932
   175
    echo
wenzelm@28932
   176
    echo "This is an unofficial snapshot of Isabelle, created by $LOGNAME $DATE."
wenzelm@28932
   177
    echo "See $REPOS/log/$IDENT for details."
wenzelm@28932
   178
    echo
wenzelm@28932
   179
  } >ANNOUNCE
wenzelm@28932
   180
else
wenzelm@41560
   181
  rm Isabelle Isabelle.exe
wenzelm@28932
   182
  perl -pi -e "s,val is_official = false,val is_official = true,g" src/Pure/ROOT.ML
wenzelm@28932
   183
fi
wenzelm@28932
   184
wenzelm@28932
   185
perl -pi -e "s,val changelog = \"\",val changelog = \"$REPOS/log/$IDENT\",g" src/Pure/ROOT.ML
wenzelm@41511
   186
perl -pi -e "s,ISABELLE_ID=\"\",ISABELLE_ID=\"$IDENT\",g" lib/scripts/getsettings
wenzelm@28932
   187
perl -pi -e "s,ISABELLE_IDENTIFIER=\"\",ISABELLE_IDENTIFIER=\"$DISTNAME\",g" lib/scripts/getsettings
wenzelm@28932
   188
perl -pi -e "s,{ISABELLE},$DISTNAME,g" lib/html/library_index_header.template
wenzelm@32361
   189
perl -pi -e "s,unidentified repository version,$DISTVERSION,g" src/Pure/ROOT.ML lib/Tools/version
wenzelm@32361
   190
perl -pi -e "s,some unidentified repository version of Isabelle,$DISTVERSION,g" README
wenzelm@28932
   191
wenzelm@28932
   192
wenzelm@37341
   193
# create archive
wenzelm@28932
   194
wenzelm@28932
   195
echo "###"
wenzelm@37341
   196
echo "### Creating archive ..."
wenzelm@28932
   197
echo "###"
wenzelm@28932
   198
wenzelm@28932
   199
cd "$DISTBASE"
wenzelm@28932
   200
wenzelm@28932
   201
echo "$DISTBASE/$DISTNAME.tar.gz" > ../ISABELLE_DIST
wenzelm@28932
   202
echo "$IDENT" >../ISABELLE_IDENT
wenzelm@28932
   203
wenzelm@28932
   204
chown -R "$LOGNAME" "$DISTNAME"
wenzelm@28932
   205
chmod -R u+w "$DISTNAME"
wenzelm@28932
   206
chmod -R g=o "$DISTNAME"
wenzelm@40713
   207
chgrp -R isabelle "$DISTNAME"
wenzelm@28932
   208
wenzelm@28932
   209
echo "$DISTNAME.tar.gz"
wenzelm@40713
   210
tar -czf "$DISTNAME.tar.gz" "$DISTNAME"
wenzelm@28932
   211
wenzelm@28932
   212
wenzelm@28932
   213
# cleanup dist
wenzelm@28932
   214
wenzelm@28932
   215
mv "$DISTNAME" "${DISTNAME}-old"
wenzelm@28932
   216
mkdir "$DISTNAME"
wenzelm@28932
   217
wenzelm@37368
   218
mv "${DISTNAME}-old/README" "${DISTNAME}-old/NEWS" "${DISTNAME}-old/ANNOUNCE" \
wenzelm@37368
   219
  "${DISTNAME}-old/COPYRIGHT" "${DISTNAME}-old/CONTRIBUTORS" "$DISTNAME"
wenzelm@28932
   220
mkdir "$DISTNAME/doc"
wenzelm@28932
   221
mv "${DISTNAME}-old/doc/"*.pdf "${DISTNAME}-old/doc/Contents" "$DISTNAME/doc"
wenzelm@28932
   222
wenzelm@41984
   223
rm -f Isabelle && ln -sf "$DISTNAME" Isabelle
wenzelm@41984
   224
wenzelm@28932
   225
chgrp -R isabelle "$DISTNAME"
wenzelm@28932
   226
wenzelm@28932
   227
rm -rf "${DISTNAME}-old"
wenzelm@28932
   228
wenzelm@37341
   229
wenzelm@37341
   230
echo "DONE"