Chameleon

Chameleon Commit Details

Date:2011-09-19 11:46:43 (12 years 7 months ago)
Author:blackosx
Commit:1534
Parents: 1533
Message:Merge in re-worked package installer scripts from http://forge.voodooprojects.org/p/chameleonApplications/source/tree/H EAD/branches/blackosx.
Changes:
A/branches/blackosx/package/Scripts/Install/UnMountEFIvolumes.sh
A/branches/blackosx/package/Scripts/Install/WriteChameleonStage0.sh
A/branches/blackosx/package/Scripts/Install/WriteChameleonStage2.sh
A/branches/blackosx/package/Scripts/Install/CheckDiskMicrocode.sh
A/branches/blackosx/package/Scripts/Install/CheckWindowsDiskSignature.sh
A/branches/blackosx/package/Scripts/Install/CheckFormat.sh
A/branches/blackosx/package/Scripts/Install/CheckPartitionScheme.sh
A/branches/blackosx/package/Scripts/Install/CheckGRUBLinuxLoader.sh
A/branches/blackosx/package/Scripts/Install/CheckFatType.sh
A/branches/blackosx/package/Scripts/Install/WriteChameleonStage1.sh
A/branches/blackosx/package/Scripts/Install/CheckProceed.sh
A/branches/blackosx/package/Scripts/Install/SetActivePartition.sh
A/branches/blackosx/package/Scripts/Install
M/branches/blackosx/package/Scripts/Advanced/UseNvidiaROM/postinstall
M/branches/blackosx/package/Scripts/Keymaps/postinstall.in
M/branches/blackosx/package/Scripts/BaseOptions/RestartFix/postinstall
M/branches/blackosx/package/Scripts/Post/postinstall
M/branches/blackosx/package/Scripts/Advanced/EHCIacquire/postinstall
M/branches/blackosx/package/Scripts/Advanced/VBIOS/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1024x600x32/postinstall
M/branches/blackosx/package/Scripts/Advanced/SMBIOSdefaults/postinstall
M/branches/blackosx/package/Scripts/Advanced/LegacyLogo/postinstall
M/branches/blackosx/package/Scripts/Advanced/Wake/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1280x800x32/postinstall
M/branches/blackosx/package/Scripts/Advanced/UHCIreset/postinstall
M/branches/blackosx/package/Scripts/Advanced/ShowInfo/postinstall
M/branches/blackosx/package/Scripts/EFI/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/EnableC3State/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/GenerateCStates/postinstall
M/branches/blackosx/package/Scripts/Advanced/Wait/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1920x1200x32/postinstall
M/branches/blackosx/package/Scripts/Advanced/ForceWake/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1280x1024x32/postinstall
M/branches/blackosx/package/Scripts/Advanced/UseAtiROM/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/GraphicsEnabler/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1680x1050x32/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1920x1080x32/postinstall
M/branches/blackosx/package/Scripts/Advanced/QuietBoot/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/CSTUsingSystemIO/postinstall
M/branches/blackosx/package/Scripts/Advanced/ForceHPET/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/GeneratePStates/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/DropSSDT/postinstall
M/branches/blackosx/package/Scripts/Advanced/UseMemDetect/postinstall
M/branches/blackosx/package/Scripts/Advanced/GUI/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1600x900x32/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/EthernetBuiltIn/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/InstantMenu/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1440x900x32/postinstall
M/branches/blackosx/package/Scripts/Advanced/Npci/postinstall
M/branches/blackosx/package/Scripts/Advanced/BootBanner/postinstall
M/branches/blackosx/package/Scripts/Standard/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/EnableC2State/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/arch/postinstall
M/branches/blackosx/package/Scripts/BaseOptions/EnableC4State/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1280x960x32/postinstall
M/branches/blackosx/package/Scripts/Resolutions/1024x768x32/postinstall

File differences

