Chameleon

Chameleon Commit Details

Date:2011-10-06 00:22:33 (7 years 1 month ago)
Author:blackosx
Commit:1608
Parents: 1607
Message:Don't create /Extra folder if process is stopped due to exisiting Chameleon installation found.
Changes:
M/branches/blackosx/package/Scripts/Main/EFI/postinstall
M/branches/blackosx/package/Scripts/Main/Post/postinstall
M/branches/blackosx/package/Scripts/Main/Standard/postinstall

File differences

branches/blackosx/package/Scripts/Main/Standard/postinstall
170170
171171
172172
173
174
173175
174176
175177
"$scriptDir"SetActivePartition.sh "${espformat}" "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolume}" "${scriptDir}"
fi
fi
else
echo "Stop" >"${targetVolume}"/.ChameleonExists
fi
"$scriptDir"InstallLog.sh "${targetVolume}" "LineBreak"
branches/blackosx/package/Scripts/Main/EFI/postinstall
9292
9393
9494
95
95
9696
9797
9898
......
173173
174174
175175
176
177
176178
177179
178180
# 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 "${targetDisk}" "${targetDeviceRaw}" "${targetVolume}" "${targetDeviceChosenByUser}" "${targetVolumeChosenByUser}" "${scriptDir}"
"$scriptDir"CheckProceed.sh "${targetDisk}" "${targetDeviceRaw}" "${targetVolume}" "${targetDeviceChosenByUser}" "${targetVolumeChosenByUser}" "${scriptDir}"
returnValue=$?
if [ ${returnValue} = 0 ]; then
# OK to proceed
"$scriptDir"SetActivePartition.sh "${espformat}" "${diskSigCheck}" "${targetDiskRaw}" "${targetSlice}" "${targetVolumeChosenByUser}" "${scriptDir}"
fi
fi
else
echo "Stop" >"${targetVolumeChosenByUser}"/.ChameleonExists
fi
else
#echo "ERROR Volume is not on a GPT partitioned disc."
branches/blackosx/package/Scripts/Main/Post/postinstall
5353
5454
5555
56
57
58
59
56
57
58
6059
61
62
63
64
65
66
67
68
69
60
61
62
63
64
65
66
67
68
7069
71
72
73
74
75
76
77
78
79
70
71
72
73
74
75
76
77
78
8079
81
82
83
84
85
86
87
80
81
82
83
84
85
86
8887
89
90
88
89
9190
92
93
94
95
91
92
93
94
9695
97
98
99
96
97
98
10099
101
102
103
104
105
106
100
101
102
103
104
105
107106
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
129128
130
131
132
133
134
135
136
137
138
139
140
141
142
143
129
130
131
132
133
134
135
136
137
138
139
140
141
142
144143
145
146
147
148
149
150
151
152
144
145
146
147
148
149
150
151
153152
154
153
155154
156
157
155
156
158157
159
160
161
162
163
164
165
166
167
158
159
160
161
162
163
164
165
166
168167
169
170
171
172
173
174
175
168
169
170
171
172
173
174
176175
177
178
179
180
181
182
183
184
185
176
177
178
179
180
181
182
183
184
185
186
187
188
189
186190
187191
188192
# set temporary directory
chamTemp="$dest_vol/usr/local/chamTemp"
# Check for temporary directory/Extra folder.
#if [ ! -d "$chamTemp"/Extra ]; then
#mkdir "$chamTemp"/Extra
#fi
# Check for stopped installation due to Chameleon
# already existing on the same disk.
if [ ! -f "$dest_vol"/.ChameleonExists ]; then
# ---------------------------------------------
# Add any installed modules to the Install Log
# ---------------------------------------------
if [ -e "${chamTemp}"/Extra/modules ]; then
ls "${chamTemp}"/Extra/modules | while read FILE
do
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed module:$FILE"
done
fi
# ---------------------------------------------
# Add any installed modules to the Install Log
# ---------------------------------------------
if [ -e "${chamTemp}"/Extra/modules ]; then
ls "${chamTemp}"/Extra/modules | while read FILE
do
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed module:$FILE"
done
fi
# ---------------------------------------------
# Add any installed themes to the Install Log
# ---------------------------------------------
if [ -e "${chamTemp}"/Extra/Themes ]; then
ls "${chamTemp}"/Extra/Themes | while read FILE
do
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed Theme:$FILE"
done
fi
# ---------------------------------------------
# Add any installed themes to the Install Log
# ---------------------------------------------
if [ -e "${chamTemp}"/Extra/Themes ]; then
ls "${chamTemp}"/Extra/Themes | while read FILE
do
"$scriptDir"InstallLog.sh "${dest_vol}" "Installed Theme:$FILE"
done
fi
# ---------------------------------------------
# Build org.chameleon.Boot.plist
# ---------------------------------------------
# All options selected are now dummy files with
# the filename of the option and value residing
# in /usr/local/chamTemp/options/
# for example. Boot Banner=Yes
# ---------------------------------------------
# Build org.chameleon.Boot.plist
# ---------------------------------------------
# All options selected are now dummy files with
# the filename of the option and value residing
# in /usr/local/chamTemp/options/
# for example. Boot Banner=Yes
# Are there any options to build?
if [ "$(ls -A ${chamTemp}/options )" ]; then
# Are there any options to build?
if [ "$(ls -A ${chamTemp}/options )" ]; then
# Check for temporary directory/Extra folder.
if [ ! -d "$chamTemp"/Extra ]; then
mkdir "$chamTemp"/Extra
fi
# Check for temporary directory/Extra folder.
if [ ! -d "$chamTemp"/Extra ]; then
mkdir "$chamTemp"/Extra
fi
# Create template for org.chameleon.Boot.plist"
tempOCBP="$chamTemp"/Extra/org.chameleon.Boot.plist
cp "$4"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist "$tempOCBP"
# Create template for org.chameleon.Boot.plist"
tempOCBP="$chamTemp"/Extra/org.chameleon.Boot.plist
cp "$4"/Library/Preferences/SystemConfiguration/com.apple.Boot.plist "$tempOCBP"
# Read list of all boot options the user added.
arrayCount=0
kernelFlagCount=0
while read FILE
do
options[arrayCount]="${FILE##*/}"
# Read list of all boot options the user added.
arrayCount=0
kernelFlagCount=0
while read FILE
do
options[arrayCount]="${FILE##*/}"
# Check keyRead for 'KF' at beginning to
# indicate that should be a kernel flag
if [ ${options[arrayCount]:0:2} = "KF" ];then
# plistbuddy only add's if the key doesn't already exist.
# same time once when we reach the end of the options list.
kernelflag[kernelFlagCount]="${options[arrayCount]##*flag=}"
"$scriptDir"InstallLog.sh "${dest_vol}" "Added kernel flag: ${kernelflag[kernelFlagCount]}"
(( kernelFlagCount++ ))
else
keyRead="${options[$arrayCount]%=*}"
value="${options[$arrayCount]#*=}"
# escape any spaces
keyToUse=$( echo $keyRead | sed 's/ /\\ /g' )
if [ "${keyToUse}" != "DONT" ] && [ "${value}" != "USE" ]; then
sudo /usr/libexec/plistbuddy -c "Add :${keyToUse} string ${value}" "$tempOCBP"
"$scriptDir"InstallLog.sh "${dest_vol}" "Added boot option: ${keyRead}=${value}"
fi
fi
(( arrayCount++ ))
done < <(ls "${chamTemp}"/options )
# Check keyRead for 'KF' at beginning to
# indicate that should be a kernel flag
if [ ${options[arrayCount]:0:2} = "KF" ];then
# plistbuddy only add's if the key doesn't already exist.
# So let's store any kernelflags and add them all at the
# same time once when we reach the end of the options list.
kernelflag[kernelFlagCount]="${options[arrayCount]##*flag=}"
"$scriptDir"InstallLog.sh "${dest_vol}" "Added kernel flag: ${kernelflag[kernelFlagCount]}"
(( kernelFlagCount++ ))
else
keyRead="${options[$arrayCount]%=*}"
value="${options[$arrayCount]#*=}"
# escape any spaces
keyToUse=$( echo $keyRead | sed 's/ /\\ /g' )
if [ "${keyToUse}" != "DONT" ] && [ "${value}" != "USE" ]; then
sudo /usr/libexec/plistbuddy -c "Add :${keyToUse} string ${value}" "$tempOCBP"
"$scriptDir"InstallLog.sh "${dest_vol}" "Added boot option: ${keyRead}=${value}"
fi
fi
(( arrayCount++ ))
done < <(ls "${chamTemp}"/options )
if [ $kernelFlagCount -gt 0 ]; then
# Add kernel flags
for (( i=0 ; i < $kernelFlagCount ; i++ ))
do
# Add any kernel flags together in to one string.
kernelFlagString="${kernelFlagString} ${kernelflag[i]}"
done
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"
if [ ${returnValue}=1 ]; then # key already exists.
sudo /usr/libexec/plistbuddy -c "Delete :Kernel\ Flags" "$tempOCBP"
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"
fi
fi
fi
if [ $kernelFlagCount -gt 0 ]; then
# Add kernel flags
for (( i=0 ; i < $kernelFlagCount ; i++ ))
do
# Add any kernel flags together in to one string.
kernelFlagString="${kernelFlagString} ${kernelflag[i]}"
done
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"
if [ ${returnValue}=1 ]; then # key already exists.
sudo /usr/libexec/plistbuddy -c "Delete :Kernel\ Flags" "$tempOCBP"
sudo /usr/libexec/plistbuddy -c "Add :Kernel\ Flags string $kernelFlagString" "$tempOCBP"
fi
fi
fi
# ---------------------------------------------
# Copy temp Extra folder to target destination
# ---------------------------------------------
# If we've made a temporary Extra folder to use then
# check for an existing /Extra folder. If found, back it up
# before copying the temporary Extra folder to destination.
# Extra folder now resides in /usr/local/chamTemp/
# Copy /usr/local/chamTemp/Extra to correct location.
# ---------------------------------------------
# Copy temp Extra folder to target destination
# ---------------------------------------------
# If we've made a temporary Extra folder to use then
# check for an existing /Extra folder. If found, back it up
# before copying the temporary Extra folder to destination.
# Extra folder now resides in /usr/local/chamTemp/
# Copy /usr/local/chamTemp/Extra to correct location.
if [ -d "$chamTemp"/Extra ]; then
if [ -d "$chamTemp"/Extra ]; then
if [ ! -f "$dest_vol"/.ChameleonEFI ]; then
# The Standard install option chosen
if [ ! -f "$dest_vol"/.ChameleonEFI ]; then
# The Standard install option chosen
# Does and /Extra folder already exist?
if [ -e "$dest_vol"/Extra ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing $dest_vol/Extra folder. Renaming it $dest_vol/Extra-OLD-$( date "+%H-%M-%S" )"
mv "$dest_vol/Extra" "$dest_vol/Extra_OLD-"$( date "+%H-%M-%S" )
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: $dest_vol/Extra"
cp -R "$chamTemp"/Extra "$dest_vol"
else
# The EFI system partition install option was chosen
# Does and /Extra folder already exist?
if [ -e "$dest_vol"/Extra ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing $dest_vol/Extra folder. Renaming it $dest_vol/Extra-OLD-$( date "+%H-%M-%S" )"
mv "$dest_vol/Extra" "$dest_vol/Extra_OLD-"$( date "+%H-%M-%S" )
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: $dest_vol/Extra"
cp -R "$chamTemp"/Extra "$dest_vol"
else
# The EFI system partition install option was chosen
# Does a /Volumes/Extra folder already exist?
if [ -e "/Volumes/EFI/Extra" ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing /Volumes/EFI/Extra folder. Renaming it Extra-OLD-$( date "+%H-%M-%S" )"
mv "/Volumes/EFI/Extra" "/Volumes/EFI/Extra_OLD-"$( date "+%H-%M-%S" )
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: /Volumes/EFI/Extra"
cp -R "$chamTemp"/Extra "/Volumes/EFI"
# Does a /Volumes/Extra folder already exist?
if [ -e "/Volumes/EFI/Extra" ]; then
"$scriptDir"InstallLog.sh "${dest_vol}" "Found existing /Volumes/EFI/Extra folder. Renaming it Extra-OLD-$( date "+%H-%M-%S" )"
mv "/Volumes/EFI/Extra" "/Volumes/EFI/Extra_OLD-"$( date "+%H-%M-%S" )
fi
"$scriptDir"InstallLog.sh "${dest_vol}" "Writing folder: /Volumes/EFI/Extra"
cp -R "$chamTemp"/Extra "/Volumes/EFI"
# unmount /Volumes/EFI
attempts=1
while [ "$( df | grep EFI )" ] && [ "${attempts}" -lt 5 ]; do
echo "Unmounting $( df | grep EFI | awk '{print $1}' )"
"$scriptDir"InstallLog.sh "${dest_vol}" "Unmounting $( df | grep EFI | awk '{print $1}' )"
umount -f $( df | grep EFI | awk '{print $1}' )
attempts=$(( ${attempts} + 1 ))
done
fi
# unmount /Volumes/EFI
attempts=1
while [ "$( df | grep EFI )" ] && [ "${attempts}" -lt 5 ]; do
echo "Unmounting $( df | grep EFI | awk '{print $1}' )"
"$scriptDir"InstallLog.sh "${dest_vol}" "Unmounting $( df | grep EFI | awk '{print $1}' )"
umount -f $( df | grep EFI | awk '{print $1}' )
attempts=$(( ${attempts} + 1 ))
done
fi
fi
else
echo "Removing /.ChameleonExists file"
"$scriptDir"InstallLog.sh "${dest_vol}" "Cleanup 4"
rm "$dest_vol"/.ChameleonExists
fi
# ---------------------------------------------

Archive Download the corresponding diff file

Revision: 1608