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