Admin/makedist
author haftmann
Wed Jan 30 10:57:47 2008 +0100 (2008-01-30)
changeset 26015 ad2756de580e
parent 25949 850b4c2d0f17
child 26108 46f4e4cd3b69
permissions -rwxr-xr-x
idempotent semigroups
     1 #!/usr/bin/env bash
     2 #
     3 # $Id$
     4 #
     5 # makedist -- make Isabelle source distribution.
     6 
     7 
     8 ## global settings
     9 
    10 DISTPREFIX=${DISTPREFIX:-~/tmp/isadist}
    11 SRCS="CCL CTT Cube FOL FOLP HOL HOLCF LCF Provers Pure Sequents Tools ZF"
    12 
    13 export CVSROOT=/usr/proj/isabelle-repository/archive
    14 [ ! -d "$CVSROOT" ] && CVSROOT="${ISABELLE_USER:-$USER}@sunbroy2.informatik.tu-muenchen.de:$CVSROOT"
    15 
    16 umask 022
    17 
    18 TAR=tar
    19 type -path gtar >/dev/null && TAR=gtar
    20 
    21 FIND=find
    22 type -path gfind >/dev/null && FIND=gfind
    23 
    24 
    25 ## diagnostics
    26 
    27 PRG=$(basename "$0")
    28 THIS=$(cd $(dirname "$0"); echo "$PWD")
    29 
    30 function usage()
    31 {
    32   cat <<EOF
    33 
    34 Usage: $PRG VERSION [NAME]
    35 
    36   Make Isabelle distribution from the master sources at TUM.
    37 
    38   VERSION may be either a tag like "IsabelleXXXX" that specifies the
    39   release to be exported from the repository, or "-" to checkout the
    40   current sources as an unofficial release.
    41 
    42   NAME specifies an explicit distribution name, by default it is
    43   derived from VERSION.
    44 
    45   Checklist for official releases (before running this script):
    46 
    47     * Check ANNOUNCE, README, INSTALL, NEWS, COPYRIGHT, CONTRIBUTORS.
    48     * Try "isatool makeall all" with Poly/ML, SML/NJ, etc.
    49     * Tag the current repository version, e.g.:
    50         cvs -d /usr/proj/isabelle-repository/archive rtag IsabelleXXXX isabelle
    51       PLEASE DO NOT DO THIS UNLESS YOU KNOW WHAT YOU ARE DOING!
    52 
    53    After running this script:
    54 
    55     * Symlink generated files in website/ directory to their appropriate
    56       places in the isabelle website sources.
    57 
    58 EOF
    59   exit 1
    60 }
    61 
    62 function fail()
    63 {
    64   echo "$1" >&2
    65   exit 2
    66 }
    67 
    68 
    69 ## process command line
    70 
    71 [ "$#" -ne 1 -a "$#" -ne 2 ] && usage
    72 
    73 VERSION="$1"; shift
    74 
    75 if [ "$#" -eq 0 ]; then
    76   DISTNAME=""
    77 else
    78   DISTNAME="$1"; shift
    79 fi
    80 
    81 
    82 ## main
    83 
    84 # dist version
    85 
    86 DATE=$(env LC_ALL=C date "+%d-%b-%Y")
    87 DISTDATE=$(env LC_ALL=C date "+%B %Y")
    88 
    89 if [ "$VERSION" = "-" ]; then
    90   DISTIDENT="Isabelle_$DATE"
    91   [ -z "$DISTNAME" ] && DISTNAME="$DISTIDENT"
    92   DISTVERSION="$DISTNAME"
    93   EXPORT="cvs -f -q checkout -P -d $DISTNAME isabelle"
    94   UNOFFICIAL=true
    95 else
    96   DISTIDENT="$VERSION"
    97   [ -z "$DISTNAME" ] && DISTNAME="$DISTIDENT"
    98   DISTVERSION="$DISTNAME: $DISTDATE"
    99   EXPORT="cvs -f -q export -r $VERSION -d $DISTNAME isabelle"
   100   UNOFFICIAL=""
   101 fi
   102 
   103 DISTBASE="$DISTPREFIX/dist-$DISTNAME"
   104 mkdir -p "$DISTBASE" || fail "Unable to create distribution base dir $DISTBASE!"
   105 [ -e "$DISTBASE/$DISTNAME" ] && fail "$DISTBASE/$DISTNAME already exists!"
   106 [ -e "$DISTBASE/pdf/$DISTNAME" ] && fail "$DISTBASE/pdf/$DISTNAME already exists!"
   107 
   108 
   109 # export repository
   110 
   111 echo "###"
   112 echo "### Exporting $DISTIDENT ..."
   113 echo "###"
   114 
   115 cd "$DISTBASE"
   116 
   117 $EXPORT || fail "Export failed!"
   118 
   119 if [ -n "$CVS2CL" ]; then
   120   cd $DISTNAME
   121   $CVS2CL
   122   gzip ChangeLog
   123   mv ChangeLog.gz ..
   124   cd ..
   125 fi
   126 
   127 $FIND . -name CVS -print | xargs rm -rf
   128 $FIND . -name .cvsignore -print | xargs rm -rf
   129 $FIND . "(" -name \*.thy -o -name \*.ML ")" -perm +111 -print | xargs chmod -x
   130 $FIND . -print | xargs chmod u+rw
   131 
   132 
   133 # build docs
   134 
   135 echo "###"
   136 echo "### Building docs ..."
   137 echo "###"
   138 
   139 cd "$DISTBASE/$DISTNAME/Doc"
   140 PDFLATEX=$(type -path pdflatex)
   141 
   142 for DOC in $(cat Contents)
   143 do
   144   pushd "$DOC" > /dev/null
   145   make dvi || fail "DVI document for $DOC failed!"
   146   { [ -n "$PDFLATEX" ] && make clean pdf; } || fail "PDF document for $DOC failed!"
   147   popd
   148 done
   149 
   150 
   151 # prepare dist dir for release
   152 
   153 echo "###"
   154 echo "### Preparing distribution ..."
   155 echo "###"
   156 
   157 cd "$DISTBASE/$DISTNAME" || fail "No dist directory: $DISTBASE/$DISTNAME"
   158 
   159 mkdir -p ../website
   160 cat > ../website/distinfo.mak <<EOF
   161 # this is a generated file - do not edit unless you know what you are doing!
   162 
   163 DISTNAME=$DISTNAME
   164 DISTIDENT=$DISTIDENT
   165 DISTBASE=$DISTBASE
   166 EOF
   167 
   168 cp Distribution/lib/html/library_index_content.template ../website/
   169 
   170 MOVE=$($FIND Doc \( -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')
   171 mv -f $MOVE Distribution/doc
   172 rm Distribution/doc/Isa-logics.eps
   173 rm -rf Doc
   174 
   175 mkdir src contrib
   176 mv $SRCS src
   177 
   178 mv Distribution/* .
   179 rmdir Distribution
   180 
   181 
   182 #paranoia setting for sunbroy
   183 PATH=/usr/local/dist/DIR/j2sdk1.5.0/bin:$PATH
   184 
   185 ( cd lib/browser; make; ) || fail "Failed to build graph browser!"
   186 
   187 ( cd lib/classes; ./mk; )
   188 [ -f lib/classes/isabelle.jar ] || fail "Failed to build Isabelle process wrapper!"
   189 
   190 if type -p scalac >/dev/null
   191 then
   192   ( cd lib/jedit/plugin; ./mk; )
   193   [ -f lib/jedit/isabelle.jar ] || fail "Failed to build jEdit plugin!"
   194 else
   195   echo "Warning: Scala unavailable -- skipping jEdit plugin"
   196 fi
   197 
   198 
   199 cp doc/isabelle*.eps lib/logo
   200 
   201 
   202 if [ -n "$UNOFFICIAL" ]; then
   203   {
   204     echo
   205     echo "IMPORTANT NOTE"
   206     echo "=============="
   207     echo
   208     echo "This is an unofficial release of Isabelle, created by $LOGNAME $DATE."
   209     echo
   210   } >ANNOUNCE
   211 fi
   212 
   213 perl -pi -e "s/ISABELLE_IDENTIFIER=\"\"/ISABELLE_IDENTIFIER=\"$DISTNAME\"/g;" lib/scripts/getsettings
   214 perl -pi -e "s/{ISABELLE}/$DISTNAME/g;" lib/html/library_index_header.template
   215 perl -pi -e "s/Isabelle repository version/$DISTVERSION/" src/Pure/ROOT.ML lib/Tools/version
   216 perl -pi -e "s/the internal repository version of Isabelle/$DISTVERSION/" README
   217 
   218 ( cd src; ../Admin/maketags; )
   219 
   220 rm -rf Admin
   221 rm -f TODO
   222 
   223 
   224 # create archive
   225 
   226 echo "###"
   227 echo "### Creating archives ..."
   228 echo "###"
   229 
   230 cd "$DISTBASE"
   231 
   232 echo "$DISTBASE/$DISTNAME.tar.gz" > ../ISABELLE_DIST
   233 
   234 rm -f Isabelle
   235 ln -s "$DISTNAME" Isabelle
   236 
   237 chown -R "$LOGNAME" "$DISTNAME"
   238 chmod -R u+w "$DISTNAME"
   239 chmod -R g=o "$DISTNAME"
   240 chgrp -R isabelle "$DISTNAME" Isabelle
   241 
   242 mkdir -p "pdf/$DISTNAME/doc"
   243 mv "$DISTNAME/doc/"*.pdf "pdf/$DISTNAME/doc"
   244 
   245 sync; sleep 3
   246 
   247 echo "$DISTNAME.tar.gz"
   248 "$TAR" cf "$DISTNAME.tar" Isabelle "$DISTNAME"
   249 gzip "$DISTNAME.tar"
   250 
   251 echo "${DISTNAME}_pdf.tar.gz"
   252 ( cd pdf; "$TAR" cf "../${DISTNAME}_pdf.tar" "$DISTNAME"; )
   253 gzip "${DISTNAME}_pdf.tar"
   254 
   255 mv "pdf/$DISTNAME/doc/"*.pdf "$DISTNAME/doc"
   256 rmdir "pdf/$DISTNAME/doc" "pdf/$DISTNAME" pdf
   257 
   258 
   259 # cleanup dist
   260 
   261 mv "$DISTNAME" "${DISTNAME}-old"
   262 mkdir "$DISTNAME"
   263 
   264 mv "${DISTNAME}-old/README" "${DISTNAME}-old/INSTALL" "${DISTNAME}-old/NEWS" \
   265   "${DISTNAME}-old/ANNOUNCE" "${DISTNAME}-old/COPYRIGHT" "${DISTNAME}-old/CONTRIBUTORS" \
   266   "$DISTNAME"
   267 mkdir "$DISTNAME/doc"
   268 mv "${DISTNAME}-old/doc/"*.pdf "${DISTNAME}-old/doc/Contents" "$DISTNAME/doc"
   269 
   270 chgrp -R isabelle "$DISTNAME"
   271 
   272 rm -rf "${DISTNAME}-old"
   273 
   274 
   275 # final note
   276 
   277 echo "###"
   278 echo "### Finished makedist."
   279 echo "###"