Chameleon

Chameleon Commit Details

Date:2011-12-22 19:00:30 (8 years 11 months ago)
Author:JrCs
Commit:1741
Parents: 1740
Message:Enhanced installer - We can add an option without an associated package - We can have an option that install multiple packages - No more "fake" option (none) - The package that is build is already compressed (no need to compress it again)
Changes:
M/trunk/Makefile
M/trunk/package/buildpkg.sh
M/trunk/package/Distribution

File differences

trunk/package/Distribution
22
33
44
5
6
5
6
77
8
9
10
11
12
8
9
10
11
12
1313
14
14
1515
16
16
1717
18
19
20
21
22
23
24
25
26
27
28
29
18
19
20
21
22
23
24
25
26
27
28
3029
31
32
33
34
35
30
31
32
33
3634
37
38
39
40
41
42
43
44
45
46
47
35
36
37
38
39
40
4841
49
50
51
42
43
44
5245
5346
<installer-gui-script minSpecVersion='1'>
<options hostArchitectures='i386' allow-external-scripts="no"/>
<domains enable_anywhere="true"/>
<options hostArchitectures='i386' allow-external-scripts="no"/>
<domains enable_anywhere="true"/>
<welcome file='Welcome.rtfd'/>
<license file="License.rtf" sla="EA0401"/>
<readme file='Description.html'/>
<conclusion file="Conclusion.rtfd"/>
<background file='background.tiff' alignment='topleft' scaling='tofit'/>
<welcome file='Welcome.rtfd'/>
<license file="License.rtf" sla="EA0401"/>
<readme file='Description.html'/>
<conclusion file="Conclusion.rtfd"/>
<background file='background.tiff' alignment='topleft' scaling='tofit'/>
<title>Chameleon_title</title>
<title>Chameleon_title</title>
<script>
<script>
function installCheckScript()
{
var obj = system.ioregistry.matchingClass("AppleSMC");
if (obj) {
system.log('installCheckScript: Found AppleSMC');
my.result.message = system.localizedStringWithFormat('Intel_Mac_message');
my.result.type = 'Fatal';
return false;
}
system.log('installCheckScript: Failed.');
return false;
}
function installCheckScript() {
var obj = system.ioregistry.matchingClass("AppleSMC");
if (obj) {
system.log('installCheckScript: Found AppleSMC');
my.result.message = system.localizedStringWithFormat('Intel_Mac_message');
my.result.type = 'Fatal';
return false;
}
system.log('installCheckScript: Failed.');
return false;
}
function volCheckScript()
{
system.log('volCheckScript: Failed.');
return true;
}
function volCheckScript() {
system.log('volCheckScript: Failed.');
return true;
}
function systemHasGPT(){
var obj = system.ioregistry.matchingName("EFI System Partition");
if (obj)
return true;
return false;
}
function exclusive(toggle){
toggle.selected = ( my.choice.selected != "false" ? "false" : "true" );
return ( toggle.selected != false ? false : true );
}
function systemHasGPT() {
var obj = system.ioregistry.matchingName("EFI System Partition");
if (obj)
return true;
return false;
}
function chameleon_boot_plist_exists() {
return system.files.fileExistsAtPath(my.target.mountpoint + '/Extra/org.chameleon.Boot.plist');
}
function chameleon_boot_plist_exists() {
return system.files.fileExistsAtPath(my.target.mountpoint + '/Extra/org.chameleon.Boot.plist');
}
</script>
trunk/package/buildpkg.sh
3939
4040
4141
42
43
44
45
46
47
48
49
50
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
90
91
92
4293
4394
4495
4596
4697
47
48
49
50
51
52
98
99
100
101
102
103
53104
54
105
55106
56107
57
58
59
60
61
62
63
64
65
66
67
108
109
110
111
112
113
114
115
116
117
118
119
120
121
68122
69123
70124
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
89145
90
146
91147
92
93
94
95
96
97
98
99
100
101
102
103
148
149
150
151
152
153
104154
105
106
107
108
109
110
155
156
157
158
159
160
161
162
163
164
111165
166
167
168
169
170
171
172
173
174
175
176
112177
113178
114
179
115180
116181
117
118
119
120
121
122
123
124
125
126
127
128
129
130
182
183
184
185
131186
132
133
134
135
136
137
138
139
140
187
141188
142
143
144
145
146
189
190
191
192
193
194
195
196
197
198
199
200
201
147202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
148227
149228
150229
151230
152231
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
168247
169
170
171
172
173
174
175
176
248
249
250
251
252
253
254
255
256
257
258
259
260
261
177262
178
179
180
181
182
183
184
185
263
264
265
266
267
268
269
270
271
272
273
274
275
276
186277
187
188
189
190
191
192
193
194
195
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
196294
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
218317
219
220
221
222
223
224
225
226
318
319
320
321
322
323
324
325
326
327
328
329
330
331
227332
228333
229
230
334
231335
232
233
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
234356
357
235358
236359
237
360
238361
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
362
363
364
365
366
367
368
369
370
371
372
273373
274
275
276
277
278
279
374
375
280376
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
377
378
379
380
381
382
383
384
385
386
306387
307
388
389
308390
309
310
391
392
311393
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
394
395
396
397
398
399
400
401
331402
332403
333404
334405
335
406
336407
337
338
339
340
341
342
343
344
345
346
347
348
349
408
409
410
411
412
413
414
350415
351
352
416
417
418
419
420
421
422
423
424
425
426
427
428
353429
354
430
431
355432
356
433
434
435
436
437
438
439
440
441
357442
358
443
444
359445
360
446
361447
362
448
449
450
363451
364
365
366
367
368
369
370
452
453
454
455
456
371457
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
458
459
460
461
462
463
464
465
466
467
468
469
470
405471
406
407
472
473
474
408475
409
410
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
411492
412
493
494
413495
414
415
416
417
418
496
419497
420
421
422
423
424
425
498
426499
427
428
429
500
501
430502
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457503
458504
459505
460506
461
462
463
464
507
508
509
510
511
512
513
514
515
516
517
465518
466
519
520
521
522
523
524
525
526
467527
468
469
470
471
472
473
474
475
476
477
528
478529
479
530
531
480532
481
482
533
483534
484
535
536
537
485538
486
487
488
539
540
489541
490
491
542
543
544
545
546
547
548
549
550
551
492552
493
494
495
496
497
498
499
500
501
502
503
504
553
554
505555
506
507
508
509
510
511
556
557
558
512559
513
560
561
514562
515
563
564
516565
517
518
519
520
566
521567
522
523
524
525568
526569
527570
528571
529
572
573
574
530575
531
576
577
578
579
580
532581
533
534
535
536
582
583
584
585
586
587
588
589
590
591
592
593
537594
538595
539
540
596
597
598
541599
542
600
601
602
543603
544
545
546
547
604
548605
549
550
551
552
606
607
553608
554
609
610
611
555612
556
557
613
614
615
558616
559
560
561
562
617
618
619
620
563621
564
565
566
622
623
624
625
567626
568
569
570
571
627
628
572629
573630
574
575
576
577
578
579
580
581
582
631
632
633
634
635
636
583637
584638
585
586
587
639
640
641
588642
589
590
591
592
593
594
595
596
597
598
599
600
643
644
645
646
647
648
649
650
651
652
653
654
601655
602656
603657
604658
605
indent[2]="\t\t\t"
indent[3]="\t\t\t\t"
declare -a pkgrefs
# Package identifiers
modules_packages_identity="org.chameleon.modules"
getPackageRefId () {
echo ${1//_/.}.${2//_/.} | tr [:upper:] [:lower:]
}
addChoice () {
# $1 Choice Id
# $2 Choice Options
# $3..$n Package reference id (optional)
local choiceId="${1}"
local choiceOptions="${2}"
local choiceNode="\t<choice\n\t\tid=\"${choiceId}\"\n\t\ttitle=\"${choiceId}_title\"\n\t\tdescription=\"${choiceId}_description\""
[[ -n "${choiceOptions}" ]] && choiceNode="${choiceNode}\n\t\t${choiceOptions}"
choiceNode="${choiceNode}>"
if [[ $# -ge 3 ]];then
for pkgRefId in ${@:3};do
choiceNode="${choiceNode}\n\t\t<pkg-ref id=\"${pkgRefId}\"/>"
done
fi
choiceNode="${choiceNode}\n\t</choice>\n"
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"${choiceId}\"/>"
choices[$((choicescount++))]="$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 separator=' || ';
for choice in ${@:2};do
if [[ "$choice" != "$myChoice" ]];then
result="${result}choices['$choice'].selected${separator}";
fi
done
echo "!(${result%$separator})"
}
exclusive_zero_or_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;
echo "(my.choice.selected &amp;&amp; $(exclusive_one_choice ${@}))"
}
main ()
{
# clean up the destination path
rm -R -f "${1}"
echo ""
echo -e $COL_CYAN"----------------------------------"$COL_RESET
echo -e $COL_CYAN"Building $packagename Install Package"$COL_RESET
echo -e $COL_CYAN"----------------------------------"$COL_RESET
echo ""
rm -R -f "${1}"
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[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build pre install package
echo "================= Preinstall ================="
((xmlindent++))
packagesidentity="org.chameleon"
mkdir -p ${1}/Pre/Root
mkdir -p ${1}/Pre/Scripts
ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Pre/Scripts/Resources/revision
ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Pre/Scripts/Resources/version
cp -f ${pkgroot}/Scripts/Main/preinstall ${1}/Pre/Scripts
cp -f ${pkgroot}/Scripts/Sub/InstallLog.sh ${1}/Pre/Scripts
echo "[BUILD] Pre "
buildpackage "${1}/Pre" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
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
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/"
addChoice "${choiceId}" "start_visible=\"false\" start_selected=\"true\"" "$packageRefId"
# End build pre install package
# build core package
echo "================= Core ================="
packagesidentity="org.chameleon"
mkdir -p ${1}/Core/Root/usr/local/bin
mkdir -p ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot0md ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386
ditto --noextattr --noqtn ${1%/*}/i386/fdisk440 ${1}/Core/Root/usr/local/bin
ditto --noextattr --noqtn ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/local/bin
local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
echo "[BUILD] i386 "
buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
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
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${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"
((xmlindent++))
packagesidentity="org.chameleon.type"
# build new install package
mkdir -p ${1}/New/Root
echo "" > "${1}/New/Root/install_type_new"
echo "[BUILD] New "
buildpackage "${1}/New" "/$chamTemp" "" "start_enabled=\"true\" selected=\"exclusive(choices['Upgrade'])\"" >/dev/null 2>&1
# End build new install package
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"
((xmlindent++))
packagesidentity="org.chameleon.type"
allChoices="New Upgrade"
# build upgrade package
mkdir -p ${1}/Upgrade/Root
echo "" > "${1}/Upgrade/Root/install_type_upgrade"
echo "[BUILD] Upgrade "
buildpackage "${1}/Upgrade" "/$chamTemp" "" "start_selected=\"chameleon_boot_plist_exists()\" selected=\"exclusive(choices['New'])\"" >/dev/null 2>&1
# End build upgrade package
# build new install package
choiceId="New"
mkdir -p ${1}/${choiceId}/Root
echo "" > "${1}/${choiceId}/Root/install_type_new"
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${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"
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${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>"
# End build install type
# 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"
((xmlindent++))
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/Standardpostinstall ${1}/Standard/Scripts/postinstall
cp -f ${pkgroot}/Scripts/Sub/* ${1}/Standard/Scripts
ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Resources/SetFile
echo "[BUILD] Standard "
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build standard 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"
((xmlindent++))
# build efi package
mkdir -p ${1}/EFI/Root
mkdir -p ${1}/EFI/Scripts/Resources
cp -f ${pkgroot}/Scripts/Main/ESPpostinstall ${1}/EFI/Scripts/postinstall
cp -f ${pkgroot}/Scripts/Sub/* ${1}/EFI/Scripts
ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Resources/SetFile
echo "[BUILD] EFI "
buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
# End build efi package
allChoices="Standard EFI noboot"
# build reset choice package
mkdir -p ${1}/noboot/Root
echo "[BUILD] Reset choice "
buildpackage "${1}/noboot" "/$chamTemp" "" "selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
# End build reset choice package
# 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
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${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
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${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
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${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>"
# End build Chameleon package
# build Modules package
echo "================= Modules ================="
###############################
# Supported Modules #
###############################
# klibc.dylib #
# Resolution.dylib #
# uClibcxx.dylib #
# Keylayout.dylib #
###############################
if [ "$(ls -A "${1%/*}/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"
((xmlindent++))
packagesidentity="org.chameleon.modules"
echo "================= Modules ================="
###############################
# Supported Modules #
###############################
# klibc.dylib #
# Resolution.dylib #
# uClibcxx.dylib #
# Keylayout.dylib #
###############################
if [ "$(ls -A "${1%/*}/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"
((xmlindent++))
# -
if [ -e ${1%/*}/i386/modules/klibc.dylib ]; then
{
mkdir -p ${1}/klibc/Root
ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/klibc/Root
echo "[BUILD] klibc "
buildpackage "${1}/klibc" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
}
fi
if [ -e ${1%/*}/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
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp/Extra/modules"
addChoice "${choiceId}" "start_selected=\"false\"" "$packageRefId"
# End build klibc package module
}
fi
# -
if [ -e ${1%/*}/i386/modules/Resolution.dylib ]; then
{
mkdir -p ${1}/AutoReso/Root
ditto --noextattr --noqtn ${1%/*}/i386/modules/Resolution.dylib ${1}/AutoReso/Root
echo "[BUILD] Resolution "
buildpackage "${1}/AutoReso" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
}
fi
if [ -e ${1%/*}/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
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp/Extra/modules"
addChoice "${choiceId}" "start_selected=\"false\"" "$packageRefId"
# End build Resolution package module
}
fi
# -
if [ -e ${1%/*}/i386/modules/uClibcxx.dylib ]; then
{
mkdir -p ${1}/uClibc/Root
ditto --noextattr --noqtn ${1%/*}/i386/modules/uClibcxx.dylib ${1}/uClibc/Root
ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/uClibc/Root
echo "[BUILD] uClibc++ "
buildpackage "${1}/uClibc" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
}
fi
if [ -e ${1%/*}/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
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${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")
# End build uClibc package module
}
fi
# -
# Warning Keylayout module need additional files
if [ -e ${1%/*}/i386/modules/Keylayout.dylib ]; then
{
mkdir -p ${1}/Keylayout/Root/Extra/{modules,Keymaps}
mkdir -p ${1}/Keylayout/Root/usr/local/bin
layout_src_dir="${1%/sym/*}/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)
fi
# Adding module
ditto --noextattr --noqtn ${1%/*}/i386/modules/Keylayout.dylib ${1}/Keylayout/Root/Extra/modules
# Adding Keymaps
ditto --noextattr --noqtn ${1%/sym/*}/Keymaps ${1}/Keylayout/Root/Extra/Keymaps
# Adding tools
ditto --noextattr --noqtn ${1%/*}/i386/cham-mklayout ${1}/Keylayout/Root/usr/local/bin
echo "[BUILD] Keylayout "
buildpackage "${1}/Keylayout" "/" "" "start_selected=\"true\"" >/dev/null 2>&1
}
fi
# Warning Keylayout module need additional files
if [ -e ${1%/*}/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"
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)
fi
# Adding module
ditto --noextattr --noqtn ${1%/*}/i386/modules/${choiceId}.dylib ${1}/${choiceId}/Root/Extra/modules
# Adding Keymaps
ditto --noextattr --noqtn ${1%/sym/*}/Keymaps ${1}/${choiceId}/Root/Extra/Keymaps
# Adding tools
ditto --noextattr --noqtn ${1%/*}/i386/cham-mklayout ${1}/${choiceId}/Root/usr/local/bin
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/$chamTemp"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
}
else
{
echo "-= no modules to include =-"
}
fi
# Don't add a choice for Keylayout module
# addChoice "${choiceId}" "start_selected=\"false\"" "$packageRefId"
# End build Keylayout package module
}
fi
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
}
else
{
echo " -= no modules to include =-"
}
fi
# End build Modules packages
# build Extras package
# build options packages
# 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[$((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"
((xmlindent++))
# ------------------------------------------------------
# parse OptionalSettings folder to find files of boot options.
# ------------------------------------------------------
OptionalSettingsFolder="${pkgroot}/OptionalSettings"
OptionalSettingsFiles=($( find "${OptionalSettingsFolder}" -depth 1 ! -name '.svn' ! -name '.DS_Store' ))
for (( i = 0 ; i < ${#OptionalSettingsFiles[@]} ; i++ ))
do
# Take filename and Strip .txt from end and path from front
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"
((xmlindent++))
packagesidentity="org.chameleon.options.$builtOptionsList"
# ------------------------------------------------------
# parse OptionalSettings folder to find files of boot options.
# Read boot option file into an array.
# ------------------------------------------------------
OptionalSettingsFolder="${pkgroot}/OptionalSettings"
OptionalSettingsFiles=($( find "${OptionalSettingsFolder}" -depth 1 ! -name '.svn' ! -name '.DS_Store' ))
for (( i = 0 ; i < ${#OptionalSettingsFiles[@]} ; i++ ))
do
# Take filename and Strip .txt from end and path from front
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"
((xmlindent++))
packagesidentity="org.chameleon.options.$builtOptionsList"
# ------------------------------------------------------
# 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
# 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
availableOptions=() # array to hold the list of boot options, per 'section'.
exclusiveFlag=0 # used to indicate list has exclusive options
count=0 # used as index for stepping through array.
while read textLine; do
# 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
else
availableOptions[${#availableOptions[@]}]=$textLine
fi
done < ${OptionalSettingsFiles[$i]}
buildoptionalsettings "$1" "${exclusiveFlag}" "${exclusiveName}"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
done
fi
done < ${OptionalSettingsFiles[$i]}
# 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"
((xmlindent++))
packagesidentity="org.chameleon.options.keylayout"
# ------------------------------------------------------
# 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||' ))
# Adjust array contents to match expected format
# for boot options which is: name:key=value
for (( i = 0 ; i < ${#availableOptions[@]} ; i++ ))
do
availableOptions[i]=${availableOptions[i]}":KeyLayout="${availableOptions[i]}
done
# to indicate exclusive option, call buildoptionalsettings with the 2nd parameter set to 1 .
buildoptionalsettings "$1" "1" "keylayout"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
# ------------------------------------------------------
# Loop through options in array and process each in turn
# ------------------------------------------------------
allChoices="${availableOptions[@]//:*/}"
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##*:}
# End build KeyLayout options packages
# create folders required for each boot option
mkdir -p "${1}/$optionName/Root/"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
# create dummy file with name of key/value
echo "" > "${1}/$optionName/Root/${keyValue}"
# 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"
((xmlindent++))
# Using themes section from Azi's/package branch.
packagesidentity="org.chameleon.themes"
artwork="${1%/sym/package}/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}"
echo "[BUILD] ${theme}"
buildpackage "${1}/${theme}" "/$chamTemp/Extra/Themes" "" "start_selected=\"false\"" >/dev/null 2>&1
echo -e "\t[BUILD] ${optionName} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}")
buildpackage "$packageRefId" "${optionName}" "${1}/${optionName}" "/$chamTemp/options"
exclusiveSelect=""
if [[ ${exclusiveFlag} -eq 1 ]];then
exclusiveSelect="selected=\"$(exclusive_zero_or_one_choice "$optionName" "$allChoices")\""
fi
addChoice "${optionName}" "start_selected=\"false\" ${exclusiveSelect}" "$packageRefId"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
# End build theme packages# End build Extras package
done
# build post install package
echo "================= Post ================="
packagesidentity="org.chameleon"
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Main/postinstall ${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 "
buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
# End build post install package
# 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"
((xmlindent++))
packagesidentity="org.chameleon.options.keylayout"
keylayoutPackageRefId=$(getPackageRefId "${modules_packages_identity}" "Keylayout")
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# ------------------------------------------------------
# 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||' ))
allChoices="${availableOptions[@]}"
# Adjust array contents to match expected format
# for boot options which is: name:key=value
for (( i = 0 ; i < ${#availableOptions[@]} ; i++ )); do
# availableOptions[i]=${availableOptions[i]}":KeyLayout="${availableOptions[i]}
# Start build of a keymap package module
choiceId="${availableOptions[i]}"
mkdir -p ${1}/${choiceId}/Root
# build meta package
# create dummy file with name of key/value
echo "" > "${1}/${choiceId}/Root/KeyLayout=${availableOptions[i]}"
makedistribution "${1}" "${2}" "${3}" "${4}" #"${5}"
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${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}\"" \
"$packageRefId" "$keylayoutPackageRefId"
# End build uClibc package module
done
# clean up
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
rm -R -f "${1}"
# End build KeyLayout options packages
}
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
# End build options packages
fixperms ()
{
# $1 path
find "${1}" -type f -exec chmod 644 {} \;
find "${1}" -type d -exec chmod 755 {} \;
chown -R 0:0 "${1}"
}
# 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"
((xmlindent++))
buildoptionalsettings()
{
# $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
# user a chance to choose none of them.
# ------------------------------------------------------
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##*:}
# Using themes section from Azi's/package branch.
packagesidentity="org.chameleon.themes"
artwork="${1%/sym/package}/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}"
echo -e "\t[BUILD] ${theme}"
packageRefId=$(getPackageRefId "${packagesidentity}" "${theme}")
buildpackage "$packageRefId" "${theme}" "${1}/${theme}" "/$chamTemp/Extra/Themes"
addChoice "${theme}" "start_selected=\"false\"" "$packageRefId"
done
# create folders required for each boot option
mkdir -p "${1}/$optionName/Root/"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
# End build theme packages# End build Extras package
# create dummy file with name of key/value
echo "" > "${1}/$optionName/Root/${keyValue}"
# 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
echo -e "\t[BUILD] ${choiceId} "
packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
buildpackage "$packageRefId" "${choiceId}" "${1}/${choiceId}" "/"
addChoice "${choiceId}" "start_visible=\"false\" start_selected=\"true\"" "$packageRefId"
# End build post install package
echo "[BUILD] ${optionName} "
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# ------------------------------------------------------
# Before calling buildpackage, add exclusive options
# to buildpackage call if requested.
# ------------------------------------------------------
if [ $2 = "1" ]; then
# build meta package
# Prepare individual string parts
stringStart="selected=\""
stringBefore="exclusive(choices['"
stringAfter="']) &amp;&amp; "
stringEnd="'])\""
x=${stringStart}${stringBefore}
makedistribution "${1}" "${2}" "${3}" "${4}" #"${5}"
# build string for sending to buildpackage
totalItems="${#availableOptions[@]}"
lastItem=$((totalItems-1))
# clean up
# rm -R -f "${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}"
# First exclusive option is the 'no choice' option, so let's make that selected by default.
if [ $c = 0 ]; then
initialChoice="true"
else
initialChoice="false"
fi
buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"${initialChoice}\" ${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
# $2 Install Location
# $3 Size
# $4 Options
# $1 Package Reference Id (ie: org.chameleon.themes.default)
# $2 Package Name (ie: Default)
# $3 Path to package to build containing Root and/or Scripts
# $4 Target install location
# $5 Size (optional)
if [[ -d "${3}/Root" ]]; then
local packageRefId="$1"
local packageName="$2"
local packagePath="$3"
local targetPath="$4"
local packageSize="$5"
if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
find "${packagePath}" -name '.DS_Store' -delete
local filecount=$( find "${packagePath}/Root" | wc -l )
if [ "${packageSize}" ]; then
local installedsize="${packageSize}"
else
local installedsize=$( du -hkc "${packagePath}/Root" | tail -n1 | awk {'print $1'} )
fi
local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
local packagename="${1##*/}"
local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )
find "${1}" -name '.DS_Store' -delete
local filecount=$( find "${1}/Root" | wc -l )
if [ "${3}" ]; then
local installedsize="${3}"
else
local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )
fi
local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
header+="identifier=\"${packageRefId}\" "
header+="version=\"${version}\" "
header+="identifier=\"${identifier}\" "
header+="version=\"${version}\" "
[ "${targetPath}" != "relocatable" ] && header+="install-location=\"${targetPath}\" "
[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
rm -R -f "${packagePath}/Temp"
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
rm -R -f "${1}/Temp"
[ -d "${packagePath}/Temp" ] || mkdir -m 777 "${packagePath}/Temp"
[ -d "${packagePath}/Root" ] && mkbom "${packagePath}/Root" "${packagePath}/Temp/Bom"
[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
if [ -d "${packagePath}/Scripts" ]; then
header+="\t<scripts>\n"
for script in $( find "${packagePath}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) ); do
header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
done
header+="\t</scripts>\n"
# Create the Script archive file (cpio format)
(cd "${packagePath}/Scripts" && find . -print | cpio -o -z -R 0:0 --format cpio > "${packagePath}/Temp/Scripts") 2>&1 | \
grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages
fi
if [ -d "${1}/Scripts" ]; then
header+="\t<scripts>\n"
for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )
do
header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
done
header+="\t</scripts>\n"
chown -R 0:0 "${1}/Scripts"
pushd "${1}/Scripts" >/dev/null
find . -print | cpio -o -z -H cpio > "../Temp/Scripts"
popd >/dev/null
fi
header+="</pkg-info>"
echo -e "${header}" > "${packagePath}/Temp/PackageInfo"
header+="</pkg-info>"
echo -e "${header}" > "${1}/Temp/PackageInfo"
pushd "${1}/Root" >/dev/null
find . -print | cpio -o -z -H cpio > "../Temp/Payload"
popd >/dev/null
pushd "${1}/Temp" >/dev/null
# Create the Payload file (cpio format)
(cd "${packagePath}/Root" && find . -print | cpio -o -z -R 0:0 --format cpio > "${packagePath}/Temp/Payload") 2>&1 | \
grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages
xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
# Create the package
(cd "${packagePath}/Temp" && xar -c -f "${packagePath}/../${packageName}.pkg" --compression none .)
popd >/dev/null
# Add the package to the list of build packages
pkgrefs[${#pkgrefs[*]}]="\t<pkg-ref id=\"${packageRefId}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}'>#${packageName}.pkg</pkg-ref>"
outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"${packagename// /}\"/>"
if [ "${4}" ]; then
local choiceoptions="\t\t${4}"
rm -rf "${packagePath}"
fi
choices[$((choicescount++))]="\t<choice\n\t\tid=\"${packagename// /}\"\n\t\ttitle=\"${packagename}_title\"\n\t\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' >#${packagename// /}.pkg</pkg-ref>\n\t</choice>\n"
rm -R -f "${1}"
fi
}
makedistribution ()
{
rm -f "${1%/*}/${packagename// /}"*.pkg
distributionDestDir="${1%/*}"
distributionFilename="${packagename// /}-${version}-r${revision}.pkg"
distributionFilePath="${distributionDestDir}/${distributionFilename}"
find "${1}" -type f -name '*.pkg' -depth 1 | while read component
rm -f "${distributionDestDir}/${packagename// /}"*.pkg
mkdir -p "${1}/${packagename}"
find "${1}" -type f -name '*.pkg' -depth 1 | while read component
do
mkdir -p "${1}/${packagename}/${component##*/}"
pushd "${1}/${packagename}/${component##*/}" >/dev/null
xar -x -f "${1%}/${component##*/}"
popd >/dev/null
pkg="${component##*/}" # ie: EFI.pkg
pkgdir="${1}/${packagename}/${pkg}"
# expand individual packages
pkgutil --expand "${1%}/${pkg}" "$pkgdir"
rm -f "${1%}/${pkg}"
done
# Create the Distribution file
ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
for (( i=0; i < ${#outline[*]} ; i++)); do
echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
done
ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
for (( i=0; i < ${#choices[*]} ; i++)); do
echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
done
find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
for (( i=0; i < ${#pkgrefs[*]} ; i++)); do
echo -e "${pkgrefs[$i]}" >> "${1}/${packagename}/Distribution"
done
for (( i=0; i < ${#outline[*]} ; i++));
do
echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
done
echo -e "\n</installer-gui-script>" >> "${1}/${packagename}/Distribution"
for (( i=0; i < ${#choices[*]} ; i++));
do
echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
done
# Create the Resources directory
ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"
# CleanUp the directory
find "${1}/${packagename}" -type d -name '.svn' -exec rm -rf {} \; 2>/dev/null
find "${1}/${packagename}" -name '.DS_Store' -delete
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`
# 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 )
# 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`
# 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 )
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`
# 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 )
find "${1}/${packagename}" -name '.DS_Store' -delete
pushd "${1}/${packagename}" >/dev/null
xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .
popd >/dev/null
# Create the final package
pkgutil --flatten "${1}/${packagename}" "${distributionFilePath}"
# Here is the place for assign a Icon to the pkg
# command use to generate the file:
# ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip
# ----
ditto -xk "${pkgroot}/Icons/pkg.zip" "${pkgroot}/Icons/"
DeRez -only icns "${pkgroot}/Icons/Icons/pkg.icns" > tempicns.rsrc
Rez -append tempicns.rsrc -o "${1%/*}/$packagename-${version}-r$revision.pkg"
SetFile -a C "${1%/*}/$packagename-${version}-r$revision.pkg"
rm -f tempicns.rsrc
rm -rf "${pkgroot}/Icons/Icons"
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}"
SetFile -a C "${distributionFilePath}"
rm -rf "${1}/Icons"
# End
md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" | awk {'print $4'} )
echo "MD5 (${packagename// /}-${version}-r${revision}.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}.pkg.md5"
echo ""
md5=$( md5 "${distributionFilePath}" | awk {'print $4'} )
echo "MD5 (${distributionFilePath}) = ${md5}" > "${distributionFilePath}.md5"
echo ""
echo -e $COL_GREEN"--------------------------"$COL_RESET
echo -e $COL_GREEN"Building process complete!"$COL_RESET
echo -e $COL_GREEN"--------------------------"$COL_RESET
echo ""
echo -e $COL_GREEN"Build info."
echo -e $COL_GREEN"==========="
echo -e $COL_BLUE"Package name:"$COL_RESET"$packagename-${version}-r$revision.pkg"
echo -e $COL_BLUE"MD5:"$COL_RESET"$md5"
echo -e $COL_BLUE"Version:"$COL_RESET"$version"
echo -e $COL_BLUE"Stage:"$COL_RESET"$stage"
echo -e $COL_BLUE"Date/Time:"$COL_RESET"$builddate"
echo ""
echo -e $COL_GREEN" --------------------------"$COL_RESET
echo -e $COL_GREEN" Building process complete!"$COL_RESET
echo -e $COL_GREEN" --------------------------"$COL_RESET
echo ""
echo -e $COL_GREEN" Build info."
echo -e $COL_GREEN" ==========="
echo -e $COL_BLUE" Package name: "$COL_RESET"${distributionFilename}"
echo -e $COL_BLUE" MD5: "$COL_RESET"$md5"
echo -e $COL_BLUE" Version: "$COL_RESET"$version"
echo -e $COL_BLUE" Stage: "$COL_RESET"$stage"
echo -e $COL_BLUE" Date/Time: "$COL_RESET"$builddate"
echo ""
}
main "${1}" "${2}" "${3}" "${4}" #"${5}"
trunk/Makefile
9999
100100
101101
102
102
103103
104104
105105
......
122122
123123
124124
125
126
127
128
125
129126
127
128
129
130
130131
131132
132133
@gzip --best ${DISTFILE}.tar
@mv ${DISTFILE}.tar.gz ${DISTFILE}.tgz
clean-local:
clean-local: clean-pkg-local
@if [ -f "$(HEADER_VERSION)" ];then echo "\t[RM] $(HEADER_VERSION)"; fi
@if [ -f "$(SRCROOT)/revision" ];then echo "\t[RM] $(SRCROOT)/revision"; fi
@rm -f $(HEADER_VERSION) $(SRCROOT)/revision
$(SRCROOT)/autoconf.inc
pkg installer: all
${SRCROOT}/package/buildpkg.sh ${SYMROOT}/package;
@echo "\t[ZIP] ${DISTFILE}.pkg"
@ditto -c -k --sequesterRsrc ${DISTFILE}.pkg ${DISTFILE}.pkg.zip
@rm -r ${DISTFILE}.pkg
${SRCROOT}/package/buildpkg.sh ${SYMROOT}/package
clean-pkg-local:
@if [ -d "$(SYMROOT)/package" ];then echo "\t[RMDIR] $(SYMROOT)/package"; fi
@rm -rf "$(SYMROOT)/package"
.PHONY: config
.PHONY: clean
.PHONY: image

Archive Download the corresponding diff file

Revision: 1741