Chameleon

Chameleon Commit Details

Date:2011-12-28 19:07:01 (8 years 10 months ago)
Author:JrCs
Commit:1756
Parents: 1755
Message:Improved buildpkg script - Make the script more robust against errors - Replace misleading variables
Changes:
M/trunk/Makefile
M/trunk/package/buildpkg.sh

File differences

trunk/package/buildpkg.sh
11
22
3
3
4
5
46
5
6
7
8
7
8
9
10
11
912
13
14
15
16
17
18
19
20
21
22
23
24
25
26
1027
1128
1229
......
1734
1835
1936
37
38
2039
2140
2241
2342
2443
2544
26
45
2746
28
29
30
47
48
49
3150
3251
3352
34
3553
3654
3755
......
3957
4058
4159
60
4261
62
63
4364
4465
45
66
67
68
69
4670
71
72
4773
4874
4975
......
6490
6591
6692
67
68
93
94
6995
7096
7197
7298
7399
74100
75
101
76102
77103
78104
79105
80106
81107
82
108
109
110
83111
84112
85113
......
95123
96124
97125
98
126
99127
100128
101129
102130
103131
104132
105
133
106134
107135
108136
109137
110138
111139
112
113
114
115
116
117
140
141
142
143
144
145
118146
119147
120
148
121149
122150
123151
......
125153
126154
127155
128
129
130
131
132
133
134
135
136
137
138
139
140
156
157
158
159
160
161
162
163
164
165
166
167
168
141169
142170
143
171
144172
145173
146174
147175
148176
149
150
177
178
151179
152180
153181
154182
155183
156184
157
158
185
186
159187
160188
161
189
162190
163191
164192
165193
166194
167195
168
169
196
197
170198
171199
172
200
173201
174202
175203
176204
177205
178
206
179207
180208
181209
182210
183
184
211
212
185213
186214
187215
188216
189217
190218
191
192
193
194
195
219
220
221
222
223
196224
197225
198
226
199227
200228
201229
202230
203231
204232
205
206
207
208
209
233
234
235
236
237
210238
211239
212
240
213241
214242
215243
216244
217245
218246
219
247
220248
221249
222
250
223251
224252
225253
226254
227255
228
256
229257
230258
231259
......
238266
239267
240268
241
269
242270
243
244
271
272
245273
246274
247275
248
276
249277
250278
251279
252
253
280
281
254282
255283
256
284
257285
258286
259287
260288
261289
262290
263
291
264292
265293
266294
267
268
295
296
269297
270298
271
299
272300
273301
274302
275303
276304
277305
278
306
279307
280308
281309
282
283
310
311
284312
285313
286
314
287315
288316
289317
......
293321
294322
295323
296
324
297325
298326
299327
300
301
302
328
329
330
303331
304332
305333
306
334
307335
308336
309
337
310338
311
339
312340
313
341
314342
315343
316
344
317345
318346
319347
......
322350
323351
324352
325
353
326354
327355
328356
......
333361
334362
335363
336
337
364
365
338366
339367
340368
341369
342370
343371
344
372
345373
346374
347375
......
351379
352380
353381
354
355
382
383
356384
357385
358386
......
386414
387415
388416
389
417
390418
391419
392
420
393421
394422
395423
396
424
397425
398426
399427
......
402430
403431
404432
405
433
406434
407435
408436
409437
410
411
438
439
412440
413441
414442
......
417445
418446
419447
420
448
421449
422450
423451
......
425453
426454
427455
428
456
429457
430458
431
459
432460
433461
434462
435
463
436464
437465
438466
......
441469
442470
443471
444
472
445473
446474
447475
448476
449
477
450478
451479
452480
453481
454
455
482
483
456484
457485
458486
459487
460
488
461489
462490
463491
464
465
492
493
466494
467495
468
496
469497
470498
471499
472500
473
501
474502
475503
476504
477505
478506
479507
480
481
482
483
484
485
486
508
509
510
511
512
513
514
487515
488516
489
517
490518
491519
492520
493521
494
522
495523
496
497
498
499
500
501
502
503524
504525
505526
......
514535
515536
516537
517
538
539
540
518541
519542
520543
......
569592
570593
571594
572
595
573596
574597
575598
576599
577600
578
601
579602
580
603
581604
582605
583
606
584607
585
586
608
609
587610
588611
589612
590
613
591614
592615
593
616
594617
595618
596619
597
620
598621
599622
600623
601
624
602625
603626
604
627
605628
606629
607
630
608631
609632
610
611
633
612634
613635
614
615
636
637
616638
617639
618640
619641
620
642
621643
622644
623
624
625
645
646
647
626648
627649
628
650
629651
630652
631
632
633
653
654
655
634656
635
657
636658
637659
638660
......
655677
656678
657679
658
680
681
682
683
684
#!/bin/bash
# $1 Path to store built package
# $0 SRCROOT directory
# $1 SYMROOT directory
# $2 directory where pkgs will be created
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
chamTemp="usr/local/chamTemp"
# Directory paths
PKGROOT="${0%/*}"
SRCROOT="$1"
SYMROOT="$2"
PKG_BUILD_DIR="$3"
if [[ $# -lt 3 ]];then
echo "Too few arguments. Aborting..." >&2 && exit 1
fi
if [[ ! -d "$SYMROOT" ]];then
echo "Directory ${SYMROOT} doesn't exit. Aborting..." >&2 && exit 1
fi
# Prevent the script from doing bad things
set -u # Abort with unset variables
#set -e # Abort with any error can be suppressed locally using EITHER cmd||true OR set -e;cmd;set +e
# ====== COLORS ======
COL_BLACK="\x1b[30;01m"
COL_RED="\x1b[31;01m"
COL_GREEN="\x1b[32;01m"
COL_BLUE="\x1b[34;01m"
COL_RESET="\x1b[39;49;00m"
# ====== REVISION/VERSION ======
version=$( cat version )
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )
builddate=$( grep I386BOOT_BUILDDATE vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
# =================
# ====== CREDITS ======
develop=$(awk "NR==6{print;exit}" ${pkgroot}/../CREDITS)
credits=$(awk "NR==10{print;exit}" ${pkgroot}/../CREDITS)
pkgdev=$(awk "NR==14{print;exit}" ${pkgroot}/../CREDITS)
develop=$(awk "NR==6{print;exit}" ${PKGROOT}/../CREDITS)
credits=$(awk "NR==10{print;exit}" ${PKGROOT}/../CREDITS)
pkgdev=$(awk "NR==14{print;exit}" ${PKGROOT}/../CREDITS)
# =================
distributioncount=0
xmlindent=0
indent[0]="\t"
indent[2]="\t\t\t"
indent[3]="\t\t\t\t"
# ====== GLOBAL VARIABLES ======
declare -a pkgrefs
declare -a outline
declare -a choices
# Package identifiers
modules_packages_identity="org.chameleon.modules"
packagesidentity="org.chameleon"
modules_packages_identity="${packagesidentity}.modules"
packagename="Chameleon"
chamTemp="usr/local/chamTemp"
# ====== FUNCTIONS ======
getPackageRefId () {
echo ${1//_/.}.${2//_/.} | tr [:upper:] [:lower:]
}
fi
choiceNode="${choiceNode}\n\t</choice>\n"
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"${choiceId}\"/>"
choices[$((choicescount++))]="$choiceNode"
outline[${#outline[*]}]="${indent[$xmlindent]}<line choice=\"${choiceId}\"/>"
choices[${#choices[*]}]="$choiceNode"
}
exclusive_one_choice () {
# $1 Current choice (ie: test1)
# $2..$n Others choice(s) (ie: "test2" "test3"). Current can or can't be in the others choices
local myChoice="${1}"
local result;
local result="";
local separator=' || ';
for choice in ${@:2};do
if [[ "$choice" != "$myChoice" ]];then
result="${result}choices['$choice'].selected${separator}";
fi
done
echo "!(${result%$separator})"
if [[ -n "$result" ]];then
echo "!(${result%$separator})"
fi
}
exclusive_zero_or_one_choice () {
# clean up the destination path
rm -R -f "${1}"
rm -R -f "${PKG_BUILD_DIR}"
echo ""
echo -e $COL_CYAN" ----------------------------------"$COL_RESET
echo -e $COL_CYAN" Building $packagename Install Package"$COL_RESET
echo -e $COL_CYAN" ----------------------------------"$COL_RESET
echo ""
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
outline[${#outline[*]}]="${indent[$xmlindent]}<choices-outline>"
# build pre install package
echo "================= Preinstall ================="
((xmlindent++))
packagesidentity="org.chameleon"
choiceId="Pre"
mkdir -p ${1}/${choiceId}/Root
mkdir -p ${1}/${choiceId}/Scripts
ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/${choiceId}/Scripts/Resources/revision
ditto --noextattr --noqtn ${1%/*/*}/version ${1}/${choiceId}/Scripts/Resources/version
cp -f ${pkgroot}/Scripts/Main/preinstall ${1}/${choiceId}/Scripts
cp -f ${pkgroot}/Scripts/Sub/InstallLog.sh ${1}/${choiceId}/Scripts
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts
ditto --noextattr --noqtn ${SRCROOT}/revision ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/revision
ditto --noextattr --noqtn ${SRCROOT}/version ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/version
cp -f ${PKGROOT}/Scripts/Main/preinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts
cp -f ${PKGROOT}/Scripts/Sub/InstallLog.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
addChoice "${choiceId}" "start_visible=\"false\" start_selected=\"true\"" "$packageRefId"
# End build pre install package
echo "================= Core ================="
packagesidentity="org.chameleon"
choiceId="Core"
mkdir -p ${1}/${choiceId}/Root/usr/local/bin
mkdir -p ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot0 ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot0md ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot1f32 ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot1h ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot1he ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot1hp ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/cdboot ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/chain0 ${1}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/fdisk440 ${1}/${choiceId}/Root/usr/local/bin
ditto --noextattr --noqtn ${1%/*}/i386/bdmesg ${1}/${choiceId}/Root/usr/local/bin
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot0md ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1f32 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1h ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1he ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/boot1hp ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/cdboot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/chain0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
ditto --noextattr --noqtn ${SYMROOT}/i386/fdisk440 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
ditto --noextattr --noqtn ${SYMROOT}/i386/bdmesg ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
addChoice "${choiceId}" "start_visible=\"false\" start_selected=\"true\"" "$packageRefId"
# End build core package
# build install type
echo "================= Chameleon ================="
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"InstallType\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"InstallType\"\n\t\ttitle=\"InstallType_title\"\n\t\tdescription=\"InstallType_description\">\n\t</choice>\n"
outline[${#outline[*]}]="${indent[$xmlindent]}<line choice=\"InstallType\">"
choices[${#choices[*]}]="\t<choice\n\t\tid=\"InstallType\"\n\t\ttitle=\"InstallType_title\"\n\t\tdescription=\"InstallType_description\">\n\t</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.type"
allChoices="New Upgrade"
# build new install package
choiceId="New"
mkdir -p ${1}/${choiceId}/Root
echo "" > "${1}/${choiceId}/Root/install_type_new"
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/install_type_new"
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp"
exclusiveChoice=$(exclusive_one_choice "$choiceId" "$allChoices")
addChoice "${choiceId}" "start_selected=\"!choices['Upgrade'].selected\" selected=\"${exclusiveChoice}\"" "$packageRefId"
# End build new install package
# build upgrade package
choiceId="Upgrade"
mkdir -p ${1}/${choiceId}/Root
echo "" > "${1}/${choiceId}/Root/install_type_upgrade"
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/install_type_upgrade"
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp"
exclusiveChoice=$(exclusive_one_choice "$choiceId" "$allChoices")
addChoice "${choiceId}" "start_selected=\"chameleon_boot_plist_exists()\" selected=\"${exclusiveChoice}\"" "$packageRefId"
# End build upgrade package
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
outline[${#outline[*]}]="${indent[$xmlindent]}</line>"
# End build install type
# build Chameleon package
echo "================= Chameleon ================="
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Chameleon\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"Chameleon\"\n\t\ttitle=\"Chameleon_title\"\n\t\tdescription=\"Chameleon_description\">\n\t</choice>\n"
outline[${#outline[*]}]="${indent[$xmlindent]}<line choice=\"Chameleon\">"
choices[${#choices[*]}]="\t<choice\n\t\tid=\"Chameleon\"\n\t\ttitle=\"Chameleon_title\"\n\t\tdescription=\"Chameleon_description\">\n\t</choice>\n"
((xmlindent++))
allChoices="Standard EFI noboot"
# build standard package
choiceId="Standard"
mkdir -p ${1}/${choiceId}/Root
mkdir -p ${1}/${choiceId}/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/${choiceId}postinstall ${1}/${choiceId}/Scripts/postinstall
cp -f ${pkgroot}/Scripts/Sub/* ${1}/${choiceId}/Scripts
ditto --arch i386 `which SetFile` ${1}/${choiceId}/Scripts/Resources/SetFile
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources
cp -f ${PKGROOT}/Scripts/Main/${choiceId}postinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall
cp -f ${PKGROOT}/Scripts/Sub/* ${PKG_BUILD_DIR}/${choiceId}/Scripts
ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
exclusiveChoice=$(exclusive_one_choice "$choiceId" "$allChoices")
addChoice "${choiceId}" "start_selected=\"true\" selected=\"${exclusiveChoice}\"" "$packageRefId"
# End build standard package
# build efi package
choiceId="EFI"
mkdir -p ${1}/${choiceId}/Root
mkdir -p ${1}/${choiceId}/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/ESPpostinstall ${1}/${choiceId}/Scripts/postinstall
cp -f ${pkgroot}/Scripts/Sub/* ${1}/${choiceId}/Scripts
ditto --arch i386 `which SetFile` ${1}/${choiceId}/Scripts/Resources/SetFile
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources
cp -f ${PKGROOT}/Scripts/Main/ESPpostinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall
cp -f ${PKGROOT}/Scripts/Sub/* ${PKG_BUILD_DIR}/${choiceId}/Scripts
ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
exclusiveChoice=$(exclusive_one_choice "$choiceId" "$allChoices")
addChoice "${choiceId}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"${exclusiveChoice}\"" "$packageRefId"
# End build efi package
# build no bootloader choice package
choiceId="noboot"
mkdir -p ${1}/${choiceId}/Root
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
exclusiveChoice=$(exclusive_one_choice "$choiceId" "$allChoices")
addChoice "${choiceId}" "start_selected=\"false\" selected=\"${exclusiveChoice}\"" "$packageRefId"
# End build no bootloader choice package
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
outline[${#outline[*]}]="${indent[$xmlindent]}</line>"
# End build Chameleon package
# build Modules package
# uClibcxx.dylib #
# Keylayout.dylib #
###############################
if [ "$(ls -A "${1%/*}/i386/modules")" ]; then
if [ "$(ls -A "${SYMROOT}/i386/modules")" ]; then
{
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Module\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"Module\"\n\t\ttitle=\"Module_title\"\n\t\tdescription=\"Module_description\">\n\t</choice>\n"
outline[${#outline[*]}]="${indent[$xmlindent]}<line choice=\"Module\">"
choices[${#choices[*]}]="\t<choice\n\t\tid=\"Module\"\n\t\ttitle=\"Module_title\"\n\t\tdescription=\"Module_description\">\n\t</choice>\n"
((xmlindent++))
# -
if [ -e ${1%/*}/i386/modules/klibc.dylib ]; then
if [ -e ${SYMROOT}/i386/modules/klibc.dylib ]; then
{
# Start build klibc package module
choiceId="klibc"
mkdir -p ${1}/${choiceId}/Root
ditto --noextattr --noqtn ${1%/*}/i386/modules/${choiceId}.dylib ${1}/${choiceId}/Root
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
ditto --noextattr --noqtn ${SYMROOT}/i386/modules/${choiceId}.dylib ${PKG_BUILD_DIR}/${choiceId}/Root
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp/Extra/modules"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules"
addChoice "${choiceId}" "start_selected=\"false\"" "$packageRefId"
# End build klibc package module
}
fi
# -
if [ -e ${1%/*}/i386/modules/Resolution.dylib ]; then
if [ -e ${SYMROOT}/i386/modules/Resolution.dylib ]; then
{
# Start build Resolution package module
choiceId="AutoReso"
mkdir -p ${1}/${choiceId}/Root
ditto --noextattr --noqtn ${1%/*}/i386/modules/Resolution.dylib ${1}/${choiceId}/Root
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
ditto --noextattr --noqtn ${SYMROOT}/i386/modules/Resolution.dylib ${PKG_BUILD_DIR}/${choiceId}/Root
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp/Extra/modules"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules"
addChoice "${choiceId}" "start_selected=\"false\"" "$packageRefId"
# End build Resolution package module
}
fi
# -
if [ -e ${1%/*}/i386/modules/uClibcxx.dylib ]; then
if [ -e ${SYMROOT}/i386/modules/uClibcxx.dylib ]; then
{
# Start build uClibc package module
choiceId="uClibc"
mkdir -p ${1}/${choiceId}/Root
ditto --noextattr --noqtn ${1%/*}/i386/modules/uClibcxx.dylib ${1}/${choiceId}/Root
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
ditto --noextattr --noqtn ${SYMROOT}/i386/modules/uClibcxx.dylib ${PKG_BUILD_DIR}/${choiceId}/Root
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp/Extra/modules"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules"
# Add the klibc package because the uClibc module is dependent of klibc module
addChoice "${choiceId}" "start_selected=\"false\"" \
"$packageRefId" $(getPackageRefId "${modules_packages_identity}" "klibc")
# -
# Warning Keylayout module need additional files
if [ -e ${1%/*}/i386/modules/Keylayout.dylib ]; then
if [ -e ${SYMROOT}/i386/modules/Keylayout.dylib ]; then
{
# Start build Keylayout package module
choiceId="Keylayout"
mkdir -p ${1}/${choiceId}/Root/Extra/{modules,Keymaps}
mkdir -p ${1}/${choiceId}/Root/usr/local/bin
layout_src_dir="${1%/sym/*}/i386/modules/Keylayout/layouts/layouts-src"
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/{modules,Keymaps}
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
layout_src_dir="${SRCROOT}/i386/modules/Keylayout/layouts/layouts-src"
if [ -d "$layout_src_dir" ];then
# Create a tar.gz from layout sources
(cd "$layout_src_dir"; \
tar czf "${1}/Keylayout/Root/Extra/Keymaps/layouts-src.tar.gz" README *.slt)
tar czf "${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps/layouts-src.tar.gz" README *.slt)
fi
# Adding module
ditto --noextattr --noqtn ${1%/*}/i386/modules/${choiceId}.dylib ${1}/${choiceId}/Root/Extra/modules
ditto --noextattr --noqtn ${SYMROOT}/i386/modules/${choiceId}.dylib ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/modules
# Adding Keymaps
ditto --noextattr --noqtn ${1%/sym/*}/Keymaps ${1}/${choiceId}/Root/Extra/Keymaps
ditto --noextattr --noqtn ${SRCROOT}/Keymaps ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps
# Adding tools
ditto --noextattr --noqtn ${1%/*}/i386/cham-mklayout ${1}/${choiceId}/Root/usr/local/bin
ditto --noextattr --noqtn ${SYMROOT}/i386/cham-mklayout ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp"
# Don't add a choice for Keylayout module
# addChoice "${choiceId}" "start_selected=\"false\"" "$packageRefId"
fi
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
outline[${#outline[*]}]="${indent[$xmlindent]}</line>"
}
else
{
# build Options packages
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Options\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"Options\"\n\t\ttitle=\"Options_title\"\n\t\tdescription=\"Options_description\">\n\t</choice>\n"
outline[${#outline[*]}]="${indent[$xmlindent]}<line choice=\"Options\">"
choices[${#choices[*]}]="\t<choice\n\t\tid=\"Options\"\n\t\ttitle=\"Options_title\"\n\t\tdescription=\"Options_description\">\n\t</choice>\n"
((xmlindent++))
# ------------------------------------------------------
# parse OptionalSettings folder to find files of boot options.
# ------------------------------------------------------
OptionalSettingsFolder="${pkgroot}/OptionalSettings"
OptionalSettingsFolder="${PKGROOT}/OptionalSettings"
OptionalSettingsFiles=($( find "${OptionalSettingsFolder}" -depth 1 ! -name '.svn' ! -name '.DS_Store' ))
for (( i = 0 ; i < ${#OptionalSettingsFiles[@]} ; i++ ))
builtOptionsList=$( echo ${OptionalSettingsFiles[$i]%.txt} )
builtOptionsList=$( echo ${builtOptionsList##*/} )
echo "================= $builtOptionsList ================="
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"${builtOptionsList}\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"${builtOptionsList}\"\n\t\ttitle=\"${builtOptionsList}_title\"\n\t\tdescription=\"${builtOptionsList}_description\">\n\t</choice>\n"
outline[${#outline[*]}]="${indent[$xmlindent]}<line choice=\"${builtOptionsList}\">"
choices[${#choices[*]}]="\t<choice\n\t\tid=\"${builtOptionsList}\"\n\t\ttitle=\"${builtOptionsList}_title\"\n\t\tdescription=\"${builtOptionsList}_description\">\n\t</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.options.$builtOptionsList"
keyValue=${textLine##*:}
# create folders required for each boot option
mkdir -p "${1}/$optionName/Root/"
mkdir -p "${PKG_BUILD_DIR}/$optionName/Root/"
# create dummy file with name of key/value
echo "" > "${1}/$optionName/Root/${keyValue}"
echo "" > "${PKG_BUILD_DIR}/$optionName/Root/${keyValue}"
echo -e "\t[BUILD] ${optionName} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}")
buildpackage "$packageRefId" "${optionName}" "${1}/${optionName}" "/$chamTemp/options"
buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/$chamTemp/options"
exclusiveSelect=""
if [[ ${exclusiveFlag} -eq 1 ]];then
exclusiveSelect="selected=\"$(exclusive_zero_or_one_choice "$optionName" "$allChoices")\""
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
outline[${#outline[*]}]="${indent[$xmlindent]}</line>"
done
# build KeyLayout options packages
echo "================= Keymaps Options ================="
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"KeyLayout\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"KeyLayout\"\n\t\ttitle=\"KeyLayout_title\"\n\t\tdescription=\"KeyLayout_description\">\n\t</choice>\n"
outline[${#outline[*]}]="${indent[$xmlindent]}<line choice=\"KeyLayout\">"
choices[${#choices[*]}]="\t<choice\n\t\tid=\"KeyLayout\"\n\t\ttitle=\"KeyLayout_title\"\n\t\tdescription=\"KeyLayout_description\">\n\t</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.options.keylayout"
keylayoutPackageRefId=$(getPackageRefId "${modules_packages_identity}" "Keylayout")
# Available Keylayout boot options are discovered by
# reading contents of /Keymaps folder after compilation
# ------------------------------------------------------
availableOptions=($( find "${1%/sym/*}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))
availableOptions=($( find "${SRCROOT}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))
allChoices="${availableOptions[@]}"
# Adjust array contents to match expected format
# for boot options which is: name:key=value
# availableOptions[i]=${availableOptions[i]}":KeyLayout="${availableOptions[i]}
# Start build of a keymap package module
choiceId="${availableOptions[i]}"
mkdir -p ${1}/${choiceId}/Root
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
# create dummy file with name of key/value
echo "" > "${1}/${choiceId}/Root/KeyLayout=${availableOptions[i]}"
echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/KeyLayout=${availableOptions[i]}"
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp/options"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/options"
exclusiveChoice=$(exclusive_zero_or_one_choice "$choiceId" "$allChoices")
# Add the Keylayout package because the Keylayout module is needed
addChoice "${choiceId}" "start_selected=\"false\" selected=\"${exclusiveChoice}\"" \
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
outline[${#outline[*]}]="${indent[$xmlindent]}</line>"
# End build KeyLayout options packages
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
outline[${#outline[*]}]="${indent[$xmlindent]}</line>"
# End build options packages
# build theme packages
echo "================= Themes ================="
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Themes\">"
choices[$((choicescount++))]="\t<choice\n\t\tid=\"Themes\"\n\t\ttitle=\"Themes_title\"\n\t\tdescription=\"Themes_description\">\n\t</choice>\n"
outline[${#outline[*]}]="${indent[$xmlindent]}<line choice=\"Themes\">"
choices[${#choices[*]}]="\t<choice\n\t\tid=\"Themes\"\n\t\ttitle=\"Themes_title\"\n\t\tdescription=\"Themes_description\">\n\t</choice>\n"
((xmlindent++))
# Using themes section from Azi's/package branch.
packagesidentity="org.chameleon.themes"
artwork="${1%/sym/package}/artwork/themes"
artwork="${SRCROOT}/artwork/themes"
themes=($( find "${artwork}" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#themes[@]} ; i++ )); do
theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )
mkdir -p "${1}/${theme}/Root/"
rsync -r --exclude=.svn "${themes[$i]}/" "${1}/${theme}/Root/${theme}"
mkdir -p "${PKG_BUILD_DIR}/${theme}/Root/"
rsync -r --exclude=.svn "${themes[$i]}/" "${PKG_BUILD_DIR}/${theme}/Root/${theme}"
echo -e "\t[BUILD] ${theme}"
packageRefId=$(getPackageRefId "${packagesidentity}" "${theme}")
buildpackage "$packageRefId" "${theme}" "${1}/${theme}" "/$chamTemp/Extra/Themes"
buildpackage "$packageRefId" "${theme}" "${PKG_BUILD_DIR}/${theme}" "/$chamTemp/Extra/Themes"
addChoice "${theme}" "start_selected=\"false\"" "$packageRefId"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
outline[${#outline[*]}]="${indent[$xmlindent]}</line>"
# End build theme packages# End build Extras package
# build post install package
echo "================= Post ================="
packagesidentity="org.chameleon"
choiceId="Post"
mkdir -p ${1}/${choiceId}/Root
mkdir -p ${1}/${choiceId}/Scripts
cp -f ${pkgroot}/Scripts/Main/postinstall ${1}/${choiceId}/Scripts
cp -f ${pkgroot}/Scripts/Sub/InstallLog.sh ${1}/${choiceId}/Scripts
cp -f ${pkgroot}/Scripts/Sub/UnMountEFIvolumes.sh ${1}/${choiceId}/Scripts
ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/${choiceId}/Scripts/Resources/revision
ditto --noextattr --noqtn ${1%/*/*}/version ${1}/${choiceId}/Scripts/Resources/version
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts
cp -f ${PKGROOT}/Scripts/Main/postinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts
cp -f ${PKGROOT}/Scripts/Sub/InstallLog.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts
cp -f ${PKGROOT}/Scripts/Sub/UnMountEFIvolumes.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts
ditto --noextattr --noqtn ${SRCROOT}/revision ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/revision
ditto --noextattr --noqtn ${SRCROOT}/version ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/version
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/"
buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
addChoice "${choiceId}" "start_visible=\"false\" start_selected=\"true\"" "$packageRefId"
# End build post install package
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
outline[${#outline[*]}]="${indent[$xmlindent]}</choices-outline>"
# build meta package
makedistribution "${1}" "${2}" "${3}" "${4}" #"${5}"
# clean up
# rm -R -f "${1}"
}
buildpackage ()
local packageName="$2"
local packagePath="$3"
local targetPath="$4"
local packageSize="$5"
set +u # packageSize is optional
local packageSize="$5"
set -u
find "${packagePath}" -name '.DS_Store' -delete
local filecount=$( find "${packagePath}/Root" | wc -l )
makedistribution ()
{
distributionDestDir="${1%/*}"
distributionDestDir="${SYMROOT}"
distributionFilename="${packagename// /}-${version}-r${revision}.pkg"
distributionFilePath="${distributionDestDir}/${distributionFilename}"
rm -f "${distributionDestDir}/${packagename// /}"*.pkg
mkdir -p "${1}/${packagename}"
mkdir -p "${PKG_BUILD_DIR}/${packagename}"
find "${1}" -type f -name '*.pkg' -depth 1 | while read component
find "${PKG_BUILD_DIR}" -type f -name '*.pkg' -depth 1 | while read component
do
pkg="${component##*/}" # ie: EFI.pkg
pkgdir="${1}/${packagename}/${pkg}"
pkgdir="${PKG_BUILD_DIR}/${packagename}/${pkg}"
# expand individual packages
pkgutil --expand "${1%}/${pkg}" "$pkgdir"
rm -f "${1%}/${pkg}"
pkgutil --expand "${PKG_BUILD_DIR}/${pkg}" "$pkgdir"
rm -f "${PKG_BUILD_DIR}/${pkg}"
done
# Create the Distribution file
ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
ditto --noextattr --noqtn "${PKGROOT}/Distribution" "${PKG_BUILD_DIR}/${packagename}/Distribution"
for (( i=0; i < ${#outline[*]} ; i++)); do
echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
echo -e "${outline[$i]}" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
done
for (( i=0; i < ${#choices[*]} ; i++)); do
echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
echo -e "${choices[$i]}" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
done
for (( i=0; i < ${#pkgrefs[*]} ; i++)); do
echo -e "${pkgrefs[$i]}" >> "${1}/${packagename}/Distribution"
echo -e "${pkgrefs[$i]}" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
done
echo -e "\n</installer-gui-script>" >> "${1}/${packagename}/Distribution"
echo -e "\n</installer-gui-script>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
# Create the Resources directory
ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
ditto --noextattr --noqtn "${PKGROOT}/Resources" "${PKG_BUILD_DIR}/${packagename}/Resources"
# CleanUp the directory
find "${1}/${packagename}" -type d -name '.svn' -exec rm -rf {} \; 2>/dev/null
find "${1}/${packagename}" -name '.DS_Store' -delete
find "${PKG_BUILD_DIR}/${packagename}" \( -type d -name '.svn' \) -o -name '.DS_Store' -exec rm -rf {} \;
# Add Chameleon Version and Revision
perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" $( find "${1}/${packagename}/Resources" -type f )
perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" $( find "${1}/${packagename}/Resources" -type f )
perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )
perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )
# Add Chameleon Stage
stage=${stage/RC/Release Candidate }
stage=${stage/FINAL/2.0 Final}
perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" $( find "${1}/${packagename}/Resources" -type f )
perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )
# Adding Developer and credits
perl -i -p -e "s/%DEVELOP%/${develop}/g" $( find "${1}/${packagename}/Resources" -type f )
perl -i -p -e "s/%CREDITS%/${credits}/g" $( find "${1}/${packagename}/Resources" -type f )
perl -i -p -e "s/%PKGDEV%/${pkgdev}/g" $( find "${1}/${packagename}/Resources" -type f )
perl -i -p -e "s/%DEVELOP%/${develop}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )
perl -i -p -e "s/%CREDITS%/${credits}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )
perl -i -p -e "s/%PKGDEV%/${pkgdev}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )
# Create the final package
pkgutil --flatten "${1}/${packagename}" "${distributionFilePath}"
pkgutil --flatten "${PKG_BUILD_DIR}/${packagename}" "${distributionFilePath}"
# Here is the place for assign a Icon to the pkg
ditto -xk "${pkgroot}/Icons/pkg.zip" "${1}/Icons/"
DeRez -only icns "${1}/Icons/Icons/pkg.icns" > "${1}/Icons/tempicns.rsrc"
Rez -append "${1}/Icons/tempicns.rsrc" -o "${distributionFilePath}"
ditto -xk "${PKGROOT}/Icons/pkg.zip" "${PKG_BUILD_DIR}/Icons/"
DeRez -only icns "${PKG_BUILD_DIR}/Icons/Icons/pkg.icns" > "${PKG_BUILD_DIR}/Icons/tempicns.rsrc"
Rez -append "${PKG_BUILD_DIR}/Icons/tempicns.rsrc" -o "${distributionFilePath}"
SetFile -a C "${distributionFilePath}"
rm -rf "${1}/Icons"
rm -rf "${PKG_BUILD_DIR}/Icons"
# End
}
main "${1}" "${2}" "${3}" "${4}" #"${5}"
# build packages
main
# build meta package
makedistribution
trunk/Makefile
66
77
88
9
910
10
1111
1212
1313
......
100100
101101
102102
103
103
104104
105105
106
106
107107
108108
109109
......
121121
122122
123123
124
124
125
125126
126127
127128
DOCROOT = $(SRCROOT)/doc
IMGSKELROOT = $(SRCROOT)/imgskel
CDBOOT = ${IMGROOT}/usr/standalone/i386/cdboot
PKG_BUILD_DIR = $(SYMROOT)/package
include Make.rules
@mv ${DISTFILE}.tar.gz ${DISTFILE}.tgz
clean-local:
@if [ -d "$(SYMROOT)/package" ];then echo "\t[RMDIR] $(SYMROOT)/package"; fi
@if [ -d "$(PKG_BUILD_DIR)" ];then echo "\t[RMDIR] $(PKG_BUILD_DIR)"; fi
@if [ -f "$(HEADER_VERSION)" ];then echo "\t[RM] $(HEADER_VERSION)"; fi
@if [ -f "$(SRCROOT)/revision" ];then echo "\t[RM] $(SRCROOT)/revision"; fi
@rm -rf "$(SYMROOT)/package" $(HEADER_VERSION) $(SRCROOT)/revision
@rm -rf "$(PKG_BUILD_DIR)" $(HEADER_VERSION) $(SRCROOT)/revision
AUTOCONF_FILES = $(SRCROOT)/auto.conf $(SRCROOT)/autoconf.h \
$(SRCROOT)/autoconf.inc $(SRCROOT)/.config $(SRCROOT)/.config.old
$(AUTOCONF_FILES)
pkg installer: all
${SRCROOT}/package/buildpkg.sh ${SYMROOT}/package
@echo "================= Building Package ================="
@${SRCROOT}/package/buildpkg.sh "$(SRCROOT)" "$(SYMROOT)" "$(PKG_BUILD_DIR)"
help:
@echo 'Configuration target:'

Archive Download the corresponding diff file

Revision: 1756