Admin/java/build
author blanchet
Mon May 19 23:43:53 2014 +0200 (2014-05-19)
changeset 57008 10f68b83b474
parent 56607 ab7c656215f2
child 57392 f7a604a2fa63
permissions -rwxr-xr-x
use E 1.8's auto scheduler option
     1 #!/usr/bin/env bash
     2 
     3 ## diagnostics
     4 
     5 function fail()
     6 {
     7   echo "$1" >&2
     8   exit 2
     9 }
    10 
    11 
    12 ## parameters
    13 
    14 VERSION="8u5"
    15 FULL_VERSION="1.8.0_05"
    16 
    17 ARCHIVE_LINUX32="jdk-${VERSION}-linux-i586.tar.gz"
    18 ARCHIVE_LINUX64="jdk-${VERSION}-linux-x64.tar.gz"
    19 ARCHIVE_DARWIN="jdk${FULL_VERSION}.jdk.tar.gz"
    20 ARCHIVE_WINDOWS="jdk${FULL_VERSION}.tar.gz"
    21 
    22 
    23 ## main
    24 
    25 DIR="jdk-${VERSION}"
    26 mkdir "$DIR" || fail "Cannot create fresh directory: \"$DIR\""
    27 
    28 
    29 # README
    30 
    31 cat >> "$DIR/README" << EOF
    32 This is JDK $FULL_VERSION as required for Isabelle.
    33 
    34 See http://www.oracle.com/technetwork/java/javase/downloads/index.html
    35 for the original downloads, which are covered by the Oracle Binary
    36 Code License Agreement for Java SE.
    37 
    38 Linux, Mac OS X, Windows work uniformly, depending on certain
    39 platform-specific subdirectories.
    40 EOF
    41 
    42 
    43 # settings
    44 
    45 mkdir "$DIR/etc"
    46 cat >> "$DIR/etc/settings" << EOF
    47 # -*- shell-script -*- :mode=shellscript:
    48 
    49 case "\${ISABELLE_PLATFORM64:-\$ISABELLE_PLATFORM32}" in
    50   x86-darwin)
    51     echo "### Java 1.7 unavailable on 32bit Macintosh!" >&2
    52     ;;
    53   x86_64-darwin)
    54     ISABELLE_JDK_HOME="\$COMPONENT/\$ISABELLE_PLATFORM64/Contents/Home"
    55     ;;
    56   *)
    57     ISABELLE_JDK_HOME="\$COMPONENT/\${ISABELLE_PLATFORM64:-\$ISABELLE_PLATFORM32}"
    58     ;;
    59 esac
    60 
    61 if [ -n "\$ISABELLE_JDK_HOME" ]; then
    62   if [ -d "\$ISABELLE_JDK_HOME" ]; then
    63     ISABELLE_JAVA_EXT="\${ISABELLE_JDK_HOME}/jre/lib/ext"
    64   else
    65     echo "### Missing Java 1.7 platform directory: \"\$ISABELLE_JDK_HOME\"" >&2
    66     unset ISABELLE_JDK_HOME
    67   fi
    68 fi
    69 EOF
    70 
    71 
    72 # content
    73 
    74 #GNU tar (notably on Mac OS X)
    75 if [ -x /usr/bin/gnutar ]; then
    76   function tar() { /usr/bin/gnutar "$@"; }
    77 fi
    78 
    79 mkdir "$DIR/x86-linux" "$DIR/x86_64-linux" "$DIR/x86_64-darwin" "$DIR/x86-cygwin"
    80 
    81 tar -C "$DIR/x86-linux" -xf "$ARCHIVE_LINUX32"
    82 tar -C "$DIR/x86_64-linux" -xf "$ARCHIVE_LINUX64"
    83 tar -C "$DIR/x86_64-darwin" -xf "$ARCHIVE_DARWIN"
    84 tar -C "$DIR/x86-cygwin" -xf "$ARCHIVE_WINDOWS"
    85 
    86 (
    87   cd "$DIR"
    88   for PLATFORM in x86-linux x86_64-linux x86-cygwin
    89   do
    90     mv "$PLATFORM/jdk${FULL_VERSION}"/* "$PLATFORM"/.
    91     rmdir "$PLATFORM/jdk${FULL_VERSION}"
    92   done
    93   PLATFORM=x86_64-darwin
    94   mv "$PLATFORM/jdk${FULL_VERSION}.jdk"/* "$PLATFORM"/.
    95   rmdir "$PLATFORM/jdk${FULL_VERSION}.jdk"
    96 )
    97 
    98 chgrp -R isabelle "$DIR"
    99 chmod -R a+r "$DIR"
   100 chmod -R a+X "$DIR"
   101 
   102 find "$DIR/x86_64-darwin" -name "._*" -exec rm -f {} ";"
   103 
   104 echo "Sharing ..."
   105 (
   106   cd "$DIR/x86-linux"
   107   for FILE in $(find . -type f)
   108   do
   109     for OTHER in \
   110       "../x86_64-linux/$FILE" \
   111       "../x86_64-darwin/Contents/Home/$FILE" \
   112       "../x86-cygwin/$FILE"
   113     do
   114       if cmp -s "$FILE" "$OTHER"
   115       then
   116         echo -n "."
   117         ln -f "$FILE" "$OTHER"
   118       fi
   119     done
   120   done
   121 )
   122 echo
   123 
   124 
   125 # create archive
   126 
   127 echo "Archiving ..."
   128 tar -c -z -f "${DIR}.tar.gz" "$DIR" && echo "${DIR}.tar.gz"