Admin/java/build
author wenzelm
Sun, 20 Jan 2013 13:59:13 +0100
changeset 50990 11996ea98bbe
parent 50890 097e38daa03a
child 51074 f95817852bdd
permissions -rwxr-xr-x
tuned;

#!/usr/bin/env bash

## diagnostics

function fail()
{
  echo "$1" >&2
  exit 2
}


## parameters

VERSION="7u11"
FULL_VERSION="1.7.0_11"

ARCHIVE_LINUX32="jdk-${VERSION}-linux-i586.tar.gz"
ARCHIVE_LINUX64="jdk-${VERSION}-linux-x64.tar.gz"
ARCHIVE_DARWIN="jdk${FULL_VERSION}.jdk.tar.gz"
ARCHIVE_WINDOWS="jdk${FULL_VERSION}.tar.gz"


## main

DIR="jdk-${VERSION}"
mkdir "$DIR" || fail "Cannot create fresh directory: \"$DIR\""


# README

cat >> "$DIR/README" << EOF
This is JDK $FULL_VERSION as required for Isabelle.

See http://www.oracle.com/technetwork/java/javase/downloads/index.html
for the original downloads, which are covered by the Oracle Binary
Code License Agreement for Java SE.

Linux, Mac OS X, Windows work uniformly, depending on certain
platform-specific subdirectories.

Note that Java 1.7 on Mac OS X requires 64bit hardware!
EOF


# settings

mkdir "$DIR/etc"
cat >> "$DIR/etc/settings" << EOF
# -*- shell-script -*- :mode=shellscript:

case "\${ISABELLE_PLATFORM64:-\$ISABELLE_PLATFORM32}" in
  x86-darwin)
    echo "### Java 1.7 unavailable on 32bit Macintosh!" >&2
    ;;
  x86_64-darwin)
    ISABELLE_JDK_HOME="\$COMPONENT/\$ISABELLE_PLATFORM64/jdk${FULL_VERSION}.jdk/Contents/Home"
    ;;
  *)
    ISABELLE_JDK_HOME="\$COMPONENT/\${ISABELLE_PLATFORM64:-\$ISABELLE_PLATFORM32}/jdk${FULL_VERSION}"
    ;;
esac

if [ -n "\$ISABELLE_JDK_HOME" ]; then
  if [ -d "\$ISABELLE_JDK_HOME" ]; then
    ISABELLE_JAVA_EXT="\${ISABELLE_JDK_HOME}/jre/lib/ext"
  else
    echo "### Missing Java 1.7 platform directory: \"\$ISABELLE_JDK_HOME\"" >&2
    unset ISABELLE_JDK_HOME
  fi
fi
EOF


# content

export COPYFILE_DISABLE=true

mkdir "$DIR/x86-linux" "$DIR/x86_64-linux" "$DIR/x86_64-darwin" "$DIR/x86-cygwin"

tar -C "$DIR/x86-linux" -xf "$ARCHIVE_LINUX32"
tar -C "$DIR/x86_64-linux" -xf "$ARCHIVE_LINUX64"
tar -C "$DIR/x86_64-darwin" -xf "$ARCHIVE_DARWIN"
tar -C "$DIR/x86-cygwin" -xf "$ARCHIVE_WINDOWS"

chgrp -R isabelle "$DIR"
chmod -R a+r "$DIR"
chmod -R a+X "$DIR"

find "$DIR/x86_64-darwin" -name "._*" -exec rm -f {} ";"

echo "Sharing ..."
(
  cd "$DIR/x86-linux/jdk${FULL_VERSION}"
  for FILE in $(find . -type f)
  do
    for OTHER in \
      "../../x86_64-linux/jdk${FULL_VERSION}/$FILE" \
      "../../x86_64-darwin/jdk${FULL_VERSION}.jdk/Contents/Home/$FILE" \
      "../../x86-cygwin/jdk${FULL_VERSION}/$FILE"
    do
      if cmp -s "$FILE" "$OTHER"
      then
        ln -f "$FILE" "$OTHER"
      fi
    done
  done
)


# create archive

echo "Archiving ..."
tar -c -z -f "${DIR}.tar.gz" "$DIR" && echo "${DIR}.tar.gz"