Admin/java/build
author wenzelm
Mon Sep 16 12:51:33 2013 +0200 (2013-09-16)
changeset 53658 9e8714b4661a
parent 53631 e68732cd842e
child 53913 5ff12177a067
permissions -rwxr-xr-x
updated to smlnj 110.76;
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@53625
    14
VERSION="7u40"
wenzelm@53625
    15
FULL_VERSION="1.7.0_40"
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@50863
    74
export COPYFILE_DISABLE=true
wenzelm@50863
    75
wenzelm@48825
    76
mkdir "$DIR/x86-linux" "$DIR/x86_64-linux" "$DIR/x86_64-darwin" "$DIR/x86-cygwin"
wenzelm@47970
    77
wenzelm@48825
    78
tar -C "$DIR/x86-linux" -xf "$ARCHIVE_LINUX32"
wenzelm@48825
    79
tar -C "$DIR/x86_64-linux" -xf "$ARCHIVE_LINUX64"
wenzelm@48825
    80
tar -C "$DIR/x86_64-darwin" -xf "$ARCHIVE_DARWIN"
wenzelm@48825
    81
tar -C "$DIR/x86-cygwin" -xf "$ARCHIVE_WINDOWS"
wenzelm@48825
    82
wenzelm@53417
    83
(
wenzelm@53417
    84
  cd "$DIR"
wenzelm@53417
    85
  for PLATFORM in x86-linux x86_64-linux x86-cygwin
wenzelm@53417
    86
  do
wenzelm@53417
    87
    mv "$PLATFORM/jdk${FULL_VERSION}"/* "$PLATFORM"/.
wenzelm@53417
    88
    rmdir "$PLATFORM/jdk${FULL_VERSION}"
wenzelm@53417
    89
  done
wenzelm@53417
    90
  PLATFORM=x86_64-darwin
wenzelm@53417
    91
  mv "$PLATFORM/jdk${FULL_VERSION}.jdk"/* "$PLATFORM"/.
wenzelm@53417
    92
  rmdir "$PLATFORM/jdk${FULL_VERSION}.jdk"
wenzelm@53417
    93
)
wenzelm@53417
    94
wenzelm@48825
    95
chgrp -R isabelle "$DIR"
wenzelm@48825
    96
chmod -R a+r "$DIR"
wenzelm@48825
    97
chmod -R a+X "$DIR"
wenzelm@47970
    98
wenzelm@50294
    99
find "$DIR/x86_64-darwin" -name "._*" -exec rm -f {} ";"
wenzelm@50294
   100
wenzelm@50890
   101
echo "Sharing ..."
wenzelm@47970
   102
(
wenzelm@53417
   103
  cd "$DIR/x86-linux"
wenzelm@47970
   104
  for FILE in $(find . -type f)
wenzelm@47970
   105
  do
wenzelm@48825
   106
    for OTHER in \
wenzelm@53631
   107
      "../x86_64-linux/$FILE" \
wenzelm@53631
   108
      "../x86_64-darwin/Contents/Home/$FILE" \
wenzelm@53631
   109
      "../x86-cygwin/$FILE"
wenzelm@48825
   110
    do
wenzelm@48825
   111
      if cmp -s "$FILE" "$OTHER"
wenzelm@48825
   112
      then
wenzelm@53631
   113
        echo -n "."
wenzelm@48825
   114
        ln -f "$FILE" "$OTHER"
wenzelm@48825
   115
      fi
wenzelm@48825
   116
    done
wenzelm@47970
   117
  done
wenzelm@47970
   118
)
wenzelm@53631
   119
echo
wenzelm@47970
   120
wenzelm@47970
   121
wenzelm@47970
   122
# create archive
wenzelm@47970
   123
wenzelm@50890
   124
echo "Archiving ..."
wenzelm@50890
   125
tar -c -z -f "${DIR}.tar.gz" "$DIR" && echo "${DIR}.tar.gz"