branches/blackosx/package/Scripts/Standard/postinstall
11
22
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
433
44
45
46
47
48
49
50
51
52
53
54
55
56
4
5
576
587
59
60
618
62
63
64
65
66
9
10
6711
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
12
13
14
8315
8416
17
18
19
20
21
22
23
24
25
26
27
28
29
8530
86
87
88
89
90
9131
92
9332
94
33
9534
96
97
35
36
37
38
39
9840
99
41
42
43
44
45
46
10047
101
102
103
104
105
106
107
108
109
110
111
112
11348
114
115
116
117
118
119
120
121
12249
123
124
125
50
51
52
12653
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
54
55
56
57
58
59
60
61
62
63
64
65
15766
15867
159
160
16168
16269
163
164
165
166
167
16870
169
71
72
17073
171
74
75
76
77
17278
173
174
175
176
177
178
179
180
181
18279
80
81
18382
83
84
85
86
18487
185
186
187
188
189
19088
191
89
90
19291
193
194
92
93
19594
196
19795
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
96
97
98
99
219100
220
221
222
223
101
102
224103
225104
226
105
106
107
108
227109
110
111
228112
229
230
231
232113
233
234
235
236
237
238
239
240
241
242
243
114
115
116
117
118
244119
120
121
122
123
245124
246
247
248
125
126
127
249128
250
251
252
253
254
255
256
257
258
259
129
130
260131
261
262
263
264
265132
266
267
268
269
133
134
135
136
137
270138
139
140
141
142
271143
272
144
145
273146
147
148
274149
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
150
151
152
302153
303
304
305154
306155
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328156
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
157
158
356159
357160
358
359161
360
361
362
363
364
162
#!/bin/bash
diskloader="boot0"
diskloaderdualboot="boot0md"
partitionloaderhfs="boot1h"
partitionloaderfat="boot1f32"
filesystemloader="boot"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
start ()
{
# $1 volume
bootvolume="${@}"
echo "Volume is $bootvolume"
bootresources="${0%/*}"
echo "$bootresources"
if [ -z "${bootvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
echo
exit
fi
bootdev=$( df "${bootvolume}" | sed -n '2p' | awk '{print $1}' )
bootrdev=${bootdev/disk/rdisk}
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo
exit
fi
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "==============================================="
echo "Installer Variables:"
echo "********************"
echo "bootvolume: Volume is ${bootvolume}"
echo "bootdev: Volume device is ${bootdev}"
echo "bootrdev: Volume raw device is ${bootrdev}"
echo "bootslice: Volume slice is ${bootslice}"
echo "bootdisk: Disk device is ${bootdisk}"
echo "bootrdisk: Disk raw device is ${bootrdisk}"
echo "diskloader: Disk loader is ${diskloader}"
echo "partitionloaderhfs: Partition loader is ${partitionloaderhfs}"
echo "partitionloaderfat: Partition loader is ${partitionloaderfat}"
echo "filesystemloader: Filesystem loader is ${filesystemloader}"
echo "bootresources: Boot Resources is ${bootresources}"
echo "Main Standard Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
echo ""
echo ""
}
checkdiskmicrocodetype ()
{
echo "==============================================="
echo "Diskmicrocodetype:"
echo "******************"
# Find location of this script in the package installer
# so we know where all the other scripts are located.
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
else
echo "Didn't find a match for ${diskmicrocodetype[${diskmicrocodetypecounter}]%,*}"
fi
done
echo "-----------------------------------------------"
echo ""
echo ""
}
MYLOCATION="${PWD}/${BASH_ARGV[0]}"
export MYLOCATION="${MYLOCATION%/*}"
scriptDir=$MYLOCATION
#echo "==============================================="
#echo "Apple Installer Package Variables"
#echo "*********************************"
#echo "DEBUG: $ 1 = Full path to the installation package the installer app is processing: " $1
#echo "DEBUG: $ 2 = Full path to the installation destination: " $2
#echo "DEBUG: $ 3 = Installation volume (mountpoint) to receive the payload: " $3
#echo "DEBUG: $ 4 = Root directory for the system: " $4
#echo "DEBUG: Script Name: " $SCRIPT_NAME
#echo "DEBUG: Package Path: " $PACKAGE_PATH
#echo "DEBUG: Installer Temp: " $INSTALLER_TEMP
#echo "DEBUG: Full path to the temp directory containing the operation executable: " $RECEIPT_PATH
#echo "-----------------------------------------------"
#echo ""
checkdiskmicrocode ()
{
echo "==============================================="
echo "Diskmicrocode:"
echo "*************"
# Note: The checks for Boot0 and Boot0hfs assume the code doesn't change!!
# 1 action ( check or set )
# Initialise Script Globals
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
stage0Loader="boot0"
stage0LoaderDualBoot="boot0hfs"
stage1LoaderHFS="boot1h"
stage1LoaderFAT="boot1f32"
stage2Loader="boot"
#echo "${diskmicrocode}"
targetVolume=$3
targetDevice=$( df "${targetVolume}" | sed -n '2p' | awk '{print $1}' )
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetDiskRaw=${targetDisk/disk/rdisk}
targetSlice=${targetDevice#*disk*s}
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
echo "Diskmicrocode = 874 (Which means the first 437 bytes of the MBR Disk Sector is blank)"
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
echo "diskupdate is now set to true."
else
echo "No disk microcode found."
fi
else
# There is already something on the MBR
if [ ${1} = set ]; then
# See if a Windows bootloader already exists
windowsloader=$( dd 2>/dev/null if=${bootdisk} count=4 bs=1 | xxd | awk '{print $2$3}' )
if [ "${windowsloader}" == "33c08ed0" ] ; then
echo "Found existing Windows Boot Loader"
echo "Will replace loader with Boot0hfs"
diskupdate=true
echo "diskupdate is now set to true."
fi
# See if a Chameleon stage0 boot file already exists
stage0type=$( dd 2>/dev/null if=${bootdisk} count=3 bs=1 skip=105 | xxd | awk '{print $2$3}' )
if [ "${stage0type}" == "0b807c" ] || [ "${stage0type}" == "0a803c" ] ; then
echo "==============================================="
echo "DEBUG: display script variables"
echo "*******************************"
echo "Found existing Chameleon Stage 0 Loader"
# if found Boot0HFS without a Windows installation set diskupdate to true
if [ "${stage0type}" == "0b807c" ] && [ "${disksignature}" == "00000000" ]; then
echo "Found existing Chameleon Boot0HFS without a Windows installation"
echo "Will replace loader with Boot0"
diskupdate=true
echo "diskupdate is now set to true."
fi
# if found Boot0 with a Windows installation set diskupdate to true
if [ "${stage0type}" == "0a803c" ] && [ "${disksignature}" != "00000000" ]; then
echo "Found existing Chameleon Boot0 with a Windows installation"
echo "Will replace loader with Boot0hfs"
diskupdate=true
echo "diskupdate is now set to true."
fi
fi
# If neither a Windows or Chameleon Boot Loader exists
if [ "${stage0type}" != "0b807c" ] && [ "${stage0type}" != "0a803c" ] && [ "${windowsloader}" != "33c08ed0" ] ; then
test=$(echo "${diskmicrocode}" | awk -F0 '{print NF-1}' )
echo "Disk microcode found: ${test} - Preserving."
echo "diskupdate is left at false"
fi
else
test=$(echo "${diskmicrocode}" | awk -F0 '{print NF-1}' )
echo "Disk microcode found: ${test}"
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}"
echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot}"
echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}"
echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}"
echo "DEBUG: stage2Loader: Filesystem loader is ${stage2Loader}"
echo "DEBUG: targetVolume: Volume is ${targetVolume}"
echo "DEBUG: targetDevice: Volume device is ${targetDevice}"
echo "DEBUG: targetDeviceRaw: Volume raw device is ${targetDeviceRaw}"
echo "DEBUG: targetDisk: Disk device is ${targetDisk}"
echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}"
echo "DEBUG: targetSlice: Volume slice is ${targetSlice}"
echo "DEBUG: targetResources: Boot Resources is ${targetResources}"
echo "-----------------------------------------------"
echo ""
echo ""
}
checkdisksignature ()
{
echo "==============================================="
echo "Find Disk Signature:"
echo "*************"
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
# Double check we can see the selected partition and it's of the right type
# if not the following script returns to indicate failure.
echo "${disksignature}"
"$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDevice}"
returnValue=$?
if [ ${returnValue}=0 ]; then
# OK to proceed
if [ $disksignature = "00000000" ]; then
echo "Just Zero's found meaning Windows isn't installed."
else
echo "Non Zero means we've found a Windows installation"
fi
echo "-----------------------------------------------"
echo ""
echo ""
}
# Does a GRUB or Linux loader already exist in the disk's MBR?
# The script returns 1 if yes, 0 if no.
"$scriptDir"CheckGRUBLinuxLoader.sh "${targetDisk}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
checkpartitionbootcode ()
{
echo "==============================================="
echo "Find Partition Bootcode:"
echo "************************"
# 1 action ( check or set )
# check for a 4-byte Windows disk signature in the disk's MBR.
# the following script returns 1 if a Windows disk signature exists, and 0 if not.
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
"$scriptDir"CheckWindowsDiskSignature.sh "${targetDisk}"
diskSigCheck=$?
echo "${partitionbootcode}"
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
echo "partitionbootcode = 1024 (Which means the whole 512 bytes of the MBR Disk Sector is blank)"
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
# check for existing bootloaders in the disk's MBR
# and find out if we can write the Chameleon boot files.
# the following script returns 0 if we can proceed
# with writing the boot files, and 1 for not.
echo "-----------------------------------------------"
echo ""
echo ""
}
"$scriptDir"CheckDiskMicrocode.sh "${targetDisk}" "${diskSigCheck}"
diskupdate=$?
start ${3}
# check the format of the selected partition.
# the following script returns 1 if HFS
# the following script returns 2 if MSDOS
# the following script returns 0 if nothing
"$scriptDir"CheckFormat.sh "${targetDevice}"
espformat=$?
echo "==============================================="
echo "Check the format of the selected partition"
echo "*************************************"
if [ "$( fstyp ${bootdev} | grep hfs )" ]; then
echo "${bootdev} is currently formatted as HFS"
efiformat="hfs"
fi
if [ "$( fstyp ${bootdev} | grep msdos )" ]; then
echo "${bootdev} is currently formatted as msdos"
efiformat="msdos"
fi
echo "-----------------------------------------------"
echo ""
echo ""
# check the partition scheme used for the selected disk.
# the following script returns 1 if GPT
# the following script returns 2 if GPT/MBR
# the following script returns 3 if MBR
# the following script returns 0 if nothing
"$scriptDir"CheckPartitionScheme.sh "${targetDisk}"
partitionTable=$?
if [ ${partitionTable} = 3 ]; then
# If MBR partition scheme then check for FAT16 or FAT32
echo "==============================================="
echo "Determine Partition Scheme:"
echo "***************************"
# the following script returns 1 if FAT16
# the following script returns 2 if FAT32
# the following script returns 0 if nothing
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:0:16}" == "4546492050415254" ]; then
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:8:2}" == "ee" ]; then
echo "Found System ID 'EE' to identify GPT Partition"
if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then
echo "Found System ID '00' for each remaining possible partition"
partitiontable="GPT"
else
partitiontable="GPT/MBR"
"$scriptDir"CheckFatType.sh "${targetDeviceRaw}"
fatType=$?
fi
fi
else
partitiontable="MBR"
fi
echo "${partitiontable} found."
echo "-----------------------------------------------"
echo ""
echo ""
if [ "${fatType}" = 1 ] && [ "${partitionTable}" = 3 ]; then
echo "ERROR: - Can't install to a device using FAT16"
# Write error to Chameleon_Error_Log file
else
# Continue if the selected device is not a FAT16 format device
# If diskupdate is flagged as 0 then the stage 0 loader can be written to the MBR
if [ ${diskupdate} = 0 ]; then
"$scriptDir"WriteChameleonStage0.sh "${diskupdate}" "${diskSigCheck}" "${stage0Loader}" "${stage0LoaderDualBoot}" "${targetDisk}" "${targetVolume}" "${scriptDir}"
fi
diskupdate=false
# Write the stage 1 loader to the partition boot sector
"$scriptDir"WriteChameleonStage1.sh "${espformat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}"
# Write the stage 2 loader to the root of the selected partition
"$scriptDir"WriteChameleonStage2.sh "${espformat}" "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}"
checkdisksignature
checkdiskmicrocodetype
checkdiskmicrocode set
checkpartitionbootcode set
echo "==============================================="
echo "Can we install the Chameleon bootloader files?"
echo "**********************************************"
if ${diskupdate}; then
echo "Diskupdate = true, so yes"
#---------------------------------------------------------------------
# Check bytes 438-446 of the GPTdiskProtectiveMBR for a Windows Disk Signature
# If there's no Windows disk signature then we can write boot0
#---------------------------------------------------------------------
if [ ${disksignature} == "00000000" ]; then
echo "Executing command: fdisk440 -u -f /usr/standalone/i386/${diskloader} -y ${bootdisk}"
"${bootresources}/Tools/fdisk440" -u -f "${bootvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}
else
#---------------------------------------------------------------------
# If it exists then Windows is also installed on the HDD and we need to write boot0hfs
#---------------------------------------------------------------------
echo "Executing command: fdisk440 -u -f /usr/standalone/i386/${diskloaderdualboot} -y ${bootdisk}"
"${bootresources}/Tools/fdisk440" -u -f "${bootvolume}/usr/standalone/i386/${diskloaderdualboot}" -y ${bootdisk}
# Set the active partition ONLY if Windows is not installed
"$scriptDir"SetActivePartition.sh "${espformat}" "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolume}" "${scriptDir}"
fi
fi
else
echo "Diskupdate is false, so no stage 0 file was written"
fi
if [ ${efiformat} = "hfs" ]; then
echo "Executing command: dd if=/usr/standalone/i386/${partitionloaderhfs} of=${bootrdev}"
dd if="${bootvolume}/usr/standalone/i386/${partitionloaderhfs}" of=${bootrdev}
fi
if [ ${efiformat} = "msdos" ]; then
echo "Executing command: dd if=/usr/standalone/i386/${partitionloaderfat} of=${bootrdev}"
dd if="${bootvolume}/usr/standalone/i386/${partitionloaderfat}" of=${bootrdev}
fi
echo "Executing command: cp /usr/standalone/i386/${filesystemloader} ${bootvolume}"
cp "${bootvolume}/usr/standalone/i386/${filesystemloader}" "${bootvolume}"
echo "Executing command: ${bootresources}/Tools/SetFile -a V ${bootvolume}/${filesystemloader}"
"${bootresources}/Tools/SetFile" -a V "${bootvolume}/${filesystemloader}"
echo "-----------------------------------------------"
echo ""
echo ""
echo "==============================================="
echo "Set Active Partition ONLY if Windows is not installed"
echo "*****************************************************"
if [ ${disksignature} == "00000000" ]; then
# echo "Windows is not installed so let's change the active partition"
partitionactive=$( "${bootresources}/Tools/fdisk440" -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
echo "Current Active Partition: ${partitionactive}"
if [ "${partitionactive}" = "${bootslice}" ]; then
echo "${bootvolume} is already flagged as active"
else
echo "${bootvolume} is not flagged as active, so let's do it."
# BadAxe requires EFI partition to be flagged active.
# but it doesn't' hurt to do it for any non-windows partition.
"${bootresources}/Tools/fdisk440" -e ${bootrdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
fi
else
echo "Windows is installed so we let that remain the active partition"
fi
echo "END - Standard Post-Install Script"
echo "*********************************"
echo "-----------------------------------------------"
echo ""
echo ""
# hide boot file
chflags hidden "${3}/boot"
echo "boot file hidden ${3}/boot"
exit
exit 0
branches/blackosx/package/Scripts/EFI/postinstall
11
22
3
4
5
6
7
8
3
4
5
6
7
98
10
9
10
1111
12
13
12
13
14
1415
15
16
17
1816
19
17
18
19
20
21
22
23
24
25
26
27
28
29
2030
21
22
23
24
25
31
2632
27
33
34
35
36
37
2838
29
30
31
32
33
34
35
39
40
3641
37
38
42
43
44
45
46
47
3948
40
41
42
43
44
45
4649
47
48
49
50
51
52
53
5450
55
5651
57
52
5853
59
60
61
62
63
64
6554
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
55
56
57
58
59
60
61
62
63
64
65
66
67
8768
8869
89
9070
9171
92
93
94
95
96
72
9773
98
74
75
9976
100
101
102
103
104
105
106
107
108
109
110
111
112
113
77
78
11479
80
11581
116
117
118
119
120
82
83
84
85
12186
122
12387
124
88
89
12590
126
127
91
92
93
94
12895
129
130
131
132
133
134
135
136
137
138
139
140
14196
142
143
144
145
146
147
148
149
97
98
15099
151
152
153
100
101
154102
155
156
157
158
159
160
161
162
163103
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
104
105
106
107
188108
109
110
189111
190
191
192
193
194
195
196112
197
113
114
115
116
198117
199
200
201
202
203
204
205
206
207
118
119
208120
209121
210
211
212
213
214
122
123
215124
216
125
217126
218
219
220127
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
128
129
130
246131
132
133
134
135
247136
248
249137
138
139
140
141
250142
251
143
144
252145
146
147
253148
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
149
150
151
152
153
315154
316155
317
156
318157
319158
320
321
322159
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
160
161
162
163
353164
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
165
166
167
399168
400
401
402
403169
170
171
404172
405
406
407
408
173
174
175
409176
410
411177
412
413
414
415
416
417
418
419
420
421
422
178
179
423180
424181
425
426182
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
183
#!/bin/bash
diskloader="boot0"
partitionloaderhfs="boot1h"
partitionloaderfat="boot1f32"
filesystemloader="boot"
bootervolumename="EFI"
booterextensions="Extra/Extensions"
echo "==============================================="
echo "Main EFI System Partition Post-Install Script"
echo "*********************************************"
echo "-----------------------------------------------"
echo ""
bootresources="${0%/*}"
# Find location of this script in the package installer
# so we know where all the other scripts are located.
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
MYLOCATION="${PWD}/${BASH_ARGV[0]}"
export MYLOCATION="${MYLOCATION%/*}"
scriptDir=$MYLOCATION
start ()
{
# $1 volume
osxvolume="${@}"
#echo "==============================================="
#echo "Apple Installer Package Variables"
#echo "*********************************"
#echo "DEBUG: $ 1 = Full path to the installation package the installer app is processing: " $1
#echo "DEBUG: $ 2 = Full path to the installation destination: " $2
#echo "DEBUG: $ 3 = Installation volume (mountpoint) to receive the payload: " $3
#echo "DEBUG: $ 4 = Root directory for the system: " $4
#echo "DEBUG: Script Name: " $SCRIPT_NAME
#echo "DEBUG: Package Path: " $PACKAGE_PATH
#echo "DEBUG: Installer Temp: " $INSTALLER_TEMP
#echo "DEBUG: Full path to the temp directory containing the operation executable: " $RECEIPT_PATH
#echo "-----------------------------------------------"
#echo ""
if [ -z "${osxvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
exit
fi
# Initialise Script Globals
bootdev=$( df "${osxvolume}" | sed -n '2p' | awk '{print $1}' )
stage0Loader="boot0"
stage0LoaderDualBoot="boot0hfs"
stage1LoaderHFS="boot1h"
stage1LoaderFAT="boot1f32"
stage2Loader="boot"
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo "Volume may be stored on a RAID array."
echo
exit
fi
targetVolumeTemp=$3
targetDeviceTemp=$( df "${targetVolumeTemp}" | sed -n '2p' | awk '{print $1}' )
bootuuid=$( diskutil info "$bootdev" | grep Volume\ UUID | awk {'print $3'} )
partitiontable=$( diskutil list ${bootdev%s*} | sed -n '3p' | awk '{print $2}' )
targetVolume="/Volumes/EFI"
targetDevice=${targetDeviceTemp%s*}s1
targetDeviceRaw=${targetDevice/disk/rdisk}
targetDisk=${targetDevice%s*}
targetDiskRaw=${targetDisk/disk/rdisk}
targetSlice=${targetDevice#*disk*s}
if [ ${partitiontable} != "GUID_partition_scheme" ]; then
echo
echo "ERROR Volume is not on a GPT partitioned disc."
echo
exit
fi
echo "==============================================="
echo "Partition Type Identified:"
echo "**************************"
echo "GPT found."
echo "-----------------------------------------------"
echo ""
echo ""
echo "==============================================="
echo "Installer Variables Part 1:"
echo "DEBUG: display script variables"
echo "***************************"
echo "OS X Volume is ${osxvolume}"
echo "OX X Volume device is ${bootdev}"
echo "OS X Volume UUID is ${bootuuid}"
echo "-----------------------------------------------"
echo ""
echo ""
bootvolume="/Volumes/$bootervolumename"
bootdev=${bootdev%s*}s1
bootrdev=${bootdev/disk/rdisk}
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "==============================================="
echo "Installer Variables Part 2:"
echo "***************************"
echo "EFI Volume device is ${bootdev}"
echo "EFI Volume raw device is ${bootrdev}"
echo "EFI Volume slice is ${bootslice}"
echo "Disk device is ${bootdisk}"
echo "Disk raw device is ${bootrdisk}"
echo "Disk loader normal is ${diskloader}"
echo "Disk loader dual boot is also ${diskloader}"
echo "Partition loader HFS is ${partitionloaderhfs}"
echo "Partition loader FAT is ${partitionloaderfat}"
echo "Filesystem loader is ${filesystemloader}"
echo "DEBUG: stage0Loader: Disk loader is ${stage0Loader}"
echo "DEBUG: stage0LoaderDualBoot: Disk loader is ${stage0LoaderDualBoot}"
echo "DEBUG: stage1LoaderHFS: Partition loader is ${stage1LoaderHFS}"
echo "DEBUG: stage1LoaderFat: Partition loader is ${stage1LoaderFAT}"
echo "DEBUG: stage2Loader: Filesystem loader is ${stage2Loader}"
echo "DEBUG: targetVolumeTemp: Volume is ${targetVolumeTemp}"
echo "DEBUG: targetDeviceTemp: Volume device is ${targetDeviceTemp}"
echo "DEBUG: targetVolume: Volume is ${targetVolume}"
echo "DEBUG: targetDevice: Volume device is ${targetDevice}"
echo "DEBUG: targetDeviceRaw: Volume raw device is ${targetDeviceRaw}"
echo "DEBUG: targetDisk: Disk device is ${targetDisk}"
echo "DEBUG: targetDiskRaw: Disk raw device is ${targetDiskRaw}"
echo "DEBUG: targetSlice: Volume slice is ${targetSlice}"
echo "-----------------------------------------------"
echo ""
echo ""
checkdiskmicrocodetype ()
{
echo "==============================================="
echo "Diskmicrocodetype:"
echo "******************"
# Check to see if the selected disk uses a GPT
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
bootuuid=$( diskutil info "$targetDeviceTemp" | grep Volume\ UUID | awk {'print $3'} )
partitiontable=$( diskutil list ${targetDeviceTemp%s*} | sed -n '3p' | awk '{print $2}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
else
echo "Didn't find a match for ${diskmicrocodetype[${diskmicrocodetypecounter}]%,*}"
fi
done
echo "-----------------------------------------------"
echo ""
echo ""
}
if [ ${partitiontable} = "GUID_partition_scheme" ]; then
echo "Confirm this is a GPT partitioned disk."
# Double check we can see the selected partition and it's of the right type
checkdiskmicrocode ()
{
echo "==============================================="
echo "Diskmicrocode:"
echo "*************"
"$scriptDir"CheckProceed.sh "${targetVolumeTemp}" "${targetDeviceTemp}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# Note: The checks for Boot0 and Boot0hfs assume the code doesn't change!!
# 1 action ( check or set )
# Does a GRUB or Linux loader already exist in the disk's MBR?
# The script returns 1 if yes, 0 if no.
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
"$scriptDir"CheckGRUBLinuxLoader.sh "${targetDisk}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
echo "Diskmicrocode = 874 (Which means the first 437 bytes of the MBR Disk Sector is blank)"
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
echo "diskupdate is now set to true."
else
echo "No disk microcode found."
fi
else
# There is already something on the MBR
if [ ${1} = set ]; then
# See if a Windows bootloader already exists
windowsloader=$( dd 2>/dev/null if=${bootdisk} count=4 bs=1 | xxd | awk '{print $2$3}' )
if [ "${windowsloader}" == "33c08ed0" ] ; then
echo "Found existing Windows Boot Loader"
echo "Will replace loader with Boot0hfs"
diskupdate=true
echo "diskupdate is now set to true."
fi
# check for a 4-byte Windows disk signature in the disk's MBR.
# the following script returns 1 if a Windows disk signature exists, and 0 if not.
# See if a Chameleon stage0 boot file already exists
stage0type=$( dd 2>/dev/null if=${bootdisk} count=3 bs=1 skip=105 | xxd | awk '{print $2$3}' )
if [ "${stage0type}" == "0b807c" ] || [ "${stage0type}" == "0a803c" ] ; then
"$scriptDir"CheckWindowsDiskSignature.sh "${targetDisk}"
diskSigCheck=$?
echo "Found existing Chameleon Stage 0 Loader"
# if found Boot0HFS without a Windows installation set diskupdate to true
if [ "${stage0type}" == "0b807c" ] && [ "${disksignature}" == "00000000" ]; then
echo "Found existing Chameleon Boot0HFS without a Windows installation"
echo "Will replace loader with Boot0"
diskupdate=true
echo "diskupdate is now set to true."
fi
# if found Boot0 with a Windows installation set diskupdate to true
if [ "${stage0type}" == "0a803c" ] && [ "${disksignature}" != "00000000" ]; then
echo "Found existing Chameleon Boot0 with a Windows installation"
echo "Will replace loader with Boot0hfs"
diskupdate=true
echo "diskupdate is now set to true."
fi
fi
# If neither a Windows or Chameleon Boot Loader exists
if [ "${stage0type}" != "0b807c" ] && [ "${stage0type}" != "0a803c" ] && [ "${windowsloader}" != "33c08ed0" ] ; then
test=$(echo "${diskmicrocode}" | awk -F0 '{print NF-1}' )
echo "Disk microcode found: ${test} - Preserving."
echo "diskupdate is left at false"
fi
else
test=$(echo "${diskmicrocode}" | awk -F0 '{print NF-1}' )
echo "Disk microcode found: ${test}"
fi
fi
echo "-----------------------------------------------"
echo ""
echo ""
}
# check for existing bootloaders in the disk's MBR
# and find out if we can write the Chameleon boot files.
# the following script returns 0 if we can proceed
# with writing the boot files, and 1 for not.
"$scriptDir"CheckDiskMicrocode.sh "${targetDisk}" "${diskSigCheck}"
diskupdate=$?
checkdisksignature ()
{
echo "==============================================="
echo "Find Disk Signature:"
echo "*************"
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
echo "${disksignature}"
# check the format of the selected partition.
# the following script returns 1 if HFS
# the following script returns 2 if MSDOS
# the following script returns 0 if nothing - **** the script shouldn't continue here??? as the partition is not formatted as either HFS or msdos??? ****
if [ $disksignature = "00000000" ]; then
echo "Just Zero's found meaning Windows isn't installed."
else
echo "Non Zero means we've found a Windows installation"
fi
echo "-----------------------------------------------"
echo ""
echo ""
}
"$scriptDir"CheckFormat.sh "${targetDevice}"
espformat=$?
checkpartitionbootcode ()
{
echo "==============================================="
echo "Find Partition Bootcode:"
echo "************************"
# Determine the partition scheme of the selected disk
# is it GPT or a hybrid GPT/MBR
# 1 action ( check or set )
"$scriptDir"CheckPartitionScheme.sh "${targetDisk}"
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
echo "partitionbootcode = 1024 (Which means the whole 512 bytes of the MBR Disk Sector is blank)"
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
echo "-----------------------------------------------"
echo ""
echo ""
}
# Unmount ALL mounted volumes named EFI
# the following script returns 0 if it succeeds
# the following script returns 1 if it fails to un-mount any EFI volume
"$scriptDir"UnMountEFIvolumes.sh
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
}
# If diskupdate is flagged as 0 then the stage 0 loader can be written to the MBR
if [ ${diskupdate} = 0 ]; then
"$scriptDir"WriteChameleonStage0.sh "${diskupdate}" "${diskSigCheck}" "${stage0Loader}" "${stage0LoaderDualBoot}" "${targetDisk}" "${targetVolumeTemp}" "${scriptDir}"
fi
start ${3}
# Write the stage 1 loader to the partition boot sector
"$scriptDir"WriteChameleonStage1.sh "${espformat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${targetVolumeTemp}" "${targetDeviceRaw}" "${targetVolume}"
# Write the stage 2 loader to the root of the selected partition
"$scriptDir"WriteChameleonStage2.sh "${espformat}" "${stage2Loader}" "${targetVolumeTemp}" "${targetDevice}" "${targetVolume}"
echo "==============================================="
echo "Unmount all EFI partitions and Check their format"
echo "*************************************"
# loop through and un-mount all mounted EFI partitions - Thanks kizwan
attempts=1
while [ "$( df | grep EFI )" ] && [ "${attempts}" -lt 5 ]; do
echo "Unmounting $( df | grep EFI | awk '{print $1}' )"
umount -f $( df | grep EFI | awk '{print $1}' )
attempts=$(( ${attempts} + 1 ))
done
if [ ${attempts} = 5 ]; then
echo "failed to unmount EFI partitions."
exit
fi
if [ "$( fstyp ${bootdev} | grep hfs )" ]; then
echo "${bootdev} is currently formatted as HFS"
efiformat="hfs"
fi
if [ "$( fstyp ${bootdev} | grep msdos )" ]; then
echo "${bootdev} is currently formatted as msdos"
efiformat="msdos"
fi
echo "-----------------------------------------------"
echo ""
echo ""
diskupdate=false
checkdisksignature
checkdiskmicrocodetype
checkdiskmicrocode set
checkpartitionbootcode set
#checkpartitionactive
echo "==============================================="
echo "Can we install the Chameleon bootloader files?:"
echo "**********************************************"
if ${diskupdate}; then
echo "Diskupdate = true, so yes"
#---------------------------------------------------------------------
# Check bytes 438-446 of the GPTdiskProtectiveMBR for a Windows Disk Signature
# If there's no Windows disk signature then we can write boot0
#---------------------------------------------------------------------
if [ ${disksignature} == "00000000" ]; then
echo "Executing command: fdisk -u -f "${osxvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}"
fdisk -u -f "${osxvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}
else
#---------------------------------------------------------------------
# If it exists then Windows is also installed on the HDD and we need to write boot0hfs
#---------------------------------------------------------------------
#Azipkg: diskloader=boot0 ??? boot0hfs/boot0md - remenber this is for GPT!!
echo "Executing command: fdisk -u -f "${osxvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}"
fdisk -u -f "${osxvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}
# Set the active partition ONLY if Windows is not installed
"$scriptDir"SetActivePartition.sh "${espformat}" "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolumeTemp}" "${scriptDir}"
fi
fi
fi
else
echo "Diskupdate is false, so no stage 0 file was written"
echo "ERROR Volume is not on a GPT partitioned disc."
fi
#echo "Executing command: dd if=${partitionloader} of=${bootrdev}"
#dd if="${osxvolume}/${partitionloader}" of=${bootrdev}
# if we have an original EFI ("FAT"), copy boot1f32 to newbs
if [ ${efiformat} = "msdos" ]; then
echo "Prepare Stage 1 loader"
# copy partition boot sector to origbs
echo "Executing command: dd if=${bootrdev} count=1 bs=512 of=/tmp/origbs"
dd if=${bootrdev} count=1 bs=512 of=/tmp/origbs
# copy boot1f32 to newbs
echo "Executing command: cp "${osxvolume}/usr/standalone/i386/${partitionloaderfat}" /tmp/newbs"
cp "${osxvolume}/usr/standalone/i386/${partitionloaderfat}" /tmp/newbs
# "merge" origbs into newbs
echo "Executing command: dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc"
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
echo "Write Stage 1 loader"
# write newbs to the partition boot sector
echo "Executing command: dd if=/tmp/newbs of=${bootrdev}"
dd if=/tmp/newbs of=${bootrdev}
else
#Azipkg: this is was failing for me, hanged at boot0: done. Got fine when i removed "bs=512 count=1" ??
# makes no sense but... anyway, i'd remove this!.. no need to change EFI fs if boot1f32 works fine.
# In fact, i'm not a fan of EFI installs so, i'd remove it all!! :)
echo "Write Stage 1 loader"
# just write boot1h to the partition boot sector
echo "Executing command: dd if="${osxvolume}/usr/standalone/i386/${partitionloaderhfs}" of=${bootrdev}"
dd if="${osxvolume}/usr/standalone/i386/${partitionloaderhfs}" of=${bootrdev}
# remove the temporary boot sector files if they exist
if [ -d /tmp/newbs ]; then
echo "Executing command: rm /tmp/newbs"
rm /tmp/newbs
fi
echo "-----------------------------------------------"
echo ""
echo ""
echo "==============================================="
echo "Set Active Partition ONLY if Windows is not installed:"
echo "*****************************************************"
# If table is MBR make the correct slice active. If table is GPT make the first partition active (BadAxe compatibility).
#[ "${partitiontable}" = "GUID_partition_scheme" ] && bootslice=1
#if [[ "${partitiontable}" = "FDisk_partition_scheme" || "${partitiontable}" = "GUID_partition_scheme" ]]; then
#fdisk -e ${bootdisk} <<-MAKEACTIVE
#print
#flag ${bootslice}
#write
#y
#quit
#MAKEACTIVE
#fi
if [ ${disksignature} == "00000000" ]; then
# echo "Windows is not installed so let's change the active partition"
partitionactive=$( fdisk -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
echo "Current Active Partition: ${partitionactive}"
if [ "${partitionactive}" = "${bootslice}" ]; then
echo "${bootvolume} is already flagged as active"
else
echo "${bootvolume} is not flagged as active, so let's do it."
# BadAxe requires EFI partition to be flagged active.
# but it doesn't' hurt to do it for any non-windows partition.
fdisk -e ${bootrdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
fi
else
echo "Windows is installed so we let that remain the active partition"
if [ -d /tmp/origbs ]; then
echo "Executing command: rm /tmp/origbs"
rm /tmp/origbs
fi
echo "-----------------------------------------------"
echo ""
echo ""
# Check for mounted volumes named EFI and if found, unmount
#"$scriptDir"UnMountEFIvolumes.sh - ***** commented out to allow the boot option scripts to function ****
#checkdiskmicrocode check
#checkdisksignature
#checkpartitionbootcode check
#checkpartitionactive
# Create temporary file on target volume to notify
# boot option scripts than EFI (ESP) option was chosen
echo "EFI" >"${targetVolumeTemp}"/.ChameleonEFI
echo "==============================================="
echo "Mount EFI partition:"
echo "********************"
if [ ${efiformat} = "hfs" ]; then
[ -d "${bootvolume}" ] || mkdir -p "${bootvolume}"
echo "Executing command: mount_hfs -u 0 -g 0 ${bootdev} ${bootvolume}"
mount_hfs -u 0 -g 0 "${bootdev}" "${bootvolume}"
else
[ -d "${bootvolume}" ] || mkdir -p "${bootvolume}"
echo "Executing command: mount_msdos -u 0 -g 0 ${bootdev} ${bootvolume}"
mount_msdos -u 0 -g 0 "${bootdev}" "${bootvolume}"
fi
echo "END - Main EFI System Partition Post-Install Script"
echo "*********************************************"
echo "-----------------------------------------------"
echo ""
echo ""
echo "==============================================="
echo "Write Stage 2 loader"
echo "********************"
echo "Executing command: cp "${osxvolume}/usr/standalone/i386/${filesystemloader}" ${bootvolume}/boot"
cp "${osxvolume}/usr/standalone/i386/${filesystemloader}" "${bootvolume}/boot"
echo "boot written"
echo "-----------------------------------------------"
echo ""
echo ""
# setup link for extras
#echo "Executing command: ln -s /Volumes/${bootervolumename} ${2}/.Chameleon"
#ln -s "/Volumes/${bootervolumename}" "${2}/.Chameleon"
# setup link for extras
exit
exit 0
branches/blackosx/package/Scripts/Advanced/ForceHPET/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/EHCIacquire/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/VBIOS/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/GUI/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/SMBIOSdefaults/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/UseMemDetect/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/LegacyLogo/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/Wake/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/BootBanner/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/Npci/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/UHCIreset/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/ShowInfo/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/Wait/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/UseNvidiaROM/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/ForceWake/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/UseAtiROM/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Advanced/QuietBoot/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Post/postinstall
3333
3434
3535
36
37
38
39
40
41
42
43
44
45
46
47
48
3649
3750
3851
3952
40
53
54
dest_vol="$3"
fi
# check to see if EFI system partition install option was chosen.
# if so, unmount /Volumes/EFI
if [ -f "$dest_vol"/.ChameleonEFI ]; then
attempts=1
while [ "$( df | grep EFI )" ] && [ "${attempts}" -lt 5 ]; do
echo "Unmounting $( df | grep EFI | awk '{print $1}' )"
umount -f $( df | grep EFI | awk '{print $1}' )
attempts=$(( ${attempts} + 1 ))
done
fi
# delete the temporary Chameleon folder
rm -rf "$dest_vol/tmpcham"
echo "Done..."
echo "Done..."
branches/blackosx/package/Scripts/BaseOptions/GenerateCStates/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/DropSSDT/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/EthernetBuiltIn/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/InstantMenu/postinstall
77
88
99
10
11
10
11
12
13
14
15
16
17
18
19
20
21
22
23
1224
1325
1426
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/GraphicsEnabler/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/RestartFix/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/CSTUsingSystemIO/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/EnableC2State/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/EnableC3State/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/arch/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/EnableC4State/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/BaseOptions/GeneratePStates/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Install/CheckFormat.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
#!/bin/bash
echo "==============================================="
echo "CheckFormat: Is target HFS or MSDOS?"
echo "**********************************************"
# Receives passed value for the Target Volume Device
# for example: /dev/disk0s2
# if the selected partition is formatted as HFS then exit with 1
# if the selected partition is formatted as MSDOS then exit with 2
# if fstyp doesn't return a value then exit with 0
if [ "$#" -eq 1 ]; then
targetDevice="$1"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
else
echo "Error - wrong number of values passed"
exit 9
fi
if [ "$( fstyp "$targetDevice" | grep hfs )" ]; then
echo "${targetDevice} is currently formatted as HFS"
echo "-----------------------------------------------"
echo ""
exit 1
fi
if [ "$( fstyp "$targetDevice" | grep msdos )" ]; then
echo "${targetDevice} is currently formatted as msdos"
echo "-----------------------------------------------"
echo ""
exit 2
fi
echo "WARNING: ${targetDevice} is currently not formatted as either HFS or msdos"
echo "-----------------------------------------------"
echo ""
exit 0
branches/blackosx/package/Scripts/Install/CheckFatType.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
#!/bin/bash
echo "==============================================="
echo "CheckFatType: Do we have FAT16 or FAT32?"
echo "****************************************"
# Receives passed value for the raw Target Device
# for example: /dev/rdisk0s2
# Then looks for the following in the partition boot sector
# Byte number 19 to see if it's either 00 or 02
# Byte number 22 to see if it's either F8 or F0
# Byte number 25 to see if it's either 3F or 20
#
# Exit with value 1 for FAT16, 2 for FAT32
# Exit with value 0 if nothing is found - this shouldn't happen.?
if [ "$#" -eq 1 ]; then
targetDeviceRaw="$1"
echo "DEBUG: passed argument = $targetDeviceRaw"
else
echo "Error - wrong number of values passed"
exit 9
fi
partitionBootSector=$( dd 2>/dev/null if="$targetDeviceRaw" count=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "3f" ]; then
echo "Found a FAT32 device formatted by Windows Explorer"
echo "-----------------------------------------------"
echo ""
exit 2
fi
if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f8" ] && [ "${partitionBootSector:48:2}" == "3f" ]; then
echo "Found a FAT16 device formatted by Windows Explorer"
echo "-----------------------------------------------"
echo ""
exit 1
fi
if [ "${partitionBootSector:36:2}" == "00" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
echo "Found a FAT32 device formatted by OSX Disk Utility"
echo "-----------------------------------------------"
echo ""
exit 2
fi
if [ "${partitionBootSector:36:2}" == "02" ] && [ "${partitionBootSector:42:2}" == "f0" ] && [ "${partitionBootSector:48:2}" == "20" ]; then
echo "Found a FAT16 device formatted by OSX Disk Utility"
echo "-----------------------------------------------"
echo ""
exit 1
fi
echo "-----------------------------------------------"
echo ""
exit 0
branches/blackosx/package/Scripts/Install/WriteChameleonStage0.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
#!/bin/bash
echo "==============================================="
echo "Write Chameleon Stage 0 Loader:"
echo "*******************************"
if [ "$#" -eq 7 ]; then
diskupdate="$1"
disksignature="$2"
stage0Loader="$3"
stage0Loaderdualboot="$4"
targetDisk="$5"
targetVolume="$6"
scriptDir="$7"
echo "DEBUG: passed argument for diskupdate = $diskupdate"
echo "DEBUG: passed argument for disksignature = $disksignature"
echo "DEBUG: passed argument for stage0Loader = $stage0Loader"
echo "DEBUG: passed argument for stage0Loaderdualboot = $stage0Loaderdualboot"
echo "DEBUG: passed argument for targetDisk = $targetDisk"
echo "DEBUG: passed argument for targetVolume = $targetVolume"
echo "DEBUG: passed argument for scriptDir = $scriptDir"
else
echo "Error - wrong number of values passed"
exit 9
fi
if [ ${diskupdate} = "0" ]; then
echo "Diskupdate = true, so yes"
if [ ${disksignature} = "0" ]; then
echo "Executing command: fdisk440 -u -f /usr/standalone/i386/${stage0Loader} -y ${targetDisk}"
"${scriptDir}"/Tools/fdisk440 -u -f "${targetVolume}"/usr/standalone/i386/${stage0Loader} -y ${targetDisk}
else
# Windows is also installed on the HDD and we need to write boot0hfs
echo "Executing command: /fdisk440 -u -f /usr/standalone/i386/${stage0Loaderdualboot} -y ${targetDisk}"
"${scriptDir}"/Tools/fdisk440 -u -f "${targetVolume}"/usr/standalone/i386/${stage0Loaderdualboot} -y ${targetDisk}
fi
fi
echo "-----------------------------------------------"
echo ""
echo ""
exit 0
branches/blackosx/package/Scripts/Install/WriteChameleonStage1.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
#!/bin/bash
echo "==============================================="
echo "Write Chameleon Stage 1 Loader:"
echo "*******************************"
# espformat code is 1 for HFS, 2 for MSDOS, 0 for unknown
if [ "$#" -eq 6 ]; then
espformat="$1"
stage1LoaderHFS="$2"
stage1LoaderFAT="$3"
selectedDestination="$4"
targetDeviceRaw="$5"
targetVolume="$6"
echo "DEBUG: passed argument for espformat = $espformat"
echo "DEBUG: passed argument for stage1LoaderHFS = $stage1LoaderHFS"
echo "DEBUG: passed argument for stage1LoaderFAT = $stage1LoaderFAT"
echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
echo "DEBUG: passed argument for targetDeviceRaw = $targetDeviceRaw"
echo "DEBUG: passed argument for targetVolume = $targetVolume"
else
echo "Error - wrong number of values passed"
exit 9
fi
if [ ${espformat} = "1" ]; then
# the selected partition is HFS formatted
echo "Executing command: dd if=${selectedDestination}/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"
dd if="${selectedDestination}"/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}
fi
if [ ${espformat} = "2" ]; then
# the selected partition FAT formatted
echo "Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"
dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs
echo "Executing command: cp "${selectedDestination}"/usr/standalone/i386/${stage1LoaderFAT} /tmp/newbs"
cp "${selectedDestination}"/usr/standalone/i386/${stage1LoaderFAT} /tmp/newbs
echo "Executing command: dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc"
dd if=/tmp/origbs of=/tmp/newbs skip=3 seek=3 bs=1 count=87 conv=notrunc
echo "Executing command: dd of=${targetDeviceRaw} count=1 bs=512 if=/tmp/newbs"
dd if=/tmp/newbs of="${targetDeviceRaw}" count=1 bs=512
fi
echo "-----------------------------------------------"
echo ""
exit 0
branches/blackosx/package/Scripts/Install/CheckPartitionScheme.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
#!/bin/bash
echo "==============================================="
echo "Check the Partition Scheme: GPT, GPT/MBR or MBR?"
echo "************************************************"
# Receives passed value for the Target Disk
# for example: /dev/disk0s2
# Then looks for the following:
# First 8 bytes of the GPTdiskGPTHeader to identify a GUID partition table.
# Byte number 450 of the GPTdiskProtectiveMBR to identify ID of 'EE' to identify a GPT partition.
# Byte numbers 466, 482 & 498 of the GPTdiskProtectiveMBR to identify further partitions.
#
# Exit with value 1 for GPT, 2 for GPT/MBR and 3 for MBR.
# Exit with value 0 if nothing is found - this shouldn't happen.?
if [ "$#" -eq 1 ]; then
targetDisk="$1"
echo "DEBUG: passed argument = $targetDisk"
else
echo "Error - wrong number of values passed"
exit 9
fi
partitiontable=$( dd 2>/dev/null if="$targetDisk" count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:0:16}" == "4546492050415254" ]; then
partitiontable=$( dd 2>/dev/null if="$targetDisk" count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:8:2}" == "ee" ]; then
echo "Found System ID 'EE' to identify GPT Partition"
if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then
echo "Found System ID '00' for each remaining possible partition"
partitiontable="GPT"
echo "${partitiontable} found."
echo "-----------------------------------------------"
echo ""
exit 1
else
partitiontable="GPT/MBR"
echo "${partitiontable} found."
echo "-----------------------------------------------"
echo ""
exit 2
fi
fi
else
partitiontable="MBR"
echo "${partitiontable} found."
echo "-----------------------------------------------"
echo ""
exit 3
fi
echo "No partition table found."
echo "-----------------------------------------------"
echo ""
exit 0
branches/blackosx/package/Scripts/Install/WriteChameleonStage2.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
#!/bin/bash
echo "==============================================="
echo "Write Chameleon Stage 2 Loader:"
echo "*******************************"
# for example:
# espformat code is 1 for HFS, 2 for MSDOS, 0 for unknown
if [ "$#" -eq 5 ]; then
espformat="$1"
stage2Loader="$2"
selectedDestination="$3"
targetDevice="$4"
targetVolume="$5"
echo "DEBUG: passed argument for espformat = $espformat"
echo "DEBUG: passed argument for stage2Loader = $stage2Loader"
echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
echo "DEBUG: passed argument for targetVolume = $targetVolume"
else
echo "Error - wrong number of values passed"
exit 9
fi
# check to see if install to EFI system partition was selected
# if chosen, the package installer will add a file named 'nullESP'
# in to the temporary directory /.Chameleon
#if [ -f "${selectedDestination}"/.Chameleon/nullESP ]; then
if [ "${targetVolume}" = "/Volumes/EFI" ]; then
echo "DEBUG: EFI install chosen"
if [ ! -d "${targetVolume}" ]; then
echo "Executing Command: mkdir -p ${targetVolume}"
mkdir -p "${targetVolume}"
else
echo "DEBUG: folder /Volumes/EFI already exists"
fi
#if the EFI system partition was selected then
# mount '/Volumes/EFI' with the correct format type
if [ ${espformat} = 1 ]; then
echo "Executing command: mount_hfs ${targetDevice} ${targetVolume}"
mount_hfs "${targetDevice}" "${targetVolume}"
fi
if [ ${espformat} = 2 ]; then
[ -d "${targetVolume}" ] || mkdir -p "${targetVolume}"
echo "Executing command: mount_msdos -u 0 -g 0 ${targetDevice} ${targetVolume}"
mount_msdos -u 0 -g 0 "${targetDevice}" "${targetVolume}"
fi
echo "Executing command: cp "${selectedDestination}"/usr/standalone/i386/${stage2Loader} ${targetVolume}"
cp "${selectedDestination}"/usr/standalone/i386/"${stage2Loader}" "${targetVolume}"
else
echo "Executing command: cp "${targetVolume}"/usr/standalone/i386/${stage2Loader} ${targetVolume}"
cp "${targetVolume}"/usr/standalone/i386/"${stage2Loader}" "${targetVolume}"
fi
#if [ -f "${selectedDestination}"/.Chameleon/nullhideboot ]; then
#
#echo "Executing command: SetFile -a V ${targetVolume}/${stage2Loader}"
#"${selectedDestination}"/.Chameleon//Tools/SetFile -a V "${targetVolume}"/"${stage2Loader}"
#fi
echo "-----------------------------------------------"
echo ""
echo ""
exit 0
branches/blackosx/package/Scripts/Install/CheckDiskMicrocode.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
84
85
86
87
88
#!/bin/bash
echo "==============================================="
echo "CheckDiskMicrocode: Any existing bootloaders?"
echo "*********************************************"
# This script is passed the targetDisk and diskSigCheck.
#
# it then reads the GPTdiskProtectiveMBR and searches for an existing
# Windows bootloader and also for an existing Chameleon stage 0 loader
# which might be better changed depending on whether or not a Windows
# signature is found or not.
#
# The script then exits with the value 0 to indicate that Chameleon stage0
# loader can be written, or 1 to indicate not to write the stage0 loader.
if [ "$#" -eq 2 ]; then
targetDisk="$1"
diskSigCheck="$2"
echo "DEBUG: passed argument for targetDisk = $targetDisk"
echo "DEBUG: passed argument for diskSigCheck = $diskSigCheck"
else
echo "Error - wrong number of values passed - Exiting"
exit 9
fi
# read the first 437 bytes of the MBR
mbr437=$( dd 2>/dev/null if="$targetDisk" count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
#mbr437md5=$( dd 2>/dev/null if="$targetDisk" count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
#echo "DEBUG: ${mbr437}"
if [ $( echo "${mbr437}" | awk -F0 '{print NF-1}' ) = 874 ]; then
echo "The first 437 bytes of the MBR Disk Sector is blank - Updating"
else
# There is already something on the MBR
# See if a Windows bootloader already exists
# Check bytes 440-443 of the GPTdiskProtectiveMBR for a Windows Disk Signature
windowsloader=$( dd 2>/dev/null if="$targetDisk" count=4 bs=1 | xxd | awk '{print $2$3}' )
if [ "${windowsloader}" == "33c08ed0" ] ; then
echo "Found existing Windows Boot Loader so will replace with Chameleon Boot0hfs"
fi
# See if a Chameleon stage0 boot file already exists
# Note: The checks for Boot0 and Boot0hfs assume the code stays the same.
# if the code changes then the hex values 0b807c and 0a803c used for matching
# need to be checked to see if they are the same or not.
stage0type=$( dd 2>/dev/null if="$targetDisk" count=3 bs=1 skip=105 | xxd | awk '{print $2$3}' )
echo ${stage0type}
if [ "${stage0type}" == "0b807c" ]; then
echo "Found existing Chameleon stage 0 loader - Boot0hfs"
# Script CheckDiskSignature.sh returned 0 if a Windows installation was NOT found
if [ "$diskSigCheck" == "0" ]; then
echo "Found no existing Windows installation so will replace stage 0 loader with Boot0"
fi
fi
if [ "${stage0type}" == "0a803c" ]; then
echo "Found existing Chameleon stage 0 loader - Boot0"
# Script CheckDiskSignature.sh returned 1 if a Windows installation was found
if [ "$diskSigCheck" = "1" ]; then
echo "Found existing Windows installation so will replace stage 0 loader with Boot0hfs"
fi
fi
if [ "${stage0type}" != "0b807c" ] && [ "${stage0type}" != "0a803c" ] && [ "${windowsloader}" != "33c08ed0" ] ; then
echo "Something other than Chameleon or a Windows bootloader was found"
test=$(echo "${mbr437}" | awk -F0 '{print NF-1}' )
echo "Disk microcode found: ${test} - Preserving."
echo "diskupdate is set to false"
echo "-----------------------------------------------"
echo ""
exit 1
fi
fi
echo "diskupdate is now set to true."
echo "-----------------------------------------------"
echo ""
exit 0
branches/blackosx/package/Scripts/Install/CheckProceed.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
#!/bin/bash
echo "==============================================="
echo "Check Proceed: Can the script continue?"
echo "***************************************"
# Receives targetVolume and targetDevice
# Checks the selected volume is present and the disk
# is partitioned.
if [ "$#" -eq 2 ]; then
targetVolume="$1"
targetDevice="$2"
echo "DEBUG: passed argument for targetVolume = $targetVolume"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
else
echo "Error - wrong number of values passed"
exit 9
fi
if [ -z "$targetVolume" ]; then
echo "Cannot find the volume. Exiting."
exit 1
else
echo "Confirming target volume exists"
fi
if [ "$targetDevice" = "$targetDevice#*disk*s" ]; then
echo "ERROR Volume does not use slices."
exit 1
else
echo "Confirming target device uses slices"
fi
echo "-----------------------------------------------"
echo ""
exit 0
branches/blackosx/package/Scripts/Install/SetActivePartition.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
#!/bin/bash
echo "==============================================="
echo "Set Active Partition ONLY if Windows is not installed"
echo "*****************************************************"
# for example:
# efiformat code is 1 for HFS, 2 for MSDOS, 0 for unknown
# diskSigCheck code is 1 for a Windows install, 0 for no Windows install
if [ "$#" -eq 6 ]; then
efiformat="$1"
diskSigCheck="$2"
targetDiskRaw="$3"
targetSlice="$4"
targetVolume="$5"
scriptDir="$6"
echo "DEBUG: passed argument for efiformat = $efiformat"
echo "DEBUG: passed argument for diskSigCheck = $diskSigCheck"
echo "DEBUG: passed argument for targetDiskRaw = $targetDiskRaw"
echo "DEBUG: passed argument for targetSlice = $targetSlice"
echo "DEBUG: passed argument for targetVolume = $targetVolume"
echo "DEBUG: passed argument for scriptDir = $scriptDir"
else
echo "Error - wrong number of values passed"
exit 9
fi
if [ ${diskSigCheck} == "0" ]; then
echo "DEBUG: Windows is not installed so let's change the active partition"
partitionactive=$( "${scriptDir}"/Tools/fdisk440 -d ${targetDiskRaw} | grep -n "*" | awk -F: '{print $1}')
echo "Current Active Partition: ${partitionactive}"
if [ "${partitionactive}" = "${targetSlice}" ]; then
echo "${targetVolume} is already flagged as active"
else
echo "${targetVolume} is not flagged as active, so let's do it."
# BadAxe requires EFI partition to be flagged active.
# but it doesn't' hurt to do it for any non-windows partition.
"${scriptDir}"/Tools/fdisk440 -e ${targetDiskRaw} <<-MAKEACTIVE
print
flag ${targetSlice}
write
y
quit
MAKEACTIVE
fi
else
echo "Windows is installed so we let that remain the active partition"
fi
echo "-----------------------------------------------"
echo ""
echo ""
exit 0
branches/blackosx/package/Scripts/Install/CheckGRUBLinuxLoader.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
#!/bin/bash
echo "==============================================="
echo "CheckGRUBLinuxLoader: Does GRUB or LILO exist?"
echo "**********************************************"
# This script is passed the targetdisk
# it then reads the MBR of the disk in the attempt to find the
# signature for either the GRUB or Linux bootloaders.
# The script returns 1 if either is found, or 0 if none found.
if [ "$#" -eq 1 ]; then
targetDisk="$1"
echo "DEBUG: passed argument for targetDisk = $targetDisk"
else
echo "Error - wrong number of values passed"
exit 9
fi
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
diskmicrocode=$( dd 2>/dev/null if="$targetDisk" count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
#echo "${diskmicrocode}"
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
exit 1
else
echo "Didn't find a match for ${diskmicrocodetype[${diskmicrocodetypecounter}]%,*}"
fi
done
echo "-----------------------------------------------"
echo ""
exit 0
branches/blackosx/package/Scripts/Install/UnMountEFIvolumes.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
#!/bin/bash
echo "==============================================="
echo "Unmount all volumes named EFI"
echo "*****************************"
# loop through and un-mount ALL mounted EFI system partitions - Thanks kizwan
attempts=1
while [ "$( df | grep EFI )" ] && [ "${attempts}" -lt 5 ]; do
echo "Unmounting $( df | grep EFI | awk '{print $1}' )"
umount -f $( df | grep EFI | awk '{print $1}' )
attempts=$(( ${attempts} + 1 ))
done
if [ ${attempts} = 5 ]; then
echo "failed to unmount EFI System Partition."
echo "-----------------------------------------------"
echo ""
echo ""
echo ""
exit 1
fi
echo "-----------------------------------------------"
echo ""
echo ""
echo ""
exit 0
branches/blackosx/package/Scripts/Install/CheckWindowsDiskSignature.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
#!/bin/bash
echo "==============================================="
echo "CheckWindowsDiskSignature: Is Windows installed?"
echo "************************************************"
# this script is passed the targetdisk to work from, for example /dev/disk0
# It then checks the disk sector for a 4-byte Windows disk signature
# if one is found then it exits with 1, otherwise it exits with 0
if [ "$#" -eq 1 ]; then
targetDisk="$1"
echo "DEBUG: passed argument for targetDisk = $targetDisk"
else
echo "Error - wrong number of values passed - Exiting"
exit 9
fi
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}' )
echo "${disksignature}"
if [ "${disksignature}" = "00000000" ]; then
echo "No Windows installation detected."
echo "-----------------------------------------------"
echo ""
exit 0
else
echo "Detected an existing Windows installation"
echo "-----------------------------------------------"
echo ""
exit 1
fi
echo "-----------------------------------------------"
echo ""
exit 0
branches/blackosx/package/Scripts/Resolutions/1024x768x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Resolutions/1024x600x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Resolutions/1920x1200x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Resolutions/1600x900x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Resolutions/1280x1024x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Resolutions/1440x900x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Resolutions/1280x800x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Resolutions/1680x1050x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Resolutions/1920x1080x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Resolutions/1280x960x32/postinstall
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)
branches/blackosx/package/Scripts/Keymaps/postinstall.in
66
77
88
9
10
9
10
11
12
13
14
15
16
17
18
19
20
21
22
1123
1224
1325
import shutil
vol = str(sys.argv[3])
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
# Check for .ChameleonEFI file at root of target volume
# to indicate user wants to install to EFI system partition.
espfile = "/.ChameleonEFI"
espvol = vol + espfile
if os.path.exists(espvol):
if not os.path.exists('/Volumes/EFI/Extra'):
os.makedirs('/Volumes/EFI/Extra')
plist = "/Volumes/EFI/Extra/org.chameleon.Boot.plist"
else:
boot = "/Extra/org.chameleon.Boot.plist"
plist = vol + boot
if not os.path.exists(plist):
shutil.copy('/Library/Preferences/SystemConfiguration/com.apple.Boot.plist', plist)

Archive Download the corresponding diff file

Revision: 1534