Admin/java/build
author wenzelm
Wed, 16 Mar 2016 22:19:08 +0100
changeset 62645 a2351f82bc48
parent 62211 cc1557643ab1
child 63214 7e8ef9ac3159
permissions -rwxr-xr-x
eliminated spurious Unicode, which is in conflict with Isabelle symbol interpretation;

#!/usr/bin/env bash

THIS="$(cd "$(dirname "$0")"; pwd)"


## diagnostics

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


## parameters

VERSION="8u72"
FULL_VERSION="1.8.0_72"

ARCHIVE_LINUX32="jdk-${VERSION}-linux-i586.tar.gz"
ARCHIVE_LINUX64="jdk-${VERSION}-linux-x64.tar.gz"
ARCHIVE_WINDOWS32="jdk${FULL_VERSION}-w32.tar.gz"
ARCHIVE_WINDOWS64="jdk${FULL_VERSION}-w64.tar.gz"
ARCHIVE_DARWIN="jdk${FULL_VERSION}.jdk.tar.gz"


## main

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


# README

cat >> "$DIR/README" << EOF
This is JDK/JRE $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, Windows, Mac OS X all work uniformly, depending on certain
platform-specific subdirectories.
EOF


# settings

mkdir "$DIR/etc"
cp "$THIS/settings" "$DIR/etc/settings"


# content

#GNU tar (notably on Mac OS X)
if [ -x /usr/bin/gnutar ]; then
  function tar() { /usr/bin/gnutar "$@"; }
fi

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

tar -C "$DIR/x86-linux" -xf "$ARCHIVE_LINUX32"
tar -C "$DIR/x86_64-linux" -xf "$ARCHIVE_LINUX64"
tar -C "$DIR/x86-windows" -xf "$ARCHIVE_WINDOWS32"
tar -C "$DIR/x86_64-windows" -xf "$ARCHIVE_WINDOWS64"
tar -C "$DIR/x86_64-darwin" -xf "$ARCHIVE_DARWIN"

(
  cd "$DIR"
  for PLATFORM in x86-linux x86_64-linux x86-windows x86_64-windows
  do
    mv "$PLATFORM/jdk${FULL_VERSION}"/* "$PLATFORM"/.
    rmdir "$PLATFORM/jdk${FULL_VERSION}"
  done
  PLATFORM=x86_64-darwin
  mv "$PLATFORM/jdk${FULL_VERSION}.jdk"/* "$PLATFORM"/.
  rmdir "$PLATFORM/jdk${FULL_VERSION}.jdk"
)

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"
  for FILE in $(find . -type f)
  do
    for OTHER in \
      "../x86_64-linux/$FILE" \
      "../x86-windows/$FILE" \
      "../x86_64-windows/$FILE" \
      "../x86_64-darwin/Contents/Home/$FILE"
    do
      if cmp -s "$FILE" "$OTHER"
      then
        echo -n "*"
        ln -f "$FILE" "$OTHER"
      fi
    done
  done
)
echo


# create archive

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