Chameleon

Chameleon Commit Details

Date:2011-12-11 19:46:06 (8 years 11 months ago)
Author:JrCs
Commit:1720
Parents: 1719
Message:Update installation of stage0 and stage1 boot files
Changes:
M/trunk/package/Scripts/Main/Standardpostinstall
M/trunk/package/Scripts/Sub/CheckGRUBLinuxLoader.sh

File differences

trunk/package/Scripts/Main/Standardpostinstall
4343
4444
4545
46
46
4747
4848
4949
......
5555
5656
5757
58
59
5860
5961
6062
......
8789
8890
8991
90
9192
9293
93
9494
95
96
97
98
99
100
101
102
103
104
105
106
95
96
97
98
99
100
107101
108102
109103
110104
111
112105
113106
107
114108
115109
116
117
118
110
111
112
113
119114
120
121
122115
123
124
125
126
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
127134
135
136
137
128138
129
130
131
132
139
140
141
142
143
133144
134
135
136
145
146
137147
138
139
148
149
150
151
152
140153
141154
142
143
144
155
156
157
145158
146
159
160
147161
148
149
162
163
150164
151
152
153
154
155
156
157
158165
159
160
166
167
168
161169
162
163
170
171
172
173
174
164175
176
177
178
179
180
181
165182
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
183
184
185
191186
192187
193
194
195
196
197
188
189
198190
191
192
193
194
195
196
199197
200198
201199
then
targetVolume="/Volumes/"$( ls -1F /Volumes | sed -n 's:@$::p' )
else
targetVolume="$3"
targetVolume="$3"
fi
targetResources="${targetVolume}/usr/local/bin/"
updateStage1=1 # by default update partition boot sector
echo "==============================================="
echo "DEBUG: display script variables"
echo "*******************************"
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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}" "${targetVolume}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# 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.
"$scriptDir"CheckWindowsDiskSignature.sh "${targetDisk}" "${targetVolume}" "${scriptDir}"
diskSigCheck=$?
diskupdate=$?
if [ ${diskupdate} -ne 0 ]; then
"$scriptDir"InstallLog.sh "${targetVolume}" "Found an existing GRUB/LILO bootloader in the MBR."
"$scriptDir"InstallLog.sh "${targetVolume}" "MBR and partition boot sector will not be modified."
updateStage1=0
else
# 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}" "${targetVolume}" "${scriptDir}"
diskupdate=$?
fi
# check the format of the selected partition.
# result should be either hfs or msdos
# Should really check to make sure!
# 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.
"$scriptDir"CheckWindowsDiskSignature.sh "${targetDisk}" "${targetVolume}" "${scriptDir}"
diskSigCheck=$?
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
# the following script returns 3 if MBR
# check the format of the selected partition.
# result should be either hfs or msdos
# Should really check to make sure!
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
# the following script returns 3 if MBR
# the following script returns 0 if nothing
"$scriptDir"CheckPartitionScheme.sh "${targetDisk}" "${targetVolume}" "${scriptDir}"
partitionScheme=$?
if [ ${partitionScheme} = 3 ]; then
# If MBR partition scheme then check for FAT16 or FAT32
# the following script returns 1 if FAT16
# the following script returns 2 if FAT32
# the following script returns 0 if nothing
"$scriptDir"CheckFatType.sh "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}"
fatType=$?
fi
"$scriptDir"CheckPartitionScheme.sh "${targetDisk}" "${targetVolume}" "${scriptDir}"
partitionScheme=$?
if [ ${partitionScheme} = 3 ]; then
# If MBR partition scheme then check for FAT16 or FAT32
if [ "${fatType}" = 1 ] && [ "${partitionScheme}" = 3 ]; then
# Write error to Chameleon_Error_Log file
"$scriptDir"InstallLog.sh "${targetVolume}" "FAIL: Cannot install to a device using FAT16"
else
# Continue if the selected device is not a FAT16 format device
# the following script returns 1 if FAT16
# the following script returns 2 if FAT32
# the following script returns 0 if nothing
# Append a line break to the installer log
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
"$scriptDir"CheckFatType.sh "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}"
fatType=$?
if [ ${diskupdate} -eq 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
if [ "${fatType}" = 1 ] && [ "${partitionScheme}" = 3 ]; then
# Write error to Chameleon_Error_Log file
"$scriptDir"InstallLog.sh "${targetVolume}" "FAIL: Cannot install to a device using FAT16"
if [ ${updateStage1} -eq 1 ]; then
# Write the stage 1 loader to the partition boot sector
"$scriptDir"WriteChameleonStage1.sh "${targetFormat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}"
else
# Continue if the selected device is not a FAT16 format device
"$scriptDir"InstallLog.sh "${targetVolume}" "Partition boot sector not written to ${targetDevice}."
fi
# Append a line break to the installer log
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
# Write the stage 2 loader to the root of the selected partition
"$scriptDir"WriteChameleonStage2.sh "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
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 "${targetFormat}" "${stage1LoaderHFS}" "${stage1LoaderFAT}" "${3}" "${targetDeviceRaw}" "${targetVolume}" "${scriptDir}"
# Next we look to check for existing Chameleon installations.
# But as it will check /Volumes/EFI for the stage 2 loader,
# we need to make sure it's mounted.
# Write the stage 2 loader to the root of the selected partition
"$scriptDir"WriteChameleonStage2.sh "${stage2Loader}" "${3}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
# Tell the user what's going on.
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
"$scriptDir"InstallLog.sh "${targetVolume}" "About to check your disk for previous installations"
"$scriptDir"InstallLog.sh "${targetVolume}" "which involves checking the EFI system partition if"
"$scriptDir"InstallLog.sh "${targetVolume}" "appropriate for this disk."
# Unmount ALL mounted volumes named EFI.
# Returns 0=success, 1=fail
"$scriptDir"UnMountEFIvolumes.sh "${targetVolume}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
# Next we look to check for existing Chameleon installations.
# But as it will check /Volumes/EFI for the stage 2 loader,
# we need to make sure it's mounted.
# Tell the user what's going on.
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
"$scriptDir"InstallLog.sh "${targetVolume}" "About to check your disk for previous installations"
"$scriptDir"InstallLog.sh "${targetVolume}" "which involves checking the EFI system partition if"
"$scriptDir"InstallLog.sh "${targetVolume}" "appropriate for this disk."
# Unmount ALL mounted volumes named EFI.
# Returns 0=success, 1=fail
"$scriptDir"UnMountEFIvolumes.sh "${targetVolume}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
if [ ${partitionScheme} = 1 ] || [ ${partitionScheme} = 2 ]; then
# Mount the EFI system partition
"$scriptDir"MountESP.sh "${targetDisk}" "${targetVolume}" "${scriptDir}"
fi
# Check for another existing Chameleon installation on the same disk
"$scriptDir"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
if [ ${partitionScheme} = 1 ] || [ ${partitionScheme} = 2 ]; then
# Mount the EFI system partition
"$scriptDir"MountESP.sh "${targetDisk}" "${targetVolume}" "${scriptDir}"
fi
# 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 "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolume}" "${scriptDir}"
# Check for another existing Chameleon installation on the same disk
"$scriptDir"CheckPreviousChameleon.sh "${targetDisk}" "${targetDeviceRaw}" "${targetDevice}" "${targetVolume}" "${scriptDir}"
fi
# 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 "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolume}" "${scriptDir}"
fi
fi
trunk/package/Scripts/Sub/CheckGRUBLinuxLoader.sh
3636
3737
3838
39
4039
4140
4241
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
"$scriptDir"InstallLog.sh "${targetVolume}" "FAIL: Found an exisitng GRUB/LILO bootloader in the MBR."
exit 1
#else
#echo "DEBUG: Didn't find a match for ${diskmicrocodetype[${diskmicrocodetypecounter}]%,*}"

Archive Download the corresponding diff file

Revision: 1720