Admin/java/build
author wenzelm
Thu Sep 05 16:03:44 2013 +0200 (2013-09-05)
changeset 53417 32ec957e5c3e
parent 51776 8ea64fb16bae
child 53625 a49ce8d72a44
permissions -rwxr-xr-x
updated to jdk-7u25;
less redundant directory structure;
     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="7u25"
    15 FULL_VERSION="1.7.0_25"
    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 export COPYFILE_DISABLE=true
    75 
    76 mkdir "$DIR/x86-linux" "$DIR/x86_64-linux" "$DIR/x86_64-darwin" "$DIR/x86-cygwin"
    77 
    78 tar -C "$DIR/x86-linux" -xf "$ARCHIVE_LINUX32"
    79 tar -C "$DIR/x86_64-linux" -xf "$ARCHIVE_LINUX64"
    80 tar -C "$DIR/x86_64-darwin" -xf "$ARCHIVE_DARWIN"
    81 tar -C "$DIR/x86-cygwin" -xf "$ARCHIVE_WINDOWS"
    82 
    83 (
    84   cd "$DIR"
    85   for PLATFORM in x86-linux x86_64-linux x86-cygwin
    86   do
    87     mv "$PLATFORM/jdk${FULL_VERSION}"/* "$PLATFORM"/.
    88     rmdir "$PLATFORM/jdk${FULL_VERSION}"
    89   done
    90   PLATFORM=x86_64-darwin
    91   mv "$PLATFORM/jdk${FULL_VERSION}.jdk"/* "$PLATFORM"/.
    92   rmdir "$PLATFORM/jdk${FULL_VERSION}.jdk"
    93 )
    94 
    95 chgrp -R isabelle "$DIR"
    96 chmod -R a+r "$DIR"
    97 chmod -R a+X "$DIR"
    98 
    99 find "$DIR/x86_64-darwin" -name "._*" -exec rm -f {} ";"
   100 
   101 echo "Sharing ..."
   102 (
   103   cd "$DIR/x86-linux"
   104   for FILE in $(find . -type f)
   105   do
   106     for OTHER in \
   107       "../../x86_64-linux/$FILE" \
   108       "../../x86_64-darwin/Contents/Home/$FILE" \
   109       "../../x86-cygwin/$FILE"
   110     do
   111       if cmp -s "$FILE" "$OTHER"
   112       then
   113         ln -f "$FILE" "$OTHER"
   114       fi
   115     done
   116   done
   117 )
   118 
   119 
   120 # create archive
   121 
   122 echo "Archiving ..."
   123 tar -c -z -f "${DIR}.tar.gz" "$DIR" && echo "${DIR}.tar.gz"