Chameleon

Chameleon Commit Details

Date:2011-09-27 16:34:36 (12 years 6 months ago)
Author:blackosx
Commit:1582
Parents: 1581
Message:Change BootOption text files to include a header and a place to enable exclusive lists. Re-worked the boot option code in to a function in buildpkg to allow it to be used for keylayouts. Updated en.lproj strings (other languages will have to be updated at some point).
Changes:
M/branches/blackosx/package/BootOptions/General.txt
M/branches/blackosx/package/BootOptions/KernelFlags.txt
M/branches/blackosx/package/Resources/en.lproj/Localizable.strings
M/branches/blackosx/package/buildpkg.sh
M/branches/blackosx/package/BootOptions/Control.txt
M/branches/blackosx/package/BootOptions/Resolution.txt
M/branches/blackosx/package/BootOptions/Video.txt
M/branches/blackosx/package/BootOptions/PowerManagement.txt

File differences

branches/blackosx/package/BootOptions/Resolution.txt
1
1
2
3
4
5
6
7
28
39
410
none:DONT=ADD
# ---------------------------------------------
# Chameleon boot options list.
# Note: There must be a carriage return at end of last line
# ---------------------------------------------
Exclusive=True
# ---------------------------------------------
1024x600x32:Graphics Mode=1024x600x32
1024x768x32:Graphics Mode=1024x768x32
1280x768x32:Graphics Mode=1280x768x32
branches/blackosx/package/BootOptions/Video.txt
1
2
3
4
5
6
7
18
29
310
# ---------------------------------------------
# Chameleon boot options list.
# Structure is name:key=value
# Note: There must be a carriage return at end of last line
# ---------------------------------------------
Exclusive=False
# ---------------------------------------------
GraphicsEnabler:GraphicsEnabler=Yes
UseAtiROM:UseAtiROM=Yes
UseNvidiaROM:UseNvidiaROM=Yes
branches/blackosx/package/BootOptions/PowerManagement.txt
1
1
2
3
4
5
6
7
28
39
410
CSTUsingSystemIO:CSTUsingSystemIO=Yes
# ---------------------------------------------
# Chameleon boot options list.
# Structure is name:key=value
# Note: There must be a carriage return at end of last line
# ---------------------------------------------
Exclusive=False
# ---------------------------------------------CSTUsingSystemIO:CSTUsingSystemIO=Yes
DropSSDT:DropSSDT=Yes
EnableC2State:EnableC2State=Yes
EnableC3State:EnableC3State=Yes
branches/blackosx/package/BootOptions/General.txt
1
2
3
4
5
6
7
18
29
310
# ---------------------------------------------
# Chameleon boot options list.
# Structure is name:key=value
# Note: There must be a carriage return at end of last line
# ---------------------------------------------
Exclusive=False
# ---------------------------------------------
arch:arch=i386
EHCIacquire:EHCIacquire=Yes
EthernetBuiltIn:EthernetBuiltIn=Yes
branches/blackosx/package/BootOptions/KernelFlags.txt
1
2
3
4
5
6
7
18
# ---------------------------------------------
# Chameleon boot options list.
# Structure is name:key=value
# Note: There must be a carriage return at end of last line
# ---------------------------------------------
Exclusive=False
# ---------------------------------------------
Npci:KF npci=0x2000
branches/blackosx/package/BootOptions/Control.txt
1
2
3
4
5
6
7
18
29
310
# ---------------------------------------------
# Chameleon boot options list.
# Structure is name:key=value
# Note: There must be a carriage return at end of last line
# ---------------------------------------------
Exclusive=False
# ---------------------------------------------
BootBanner:Boot Banner=No
GUI:GUI=No
LegacyLogo:Legacy Logo=Yes
branches/blackosx/package/Resources/en.lproj/Localizable.strings
173173
174174
175175
176
176
177177
178
179
180
181178
182179
183180
......
231228
232229
233230
234
231
235232
236233
237234
......
282279
283280
284281
282
283
284
285
286
287
288
289
290
291
292
285293
// Resolution
"Resolution_title" = "Resolution";
"Resolution_description" = "Set the screen resolution of your display";
"Resolution_description" = "Set one resolution to use, or select 'None' if you don't want to select a resolution.";
"none_title" = "Don't add a resolution";
"none_description" = "Don't add a resolution";
"1024x600x32_title" = "1024x600x32";
"1024x600x32_description" = "Set Graphics Mode to 1024x600x32";
// KeyLayout
"KeyLayout_title" = "KeyLayout";
"KeyLayout_description" = "Set keylayout to use";
"KeyLayout_description" = "Set one keylayout to use, or select 'None' if you don't want to select a keylayout.";
"mac-de_title" = "German Mac Keyboard";
"mac-de_description" = "Use the keyboard layout for a German Mac keyboard";
"Newer_Package_Installed_message" = "A newer version of Chameleon is already installed";
"Intel_Mac_message" = "This software cannot be installed on this computer.";
// Exclusive boot ptions string
// Name to be used should be ChooseNone-xxxxxx
// Where xxxxx = the name of the BootOptions file (minus the .txt)
"ChooseNone-Resolution_title" = "None";
"ChooseNone-Resolution_description" = "Don't choose a resolution.";
"ChooseNone-keylayout_title" = "None";
"ChooseNone-keylayout_description" = "Don't choose a keylayout.";
branches/blackosx/package/buildpkg.sh
8888
8989
9090
91
91
9292
9393
9494
......
100100
101101
102102
103
103
104104
105105
106106
......
198198
199199
200200
201
202
203
204
205
206
201
202
203
204
205
207206
208
207
209208
210209
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
210
211
212
213
214
215
216
228217
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
218
219
220
221
222
223
224
225
226
227
280228
281
282
283
229
230
231
284232
285233
286234
......
291239
292240
293241
294
295
296
297
298
299
300
301
242
243
244
245
246
247
248
249
250
251
302252
303253
304254
......
348298
349299
350300
351
301
352302
353303
354304
......
360310
361311
362312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
363392
364393
365394
......
389418
390419
391420
392
421
393422
394423
395424
......
426455
427456
428457
429
458
430459
431460
432461
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/Standard/* ${1}/Standard/Scripts
cp -f ${pkgroot}/Scripts/Sub/* ${1}/Standard/Scripts
cp -f ${pkgroot}/Scripts/Sub/* ${1}/Standard/Scripts
ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Resources/SetFile
ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Standard/Scripts/Resources/revision
ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Standard/Scripts/Resources/version
mkdir -p ${1}/EFI/Root
mkdir -p ${1}/EFI/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/EFI/* ${1}/EFI/Scripts
cp -f ${pkgroot}/Scripts/Sub/* ${1}/EFI/Scripts
cp -f ${pkgroot}/Scripts/Sub/* ${1}/EFI/Scripts
ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Resources/SetFile
ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/EFI/Scripts/Resources/revision
ditto --noextattr --noqtn ${1%/*/*}/version ${1}/EFI/Scripts/Resources/version
do
# Take filename and Strip .txt from end and path from front
builtOptionsFolderName=$( echo ${bootOptionFiles[$i]%.txt} )
builtOptionsFolderName=$( echo ${builtOptionsFolderName##*/} )
echo "================= $builtOptionsFolderName ================="
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${builtOptionsFolderName}\">"
choices[$((choicescount++))]="<choice\n\tid=\"${builtOptionsFolderName}\"\n\ttitle=\"${builtOptionsFolderName}_title\"\n\tdescription=\"${builtOptionsFolderName}_description\"\n>\n</choice>\n"
builtOptionsList=$( echo ${bootOptionFiles[$i]%.txt} )
builtOptionsList=$( echo ${builtOptionsList##*/} )
echo "================= $builtOptionsList ================="
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${builtOptionsList}\">"
choices[$((choicescount++))]="<choice\n\tid=\"${builtOptionsList}\"\n\ttitle=\"${builtOptionsList}_title\"\n\tdescription=\"${builtOptionsList}_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.options.$builtOptionsFolderName"
packagesidentity="org.chameleon.options.$builtOptionsList"
# ------------------------------------------------------
# Read boot option file in to an array.
# Structure of boot option in file is name:key=value
# Note: This requires the boot option file to have
# a carriage return at the end of the last line.
# ------------------------------------------------------
count=0
availableOptions=()
while read textLine
do
availableOptions[count]=$textLine
((count++))
done < ${bootOptionFiles[$i]}
# ------------------------------------------------------
# Loop through options in array and process each in turn
# ------------------------------------------------------
for (( c = 0 ; c < ${#availableOptions[@]} ; c++ ))
# Read boot option file in to an array.
# ------------------------------------------------------
availableOptions=() # array to hold the list of boot options, per 'section'.
exclusiveFlag=0 # used to indicate list has exclusive options.
exclusiveName="" # will be appended to exclusive 'none' option name.
count=0 # used as index for stepping through array.
while read textLine
do
textLine=${availableOptions[c]}
# split line - taking all before ':' as option name
# and all after ':' as key/value
optionName=${textLine%:*}
keyValue=${textLine##*:}
# create folders required for each boot option
mkdir -p "${1}/$optionName/Root/"
# create dummy file with name of key/value
echo "" > "${1}/$optionName/Root/${keyValue}"
echo "[BUILD] ${optionName} "
# ------------------------------------------------------
# Before calling buildpackage, see if any bootOptionFiles
# have requested being set to exclusive.
# Manually set for now to 'Resolutions'.
# It can eventually be non-specifc by adding a dedicated
# field at the top of each bootOptionFiles to indicate
# if the set should be exclusive or not.
# ------------------------------------------------------
if [ $builtOptionsFolderName = "Resolution" ]; then
# Prepare individual string parts
stringStart="selected=\""
stringBefore="exclusive(choices['"
stringAfter="']) &amp;&amp; "
stringEnd="'])\""
x=${stringStart}${stringBefore}
# build string for sending to buildpackage
totalItems="${#availableOptions[@]}"
lastItem=$((totalItems-1))
for (( r = 0 ; r < ${totalItems} ; r++ ))
do
textLineTemp=${availableOptions[r]}
optionNameTemp=${textLineTemp%:*}
if [ "${optionNameTemp}" != "${optionName}" ]; then
x="${x}${optionNameTemp}"
# Only add these to end of string up to the one before the last item
if [ $r -lt $lastItem ]; then
x="${x}${stringAfter}${stringBefore}"
fi
fi
done
x="${x}${stringEnd}"
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\" ${x}" >/dev/null 2>&1
else
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\"" >/dev/null 2>&1
# ignore lines in the file beginning with a # and Exclusive=False
if [[ ${textLine} != \#* ]] && [[ ${textLine} != "Exclusive=False" ]];then
# check for 'Exclusive=True' option in file
if [[ ${textLine} == "Exclusive=True" ]];then
exclusiveFlag=1
exclusiveName=$builtOptionsList
else
availableOptions[count]=$textLine
((count++))
fi
fi
done
done < ${bootOptionFiles[$i]}
buildbootoptions "$1" "${exclusiveFlag}" "${exclusiveName}"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
done
choices[$((choicescount++))]="<choice\n\tid=\"KeyLayout\"\n\ttitle=\"KeyLayout_title\"\n\tdescription=\"KeyLayout_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.options.keylayout"
keymaps=($( find "${1%/sym/*}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))
for (( i = 0 ; i < ${#keymaps[@]} ; i++ ))
do
mkdir -p "${1}/${keymaps[$i]##*/}/Root/"
echo "dummy file" >"${1}/${keymaps[$i]##*/}/Root/KeyLayout=${keymaps[$i]##*/}"
echo "[BUILD] ${keymaps[$i]##*/} "
buildpackage "${1}/${keymaps[$i]##*/}" "/$chamTemp/options" "" "start_selected=\"false\"" >/dev/null 2>&1
done
# ------------------------------------------------------
# Available Keylayout boot options are discovered by
# reading contents of /Keymaps folder after compilation
# ------------------------------------------------------
availableOptions=()
availableOptions=($( find "${1%/sym/*}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))
# call buildbootoptions with 1 to indicate exclusive option wanted.
buildbootoptions "$1" "1" "keylayout"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# clean up
#rm -R -f "${1}"
rm -R -f "${1}"
}
chown -R 0:0 "${1}"
}
buildbootoptions()
{
# $1 Path to package to build containing Root and or Scripts
# $2 = exclusiveFlag
# S3 = exclusiveName
# ------------------------------------------------------
# if exclusiveFlag=1 then re-build array
# adding extra boot option at beginning to give
# ------------------------------------------------------
if [ ${2} = "1" ]; then
tempArray=("${availableOptions[@]}")
availableOptions=()
availableOptions[0]="ChooseNone-"$3":DONT=ADD"
position=0
totalItems="${#tempArray[@]}"
for (( position = 0 ; position < $totalItems ; position++ ))
do
availableOptions[$position+1]=${tempArray[${position}]}
done
fi
# ------------------------------------------------------
# Loop through options in array and process each in turn
# ------------------------------------------------------
for (( c = 0 ; c < ${#availableOptions[@]} ; c++ ))
do
textLine=${availableOptions[c]}
# split line - taking all before ':' as option name
# and all after ':' as key/value
optionName=${textLine%:*}
keyValue=${textLine##*:}
# create folders required for each boot option
mkdir -p "${1}/$optionName/Root/"
# create dummy file with name of key/value
echo "" > "${1}/$optionName/Root/${keyValue}"
echo "[BUILD] ${optionName} "
# ------------------------------------------------------
# Before calling buildpackage, add exclusive options
# to buildpackage call if requested.
# ------------------------------------------------------
if [ $2 = "1" ]; then
# Prepare individual string parts
stringStart="selected=\""
stringBefore="exclusive(choices['"
stringAfter="']) &amp;&amp; "
stringEnd="'])\""
x=${stringStart}${stringBefore}
# build string for sending to buildpackage
totalItems="${#availableOptions[@]}"
lastItem=$((totalItems-1))
for (( r = 0 ; r < ${totalItems} ; r++ ))
do
textLineTemp=${availableOptions[r]}
optionNameTemp=${textLineTemp%:*}
if [ "${optionNameTemp}" != "${optionName}" ]; then
x="${x}${optionNameTemp}"
# Only add these to end of string up to the one before the last item
if [ $r -lt $lastItem ]; then
x="${x}${stringAfter}${stringBefore}"
fi
fi
done
x="${x}${stringEnd}"
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\" ${x}" >/dev/null 2>&1
else
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\"" >/dev/null 2>&1
fi
done
}
buildpackage ()
{
# $1 Path to package to build containing Root and or Scripts
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
#rm -R -f "${1}/Temp"
rm -R -f "${1}/Temp"
[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
fi
choices[$((choicescount++))]="<choice\n\tid=\"${packagename// /}\"\n\ttitle=\"${packagename}_title\"\n\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' auth='root'>#${packagename// /}.pkg</pkg-ref>\n</choice>\n"
#rm -R -f "${1}"
rm -R -f "${1}"
fi
}

Archive Download the corresponding diff file

Revision: 1582