| |||
#!/bin/bash
# This will unpack Tiger's J2SE (Release 1) onto a Panther system.
# corey.jewett (at) gmail.com
#
# No warranty implied or otherwise.
##
# v 0.2: Now installs the JDK and Documentation dmgs. Also won't overwrite 1.4's Jar Launcher on successive executions.
#
# Just run with the first argument as the path to the dmg files.
DMG_PATH=$1;
# consts
JDK_DMG="$DMG_PATH/Java15Release1.dmg"
JDK_MOUNT="/Volumes/J2SE 5.0 Release 1";
JDK_ARCHIVE_PATH="$JDK_MOUNT/Java15Release1.pkg/Contents/Archive.pax.gz";
DOC_DMG="$DMG_PATH/Java15Release1Documentation.dmg"
DOC_MOUNT="/Volumes/J2SE 5.0 Release 1 Developer";
DOC_ARCHIVE_PATH="$DOC_MOUNT/Java15Release1Documentation.pkg/Contents/Archive.pax.gz";
# functions
function help {
echo "Get DMGs here:";
echo "JDK: http://www.apple.com/support/downloads/java2se50release1.html";
echo "Doc: http://www.apple.com/support/downloads/java2se50developerdocumentation.html";
exit 1;
}
function fakesudo {
echo "Authorization required, you may be prompted... ";
sudo echo "authorized.";
}
function unpackdmg {
DMG=$1;
MOUNT=$2;
ARCHIVE_PATH=$3;
if [ ! -e "$MOUNT" ]; then
echo "Mounting $DMG";
hdiutil mount $DMG;
fi
echo "Installation starting, this will take a few minutes.";
sleep 3;
cd /;
gunzip -c "$ARCHIVE_PATH" | sudo pax -vr;
echo;
echo "Unpacking complete.";
echo "Unmounting $MOUNT";
umount "$MOUNT";
}
# start of script
if [ -z "$1" ]; then
echo "$0 ";
echo;
help;
fi
echo;
echo "About to unpack Tiger's J2SE 5.0 onto an unsupported operating system."
echo "This is operation is not recommended or supported by anyone."
echo "It may corrupt your system or render your current JDK inoperable."
echo "It might even fry your hardware or void your warranty. Who knows."
echo "You claim all responsibility for running this script."
echo;
read -p "Continue Install? (y/N)> " PROMPT;
if [ $PROMPT == 'y' -o $PROMPT == 'Y' ]; then
echo "DMG Path is $DMG_PATH";
# check for dmgs
FOUND=0;
echo -n "Looking for JDK... ";
if [ -e "$JDK_DMG" -o -e "$JDK_ARCHIVE_PATH" ]; then
echo "found.";
FOUND=1;
else
echo "not found.";
fi
echo -n "Looking for Documentation... ";
if [ -e "$JDK_DMG" -o -e "$JDK_ARCHIVE_PATH" ]; then
echo "found.";
FOUND=1;
else
echo "not found.";
fi
if [ $FOUND -eq 0 ]; then
echo;
echo "No DMGs found";
help;
fi
# bacjup jar launcher
fakesudo;
if [ ! -e "/System/Library/CoreServices/Jar Launcher 1.4.app" ]; then
echo "Moving 1.4 \"Jar Launcher.app\" to \"Jar Launcher 1.4.app\".";
mv "/System/Library/CoreServices/Jar Launcher.app" "/System/Library/CoreServices/Jar Launcher 1.4.app";
fi
# jdk
echo "Working on JDK";
fakesudo;
if [ -e "$JDK_DMG" ]; then
echo "Found, \"$JDK_DMG\"";
unpackdmg "$JDK_DMG" "$JDK_MOUNT" "$JDK_ARCHIVE_PATH";
fi
# documentation
echo "Working on DOC";
fakesudo;
if [ -e "$DOC_DMG" ]; then
echo "Found, \"$DOC_DMG\"";
unpackdmg "$DOC_DMG" "$DOC_MOUNT" "$DOC_ARCHIVE_PATH";
fi
# default JDK?
echo;
read -p "Make 1.5 your default JDK?(y/N)> " PROMPT;
if [ $PROMPT == 'y' -o $PROMPT == 'Y' ]; then
fakesudo;
echo "Changing symlinks...";
cd /System/Library/Frameworks/JavaVM.framework/Versions/;
sudo rm CurrentJDK;
sudo ln -s 1.5.0 CurrentJDK;
echo "done.";
echo "Checking Java Version: ";
java -version;
fi
else
echo "Installation halted by user.";
fi
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.