Chameleon Applications

Chameleon Applications Commit Details

Date:2010-10-31 10:11:40 (13 years 4 months ago)
Author:blackosx
Commit:199
Parents: 198
Message:Went back to the EFI script from Scrax's branch as it was working, then re-added the extra bits from the standard script it my branch. This is still under development but I am happy the EFI FAT install is now working.
Changes:
M/branches/blackosx/trunk/package/Scripts/HFS/postinstall

File differences

branches/blackosx/trunk/package/Scripts/HFS/postinstall
11
22
3
4
5
6
7
8
3
4
5
6
7
98
9
1010
11
12
1113
1214
1315
......
1618
1719
1820
19
20
2121
2222
2323
2424
25
2625
2726
2827
29
28
3029
31
30
3231
3332
33
3434
35
35
3636
3737
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
3868
39
69
4070
4171
4272
4373
4474
45
4675
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
76
77
78
79
80
81
82
83
84
85
86
87
6288
6389
6490
65
6691
92
6793
6894
6995
70
96
7197
7298
7399
100
74101
75102
76103
......
86113
87114
88115
116
89117
90118
91119
92
120
93121
94122
95123
......
99127
100128
101129
102
103
104130
105131
106132
......
144170
145171
146172
147
173
148174
149175
150176
......
155181
156182
157183
158
159184
160185
161186
......
166191
167192
168193
169
194
170195
171
172196
173197
174198
......
184208
185209
186210
187
188211
189212
190213
191
214
192215
193216
194217
......
196219
197220
198221
199
200
201222
202223
203224
......
219240
220241
221242
222
223243
224244
225245
226246
227247
228248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
229263
230264
231265
232266
233267
234
268
269
235270
236
237
271
272
238273
239274
240275
241276
277
278
279
280
281
242282
243283
244284
......
246286
247287
248288
249
250
251
289
290
291
252292
253293
254294
255295
256296
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
286297
287298
288299
......
290301
291302
292303
304
293305
294306
295
296307
297
308
298309
299310
300311
......
305316
306317
307318
308
309
319
320
310321
311322
312323
313324
314
315
325
326
327
316328
317329
318
330
319331
320332
333
334
335
336
337
338
339
340
341
321342
322
323
343
344
324345
346
325347
326
327
348
349
328350
329351
330
331
352
353
332354
333
334
355
335356
357
358
359
336360
337361
338362
339363
340364
341365
342
366
343367
344368
369
370
371
372
373
374
375
376
377
378
379
380
345381
346382
347383
......
371407
372408
373409
410
411
412
413
374414
415
375416
376
377
378
379
380
417
418
419
420
421
422
423
424
425
426
381427
382428
383429
384430
385431
432
386433
387
388
389
390
391
392
393
394
395
396
397
434
435
436
437
438
439
398440
441
442
443
444
399445
400
401
402
446
447
448
403449
404450
#!/bin/bash
diskloader="boot0"
diskloaderdualboot="boot0hfs"
partitionloaderhfs="boot1h"
partitionloaderfat="boot1f32"
filesystemloader="boot"
diskloader="/usr/standalone/i386/boot0"
diskloaderdualboot="/usr/standalone/i386/boot0hfs"
partitionloaderhfs="/usr/standalone/i386/boot1h"
partitionloaderfat="/usr/standalone/i386/boot1f32"
filesystemloader="/usr/standalone/i386/boot"
bootervolumename="EFI"
booterextensions="Extra/Extensions"
bootresources="${0%/*}"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
# $1 volume
osxvolume="${@}"
bootresources="${0%/*}"
echo "$bootresources"
if [ -z "${osxvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
echo
exit
fi
osxbootdev=$( df "${osxvolume}" | sed -n '2p' | awk '{print $1}' )
bootdev=$( df "${osxvolume}" | sed -n '2p' | awk '{print $1}' )
if [ "${osxbootdev}" = "${osxbootdev#*disk*s}" ]; then
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
exit
fi
bootuuid=$( diskutil info "$bootdev" | grep Volume\ UUID | awk {'print $3'} )
partitiontable=$( diskutil list ${bootdev%s*} | sed -n '3p' | awk '{print $2}' )
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 "***************************"
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=${osxbootdev%s*}s1
bootdev=${bootdev%s*}s1
bootrdev=${bootdev/disk/rdisk}
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "==============================================="
echo "Installer Variables:"
echo "********************"
echo "OS X Volume is ${osxvolume}"
echo "OX X Volume device is ${osxbootdev}"
echo "bootdev: EFI Volume device is ${bootdev}"
echo "bootrdev: EFI Volume raw device is ${bootrdev}"
echo "bootslice: EFI Volume slice is ${bootslice}"
echo "bootdisk: Disk device is ${bootdisk}"
echo "bootrdisk: Disk raw device is ${bootrdisk}"
echo "diskloader: Disk loader is ${diskloader}"
echo "diskloaderdualboot: Disk loader is ${diskloaderdualboot}"
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 "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 ${diskloaderdualboot}"
echo "Partition loader HFS is ${partitionloaderhfs}"
echo "Partition loader FAT is ${partitionloaderfat}"
echo "Filesystem loader is ${filesystemloader}"
echo "-----------------------------------------------"
echo ""
echo ""
}
checkdiskmicrocodetype ()
{
echo "==============================================="
echo "Diskmicrocodetype: CHECKED FOR EFI"
echo "Diskmicrocodetype:"
echo "******************"
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 ))
echo ""
}
checkdiskmicrocode ()
{
echo "==============================================="
echo "Diskmicrocode: CHECKED FOR EFI"
echo "Diskmicrocode:"
echo "*************"
# Note: The checks for Boot0 and Boot0hfs assume the code doesn't change!!
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 )
#echo "${diskmicrocode}"
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 "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}' )
test=$(echo "${diskmicrocode}" | awk -F0 '{print NF-1}' )
echo "Disk microcode found: ${test}"
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
echo "-----------------------------------------------"
echo ""
checkdisksignature ()
{
echo "==============================================="
echo "Find Disk Signature: CHECKED FOR EFI"
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}"
}
checkpartitionbootcode ()
{
echo "==============================================="
echo "Find Partition Bootcode: CHECKED FOR EFI"
echo "Find Partition Bootcode:"
echo "************************"
# 1 action ( check or set )
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}' )
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
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
echo "-----------------------------------------------"
echo ""
echo ""
}
#checkpartitionactive ()
#{
#partitionactive=$( fdisk440 -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
#if [ -n "${partitionactive}" ]; then
#echo "Partition flagged active is ${partitionactive}"
#else
#echo "No partition flagged active."
#fi
#}
}
start ${3}
echo "==============================================="
echo "Check the format of the EFI partition"
echo "***************************"
echo "*************************************"
if [ "$( df | grep ${bootdev} )" ]; then
echo "EFI partition is currently mounted, so un-mounting it"
#umount -f ${bootdev}
echo "${bootdev} is currently mounted, so un-mounting it"
umount -f ${bootdev}
else
echo "EFI partition is currently not mounted"
fi
#if [[ `dd if=/dev/disk${1}s1 count=8 bs=1 skip=82 | uuencode -m -|head -n 2|tail -n 1` != "RkFUMzIgICA=" ]]; then
#echo "${bootdev} isn't a FAT32 partition"
#newfs_msdos -v "${bootervolumename}" "${bootdev}"
#fi
if [ "$( fstyp ${bootdev} | grep hfs )" ]; then
echo "${bootdev} is a currently formatted as HFS"
efiformat="hfs"
if [ "$( fstyp ${bootdev} | grep msdos )" ]; then
echo "${bootdev} is currently formatted as msdos"
efiformat="msdos"
#echo "Executing command: newfs_hfs -v ${bootervolumename} ${bootdev}"
#newfs_hfs -v "${bootervolumename}" "${bootdev}"
fi
#echo "Executing command: newfs_msdos -F 32 ${bootdev}"
#newfs_msdos -F 32 "${bootdev}"
fi
echo "-----------------------------------------------"
echo ""
echo ""
echo "==============================================="
echo "Determine Partition Scheme: CHANGED FOR EFI"
echo "***************************"
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"
fi
fi
else
echo "ERROR Volume is not on a GPT partitioned disc."
exit
fi
echo "${partitiontable} found."
echo "-----------------------------------------------"
echo ""
echo ""
diskupdate=false
checkdiskmicrocodetype
checkdiskmicrocode set
checkpartitionbootcode set
#checkpartitionactive
echo "==============================================="
echo "Can we install the Chameleon bootloader files? : CHECKED FOR EFI"
echo "Can we install the Chameleon bootloader files?:"
echo "**********************************************"
if ${diskupdate}; then
#---------------------------------------------------------------------
if [ ${disksignature} == "00000000" ]; then
echo "Executing command: fdisk440 -u -f /usr/standalone/i386/${diskloader} -y ${bootdisk}"
fdisk440 -u -f "${bootvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}
echo "Executing command: fdisk440 -u -f ${diskloader} -y ${bootdisk}"
fdisk440 -u -f "${osxvolume}/${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}"
fdisk440 -u -f "${bootvolume}/usr/standalone/i386/${diskloaderdualboot}" -y ${bootdisk}
echo "Executing command: fdisk440 -u -f ${diskloaderdualboot} -y ${bootdisk}"
fdisk440 -u -f "${osxvolume}/${diskloaderdualboot}" -y ${bootdisk}
fi
else
echo "Diskupdate is false, so no stage 0 file was written"
echo "Diskupdate is false, so no stage 0 file was written"
fi
#echo "Executing command: dd if=${partitionloader} of=${bootrdev}"
#dd if="${osxvolume}/${partitionloader}" of=${bootrdev}
echo "Prepare Stage 1 loader"
echo "Executing command: dd if=${bootrdev} count=1 bs=512 of=/tmp/origbs"
dd if=${bootrdev} count=1 bs=512 of=/tmp/origbs
if [ ${efiformat} = "hfs" ]; then
echo "Executing command: dd if=/usr/standalone/i386/${partitionloaderhfs} of=${bootrdev}"
dd if="${bootvolume}/usr/standalone/i386/${partitionloaderhfs}" of=${bootrdev}
echo "Executing command: cp ${osxvolume}/${partitionloaderhfs} /tmp/newbs"
cp "${osxvolume}/${partitionloaderhfs}" /tmp/newbs
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}
echo "Executing command: cp ${osxvolume}/${partitionloaderfat} /tmp/newbs"
cp "${osxvolume}/${partitionloaderfat}" /tmp/newbs
fi
echo "Executing command: cp /usr/standalone/i386/${filesystemloader} ${bootvolume}"
cp "${bootvolume}/usr/standalone/i386/${filesystemloader}" "${bootvolume}"
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: ${bootresources}/Tools/SetFile -a V ${bootvolume}/${filesystemloader}"
"${bootresources}/Tools/SetFile" -a V "${bootvolume}/${filesystemloader}"
echo "Write Stage 1 loader"
echo "Executing command: dd of=${bootrdev} count=1 bs=512 if=/tmp/newbs"
dd if=/tmp/newbs of=${bootrdev} count=1 bs=512
echo "-----------------------------------------------"
echo ""
echo ""
echo "==============================================="
echo "Set Active Partition ONLY if Windows is not installed: CHECKED FOR EFI"
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
#fdisk440 -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"
echo ""
#checkdiskmicrocode check
#checkdisksignature
#checkpartitionbootcode check
#checkpartitionactive
echo "==============================================="
echo "Check EFI Partition:"
echo "***************************"
if [ -d /Volumes/EFI ]; then
umount -f /Volumes/EFI
rm -R -f /Volumes/EFI
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 "-----------------------------------------------"
echo ""
echo ""
echo "==============================================="
echo "/Extra/Extensions Folder"
echo "*****************************************************"
if [ -d "${bootvolume}/Extra/Extensions" ]; then
echo "Duplicating Extra to ExtraBackup Folder"
mkdir -p "${bootvolume}/ExtraBackup"
cp -f -R "${bootvolume}/Extra" "${bootvolume}/ExtraBackup"
else
echo "Create /Extra/Extensions"
mkdir -p "${bootvolume}/Extra/Extensions"
fi
echo "Write Stage 2 loader"
echo "********************"
echo "Executing command: cp ${osxvolume}${filesystemloader} ${bootvolume}/boot"
cp "${osxvolume}${filesystemloader}" "${bootvolume}/boot"
echo "boot written"
echo "-----------------------------------------------"
echo ""
echo ""
# setup link for extras
#[ -h "${2}/.Chameleon" ] && unlink "${2}/.Chameleon"
#echo "Executing command: ln -s . ${2}/.Chameleon"
#ln -s "${2}" "${2}/.Chameleon"
#echo "Executing command: ln -s /Volumes/${bootervolumename} ${2}/.Chameleon"
#ln -s "/Volumes/${bootervolumename}" "${2}/.Chameleon"
# setup link for extras
exit

Archive Download the corresponding diff file

Revision: 199