Chameleon

Chameleon Commit Details

Date:2011-10-05 17:31:31 (12 years 6 months ago)
Author:blackosx
Commit:1605
Parents: 1604
Message:Added check for an existing Chameleon installation on a different partition of same target disk to help stop new users from confusing themselves. I need to test this further this evening to make sure it works as intended.
Changes:
M/branches/blackosx/package/Scripts/Main/EFI/postinstall
M/branches/blackosx/package/Changes.txt
M/branches/blackosx/package/Scripts/Main/Standard/postinstall
M/branches/blackosx/package/Scripts/Sub/CheckProceed.sh

File differences

branches/blackosx/package/Changes.txt
1
1
2
3
4
5
6
7
8
9
10
211
3
4
12
13
14
15
16
17
518
19
620
7
21
22
23
24
825
26
927
28
1029
30
1131
- Re-organised Scripts folder in to Main and Sub scripts. The main scripts for the standard and EFI system partition installation options have been changed to used the code that I'd previously re-structured. The Sub scripts are the original chameleon installer scripts with maybe some tweaks/additions, split in to separate scripts. These scripts include the previous additions I'd made including checking for FAT16 partitions, installing boot0md or boot0 depending on whether or not a Windows installation is found and writing boot1h or boot1f32 depending on installing to HFS or FAT32 format partitions.
- Added check for an existing Chameleon installation on a different partition of same target disk to help stop new
users from confusing themselves. If found, the install process will exit and write the reason to the install log.
- Re-organised Scripts folder in to Main and Sub scripts. The main scripts for the standard and EFI system partition
installation options have been changed to used the code that I'd previously re-structured. The Sub scripts are the
original chameleon installer scripts with maybe some tweaks/additions, split in to separate scripts. These scripts
include the previous additions I'd made including checking for FAT16 partitions, installing boot0md or boot0 depending
on whether or not a Windows installation is found and writing boot1h or boot1f32 depending on installing to HFS or
FAT32 format partitions.
- All references of Boot0hfs removed and now replaced with Boot0md.
- Installer log added to now dump a log of useful info about the install process to the root of the selected target.
- Boot options re-thought and are now automatically created at compile time from simple lists, rather than manage a separate file of code of each option.
- Installer log added to now dump a log of useful info about the install process to the root of the selected target.
- Boot options re-thought and are now automatically created at compile time from simple lists, rather than manage a
separate file of code of each option.
- Added missing useKernelCache boot option.
- Easily enable a list to be exclusive or not.
- The main Post script now creates the org.chameleon.Boot.plist based on the modules / options / key layouts / themes selected by the user.
- The main Post script now creates the org.chameleon.Boot.plist based on the modules / options / key layouts / themes
selected by the user.
- Only create and /Extra folder if there's something to go in it.
- Backup an existing /Extra folder to /Extra-OLD(date & time).
- slimpkg.sh changed to match the revised code in buildpkg.sh where applicable.
- English Localizable.strings revised to match latest additions and some texts updated.
branches/blackosx/package/Scripts/Main/Standard/postinstall
7676
7777
7878
79
80
79
80
81
8182
82
83
8384
8485
8586
"$scriptDir"InstallLog.sh "${targetVolume}" "Target volume = ${targetVolume}"
# Double check we can see the selected partition and it's of the right type
# if not the following script returns to indicate failure.
# Double check we can see the selected partition and it's of the right type.
# Now also check for another existing Chameleon installation on the same disk.
# If the following script finds anything, it returns 1 to indicate failure.
"$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
"$scriptDir"CheckProceed.sh "${targetDisk}" "${targetDeviceRaw}" "${targetVolume}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
returnValue=$?
if [ ${returnValue}=0 ]; then
# OK to proceed
branches/blackosx/package/Scripts/Main/EFI/postinstall
8888
8989
9090
91
91
92
93
9294
93
95
9496
9597
9698
if [ ${partitiontable} = "GUID_partition_scheme" ]; then
echo "Confirm this is a GPT partitioned disk."
# Double check we can see the selected partition, it's of the right type and /Volumes/TempChamESP exists.
# Double check we can see the selected partition and it's of the right type.
# Now also check for another existing Chameleon installation on the same disk.
# If the following script finds anything, it returns 1 to indicate failure.
"$scriptDir"CheckProceed.sh "${targetVolume}" "${targetDeviceChosenByUser}" "${targetVolumeChosenByUser}" "${scriptDir}"
"$scriptDir"CheckProceed.sh "${targetDisk}" "${targetDeviceRaw}" "${targetVolume}" "${targetDeviceChosenByUser}" "${targetVolumeChosenByUser}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
branches/blackosx/package/Scripts/Sub/CheckProceed.sh
11
22
33
4
5
4
5
66
7
7
8
89
10
11
912
1013
1114
1215
1316
14
15
16
17
18
17
18
19
20
21
22
23
24
25
1926
2027
2128
......
2532
2633
2734
35
36
2837
2938
3039
......
3342
3443
3544
45
46
3647
3748
3849
......
4152
4253
4354
55
4456
4557
46
4758
4859
4960
......
5768
5869
5970
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
60131
61132
62133
#!/bin/bash
echo "==============================================="
echo "Check Proceed: Can the script continue?"
echo "***************************************"
echo "Check Proceed: Can the installation continue?"
echo "***********************************************"
# Checks the selected volume is present and the disk is partitioned.
# Checks the selected volume is present and the disk is partitioned
# Now also check for another existing Chameleon installation on the same disk.
# Receives targetDisk: for example, /dev/disk3.
# Receives targetDeviceRaw: for example, /dev/rdisk3s1.
# Receives targetVolume: Volume to install to (will be '/Volumes/EFI' if EFI install)
# Receives targetDevice: Stores device number, for example /dev/disk2s1.
# Receives installerVolume: Volume to write the installer log to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 4 ]; then
targetVolume="$1"
targetDevice="$2"
installerVolume="$3"
scriptDir="$4"
if [ "$#" -eq 6 ]; then
targetDisk="$1"
targetDeviceRaw="$2"
targetVolume="$3"
targetDevice="$4"
installerVolume="$5"
scriptDir="$6"
echo "DEBUG: passed argument for targetDisk = $targetDisk"
echo "DEBUG: passed argument for targetDeviceRaw = $targetDeviceRaw"
echo "DEBUG: passed argument for targetVolume = $targetVolume"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
echo "DEBUG: passed argument for installerVolume = $installerVolume"
exit 9
fi
# Does target volume exist?
if [ -z "$targetVolume" ]; then
echo "*** Cannot find the volume. Exiting."
"$scriptDir"InstallLog.sh "${installerVolume}" "FAIL: Cannot file the volume: $targetVolume."
echo "Confirming target volume exists"
fi
# Does target volume use slices?
if [ "$targetDevice" = "$targetDevice#*disk*s" ]; then
echo "*** ERROR Volume does not use slices. Exiting."
"$scriptDir"InstallLog.sh "${installerVolume}" "FAIL: $targetVolume doesn't use slices."
echo "Confirming target device uses slices"
fi
# Add check for installing to a 'small' HFS device like a
# 1GB USB flash drive which won't have an EFI System Partition.
if [ "$targetVolume" = "/Volumes/EFI" ]; then
# Take target device and check slice 1 matches partition named "EFI"
stripped=$( echo ${targetDevice#/dev/} )
fi
fi
# Check for existing Chameleon installations on a different
# partition of the same target disk.
echo "Checking for existing Chameleon installations on ${targetDisk#/dev/}..."
sliceNumber=$( echo ${targetDeviceRaw#*disk*s} )
# strip slice from end
targetDiskRawNoSlice=$( echo ${targetDeviceRaw%$sliceNumber} )
# Are there any other partitions on the disk?
# How many actual partitions are there?
numSlices=$(( $( diskutil list | grep $( echo ${targetDisk#/dev/} ) | sed -n '$=' ) -2 ))
# Only check the disk for Chameleon installations if there is more than one partition.
if [ $numSlices -gt 1 ]; then
#Scan all partitions for Chameleon code
for (( i=1; i <= $numSlices; i++ ));
do
stageExistence=0
targetDiskRaw=$targetDiskRawNoSlice$i
# Check for existing stage 0 boot file from CheckDiskMicrocode.sh script
stage0type=$( dd 2>/dev/null if="$targetDisk" count=3 bs=1 skip=105 | xxd | awk '{print $2$3}' )
if [ "${stage0type}" == "0b807c" ] || [ "${stage0type}" == "0a803c" ] || [ "${stage0type}" == "ee7505" ]; then
echo "boot0 found on $targetDisk"
(( stageExistence++ ))
fi
# Check for boot1h and boot1f32
boot1hSearch=$( dd 2>/dev/null if="$targetDiskRaw" count=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${boot1hSearch:0:16}" == "fa31c08ed0bcf0ff" ]; then
echo "boot1h found on "$targetDiskRaw
(( stageExistence++ ))
elif [ "${boot1hSearch:0:4}" == "e962" ] && [ "${boot1hSearch:180:12}" == "424f4f542020" ]; then
echo "boot1f32 found on "$targetDiskRaw
(( stageExistence++ ))
fi
# Check for existing stage 2 boot file also
if [ -e "$( df | grep $targetDisk"s"$i | awk '{ print $6 }' )"/boot ]; then
echo "boot found on $targetDiskRaw"
(( stageExistence++ ))
fi
if [ $stageExistence == 3 ] && [ $i -ne $sliceNumber ]; then
echo "STOP: Not recommended you install to $targetDeviceRaw as there is already an existing Chameleon installation on $targetDiskRaw"
"$scriptDir"InstallLog.sh "${installerVolume}" "STOP: Not recommended you install to $targetDeviceRaw as there is already an existing Chameleon installation on $targetDiskRaw."
echo "================================"
echo "End"
echo "--------------------------------"
exit 1
fi
done
else
echo "Just one slice"
fi
echo "-----------------------------------------------"
echo ""

Archive Download the corresponding diff file

Revision: 1605