Mac OS X 10.3.x to Mac OS X 10.4 Upgrade

By: Wout Mertens - Revised: 2006-10-03 devin

Download Script – ZIP-File, 6.6 KB

Introduction

Scripts from Wout Mertens that help in upgrading Mac OS X 10.3 to Mac OS X 10.4 with radmind. It includes three files, one script copies the original libraries in /usr/lib to another location and set DYLD_LIBRARY_PATH and reboot will not hang. Another script creates a big zip file of files that changed which makes upgrading faster. And last includes a radmind negative transcript for upgrading.

Script

convert-to-tiger.sh
#!/bin/bash
# go from panther to tiger -
# If you call this with the argument "createzip", it will create the zipfile
# for publishing. About 7-8GB free space needed then.
#
# Search for CISCO to see what's specific to us
# Also, since we change radmind versions with the upgrade, we include
# new fsdiff, ktcheck and lapply binaries in $mydir.

### CISCO
oldflag=/etc/TACSUNS/flags/do-not-radmind
statedir=/var/radmind/state
zipfile=/local/panther2tiger.zip
### CISCO - end

# We put the tiger transcripts on a different radmind with a different port. Set to 6662 if you don't.
port=6664
# We have the prebinding patch installed. Set to m= if you don't.
m=-msha1
radhost=radhost.company.com
libdir=/var/radmind/tmp/lib
applyfile=/var/radmind/tmp/tiger-apply.T

