Chameleon

Chameleon Commit Details

Date:2011-10-18 16:15:16 (12 years 6 months ago)
Author:blackosx
Commit:1634
Parents: 1633
Message:Slight restructure to allow checking the EFI system partition for the stage 2 boot file when checking for previous Chameleon installations. THIS NEEDS FURTHER TESTING
Changes:
D/branches/blackosx/package/Scripts/Sub/CheckFormat.sh
M/branches/blackosx/package/Scripts/Main/EFI/postinstall
M/branches/blackosx/package/Scripts/Sub/SetActivePartition.sh
M/branches/blackosx/package/buildpkg.sh
M/branches/blackosx/package/Scripts/Main/Post/postinstall
M/branches/blackosx/package/Scripts/Sub/CheckPreviousChameleon.sh
M/branches/blackosx/package/Scripts/Sub/WriteChameleonStage1.sh
M/branches/blackosx/package/Scripts/Sub/WriteChameleonStage2.sh
M/branches/blackosx/package/Scripts/Main/Standard/postinstall

File differences

branches/blackosx/package/Scripts/Main/Standard/postinstall
7474
7575
7676
77
78
7779
7880
7981
......
110112
111113
112114
113
114
115
115
116
116117
117
118
118
119
119120
120
121121
122122
123123
......
144144
145145
146146
147
148
149
150
151
152
153
154
155
156
157
158147
159148
160
149
150
151
161152
162
153
163154
164155
156
157
158
159
160
161
162
163
164
165
166
165167
166
168
167169
168170
169
171
170172
171173
172174
173175
174176
175
177
176178
177179
178180
"$scriptDir"InstallLog.sh "${targetVolume}" "Running Standard postinstall script"
"$scriptDir"InstallLog.sh "${targetVolume}" "Target volume = ${targetVolume} on ${targetDevice}"
# Added from EFI post script as this is now sent to CheckPreviousChameleon.sh
partitiontable=$( diskutil list ${targetDevice%s*} | sed -n '3p' | awk '{print $2}' )
# Double check we can see the selected partition and it's of the right type.
# If the following script finds anything, it returns 1 to indicate failure.
# 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
# result should be either hfs or msdos
# Should really check to make sure!
"$scriptDir"CheckFormat.sh "${targetDevice}" "${targetVolume}" "${scriptDir}"
espformat=$?
targetFormat=$( fstyp "$targetDevice" )
# check the partition scheme used for the selected disk.
# the following script returns 1 if GPT
# the following script returns 2 if GPT/MBR
else
# Continue if the selected device is not a FAT16 format device
# Append a line break to the installer log
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
if [ ${diskupdate} = "0" ]; then
# Write the stage 0 loader to the MBR
"$scriptDir"WriteChameleonStage0.sh "${diskSigCheck}" "${stage0Loader}" "${stage0LoaderDualBoot}" "${targetDisk}" "${targetResources}" "${targetVolume}" "${scriptDir}"
else
"$scriptDir"InstallLog.sh "${targetVolume}" "Stage 0 loader not written to ${targetDisk}."
fi
# 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"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
# It returns 2 to indicate failure to unmount any Volumes named "EFI"
"$scriptDir"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDevice}" "${targetVolume}" "${partitiontable}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
if [ ${returnValue} = 0 ] || [ ${returnValue} = 2 ]; then
# OK to proceed
# Append a line break to the installer log
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
if [ ${diskupdate} = "0" ]; then
# Write the stage 0 loader to the MBR
"$scriptDir"WriteChameleonStage0.sh "${diskSigCheck}" "${stage0Loader}" "${stage0LoaderDualBoot}" "${targetDisk}" "${targetResources}" "${targetVolume}" "${scriptDir}"
else
"$scriptDir"InstallLog.sh "${targetVolume}" "Stage 0 loader not written to ${targetDisk}."
fi
# Write the stage 1 loader to the partition boot sector
"$scriptDir"WriteChameleonStage1.sh "${espformat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}"
"$scriptDir"WriteChameleonStage1.sh "${targetFormat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}"
# Write the stage 2 loader to the root of the selected partition
"$scriptDir"WriteChameleonStage2.sh "${espformat}" "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
"$scriptDir"WriteChameleonStage2.sh "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
# Append a line break to the installer log
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
# Set the active partition ONLY if Windows is not installed
"$scriptDir"SetActivePartition.sh "${espformat}" "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolume}" "${scriptDir}"
"$scriptDir"SetActivePartition.sh "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolume}" "${scriptDir}"
else
echo "Stop" >"${targetVolumeChosenByUser}"/.ChameleonExists
fi
branches/blackosx/package/Scripts/Main/EFI/postinstall
123123
124124
125125
126
127
128
126
127
129128
130
131
129
130
132131
133
134132
135133
136134
137135
138136
139
140
141
142
143
144
137
138
139
140
141
145142
146
143
147144
148145
149146
......
157154
158155
159156
160
161
162
163
164
165
157
158
166159
167
168
160
161
169162
170
171
163
164
172165
173
174
175
176
177
178
179
180
166
167
168
169
181170
182171
183172
......
186175
187176
188177
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
178
179
205180
206181
207182
# 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??? ****
# result should be either hfs or msdos
# Should really check to make sure!
"$scriptDir"CheckFormat.sh "${targetDevice}" "${targetVolumeChosenByUser}" "${scriptDir}"
espformat=$?
targetFormat=$( fstyp "$targetDevice" )
# Determine the partition scheme of the selected disk
# is it GPT or a hybrid GPT/MBR
"$scriptDir"CheckPartitionScheme.sh "${targetDisk}" "${targetVolumeChosenByUser}" "${scriptDir}"
# 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 "${targetVolumeChosenByUser}" "${scriptDir}"
# Now also check for another existing Chameleon installation on the same disk.
# This also unmounts all volumes named EFI and then mounts the EFI system partition.
# If the following script finds anything, it returns 1 to indicate failure.
# It returns 2 to indicate failure to unmount any Volumes named "EFI"
"$scriptDir"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDevice}" "${targetVolumeChosenByUser}" "${partitiontable}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
if [ ${returnValue} = 0 ] && [ ${returnValue} -ne 2 ]; then
# OK to proceed
# Append a LineBreak to the installer log
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "Stage 0 loader not written to ${targetDisk}."
fi
# 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"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDeviceChosenByUser}" "${targetVolumeChosenByUser}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# Write the stage 1 loader to the partition boot sector
"$scriptDir"WriteChameleonStage1.sh "${targetFormat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${targetVolumeChosenByUser}" "${targetDeviceRaw}" "${targetVolumeChosenByUser}" "${scriptDir}"
# Write the stage 1 loader to the partition boot sector
"$scriptDir"WriteChameleonStage1.sh "${espformat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${targetVolumeChosenByUser}" "${targetDeviceRaw}" "${targetVolumeChosenByUser}" "${scriptDir}"
# Write the stage 2 loader to the root of the selected partition
"$scriptDir"WriteChameleonStage2.sh "${stage2Loader}" "${targetVolume}" "${targetDevice}" "${targetVolumeChosenByUser}" "${scriptDir}"
# Write the stage 2 loader to the root of the selected partition
"$scriptDir"WriteChameleonStage2.sh "${espformat}" "${stage2Loader}" "${targetVolume}" "${targetDevice}" "${targetVolumeChosenByUser}" "${scriptDir}"
# Append a LineBreak to the installer log
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "LineBreak"
# Append a LineBreak to the installer log
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "LineBreak"
# Set the active partition ONLY if Windows is not installed
"$scriptDir"SetActivePartition.sh "${espformat}" "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolumeChosenByUser}" "${scriptDir}"
else
echo "Stop" >"${targetVolumeChosenByUser}"/.ChameleonExists
fi
# Set the active partition ONLY if Windows is not installed
"$scriptDir"SetActivePartition.sh "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolumeChosenByUser}" "${scriptDir}"
else
echo "Stop" >"${targetVolumeChosenByUser}"/.ChameleonExists
fi
fi
fi
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "ERROR Volume is not on a GPT partitioned disc."
fi
# remove the temporary boot sector files if they exist
if [ -d /tmp/newbs ]; then
echo "Executing command: rm /tmp/newbs"
rm /tmp/newbs
fi
if [ -d /tmp/origbs ]; then
echo "Executing command: rm /tmp/origbs"
rm /tmp/origbs
fi
# Check for mounted volumes named EFI and if found, unmount
#"$scriptDir"UnMountEFIvolumes.sh - ***** commented out to allow the boot option scripts to function ****
# Create temporary file on target volume to notify
# boot option scripts than EFI (ESP) option was chosen
# Create temporary file on target volume to notify Postinstall
# script, boot option code, that EFI (ESP) option was chosen
echo "EFI" >"${targetVolumeChosenByUser}"/.ChameleonEFI
"$scriptDir"InstallLog.sh "${targetVolumeChosenByUser}" "LineBreak"
branches/blackosx/package/Scripts/Main/Post/postinstall
183183
184184
185185
186
187
188
189
190
191
192
193
194
195
196
197
198
186
187
199188
200
201
189
202190
203191
204192
......
206194
207195
208196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
209215
210216
211
212
217
213218
214219
215220
216221
217222
218
219
220
223
224
221225
222226
223227
224228
225
226
229
227230
231
232
228233
229234
230235
fi
fi
if [ -f "$dest_vol"/.ChameleonEFI ]; then
# unmount /Volumes/EFI
# Count of 5 exists incase for some reason /Volumes/EFI fails
# be unmounted in which case the loop would run forever.
attempts=1
while [ "$( df | grep EFI )" ] && [ $attempts -lt 5 ]; do
echo "Unmounting $( df | grep EFI | awk '{print $1}' )"
"$scriptDir"InstallLog.sh "${dest_vol}" "Find and unmount any volume named 'EFI':"
"$scriptDir"InstallLog.sh "${dest_vol}" "$( df | grep EFI | awk '{print $1}' )"
umount -f $( df | grep EFI | awk '{print $1}' )
(( attempts++ ))
done
fi
# Unmount ALL mounted volumes named EFI
"$scriptDir"UnMountEFIvolumes.sh "${dest_vol}" "${scriptDir}"
else
#echo "Removing /.ChameleonExists file"
"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup 4"
cleanUp="${cleanUp},0"
rm "$dest_vol"/.ChameleonExists
fi
# Cleanup
# ---------------------------------------------
# remove any temporary boot sector files if they exist
if [ -d /tmp/newbs ]; then
cleanUp="${cleanUp},1a"
rm /tmp/newbs
fi
if [ -d /tmp/origbs ]; then
cleanUp="${cleanUp},1b"
rm /tmp/origbs
fi
if [ -d /tmp/newBootSector ]; then
cleanUp="${cleanUp},1c"
rm /tmp/newbs
fi
if [ -d /tmp/originalBootSector ]; then
cleanUp="${cleanUp},1d"
rm /tmp/origbs
fi
# delete the temporary Chameleon folder
if [ -e "$chamTemp" ]; then
#echo "Removing $chamTemp directory"
"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup 1"
cleanUp="${cleanUp},2"
rm -rf "$chamTemp"
fi
# Remove /.ChameleonEFI file
if [ -f "$dest_vol"/.ChameleonEFI ]; then
#echo "Removing /.ChameleonEFI file"
"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup 2"
rm "$dest_vol"/.ChameleonEFI
cleanUp="${cleanUp},3"
rm "$dest_vol"/.ChameleonEFI
fi
# Remove /.ChameleonLogFlag file
if [ -f "$dest_vol"/.ChameleonLogFlag ]; then
#echo "Removing /.ChameleonLogFlag file"
"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup 3"
cleanUp="${cleanUp},4"
"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup: ${cleanUp}"
# we have to add the final install log messages before
# deleting /.ChameleonLogFlag.
"$scriptDir"InstallLog.sh "${dest_vol}" "LineBreak"
branches/blackosx/package/Scripts/Sub/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
40
41
42
43
#!/bin/bash
echo "==============================================="
echo "CheckFormat: Is target HFS or MSDOS?"
echo "**********************************************"
# 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
# Receives targetDevice: for example, /dev/disk0s2
# Receives targetVolume: Volume to install to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 3 ]; then
targetDevice="$1"
targetVolume="$2"
scriptDir="$3"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
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 [ "$( fstyp "$targetDevice" | grep hfs )" ]; then
#echo "DEBUG: ${targetDevice} is currently formatted as HFS"
#"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDevice} is currently formatted as HFS"
exit 1
fi
if [ "$( fstyp "$targetDevice" | grep msdos )" ]; then
#echo "DEBUG: ${targetDevice} is currently formatted as msdos"
#"$scriptDir"InstallLog.sh "${targetVolume}" "${targetDevice} is currently formatted as msdos"
exit 2
fi
#echo "DEBUG: WARNING: ${targetDevice} is currently not formatted as either HFS or msdos"
"$scriptDir"InstallLog.sh "${targetVolume}" "WARNING: ${targetDevice} is currently not formatted as either HFS or msdos"
exit 0
branches/blackosx/package/Scripts/Sub/CheckPreviousChameleon.sh
44
55
66
7
8
7
8
9
910
1011
1112
1213
1314
15
1416
1517
16
18
1719
1820
1921
2022
21
23
24
2225
2326
2427
2528
29
2630
2731
2832
......
4448
4549
4650
47
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
89
4890
4991
5092
......
5698
5799
58100
59
101
60102
61103
62104
......
77119
78120
79121
80
81
122
123
82124
83125
84126
85127
86
87
88
89
90
91
92
93
94
95
96
97
128
98129
99130
100131
132
101133
102
134
135
136
137
138
139
103140
104
105
106
107
108
109
110
141
142
143
144
145
146
111147
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
130171
131
172
132173
133
134
135174
136175
137176
138
139177
140178
141179
echo "Check Previous Chameleon: Will there be problems?"
echo "***********************************************"
# Checks the selected volume is present and the disk is partitioned
# Now also check for another existing Chameleon installation on the same disk.
# Checks for another existing Chameleon installation on the same disk
# and tries to make sure the user doesn't end up with an un-bootable
# system due to having installed Chameleon previously elsewhere.
# Receives targetDisk: for example, /dev/disk3.
# Receives targetDeviceRaw: for example, /dev/rdisk3s1.
# Receives targetDevice: Stores device number, for example /dev/disk2s1.
# Receives installerVolume: Volume to write the installer log to.
# Receives partitiontable: for example, GUID_partition_scheme
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 5 ]; then
if [ "$#" -eq 6 ]; then
targetDisk="$1"
targetDeviceRaw="$2"
targetDevice="$3"
installerVolume="$4"
scriptDir="$5"
partitiontable="$5"
scriptDir="$6"
echo "DEBUG: passed argument for targetDisk = $targetDisk"
echo "DEBUG: passed argument for targetDeviceRaw = $targetDeviceRaw"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
echo "DEBUG: passed argument for installerVolume = $installerVolume"
echo "DEBUG: passed argument for partitiontable = $partitiontable"
echo "DEBUG: passed argument for scriptDir = $scriptDir"
else
echo "Error - wrong number of values passed"
# Only check the disk for Chameleon installations if there is more than one partition.
if [ $numSlices -gt 1 ]; then
# If a GPT is used then we are going to have the check the EFI system partition
# for the stage 2 'boot' file. As this script is called from the Main EFI
# postinstall script, so lets mount the EFI system partition here instead.
if [ "${partitiontable}" = "GUID_partition_scheme" ]; then
# 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 "${installerVolume}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
if [ ! -e "/Volumes/EFI" ]; then
#echo "DEBUG: Executing Command: mkdir -p ${/Volumes/EFI}"
mkdir -p "/Volumes/EFI"
#else
#echo "DEBUG: folder /Volumes/EFI already exists"
fi
# Mount '/Volumes/EFI' using the correct format type
if [ "$( fstyp "${targetDisk}"s1 | grep hfs )" ]; then
#echo "Executing command: mount_hfs ${targetDevice} ${targetVolume}"
"$scriptDir"InstallLog.sh "${installerVolume}" "Mounting ${targetDisk}s1 as /Volumes/EFI"
mount_hfs "${targetDisk}"s1 "/Volumes/EFI"
fi
if [ "$( fstyp "${targetDisk}"s1 | grep msdos )" ]; then
#echo "Executing command: mount_msdos -u 0 -g 0 ${targetDevice} ${/Volumes/EFI}"
"$scriptDir"InstallLog.sh "${installerVolume}" "Mounting ${targetDisk}s1 as /Volumes/EFI"
mount_msdos -u 0 -g 0 "${targetDisk}"s1 "/Volumes/EFI"
fi
else
# quit out and notify EFI post script not to write Chameleon files.
exit 2
fi
fi
#Scan all partitions for Chameleon code
for (( i=1; i <= $numSlices; i++ ));
do
# Check for existing stage 0 boot file (same code as 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" ] || [ "${stage0type}" == "742b80" ]; then
#echo "DEBUG: boot0 found on $targetDisk"
#echo "DEBUG: stage 0 loader found on $targetDisk"
(( stageExistence++ ))
# While here, check just for either existing boot0hfs, boot0md or boot0md (dmazar's boot0workV2)
previousExistence="boot1f32"
fi
# Check for existing stage 2 boot file also
# NOTE: This will fail to find /boot on /Volumes/EFI as it won't be mounted!
# Check for existing stage 2 boot file.
# Include checking the EFI system partition if it exists and is mounted.
if [ -e "$( df | grep ${targetDisk}s${i} | awk '{ print $6 }' )"/boot ]; then
#echo "DEBUG: boot found on $targetDiskRaw"
(( stageExistence++ ))
fi
#if [ $stageExistence == 3 ] && [ $i -ne $sliceNumber ]; then
#echo "DEBUG: STOP: There is already an existing Chameleon installation on $targetDiskRaw"
#"$scriptDir"InstallLog.sh "${installerVolume}" "STOP: There is already an existing Chameleon installation on $targetDiskRaw."
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: This is allowed and does work as long as you aren't dual booting Windows"
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: from the same disk and are happy to control which partition is used by"
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: flagging the required partition active. General use doesn't require two"
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: Chameleon installs on the same disk, though might be done by advanced users."
#"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: If you still want to do this then proceed by installing Chameleon manually."
#exit 1
#fi
if [ $stageExistence -ge 2 ] && [ "$previousExistence" != "NONE" ] && [ $i -ne $sliceNumber ]; then
# There is previous Chameleon stage 1 code on a partition boot sector,
# and either a complete or incomplete installation (ie. boot0 or boot are missing).
if [ $stageExistence == 3 ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "WARN: There is already an existing Chameleon installation on $targetDiskRaw."
"$scriptDir"InstallLog.sh "${installerVolume}" "INFO: There is already an existing Chameleon installation on $targetDiskRaw."
if [ $i -lt $sliceNumber ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: And that installation will still be used as it's on an earlier partition."
else
"$scriptDir"InstallLog.sh "${installerVolume}" "INFO: but won't interfere as you're installing to an earlier partition."
fi
else
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: $previousExistence already exists at ${targetDisk}s${i}"
fi
# This could prove problematic and result in either a b1f:error or boot0:error
# if the following conditions are true:
# A) Boot0hfs, Boot0md or Boot0md (dmazar's Boot0workV2) is being used.
# B) The previous stage 1 code is on a lower partiton than the one being installed to now.
"$scriptDir"InstallLog.sh "${installerVolume}" "INFO: $previousExistence already exists at ${targetDisk}s${i}"
# A b1f:error or boot0:error could result if the following conditions are true:
# A) Boot0hfs, Boot0md or Boot0md (dmazar's Boot0workV2) is being used.
# B) The previous stage 1 code is on a lower partiton than the one being installed to now.
# C) boot is missing from that partition.
# stage0FirstBootable=1 is used to know if 'A' is true.
if [ $stage0FirstBootable == 1 ]; then
# i = current slice we're checking, slicenumber = slice trying to install to.
if [ $i -lt $sliceNumber ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "WARN: Conditions point to you receiving a boot failure"
# Fix by making previous paritionboot sector un-bootable
# Change Byte 01FExh to 00 (510 decimal)
"$scriptDir"InstallLog.sh "${installerVolume}" "---"
"$scriptDir"InstallLog.sh "${installerVolume}" "FIX: Make ${targetDisk}s${i} boot sector un-bootable by changing byte 1FEh to 00."
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: Any Extra folder you had there will still be there. If you want to use"
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: ${targetDisk}s${i} again as your boot partition then re-run this installer"
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: selecting it as the target, ONLY choosing the 'Chameleon Bootloader' option"
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: and NONE of the other options."
"$scriptDir"InstallLog.sh "${installerVolume}" "---"
dd if=${targetDisk}s${i} count=1 bs=512 of=/tmp/originalBootSector
cp /tmp/originalBootSector /tmp/newBootSector
dd if="$scriptDir/patch" of=/tmp/newBootSector bs=1 count=1 seek=510 conv=notrunc
dd if=/tmp/newBootSector of=${targetDisk}s${i} count=1 bs=512
# stage0FirstBootable=1 is used to know if 'A' is true.
if [ $stage0FirstBootable == 1 ]; then
# i = current slice we're checking, slicenumber = slice trying to install to.
if [ $i -lt $sliceNumber ]; then
"$scriptDir"InstallLog.sh "${installerVolume}" "WARN: Conditions point to the possibility of a boot failure"
# Fix by making previous paritionboot sector un-bootable
# Change Byte 01FExh to 00 (510 decimal)
mesaageToPost="---
FIX: Make ${targetDisk}s${i} boot sector un-bootable by changing byte 1FEh to 00.
NOTE: Any Extra folder you had there will still be there. If you want to use
NOTE: ${targetDisk}s${i} again as your boot partition then re-run this installer
NOTE: selecting it as the target, ONLY choosing the 'Chameleon Bootloader' option
NOTE: and NONE of the other options.
---"
"$scriptDir"InstallLog.sh "${installerVolume}" "${mesaageToPost}"
dd if=${targetDisk}s${i} count=1 bs=512 of=/tmp/originalBootSector
cp /tmp/originalBootSector /tmp/newBootSector
dd if="$scriptDir/patch" of=/tmp/newBootSector bs=1 count=1 seek=510 conv=notrunc
dd if=/tmp/newBootSector of=${targetDisk}s${i} count=1 bs=512
else
"$scriptDir"InstallLog.sh "${installerVolume}" "INFO: but won't interfere as you're installing to an earlier partition."
fi
else
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: but won't interfere as you're installing to an earlier partition."
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: so select to boot that partition (if used) with active flag."
fi
else
"$scriptDir"InstallLog.sh "${installerVolume}" "NOTE: so select to boot that partition (if used) with active flag."
fi
fi
done
#else
#echo "DEBUG: Just one slice"
fi
branches/blackosx/package/Scripts/Sub/WriteChameleonStage1.sh
66
77
88
9
9
1010
1111
1212
......
1515
1616
1717
18
18
1919
2020
2121
2222
2323
2424
25
25
2626
2727
2828
......
3434
3535
3636
37
38
37
3938
4039
4140
......
4342
4443
4544
46
47
45
4846
4947
5048
# Writes Chameleon stage 1 loader.
# Receives espformat: 1 for HFS, 2 for MSDOS, 0 for unknown
# Receives targetFormat: either hfs or msdos
# Receives stage1LoaderHFS: Name of file - boot1h
# Receives stage1LoaderFAT: Name of file - boot1f32
# Receives selectedDestination: for example, /Volumes/USB
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 7 ]; then
espformat="$1"
targetFormat="$1"
stage1LoaderHFS="$2"
stage1LoaderFAT="$3"
selectedDestination="$4"
targetDeviceRaw="$5"
targetVolume="$6"
scriptDir="$7"
echo "DEBUG: passed argument for espformat = $espformat"
echo "DEBUG: passed argument for targetFormat = $targetFormat"
echo "DEBUG: passed argument for stage1LoaderHFS = $stage1LoaderHFS"
echo "DEBUG: passed argument for stage1LoaderFAT = $stage1LoaderFAT"
echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
exit 9
fi
if [ ${espformat} = "1" ]; then
# the selected partition is HFS formatted
if [ ${targetFormat} = "hfs" ]; then
#echo "DEBUG: Executing command: dd if=${selectedDestination}/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}"
dd if="${selectedDestination}"/usr/standalone/i386/${stage1LoaderHFS} of=${targetDeviceRaw}
"$scriptDir"InstallLog.sh "${targetVolume}" "Written ${stage1LoaderHFS} to ${targetDeviceRaw}."
fi
if [ ${espformat} = "2" ]; then
# the selected partition FAT formatted
if [ ${targetFormat} = "msdos" ]; then
#echo "DEBUG: Executing command: dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs"
dd if=${targetDeviceRaw} count=1 bs=512 of=/tmp/origbs
branches/blackosx/package/Scripts/Sub/WriteChameleonStage2.sh
44
55
66
7
8
9
107
118
129
......
1411
1512
1613
17
18
19
20
21
22
23
24
14
15
16
17
18
19
2520
2621
2722
......
3429
3530
3631
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
6232
6333
6434
echo "Write Chameleon Stage 2 Loader:"
echo "*******************************"
# Writes Chameleon stage 2 loader.
# Receives espformat: 1 for HFS, 2 for MSDOS, 0 for unknown
# Receives stage2Loader: Name of file - boot
# Receives selectedDestination: for example, /Volumes/ChameleonBootUSB (or /Volumes/EFI if ESP install).
# Receives targetDevice: for example, /dev/disk3s1
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 6 ]; then
espformat="$1"
stage2Loader="$2"
selectedDestination="$3"
targetDevice="$4"
targetVolume="$5"
scriptDir="$6"
echo "DEBUG: passed argument for espformat = $espformat"
if [ "$#" -eq 5 ]; then
stage2Loader="$1"
selectedDestination="$2"
targetDevice="$3"
targetVolume="$4"
scriptDir="$5"
echo "DEBUG: passed argument for stage2Loader = $stage2Loader"
echo "DEBUG: passed argument for selectedDestination = $selectedDestination"
echo "DEBUG: passed argument for targetDevice = $targetDevice"
# check to see if install to EFI system partition was selected
if [ "${selectedDestination}" = "/Volumes/EFI" ]; then
#echo "DEBUG: EFI install chosen"
if [ ! -e "${selectedDestination}" ]; then
#echo "DEBUG: Executing Command: mkdir -p ${selectedDestination}"
mkdir -p "${selectedDestination}"
#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}"
"$scriptDir"InstallLog.sh "${targetVolume}" "Mounting ${targetDevice} as ${selectedDestination}"
mount_hfs "${targetDevice}" "${selectedDestination}"
fi
if [ ${espformat} = 2 ]; then
[ -d "${selectedDestination}" ] || mkdir -p "${selectedDestination}"
#echo "Executing command: mount_msdos -u 0 -g 0 ${targetDevice} ${selectedDestination}"
"$scriptDir"InstallLog.sh "${targetVolume}" "Mounting ${targetDevice} as ${selectedDestination}"
mount_msdos -u 0 -g 0 "${targetDevice}" "${selectedDestination}"
fi
#echo "DEBUG: Executing command: cp "${targetVolume}"/usr/standalone/i386/${stage2Loader} ${selectedDestination}"
cp "${targetVolume}"/usr/standalone/i386/"${stage2Loader}" "${selectedDestination}"
"$scriptDir"InstallLog.sh "${targetVolume}" "Written boot to ${selectedDestination}."
branches/blackosx/package/Scripts/Sub/SetActivePartition.sh
66
77
88
9
109
1110
1211
1312
1413
1514
16
17
18
19
20
21
22
15
16
17
18
19
20
2321
24
2522
2623
2724
# Sets partition active if Windows is not installed.
# Receives efiformat: code is 1 for HFS, 2 for MSDOS, 0 for unknown
# Receives diskSigCheck: code is 1 for a Windows install, 0 for no Windows install
# Receives targetDiskRaw: for example, /dev/rdisk1
# Receives targetSlice: for example, 1
# Receives targetVolume: Volume to install to.
# Receives scriptDir: The location of the main script dir.
if [ "$#" -eq 6 ]; then
efiformat="$1"
diskSigCheck="$2"
targetDiskRaw="$3"
targetSlice="$4"
targetVolume="$5"
scriptDir="$6"
if [ "$#" -eq 5 ]; then
diskSigCheck="$1"
targetDiskRaw="$2"
targetSlice="$3"
targetVolume="$4"
scriptDir="$5"
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"
branches/blackosx/package/buildpkg.sh
313313
314314
315315
316
316317
317318
318319
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Main/Post/* ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Sub/InstallLog.sh ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Sub/UnMountEFIvolumes.sh ${1}/Post/Scripts
ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Post/Scripts/Resources/revision
ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Post/Scripts/Resources/version
echo "[BUILD] Post "

Archive Download the corresponding diff file

Revision: 1634