Chameleon

Chameleon Commit Details

Date:2015-02-27 00:07:29 (4 years 3 months ago)
Author:ErmaC
Commit:2584
Parents: 2583
Message:Update pkg scripts (credits to Micky1979)
Changes:
M/trunk/package/Scripts.templates/Post/postinstall
M/trunk/package/Scripts.templates/Pre/preinstall
M/trunk/package/Scripts/Main/Standardpostinstall
M/trunk/package/Scripts.templates/InstallTheme/postinstall
M/trunk/package/buildpkg.sh
M/trunk/package/Scripts.templates/InstallModule/postinstall
M/trunk/package/Scripts/Main/ESPpostinstall
M/trunk/package/Scripts.templates/AddOption/postinstall

File differences

trunk/package/Scripts.templates/AddOption/postinstall
33
44
55
6
7
8
6
7
8
99
1010
1111
......
3333
3434
3535
36
36
3737
3838
39
39
4040
4141
4242
......
4949
5050
5151
52
52
5353
5454
5555
5656
57
57
5858
5959
6060
set -u
configFile='/private/tmp/InstallConfig.plist'
v_mntptDev=$( /usr/libexec/plistbuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
key="@optionKey@"
value="@optionValue@"
case "$type" in
bool|text)
/usr/libexec/plistbuddy -c "Add :${key} string ${value}" "$bootPListFile"
/usr/libexec/PlistBuddy -c "Add :${key} string ${value}" "$bootPListFile"
;;
list)
current_values=$( /usr/libexec/plistbuddy -c "Print :${key}" \
current_values=$( /usr/libexec/PlistBuddy -c "Print :${key}" \
"$bootPListFile" 2>/dev/null )
result=$?
current_values="${current_values// /\\ }" # Escape spaces
else
new_values="${current_values}\ ${value}"
fi
/usr/libexec/plistbuddy -c "Set :${key} ${new_values}" \
/usr/libexec/PlistBuddy -c "Set :${key} ${new_values}" \
"$bootPListFile"
else
# Create a new option
new_values="${value}"
/usr/libexec/plistbuddy -c "Add :${key} string ${new_values}" \
/usr/libexec/PlistBuddy -c "Add :${key} string ${new_values}" \
"$bootPListFile"
fi
;;
trunk/package/Scripts.templates/Post/postinstall
55
66
77
8
89
910
1011
......
1920
2021
2122
22
23
23
24
2425
2526
26
27
27
28
2829
2930
3031
3132
32
33
33
34
3435
3536
36
37
37
38
39
40
41
3842
3943
44
4045
41
46
4247
4348
4449
45
46
47
48
4950
5051
5152
......
5556
5657
5758
58
59
60
59
60
61
62
6163
6264
6365
# $3 = Installation volume (mountpoint) to receive the payload
# $4 = Root directory for the system
logName="@LOG_FILENAME@"
mainLine="=============================================================================="
subLine="------------------------------------------------------------------------------"
configFile='/private/tmp/InstallConfig.plist'
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//')
targetDevice=$( /usr/libexec/PlistBuddy -c "Print :targetdev" ${configFile} )
choicedVolume=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
choicedVolume=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
backupRootDir="${targetVolume}/Chameleon.Backups"
backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} )
# Check target exists
if [ ! -d "${targetVolume}" ]; then
echo "Target volume does not exist !" >&2
if [ ! -d "${v_mntpt}" ]; then
echo "Ram disk volume does not exist !"
exit 1
fi
if [ ! -d "${v_mntpt}" ]; then
echo "Ram disk volume does not exist !" >&2
exec > >(tee -a "${v_mntpt}/${logName}") 2>&1
if [ ! -d "${targetVolume}" ]; then
echo "Target volume does not exist !"
exit 1
fi
if [ ! -d "${choicedVolume}" ]; then
echo "${choicedVolume} volume does not exist !" >&2
echo "${choicedVolume} volume does not exist !"
exit 1
fi
logName="@LOG_FILENAME@"
exec > >(tee -a "${v_mntpt}/${logName}") 2>&1
echo "$mainLine"
echo "Running Post postinstall script"
echo "Target volume = ${choicedVolume}"
echo "Moving Extra folder to ${choicedVolume}"
cp -R "${v_mntpt}/Extra" "${choicedVolume}"/
echo "NOTE: any Themes or modules you have must be there since this now is the boot partition,"
echo " ACPI tables, SMBios.plist and the org.chameleon.Boot.plist (with custom settings"
echo " for the target OSX must be in each partition that contanin it.)"
echo "NOTE: any Themes or modules you have must be there since this now"
echo " is the boot partition. ACPI tables, SMBios.plist and the"
echo " org.chameleon.Boot.plist (with custom settings for the target"
echo " OSX must be in each partition that contain it.)"
echo "$subLine"
echo "Post postinstall script complete"
trunk/package/Scripts.templates/Pre/preinstall
2929
3030
3131
32
33
32
33
3434
3535
3636
......
4545
4646
4747
48
4849
4950
5051
......
5354
5455
5556
56
57
57
58
5859
5960
6061
}
RAM_DISK() {
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x "${v_mntpt}" ) ]; then
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' | grep -x "${v_mntpt}" ) ]; then
devToUmount=$( LC_ALL=C diskutil info "${v_mntpt}" | grep -i 'Device Node:' | awk '{print $3}' )
UMOUNT_VDISK $devToUmount
fi
exit 1
fi
dev=$( echo "${dev}" | tr -d " \t\n" )
rm -f $configFile
# adding the Ram disk device to InstallConfig.plist to be shared with other packages
/usr/libexec/PlistBuddy -c "Add :ramdisk string ${dev}" $configFile
RAM_DISK
# ensure that ram disk has "/Volumes/BOOTRAMDISK" mount point
v_mntpt=$( LC_ALL=C diskutil info ${dev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntpt=$( LC_ALL=C diskutil info ${dev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
if [ ! -d "${v_mntpt}" ]; then
echo "Ram Disk not found!"
exit
trunk/package/Scripts.templates/InstallTheme/postinstall
33
44
55
6
7
8
9
6
7
8
109
1110
1211
set -u
configFile='/private/tmp/InstallConfig.plist'
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
themeName="@themeName@"
themeDir="@themeDir@"
logName="@LOG_FILENAME@"
trunk/package/Scripts.templates/InstallModule/postinstall
33
44
55
6
7
8
6
7
8
99
1010
1111
set -u
configFile='/private/tmp/InstallConfig.plist'
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//' )
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
moduleName="@moduleName@"
moduleFile="@moduleFile@"
trunk/package/Scripts/Main/ESPpostinstall
11
22
33
4
4
55
66
77
88
99
10
11
12
1013
1114
15
1216
1317
1418
......
2327
2428
2529
26
27
28
30
31
32
2933
3034
3135
......
3943
4044
4145
42
4346
4447
4548
4649
4750
51
4852
4953
5054
......
5256
5357
5458
55
59
5660
57
61
5862
5963
6064
......
6973
7074
7175
72
76
7377
74
75
78
7679
7780
7881
......
8386
8487
8588
89
8690
8791
8892
......
9397
9498
9599
96
97
100
101
98102
99103
100104
......
102106
103107
104108
105
109
106110
107111
108112
......
116120
117121
118122
119
120
121
123
124
125
122126
123127
124128
......
128132
129133
130134
131
135
132136
133137
134138
......
144148
145149
146150
147
151
148152
149153
150
154
155
151156
152157
153
158
159
154160
155161
156162
......
159165
160166
161167
162
163
168
169
170
164171
165
172
166173
167174
168175
......
202209
203210
204211
205
206212
207213
208214
......
214220
215221
216222
217
218
219
220
221
222
223
224
225
226
227
228
229
230223
231224
232225
233226
234
235227
236
237
228
229
238230
239
240
241
242
243
244
245
246
247
231
248232
249
250
251
233
234
235
252236
253237
254
255
256
257
258
259
260
261
262
263
264
265
266238
267239
268240
......
275247
276248
277249
278
279
250
251
252
280253
281
282
283
284
285
286
254
255
256
257
258
259
260
261
262
263
264
265
287266
288267
289268
......
298277
299278
300279
301
280
302281
303282
304283
......
332311
333312
334313
335
314
336315
337316
338317
......
355334
356335
357336
358
337
359338
360339
361340
......
364343
365344
366345
346
367347
368348
369349
......
372352
373353
374354
375
376
377
378
379
380355
381356
382357
......
385360
386361
387362
363
388364
389365
390366
391
392
367
368
393369
394370
395371
396
397
372
373
398374
399375
400376
401
402
403
377
378
404379
405380
406381
......
408383
409384
410385
386
387
388
389
390
391
392
393
411394
412395
413396
414397
415
398
416399
417400
418401
#!/bin/bash
# --------------------------------------------------------------------------------------------------------
# Install.sh v1.3, script to install Chameleon
# Install.sh v1.5, script to install Chameleon
# Created by Miky1979 on December 8th, 2014
# --------------------------------------------------------------------------------------------------------
targetVolume="${3}"
InstallToESP="1"
InstallBootloader="0"
espmtp="/Volumes/ESP"
WINDOWS_EXIST="0"
opt="u"
configFile="/private/tmp/InstallConfig.plist"
if [ "${InstallToESP}" == "1" ]; then TYPE="ESP"; else TYPE="Standard"; fi
if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then
# installing stage 0, 1 and 2 only if user want this:
# ie only if have no selected noboot choice
choicedVolume="${targetVolume}"
ESP_MOUNTED="0"
# --------------------------------------------------------------------------------------------------------
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//')
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
backupRootDir="${targetVolume}/Chameleon.Backups"
backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} )
logName="Chameleon_Installer_Log.txt"
stage2Loader="boot"
versionToInstall=$(cat "${i386Dir}/Boot" | grep -a 'Darwin/x86 boot v' )
# --------------------------------------------------------------------------------------------------------
localdd="/bin/dd"
SS="${usrLocalBin}/sectorsize"
# --------------------------------------------------------------------------------------------------------
# Scanning all Variables. We are switching to the target Volume or its ESP.
# This function is usefull to rescan the new target "at need"
SCAN() {
bootDevice=$( LC_ALL=C diskutil info / | grep -i 'Device Node:' | awk '{print $NF}' )
targetDevice=$( LC_ALL=C diskutil info "${choicedVolume}" | grep -i 'Device Node:' | awk '{print $NF}' )
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetSlice=${targetDevice#*disk*s}
IOContent=$( LC_ALL=C diskutil info "${targetDisk}" | grep -i 'Content (IOContent)' | awk '{print $NF}' )
FS=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'Type (Bundle)' | \
awk '{print $NF}' | awk '{print tolower($0)}' )
awk '{print $NF}' | awk '{print tolower($0)}' )
disksignature=$( dd 2>/dev/null if="${targetDisk}" count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | \
perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $InstallBootloader = "1" ];then
blocksize=$( "${SS}" "${targetDeviceRaw}" | awk '{ print $2 }' )
# Create a folder inside the Desktop called "DebugChameleon", and the log will be full
DEBUG() {
echo "$mainLine"
echo "DEBUG: display script variables (ESPpostinstall)"
echo "DEBUG: display script variables (${TYPE}postinstall)"
echo "$mainLine"
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader} (or boot0hfs)"
echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot} (or boot0hfs)"
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}"
echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}"
echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}"
echo "DEBUG: stage1LoaderExFAT: Partition loader is ${stage1LoaderExFAT}"
echo "DEBUG: targetDisk: Disk device is ${targetDisk}"
echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}"
echo "DEBUG: targetSlice: Volume slice is ${targetSlice}"
echo "DEBUG: bootDevice: Current Volume device is ${bootDevice}"
echo "DEBUG: versionToInstall: version to install is ${versionToInstall}"
echo "DEBUG: IOContent: partition scheme is ${IOContent}"
echo "DEBUG: FS: file System is ${FS}"
# --------------------------------------------------------------------------------------------------------
# Checking for unsupported FAT16 filesystem
CHECK_FAT16() {
pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' \
| awk '{print $NF}' | awk '{print tolower($0)}' )
pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' | \
awk '{print $NF}' | awk '{print tolower($0)}' )
case $pers in
fat16)
exit 1
;;
*)
echo "First Check Passed!"
echo "First Check Passed (not Fat16)!"
;;
esac
}
CHECK_ESP_MOUNTPOINT() {
# umount the ESP by its Mount Point
# and checking it if is busy by another ESP
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x '/Volumes/ESP' ) ]; then
umount -f /Volumes/ESP
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \
grep -x "${espmtp}" ) ]; then
umount -f ${espmtp}
ESP_MOUNTED="0"
fi
}
if [ $( df | grep "${espDisk}" | awk '{print $1}' | grep -x "${espDisk}" ) ];then
# ESP is already mounted, so now we aquire the Mount Point
espmtp=$( LC_ALL=C diskutil info ${espDisk} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^[ \t]*//' )
sed -e 's/^ *//' | sed -e 's/ *$//' )
if [ -d "${espmtp}" ];then
echo "ESP Mount Point is:${espmtp}, using that as target Volume!"
choicedVolume="${espmtp}"
fi
if [ $ESP_MOUNTED = "0" ];then
mkdir -p /Volumes/ESP
mkdir -p "${espmtp}"
case $( fstyp $espDisk ) in
hfs)
mount -t hfs $espDisk /Volumes/ESP
echo "Mounting $espDisk on $espmtp as hfs Volume.."
mount -t hfs $espDisk "${espmtp}"
;;
msdos)
mount -t msdos $espDisk /Volumes/ESP
echo "Mounting $espDisk on $espmtp as msdos Volume.."
mount -t msdos $espDisk "${espmtp}"
;;
*)
echo "ESP fileSystem unsupported, Installing to ${targetVolume}!"
esac
sleep 0.3
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x '/Volumes/ESP' ) ]; then
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \
grep -x "${espmtp}" ) ]; then
echo "EFI System Partition mounted!"
ESP_MOUNTED="1"
choicedVolume="/Volumes/ESP"
choicedVolume="${espmtp}"
SCAN
else
echo "ESP can't be mounted, Installing to ${targetVolume}!"
# --------------------------------------------------------------------------------------------------------
# Writing stage 0
CHECK_WINDOWS() {
WINDOWS_EXIST="0"
if [ "${disksignature}" = "00000000" ]; then
echo "Windows installation not found on ${targetDisk}."
else
WRITE_STAGE0() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 0:"
CHECK_WINDOWS
case "$1" in
hfs)
if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0hfs"; else stage0Loader="boot0"; fi
;;
msdos)
if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0md"; else stage0Loader="boot0";fi
;;
exfat)
stage0Loader="boot0"
;;
esac
"${usrLocalBin}/fdisk440" -u -f "${i386Dir}/${stage0Loader}" -y ${targetDisk}
echo "${stage0Loader} writed to ${targetDisk}"
fi
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 1 on different filesystems
WRITE_STAGE1_HFS() {
# Writing stage 1
WRITE_STAGE1() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 HFS:"
$localdd if="${i386Dir}/${stage1LoaderHFS}" of=${targetDeviceRaw}
echo "${stage1LoaderHFS} (hfs) writed to ${targetDeviceRaw}."
fi
}
WRITE_STAGE1_EXFAT() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 ExFAT:"
echo -e "${mainLine}\nWRITING STAGE 1 ${2}:"
cp -R "${usrLocalBin}/boot1-install" "${v_mntpt}"/
cp -R "${i386Dir}/${stage1LoaderExFAT}" "${v_mntpt}"/
"${v_mntpt}/boot1-install" -y -u -f "${v_mntpt}/${stage1LoaderExFAT}" ${targetDeviceRaw}
echo "${stage1LoaderExFAT} (ExFAT) writed to ${targetDeviceRaw}."
cp -R "${i386Dir}/${1}" "${v_mntpt}"/
"${v_mntpt}/boot1-install" -y "-${3}" -f "${v_mntpt}/${1}" ${targetDeviceRaw}
echo "${stage1Loader} (${2}) writed to ${targetDeviceRaw}."
fi
}
WRITE_STAGE1_FAT32() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 FAT32:"
$localdd if=${targetDeviceRaw} count=1 bs=512 of="${v_mntpt}/origbs"
cp "${i386Dir}/${stage1LoaderFAT}" "${v_mntpt}/newbs"
$localdd if="${v_mntpt}/origbs" of="${v_mntpt}/newbs" skip=3 seek=3 bs=1 count=87 conv=notrunc
$localdd if="${v_mntpt}/newbs" of="${targetDeviceRaw}" count=1 bs=512
echo "${stage1LoaderFAT} (Fat32) writed to ${targetDeviceRaw}."
fi
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 2
WRITE_STAGE2() {
}
# --------------------------------------------------------------------------------------------------------
# Waiting for targhet Volume was re-mounted before proceeding..
# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..)
WAIT_REMOUNT() {
# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..).
# exception is the EFI partition: in Mavericks autoremount...in Yosemite not..
REMOUNT() {
if [ $InstallBootloader = "1" ];then
if [ ! -d "${choicedVolume}" ]; then
echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:"
until [ -d "${choicedVolume}" ]; do
sleep 0.3
done
echo "${choicedVolume} is mounted!"
if [ "${InstallToESP}" == "1" ]; then
if [ ! -d "${choicedVolume}" ]; then
MOUNT_ESP
fi
else
if [ ! -d "${choicedVolume}" ]; then
echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:"
until [ -d "${choicedVolume}" ]; do
sleep 0.3
done
echo "${choicedVolume} is mounted!"
fi
fi
fi
}
else
echo "Extra folder already exist on ${choicedVolume}, copying to the Ram Disk.."
cp -R "${choicedVolume}/Extra" "${v_mntpt}"/
./clean_bootplist.pl "${v_mntpt}" >/dev/null
./clean_bootplist.pl "${v_mntpt}"
fi
}
# --------------------------------------------------------------------------------------------------------
exec > >(tee -a "${logFile}") 2>&1
echo "$mainLine"
echo "Main ESP Post-Install Script"
echo "Main ${TYPE} Post-Install Script"
echo "Chameleon installer log - $( date )"
if [ $InstallBootloader = "1" ];then echo "$versionToInstall"; else echo "no boot session"; fi
echo ""
echo "GPT partition Scheme detected.."
espDisk="${targetDisk}s1"
if [ $( LC_ALL=C diskutil info ${espDisk} | grep -i 'Partition Type:' | \
awk '{print $NF}' ) = "EFI" ]; then
awk '{print $NF}' | sed -e 's/^ *//' | sed -e 's/ *$//' ) = "EFI" ]; then
echo "EFI partition found is ${espDisk}, try to mount it.."
MOUNT_ESP
else
fi
;;
*)
InstallToESP = "0"
echo "Can't install on the ESP, because does not exist.."
echo "..continue installing to ${targetVolume}"
;;
SCAN
fi
if [ -d "${HOME}/Desktop/DebugChameleon" ]; then
DEBUG
fi
# adding the chosen Volume dev id to the InstallConfig.plist
/usr/libexec/PlistBuddy -c "Add :targetdev string ${targetDevice}" $configFile
echo "${mainLine}"
CHECK_FAT16
CHECK_WINDOWS
case "$FS" in
hfs)
echo "${targetDevice} is HFS formatted"
WRITE_STAGE0 hfs
WRITE_STAGE1_HFS
if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0hfs"; else stage0Loader="boot0"; fi
stage1Loader="${stage1LoaderHFS}"
;;
msdos)
echo "${targetDevice} is FAT32 formatted"
WRITE_STAGE0 msdos
WRITE_STAGE1_FAT32
if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0md"; else stage0Loader="boot0"; fi
stage1Loader="${stage1LoaderFAT}"
;;
exfat)
echo "${targetDevice} is ExFAT formatted"
WRITE_STAGE0 exfat
WRITE_STAGE1_EXFAT
WAIT_REMOUNT
stage0Loader="boot0"
stage1Loader="${stage1LoaderExFAT}"
;;
*)
echo "FileSystem unsupported, aborting!"
;;
esac
# Debug mode: create a "DebugChameleon" folder on your Desktop to debug this script
if [ -d "${HOME}/Desktop/DebugChameleon" ]; then DEBUG; fi
# if the target device is equal to the boot device keep the Volume mounted using boot1-install
if [ "${bootDevice}" = "${targetDevice}" ]; then opt="M"; fi
WRITE_STAGE0 "${stage0Loader}"
WRITE_STAGE1 "${stage1Loader}" "${FS}" "${opt}"
if [ "${bootDevice}" != "${targetDevice}" ]; then REMOUNT; fi
WRITE_STAGE2
PARTITION_ACTIVE_IF
echo "$mainLine"
echo "END - ESP Post-Install Script"
echo "END - ${TYPE} Post-Install Script"
# --------------------------------------------------------------------------------------------------------
exit 0
trunk/package/Scripts/Main/Standardpostinstall
11
22
33
4
4
55
66
77
88
99
10
11
12
1013
1114
15
1216
1317
1418
......
2327
2428
2529
26
27
28
30
31
32
2933
3034
3135
......
3943
4044
4145
42
4346
4447
4548
4649
4750
51
4852
4953
5054
......
5256
5357
5458
55
59
5660
57
61
5862
5963
6064
......
6973
7074
7175
72
76
7377
74
75
78
7679
7780
7881
......
8386
8487
8588
89
8690
8791
8892
......
9397
9498
9599
96
97
100
101
98102
99103
100104
......
102106
103107
104108
105
109
106110
107111
108112
......
116120
117121
118122
119
120
121
123
124
125
122126
123127
124128
......
128132
129133
130134
131
135
132136
133137
134138
......
144148
145149
146150
147
151
148152
149153
150
154
155
151156
152157
153
158
159
154160
155161
156162
......
159165
160166
161167
162
163
168
169
170
164171
165
172
166173
167174
168175
......
202209
203210
204211
205
206212
207213
208214
......
214220
215221
216222
217
218
219
220
221
222
223
224
225
226
227
228
229
230223
231224
232225
233226
234227
235
236
228
229
237230
238
239
240
241
242
243
244
245
246
231
247232
248
249
250
233
234
235
251236
252237
253
254
255
256
257
258
259
260
261
262
263
264
265238
266239
267240
......
274247
275248
276249
277
278
250
251
252
279253
280
281
282
283
284
285
254
255
256
257
258
259
260
261
262
263
264
265
286266
287267
288268
......
297277
298278
299279
300
280
301281
302282
303283
......
331311
332312
333313
334
314
335315
336316
337317
......
354334
355335
356336
357
337
358338
359339
360340
......
363343
364344
365345
346
366347
367348
368349
......
371352
372353
373354
374
375
376
377
378
379355
380356
381357
......
384360
385361
386362
363
387364
388365
389366
390
391
367
368
392369
393370
394371
395
396
372
373
397374
398375
399376
400
401
402
377
378
403379
404380
405381
......
407383
408384
409385
386
387
388
389
390
391
392
393
410394
411395
412396
413397
414
398
415399
416400
417401
#!/bin/bash
# --------------------------------------------------------------------------------------------------------
# Install.sh v1.3, script to install Chameleon
# Install.sh v1.5, script to install Chameleon
# Created by Miky1979 on December 8th, 2014
# --------------------------------------------------------------------------------------------------------
targetVolume="${3}"
InstallToESP="0"
InstallBootloader="0"
espmtp="/Volumes/ESP"
WINDOWS_EXIST="0"
opt="u"
configFile="/private/tmp/InstallConfig.plist"
if [ "${InstallToESP}" == "1" ]; then TYPE="ESP"; else TYPE="Standard"; fi
if [[ $( /usr/libexec/PlistBuddy -c "Print bootloader" ${configFile} ) == "true" ]];then
# installing stage 0, 1 and 2 only if user want this:
# ie only if have no selected noboot choice
choicedVolume="${targetVolume}"
ESP_MOUNTED="0"
# --------------------------------------------------------------------------------------------------------
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} | sed -e 's/[[:blank:]]*//g' )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' \
| sed -e 's/^[ \t]*//')
v_mntptDev=$( /usr/libexec/PlistBuddy -c "Print :ramdisk" ${configFile} )
v_mntpt=$( LC_ALL=C diskutil info ${v_mntptDev} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^ *//' | sed -e 's/ *$//' )
backupRootDir="${targetVolume}/Chameleon.Backups"
backupDir=$( /usr/libexec/PlistBuddy -c "Print :backupDir" ${configFile} )
logName="Chameleon_Installer_Log.txt"
stage2Loader="boot"
versionToInstall=$(cat "${i386Dir}/Boot" | grep -a 'Darwin/x86 boot v' )
# --------------------------------------------------------------------------------------------------------
localdd="/bin/dd"
SS="${usrLocalBin}/sectorsize"
# --------------------------------------------------------------------------------------------------------
# Scanning all Variables. We are switching to the target Volume or its ESP.
# This function is usefull to rescan the new target "at need"
SCAN() {
bootDevice=$( LC_ALL=C diskutil info / | grep -i 'Device Node:' | awk '{print $NF}' )
targetDevice=$( LC_ALL=C diskutil info "${choicedVolume}" | grep -i 'Device Node:' | awk '{print $NF}' )
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetSlice=${targetDevice#*disk*s}
IOContent=$( LC_ALL=C diskutil info "${targetDisk}" | grep -i 'Content (IOContent)' | awk '{print $NF}' )
FS=$( LC_ALL=C diskutil info ${targetDevice} | grep -i 'Type (Bundle)' | \
awk '{print $NF}' | awk '{print tolower($0)}' )
awk '{print $NF}' | awk '{print tolower($0)}' )
disksignature=$( dd 2>/dev/null if="${targetDisk}" count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | \
perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $InstallBootloader = "1" ];then
blocksize=$( "${SS}" "${targetDeviceRaw}" | awk '{ print $2 }' )
# Create a folder inside the Desktop called "DebugChameleon", and the log will be full
DEBUG() {
echo "$mainLine"
echo "DEBUG: display script variables (Standardpostinstall)"
echo "DEBUG: display script variables (${TYPE}postinstall)"
echo "$mainLine"
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader} (or boot0hfs)"
echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot} (or boot0hfs)"
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}"
echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}"
echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}"
echo "DEBUG: stage1LoaderExFAT: Partition loader is ${stage1LoaderExFAT}"
echo "DEBUG: targetDisk: Disk device is ${targetDisk}"
echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}"
echo "DEBUG: targetSlice: Volume slice is ${targetSlice}"
echo "DEBUG: bootDevice: Current Volume device is ${bootDevice}"
echo "DEBUG: versionToInstall: version to install is ${versionToInstall}"
echo "DEBUG: IOContent: partition scheme is ${IOContent}"
echo "DEBUG: FS: file System is ${FS}"
# --------------------------------------------------------------------------------------------------------
# Checking for unsupported FAT16 filesystem
CHECK_FAT16() {
pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' \
| awk '{print $NF}' | awk '{print tolower($0)}' )
pers=$( LC_ALL=C diskutil info "${targetDeviceRaw}" | grep -i 'File System Personality' | \
awk '{print $NF}' | awk '{print tolower($0)}' )
case $pers in
fat16)
exit 1
;;
*)
echo "First Check Passed!"
echo "First Check Passed (not Fat16)!"
;;
esac
}
CHECK_ESP_MOUNTPOINT() {
# umount the ESP by its Mount Point
# and checking it if is busy by another ESP
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x '/Volumes/ESP' ) ]; then
umount -f /Volumes/ESP
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \
grep -x "${espmtp}" ) ]; then
umount -f ${espmtp}
ESP_MOUNTED="0"
fi
}
if [ $( df | grep "${espDisk}" | awk '{print $1}' | grep -x "${espDisk}" ) ];then
# ESP is already mounted, so now we aquire the Mount Point
espmtp=$( LC_ALL=C diskutil info ${espDisk} | grep -i 'mount point' | awk '{$1=$2=""; print $0}' | \
sed -e 's/^[ \t]*//' )
sed -e 's/^ *//' | sed -e 's/ *$//' )
if [ -d "${espmtp}" ];then
echo "ESP Mount Point is:${espmtp}, using that as target Volume!"
choicedVolume="${espmtp}"
fi
if [ $ESP_MOUNTED = "0" ];then
mkdir -p /Volumes/ESP
mkdir -p "${espmtp}"
case $( fstyp $espDisk ) in
hfs)
mount -t hfs $espDisk /Volumes/ESP
echo "Mounting $espDisk on $espmtp as hfs Volume.."
mount -t hfs $espDisk "${espmtp}"
;;
msdos)
mount -t msdos $espDisk /Volumes/ESP
echo "Mounting $espDisk on $espmtp as msdos Volume.."
mount -t msdos $espDisk "${espmtp}"
;;
*)
echo "ESP fileSystem unsupported, Installing to ${targetVolume}!"
esac
sleep 0.3
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^[ \t]*//' | \
grep -x '/Volumes/ESP' ) ]; then
if [ $( df | awk '{$1=$2=$3=$4=$5=$6=$7=$8=""; print $0}' | sed -e 's/^ *//' | sed -e 's/ *$//' | \
grep -x "${espmtp}" ) ]; then
echo "EFI System Partition mounted!"
ESP_MOUNTED="1"
choicedVolume="/Volumes/ESP"
choicedVolume="${espmtp}"
SCAN
else
echo "ESP can't be mounted, Installing to ${targetVolume}!"
# --------------------------------------------------------------------------------------------------------
# Writing stage 0
CHECK_WINDOWS() {
WINDOWS_EXIST="0"
if [ "${disksignature}" = "00000000" ]; then
echo "Windows installation not found on ${targetDisk}."
else
WRITE_STAGE0() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 0:"
CHECK_WINDOWS
case "$1" in
hfs)
if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0hfs"; else stage0Loader="boot0"; fi
;;
msdos)
if [ WINDOWS_EXIST = "1" ];then stage0Loader="boo0md"; else stage0Loader="boot0";fi
;;
exfat)
stage0Loader="boot0"
;;
esac
"${usrLocalBin}/fdisk440" -u -f "${i386Dir}/${stage0Loader}" -y ${targetDisk}
echo "${stage0Loader} writed to ${targetDisk}"
fi
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 1 on different filesystems
WRITE_STAGE1_HFS() {
# Writing stage 1
WRITE_STAGE1() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 HFS:"
$localdd if="${i386Dir}/${stage1LoaderHFS}" of=${targetDeviceRaw}
echo "${stage1LoaderHFS} (hfs) writed to ${targetDeviceRaw}."
fi
}
WRITE_STAGE1_EXFAT() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 ExFAT:"
echo -e "${mainLine}\nWRITING STAGE 1 ${2}:"
cp -R "${usrLocalBin}/boot1-install" "${v_mntpt}"/
cp -R "${i386Dir}/${stage1LoaderExFAT}" "${v_mntpt}"/
"${v_mntpt}/boot1-install" -y -u -f "${v_mntpt}/${stage1LoaderExFAT}" ${targetDeviceRaw}
echo "${stage1LoaderExFAT} (ExFAT) writed to ${targetDeviceRaw}."
cp -R "${i386Dir}/${1}" "${v_mntpt}"/
"${v_mntpt}/boot1-install" -y "-${3}" -f "${v_mntpt}/${1}" ${targetDeviceRaw}
echo "${stage1Loader} (${2}) writed to ${targetDeviceRaw}."
fi
}
WRITE_STAGE1_FAT32() {
if [ $InstallBootloader = "1" ];then
echo -e "${mainLine}\nWRITING STAGE 1 FAT32:"
$localdd if=${targetDeviceRaw} count=1 bs=512 of="${v_mntpt}/origbs"
cp "${i386Dir}/${stage1LoaderFAT}" "${v_mntpt}/newbs"
$localdd if="${v_mntpt}/origbs" of="${v_mntpt}/newbs" skip=3 seek=3 bs=1 count=87 conv=notrunc
$localdd if="${v_mntpt}/newbs" of="${targetDeviceRaw}" count=1 bs=512
echo "${stage1LoaderFAT} (Fat32) writed to ${targetDeviceRaw}."
fi
}
# --------------------------------------------------------------------------------------------------------
# Writing stage 2
WRITE_STAGE2() {
}
# --------------------------------------------------------------------------------------------------------
# Waiting for targhet Volume was re-mounted before proceeding..
# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..)
WAIT_REMOUNT() {
# Note: the target Volume is umonted by boot1-install that also take the step to remount it (only waiting..).
# exception is the EFI partition: in Mavericks autoremount...in Yosemite not..
REMOUNT() {
if [ $InstallBootloader = "1" ];then
if [ ! -d "${choicedVolume}" ]; then
echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:"
until [ -d "${choicedVolume}" ]; do
sleep 0.3
done
echo "${choicedVolume} is mounted!"
if [ "${InstallToESP}" == "1" ]; then
if [ ! -d "${choicedVolume}" ]; then
MOUNT_ESP
fi
else
if [ ! -d "${choicedVolume}" ]; then
echo -e "${mainLine}\nWAITING TO RE-MOUNT ${choicedVolume}:"
until [ -d "${choicedVolume}" ]; do
sleep 0.3
done
echo "${choicedVolume} is mounted!"
fi
fi
fi
}
else
echo "Extra folder already exist on ${choicedVolume}, copying to the Ram Disk.."
cp -R "${choicedVolume}/Extra" "${v_mntpt}"/
./clean_bootplist.pl "${v_mntpt}" >/dev/null
./clean_bootplist.pl "${v_mntpt}"
fi
}
# --------------------------------------------------------------------------------------------------------
exec > >(tee -a "${logFile}") 2>&1
echo "$mainLine"
echo "Main Standard Post-Install Script"
echo "Main ${TYPE} Post-Install Script"
echo "Chameleon installer log - $( date )"
if [ $InstallBootloader = "1" ];then echo "$versionToInstall"; else echo "no boot session"; fi
echo ""
echo "GPT partition Scheme detected.."
espDisk="${targetDisk}s1"
if [ $( LC_ALL=C diskutil info ${espDisk} | grep -i 'Partition Type:' | \
awk '{print $NF}' ) = "EFI" ]; then
awk '{print $NF}' | sed -e 's/^ *//' | sed -e 's/ *$//' ) = "EFI" ]; then
echo "EFI partition found is ${espDisk}, try to mount it.."
MOUNT_ESP
else
fi
;;
*)
InstallToESP = "0"
echo "Can't install on the ESP, because does not exist.."
echo "..continue installing to ${targetVolume}"
;;
SCAN
fi
if [ -d "${HOME}/Desktop/DebugChameleon" ]; then
DEBUG
fi
# adding the chosen Volume dev id to the InstallConfig.plist
/usr/libexec/PlistBuddy -c "Add :targetdev string ${targetDevice}" $configFile
echo "${mainLine}"
CHECK_FAT16
CHECK_WINDOWS
case "$FS" in
hfs)
echo "${targetDevice} is HFS formatted"
WRITE_STAGE0 hfs
WRITE_STAGE1_HFS
if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0hfs"; else stage0Loader="boot0"; fi
stage1Loader="${stage1LoaderHFS}"
;;
msdos)
echo "${targetDevice} is FAT32 formatted"
WRITE_STAGE0 msdos
WRITE_STAGE1_FAT32
if [ $WINDOWS_EXIST = "1" ];then stage0Loader="boot0md"; else stage0Loader="boot0"; fi
stage1Loader="${stage1LoaderFAT}"
;;
exfat)
echo "${targetDevice} is ExFAT formatted"
WRITE_STAGE0 exfat
WRITE_STAGE1_EXFAT
WAIT_REMOUNT
stage0Loader="boot0"
stage1Loader="${stage1LoaderExFAT}"
;;
*)
echo "FileSystem unsupported, aborting!"
;;
esac
# Debug mode: create a "DebugChameleon" folder on your Desktop to debug this script
if [ -d "${HOME}/Desktop/DebugChameleon" ]; then DEBUG; fi
# if the target device is equal to the boot device keep the Volume mounted using boot1-install
if [ "${bootDevice}" = "${targetDevice}" ]; then opt="M"; fi
WRITE_STAGE0 "${stage0Loader}"
WRITE_STAGE1 "${stage1Loader}" "${FS}" "${opt}"
if [ "${bootDevice}" != "${targetDevice}" ]; then REMOUNT; fi
WRITE_STAGE2
PARTITION_ACTIVE_IF
echo "$mainLine"
echo "END - Standard Post-Install Script"
echo "END - ${TYPE} Post-Install Script"
# --------------------------------------------------------------------------------------------------------
exit 0
trunk/package/buildpkg.sh
475475
476476
477477
478
478479
479480
480481
ditto --noextattr --noqtn ${SYMROOT}/i386/boot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot0md ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot0hfs ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1f32 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1h ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1x ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386

Archive Download the corresponding diff file

Revision: 2584