PROG=$0
case "$PROG" in /*)  ;; *) PROG="$PWD/$PROG" ;; esac

mydir=`dirname "$PROG"`
updateneg=$mydir/update-negative.T
export PATH=$mydir:/bin:/usr/bin:/sbin:/usr/sbin

if [ ! -e "$updateneg" ]; then
    echo "I can't figure out where I live, $mydir doesn't contain update-negative.T"
    exit 2
fi

createzip=
if [ "$1" = "createzip" ]; then
    createzip=true
    echo Will create zipfile $zipfile
fi

die() {
    [ -n "$1" ] && echo "$@"
    exit 1
}
### CISCO
# turn off radmind updates, wait until radmind stops
touch "$oldflag"
while /etc/operator/sbin/is-radmind-running; do
    echo Waiting for the current radmind to stop...
    sleep 5
done
# Our tiger install uses /var/radmind/state to know what's specific to the current system
mkdir -p "$statedir"
touch "$statedir"/do-not-radmind
touch "$statedir"/tiger
### CISCO - end

# download new state
echo "Downloading new command files and transcripts"
ktcheck -w2 -h$radhost -p $port
[ "$?" -le 1 ] || die "failed to download updates"

# remove negatives
for i in /var/radmind/client/*.K; do
    mv $i $i.old
    sed 's/^n/#n/' < $i.old > $i
done
cp $updateneg /var/radmind/client/ || die "failed to apply update negative transcript"
echo n `basename "$updateneg"` >> /var/radmind/client/command.K || die "failed to apply update negative transcript"

# fix case for some files
echo Starting update...
mv /Library/CFMSupport/StuffItEngineShell.cfm /Library/CFMSupport/StuffItEngineshell.cfm
mv /System/Library/QuickTime/QuickTimeFirewireDV.component /System/Library/QuickTime/QuickTimeFireWireDV.component
mv /Developer/ADC Reference Library/documentation/Networking/Conceptual/AFP/Art /Developer/ADC Reference Library/documentation/Networking/Conceptual/AFP/ART
mv /Library/Printers/hp/Utilities/hp printer selector.app /Library/Printers/hp/Utilities/HP Printer Selector.app
mv /Library/Printers/hp/Utilities/hp inkjet toolbox.app /Library/Printers/hp/Utilities/HP Inkjet Toolbox.app
mv /Library/Printers/hp/Utilities/hp inkjet toolbox.app /Library/Printers/hp/Utilities/HP Inkjet Toolbox.app
mv /Library/Printers/hp/Utilities/hp printer selector.app /Library/Printers/hp/Utilities/HP Printer Selector.app
/Developer/Tools/SetFile -a l /System/Library/CoreServices/BootX

if [ -z "$createzip" ]; then
    # Copy libraries that we like so much
    # Otherwise, the system hangs after we're done
    # These libs were found with otool -L
    mkdir -p "$libdir" || die "Could not create $libdir"
    cp /usr/lib/libSystem.B.dylib "$libdir" || die "Could not copy libSystem"
    cp /usr/lib/system/libmathCommon.A.dylib "$libdir" || die "Could not copy libmath"
    export DYLD_LIBRARY_PATH="$libdir"
    
    if [ -e "$zipfile" ]; then
        echo Unpacking files from $zipfile...
        ditto -x -v -k --sequesterRsrc "$zipfile" /
        # if this fails, you just need to download more, no problem
    else
        echo "$zipfile not found! You will have to download the full changeset through radmind"
        echo "Sleeping for 10 seconds, just in case you made a mistake."
        sleep 10
    fi
fi

# find changes
count=3
while [ $count -gt 0 ]; do
    count=$(( $count - 1 ))
    echo "Finding needed changes"

    # create zip file if requested and bail
    if [ -n "$createzip" ]; then
        fsdiff -A -csha1 $m -v -o $applyfile / || die "failed to find changes"
        echo "Creating $zipfile..."
        make-tiger-zip.sh $applyfile $zipfile -F -% -w2 -h$radhost -p $port
        exit
    else
        # no checksumming here, takes too long
        fsdiff -A $m -v -o $applyfile / || die "failed to find changes"
    fi

    # apply
    echo Applying changes
    lapply -F -% -w2 -h$radhost -p $port $applyfile && count=-1
    
    [ $count -gt 0 ] && echo "An error occurred, trying again $count more times"
done

[ $count -eq 0 ] && die "could not update system"

# turn on updates
rm $statedir/do-not-radmind

# reboot
/sbin/reboot

make-tiger-zip.sh
#!/bin/bash
# create a zip file from a transcript, containing the new files.
#
TRAN="$1"
shift
zipfile="$1"
shift

T=/var/radmind/tmp/pca.$$
DLDIR=$T.dl
TOGET=$T.T

clean() {
    if [ -d $DLDIR ]; then
        echo "$DLDIR exists, please clean it!"
    fi
}
usage() {
    [ -n "$*" ] && echo "$*
Usage: $0 <transcript name> <zipfile name> <lapply arguments>"
    clean
    exit 1
}
die() {
    [ -n "$*" ] && echo "ERROR: $*"
    clean
    exit 1
}

trap clean 1 2 3 9 15

[ -r "$TRAN" ] || usage "Cannot read transcript $TRAN!"
touch "$zipfile" || usage "Cannot write to $zipfile!"
rm "$zipfile"
case "$zipfile" in *.zip) : ;; *) zipfile="$zipfile.zip" ;; esac

echo Processing transcript

# Get the downloadable part, create directories where needed, relativize
perl -nle '
if (/^[^ ]+:/) {
    $transcript = $_;
}
if (/^+/) {
    @parts = split;
    if ( $parts[2] =~ /^// ) {
        s///.//;
    }
    $parts[2] =~ s/^.//;
    $parts[2] =~ s/^///;
    @now = split "/", $parts[2];
    $i=0;
    while ($i < $#last && $i < $#now) {
        last if $last[$i] ne $now[$i];
        $i++;
    }
    while ($i < $#now) {
        print "d ./".join("/",@now[0 .. $i])." 700 0 0";
        $i++;
    }
    print $transcript if $transcript ne $lasttrans;
    $lasttrans = $transcript;
    print $_;
    @last=@now;
}' "$TRAN" > $TOGET

# Download fileset. This is the only bit that needs the network
echo Downloading files
mkdir $DLDIR
cd $DLDIR
lapply "$@" $TOGET || die "download failed"
cd -

# Create archive
echo Creating archive $zipfile
ditto -c -k --sequesterRsrc "$DLDIR" "$zipfile" || die "Could not create $zipfile"
rm -rf "$DLDIR"
ls -l "$zipfile"
echo "Done. Extract the archive with"
echo "  # ditto -x -k --sequesterRsrc $zipfile /"