-
Notifications
You must be signed in to change notification settings - Fork 54
/
install-universal-interfaces.sh
executable file
·83 lines (71 loc) · 2.41 KB
/
install-universal-interfaces.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/bin/bash
#
# install-universal-interfaces.sh
#
# Optionally download and attempt to install the universal interfaces from
# a Macbinary disk image containing the Interfaces&Libraries directory
#
# Usage:
# install-universal-interfaces.sh <tempdir> <filename>
#
# Decompress the Macbinary image at <tempdir>/<filename> into
# <tempdir>/InterfacesAndLibraries in the correct format for
# interfaces-and-libraries.sh.
#
set -e
TMPDIR=$1
FILENAME=$2
if [[ ! -f $TMPDIR/$FILENAME ]];
then
echo "$TMPDIR/$FILENAME not found"
exit 1
fi
echo "Decompressing $FILENAME..."
ConvertDiskImage $TMPDIR/$FILENAME $TMPDIR/$FILENAME.img
echo "Decompression complete"
# Copy over Interfaces&Libraries files
echo "Copying Interfaces&Libraries files..."
hmount $TMPDIR/$FILENAME.img
# Find Interfaces&Libraries directory, get recursive directory listing
HFSINTERFACESANDLIBSDIR=`hls -R | grep 'Interfaces&Libraries:$'`
IFS="$(printf '\n')"
echo "Found Interfaces&Libraries at $HFSINTERFACESANDLIBSDIR"
FILES=`hls -FR1 $HFSINTERFACESANDLIBSDIR`
UNIXINTERFACESANDLIBSDIR=$TMPDIR/InterfacesAndLibraries
mkdir -p $UNIXINTERFACESANDLIBSDIR
# Parse results: first line is the HFS path, following lines contain one file
# per line terminated by an empty line
while IFS= read -r LINE; do
if [[ $LINE == :* ]];
then
# If it starts with : then it is a HFS path
HFSPATH=$LINE
UNIXRELPATH=$(echo "$HFSPATH" | sed "s#$HFSINTERFACESANDLIBSDIR##g" | sed "s#:#/"#g)
UNIXPATH="$UNIXINTERFACESANDLIBSDIR/$UNIXRELPATH"
# Make UNIX directory
mkdir -p $UNIXPATH
else
# If it ends with : it is a directory so ignore (we will find it during the descent)
if [[ ! $LINE == *: ]];
then
# If it isn't empty, it must be a filename
if [[ ! -z $LINE ]];
then
HFSFULLPATH="$HFSPATH$LINE"
UNIXFULLPATH="$UNIXPATH$LINE"
echo "Copying $HFSFULLPATH to $UNIXFULLPATH"
if [[ $HFSPATH == *SharedLibraries: ]];
then
# interfaces-and-libraries.sh can detect and use PPC libraries in
# MacBinary format
hcopy -m $HFSFULLPATH $UNIXFULLPATH.bin
else
# Otherwise copy files in raw format
hcopy -r $HFSFULLPATH $UNIXFULLPATH
fi
fi
fi
fi
done <<< "$FILES"
# Unmount image
humount