Chameleon Applications

Chameleon Applications Commit Details

Date:2010-09-28 05:12:16 (13 years 6 months ago)
Author:ErmaC
Commit:156
Parents: 155
Message:Following the scrax's suggestions: 1) updated the script to boot0 and boot0hfs thanks to "el conigliot" 2) made changes to main make. Now we have: make pkg (Standard) make efipkg (EFI) make advanced (advanced) testing a new background. Now we have a ready and working (make pkg) version ;) More info --> http://forum.voodooprojects.org/index.php/topic,1521.0.html post #83
Changes:
D/branches/iFabio/Test/package/basic
D/branches/iFabio/Test/package/buildpkgTEST
A/branches/iFabio/Test/package/efipkg
M/branches/iFabio/Test/package/Scripts/Post/postinstall
M/branches/iFabio/Test/package/Resources/Italian.lproj/Localizable.strings
M/branches/iFabio/Test/package/Resources/background.tiff
M/branches/iFabio/Test/package/buildpkg
M/branches/iFabio/Test/Makefile
M/branches/iFabio/Test/package/Scripts/Standard/postinstall
M/branches/iFabio/Test/revision
M/branches/iFabio/Test/package/Scripts/Standardhfs/postinstall

File differences

branches/iFabio/Test/package/basic
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
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
280
281
282
283
284
#!/bin/bash
# $1 Path to store built package
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
#version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
version=$( cat version )
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
distributioncount=0
xmlindent=0
indent[0]="\t"
indent[1]="\t\t"
indent[2]="\t\t\t"
indent[3]="\t\t\t\t"
main ()
{
# clean up the destination path
rm -R -f "${1}"
echo "Building $packagename Install Package (Basic) v${version%%-*} $stage r$revision $builddate"
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# Start
# build Chameleon metapackages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"
choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"
((xmlindent++))
# build core package
mkdir -p ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot0hfs ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/i386
cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/i386
cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/i386
cp -f ${pkgroot}/fdisk440 ${1}/Core/Root/i386
fixperms "${1}/Core/Root/i386"
local coresize=$( du -hkc "${1}/Core/Root/i386" | tail -n1 | awk {'print $1'} )
echo "Building core package"
buildpackage "${1}/Core" "/binaries" "0" "start_visible=\"false\" start_selected=\"true\""
# End build core package
# build standard package
mkdir -p ${1}/boot0/Root
mkdir -p ${1}/boot0/Scripts
cp -f ${pkgroot}/Scripts/boot0/postinstall ${1}/boot0/Scripts
echo "Building boot0 package"
buildpackage "${1}/boot0" "/binaries" "${coresize}" "start_enabled=\"true\" start_selected=\"false\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['boot0hfs']) &amp;&amp; exclusive(choices['EnhancedFAT']) &amp;&amp; exclusive(choices['noboot'])\""
# End build standard package
# build standard package with boot0hfs
mkdir -p ${1}/boot0hfs/Root
mkdir -p ${1}/boot0hfs/Scripts
cp -f ${pkgroot}/Scripts/boot0hfs/postinstall ${1}/boot0hfs/Scripts
echo "Building boot0hfs package"
buildpackage "${1}/boot0hfs" "/binaries" "${coresize}" "start_enabled=\"true\" start_selected=\"false\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['boot0']) &amp;&amp; exclusive(choices['EnhancedFAT']) &amp;&amp; exclusive(choices['noboot'])\""
# End build standard package with boot0hfs
# build efi fat32 package
mkdir -p ${1}/EnhancedFAT/Root
mkdir -p ${1}/EnhancedFAT/Scripts/Tools
cp -f ${pkgroot}/Scripts/FAT/postinstall ${1}/EnhancedFAT/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedFAT/Scripts/Tools/SetFile
echo "Building EnhacedFAT package"
buildpackage "${1}/EnhancedFAT" "/binaries" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['boot0']) &amp;&amp; exclusive(choices['boot0hfs']) &amp;&amp; exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['noboot'])\""
# End build efi fat32 package
# build efi hfs package
mkdir -p ${1}/EnhancedHFS/Root
mkdir -p ${1}/EnhancedHFS/Scripts/Tools
cp -f ${pkgroot}/Scripts/HFS/postinstall ${1}/EnhancedHFS/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedHFS/Scripts/Tools/SetFile
echo "Building EnhacedHFS package"
buildpackage "${1}/EnhancedHFS" "/binaries" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['boot0']) &amp;&amp; exclusive(choices['boot0hfs']) &amp;&amp; exclusive(choices['EnhancedFAT']) &amp;&amp; exclusive(choices['noboot'])\""
# End build efi hfs package
# build reset choice package
mkdir -p ${1}/noboot/Root
echo "Building reset choice package"
buildpackage "${1}/noboot" "/binaries" "${coresize}" "start_visible=\"true\" start_selected=\"true\" selected=\"exclusive(choices['boot0']) &amp;&amp; exclusive(choices['boot0hfs']) &amp;&amp; exclusive(choices['EnhancedFAT']) &amp;&amp; exclusive(choices['EnhancedHFS'])\""
# End build reset choice package
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# End Chameleon metapakage
# build theme packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"
choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.theme"
artwork="${1%/*}"
themes=($( find "${artwork%/*}/artwork/themes" -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/"
ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}"
find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+
buildpackage "${1}/${theme}" "/Extra/Themes" "" "start_selected=\"false\""
rm -R -f "${1}/${i##*/}"
done
echo "Building themes package"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# End build theme packages
# build post install package
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts
buildpackage "${1}/Post" "/binaries" "" "start_visible=\"false\" start_selected=\"true\""
echo "Building post package"
# End post install package
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# End main package
# build meta package
makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
# clean up
rm -R -f "${1}"
}
fixperms ()
{
# $1 path
find "${1}" -type f -exec chmod 644 {} \;
find "${1}" -type d -exec chmod 755 {} \;
chown -R 0:0 "${1}"
}
buildpackage ()
{
# $1 Path to package to build containing Root and or Scripts
# $2 Install Location
# $3 Size
# $4 Options
if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
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\" "
header+="identifier=\"${identifier}\" "
header+="version=\"${version}\" "
[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
rm -R -f "${1}/Temp"
[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
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}" > "${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
xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
popd >/dev/null
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
if [ "${4}" ]; then
local choiceoptions="${indent[$xmlindent]}${4}\n"
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}"
fi
}
makedistribution ()
{
rm -f "${1%/*}/${packagename// /}"-Basic.pkg
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
done
ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
echo "Building Resources..."
find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
for (( i=0; i < ${#outline[*]} ; i++));
do
echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
done
for (( i=0; i < ${#choices[*]} ; i++));
do
echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
done
echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"
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/%PKGTYPE%/Basic/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`
find "${1}/${packagename}" -name '.DS_Store' -delete
pushd "${1}/${packagename}" >/dev/null
xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}-Basic.pkg" --compression none .
popd >/dev/null
md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}-Basic.pkg" | awk {'print $4'} )
echo "MD5 (${packagename// /}-${version}-r${revision}-Basic.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}-Basic.pkg.md5"
cp -R -f "${1}/${packagename}/Resources" ${1%/*}/Resources
echo "Finish! $packagename Install Package (Basic) v${version%%-*} $stage r$revision was created"
}
main "${1}" "${2}" "${3}" "${4}" "${5}"
branches/iFabio/Test/package/buildpkgTEST
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
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
280
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
306
307
308
309
310
311
312
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
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
#!/bin/bash
# $1 Path to store built package
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
#version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
version=$( cat version )
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
distributioncount=0
xmlindent=0
indent[0]="\t"
indent[1]="\t\t"
indent[2]="\t\t\t"
indent[3]="\t\t\t\t"
main ()
{
# clean up the destination path
rm -R -f "${1}"
echo "Building $packagename Install Package v${version%%-*} $stage r$revision $builddate"
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build core package
((xmlindent++))
packagesidentity="org.chameleon"
mkdir -p ${1}/Core/Root/usr/sbin
#mkdir -p ${1}/Core/Root/usr/local/bin
mkdir -p ${1}/Core/Root/usr/standalone/i386
#mkdir -p ${1}/Core/Root/Extra
cp -f ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot0hfs ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/sbin
fixperms "${1}/Core/Root/"
#cp -Rf ${pkgroot}/Configuration/Chameleon.prefPane ${1}/Core/Root/Library/PreferencePanes
#cp -f ${pkgroot}/Configuration/smbios.plist ${1}/Core/Root/Extra
cp -f ${pkgroot}/fdisk440 ${1}/Core/Root/usr/sbin
local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\""
# build Chameleon package
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"
choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Tools
cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts
ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build standard package with boot0hfs
mkdir -p ${1}/Standardhfs/Root
mkdir -p ${1}/Standardhfs/Scripts/Tools
cp -f ${pkgroot}/Scripts/Standardhfs/* ${1}/Standardhfs/Scripts
ditto --arch i386 `which SetFile` ${1}/Standardhfs/Scripts/Tools/SetFile
buildpackage "${1}/Standardhfs" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"false\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build efi fat32 package
mkdir -p ${1}/EnhancedFAT/Root
mkdir -p ${1}/EnhancedFAT/Scripts/Tools
cp -f ${pkgroot}/Scripts/FAT/* ${1}/EnhancedFAT/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedFAT/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedFAT" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['EnhancedHFS'])\""
# build efi hfs package
mkdir -p ${1}/EnhancedHFS/Root
mkdir -p ${1}/EnhancedHFS/Scripts/Tools
cp -f ${pkgroot}/Scripts/HFS/* ${1}/EnhancedHFS/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedHFS/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedHFS" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build PrefPanel package
#mkdir -p ${1}/PrefPanel/Root
#mkdir -p ${1}/PrefPanel/Root/Library/PreferencePanes
#cp -Rf ${pkgroot}/Configuration/Chameleon.prefPane ${1}/PrefPanel/Root/Library/PreferencePanes
#buildpackage "${1}/PrefPanel" "/" "${coresize}" "start_visible=\"true\" start_selected=\"false\""
# build utility package
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Utility\">"
choices[$((choicescount++))]="<choice\n\tid=\"Utility\"\n\ttitle=\"Utility_title\"\n\tdescription=\"Utility_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
# build package for bdmesg
#mkdir -p "${1}/bdmesg/Root"
#ditto --noextattr --noqtn "${1%/*}/i386/bdmesg" "${1}/bdmesg/Root"
#echo "Building bdmesg package"
#buildpackage "${1}/bdmesg" "/usr/sbin" "" "start_selected=\"false\""
# End build package for bdmesg
# build package for Chameleon PrefPanel
mkdir -p "${1}/PrefPanel/Root/"
ditto --noextattr --noqtn "${pkgroot}/Configuration/PrefPanel/Chameleon.prefPane" "${1}/PrefPanel/Root"
echo "Building Chameleon Preference Panel package"
buildpackage "${1}/PrefPanel" "/Library/PreferencePanes/Chameleon.prefPane" "" "start_selected=\"false\""
# End build package for Chameleon PrefPanel
# build package for SMBIOSDefault
mkdir -p "${1}/SMBIOSDefault/Root/"
ditto --noextattr --noqtn "${pkgroot}/Configuration/SMBIOSDefault/smbios.plist" "${1}/SMBIOSDefault/Root"
echo "Building SMBIOSDefault package"
buildpackage "${1}/SMBIOSDefault" "/Extra/Example" "" "start_selected=\"false\""
# End build package for SMBIOSDefault
# build package for EFIMounter
mkdir -p "${1}/EFIMounter/Root/"
ditto --noextattr --noqtn "${pkgroot}/Configuration/EFIMounter/EFI Mounter.app" "${1}/EFIMounter/Root"
echo "Building EFIMounter package"
buildpackage "${1}/EFIMounter" "/Applications/EFI Mounter.app" "" "start_selected=\"false\""
# End build package for EFIMounter
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# End utility package
# build Documentation package
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Documentation\">"
#choices[$((choicescount++))]="<choice\n\tid=\"Documentation\"\n\ttitle=\"Documentation_title\"\n\tdescription=\"Documentation_description\"\n>\n</choice>\n"
#((xmlindent++))
#packagesidentity="org.chameleon"
# build package for Documentation
#mkdir -p "${1}/Documentation/Root"
#cp -f ${pkgroot}/doc/BootHelp.txt ${1}/Documentation/Root
#cp -f ${pkgroot}/doc/README ${1}/Documentation/Root
#cp -f ${pkgroot}/doc/Users_Guide0.5.pdf ${1}/Documentation/Root
#echo "Building Documentation package"
#buildpackage "${1}/Documentation" "/Documentation/Chameleon2RC5" "" "start_selected=\"false\""
# End build package for bdmesg
#((xmlindent--))
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# End utility package
# build options packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"
choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.options"
options=($( find "${pkgroot}/Scripts/Options" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#options[@]} ; i++))
do
packagesidentity="org.chameleon.${#options[@]}"
flagname=($( find "${options[$i]}" -type d -depth 1 -not -name '.svn' ))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${options[$i]##*/}\">"
choices[$((choicescount++))]="<choice\n\tid=\"${options[$i]##*/}\"\n\ttitle=\"${options[$i]##*/}\"\n\tdescription=\"${options[$i]##*/}_description\"\n>\n</choice>\n"
((xmlindent++))
for (( j = 0 ; j < ${#flagname[@]} ; j++))
do
packagesidentity="org.chameleon.${#flagname[@]}"
# outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${options[$i]##*/}${flagname[$j]##*/}\">"
choices[$((choicescount++))]="<choice\n\tid=\"${options[$i]##*/}${flagname[$j]##*/}\"\n\ttitle=\"${options[$i]##*/}${flagname[$j]##*/}_title\"\n\tdescription=\"${options[$i]##*/}${flagname[$j]##*/}_description\"\n>\n</choice>\n"
((xmlindent++))
mkdir -p "${1}/${options[$i]##*/}${flagname[$j]##*/}/Root"
mkdir -p "${1}/${options[$i]##*/}${flagname[$j]##*/}/Scripts"
cp -f "${flagname[$j]}/postinstall" "${1}/${options[$i]##*/}${flagname[$j]##*/}/Scripts"
echo "Building ${options[$i]##*/}${flagname[$j]##*/} package"
buildpackage "${1}/${options[$i]##*/}${flagname[$j]##*/}" "/" "" "start_selected=\"false\""
rm -R -f "${1}/${j##*/}"
((xmlindent--))
# outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
echo "Building ${options[$i]##*/} package"
buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\""
rm -R -f "${1}/${i##*/}"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# End build options packages
# build options packages
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"
#choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"
#((xmlindent++))
#packagesidentity="org.chameleon"
#options=($( find "${pkgroot}/Scripts/Options" -type d -depth 1 -not -name '.svn' ))
#for (( i = 0 ; i < ${#options[@]} ; i++ ))
#do
#mkdir -p "${1}/${options[$i]##*/}/Root"
#mkdir -p "${1}/${options[$i]##*/}/Scripts"
#
#ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall"
#buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\""
#done
#((xmlindent--))
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build resolution packages
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Resolution\">"
#choices[$((choicescount++))]="<choice\n\tid=\"Resolution\"\n\ttitle=\"Resolution_title\"\n\tdescription=\"Resolution_description\"\n>\n</choice>\n"
#((xmlindent++))
#packagesidentity="org.chameleon.resolution"
#resolutions=($( find "${pkgroot}/Scripts/Resolutions" -type d -depth 1 -not -name '.svn' ))
#for (( i = 0 ; i < ${#resolutions[@]} ; i++ ))
#do
#mkdir -p "${1}/${resolutions[$i]##*/}/Root/"
#mkdir -p "${1}/${resolutions[$i]##*/}/Scripts/"
#ditto --noextattr --noqtn "${resolutions[$i]}/postinstall" "${1}/${resolutions[$i]##*/}/Scripts/postinstall"
#buildpackage "${1}/${resolutions[$i]##*/}" "/" "" "start_selected=\"false\""
#done
#((xmlindent--))
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build theme packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"
choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.theme"
artwork="${1%/*}"
themes=($( find "${artwork%/*}/artwork/themes" -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/"
ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}"
find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+
buildpackage "${1}/${theme}" "/.Chameleon/Extra/Themes" "" "start_selected=\"false\""
rm -R -f "${1}/${i##*/}"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Extras\">"
choices[$((choicescount++))]="<choice\n\tid=\"Extras\"\n\ttitle=\"Extras_title\"\n\tdescription=\"Extras_description\"\n>\n</choice>\n"
((xmlindent++))
# build kext packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Kexts\">"
choices[$((choicescount++))]="<choice\n\tid=\"Kexts\"\n\ttitle=\"Kexts_title\"\n\tdescription=\"Kexts_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
kexts=($( find "${pkgroot}/Kexts" -type d -name '*.kext' -depth 1 ))
for (( i = 0 ; i < ${#kexts[@]} ; i++ ))
do
filename="${kexts[$i]##*/}"
mkdir -p "${1}/${filename%.kext}/Root/"
ditto --noextattr --noqtn --arch i386 "${kexts[$i]}" "${1}/${filename%.kext}/Root/${filename}"
find "${1}/${filename%.kext}" -name '.DS_Store' -or -name '.svn' -exec rm -R -f {} \; 2>/dev/null
fixperms "${1}/${filename%.kext}/Root/"
chown 501:20 "${1}/${filename%.kext}/Root/"
buildpackage "${1}/${filename%.kext}" "/.Chameleon/Extra/Extensions" "" "start_selected=\"false\""
rm -R -f "${1}/${filename%.kext}"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build post install package
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts
buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\""
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# build meta package
makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
# clean up
rm -R -f "${1}"
}
fixperms ()
{
# $1 path
find "${1}" -type f -exec chmod 644 {} \;
find "${1}" -type d -exec chmod 755 {} \;
chown -R 0:0 "${1}"
}
buildpackage ()
{
# $1 Path to package to build containing Root and or Scripts
# $2 Install Location
# $3 Size
# $4 Options
if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
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\" "
header+="identifier=\"${identifier}\" "
header+="version=\"${version}\" "
[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
rm -R -f "${1}/Temp"
[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
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}" > "${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
xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
popd >/dev/null
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
if [ "${4}" ]; then
local choiceoptions="${indent[$xmlindent]}${4}\n"
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}"
fi
}
makedistribution ()
{
rm -f "${1%/*}/${packagename// /}"*.pkg
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
done
ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
for (( i=0; i < ${#outline[*]} ; i++));
do
echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
done
for (( i=0; i < ${#choices[*]} ; i++));
do
echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
done
echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"
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`
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`
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
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"
}
main "${1}" "${2}" "${3}" "${4}" "${5}"
branches/iFabio/Test/package/buildpkg
3030
3131
3232
33
33
3434
3535
3636
37
37
3838
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
39
6540
6641
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
11542
116
11743
118
119
120
121
122
123
44
45
46
47
48
49
50
51
52
53
54
55
12456
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
57
14958
150
151
152
153
154
59
60
61
62
63
64
65
66
15567
156
157
158
159
160
161
162
163
164
165
166
167
68
69
70
71
72
73
74
75
16876
169
77
78
79
80
81
17082
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
18683
187
84
18885
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
20886
20987
21088
21189
21290
213
214
215
216
217
218
219
220
221
222
91
92
22393
224
225
226
94
95
96
97
98
99
227100
228
229
101
102
103
104
105
106
230107
231
232
108
109
110
111
112
113
233114
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
115
255116
256
117
257118
258
259
260
261119
262
263120
264121
265
266
267
122
123
124
125
268126
127
128
269129
270130
271131
......
355215
356216
357217
358
218
359219
360220
361221
......
367227
368228
369229
370
230
371231
372232
373233
......
384244
385245
386246
387
247
248
249
388250
389251
390252
391253
392254
393255
394
256
395257
396258
397
398
259
260
261
262
263
264
399265
400266
401267
402
rm -R -f "${1}"
echo "Building $packagename Install Package v${version%%-*} $stage r$revision $builddate"
echo "Building $packagename Install Package (Standard) v${version%%-*} $stage r$revision $builddate"
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build core package
# Start
((xmlindent++))
packagesidentity="org.chameleon"
mkdir -p ${1}/Core/Root/usr/sbin
#mkdir -p ${1}/Core/Root/usr/local/bin
mkdir -p ${1}/Core/Root/usr/standalone/i386
#mkdir -p ${1}/Core/Root/Extra
cp -f ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot0hfs ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/sbin
fixperms "${1}/Core/Root/"
#cp -Rf ${pkgroot}/Configuration/Chameleon.prefPane ${1}/Core/Root/Library/PreferencePanes
#cp -f ${pkgroot}/Configuration/smbios.plist ${1}/Core/Root/Extra
cp -f ${pkgroot}/fdisk440 ${1}/Core/Root/usr/sbin
local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\""
# build Chameleon package
# build Chameleon package
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"
choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Tools
cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts
ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build standard package with boot0hfs
mkdir -p ${1}/Standardhfs/Root
mkdir -p ${1}/Standardhfs/Scripts/Tools
cp -f ${pkgroot}/Scripts/Standardhfs/* ${1}/Standardhfs/Scripts
ditto --arch i386 `which SetFile` ${1}/Standardhfs/Scripts/Tools/SetFile
buildpackage "${1}/Standardhfs" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"false\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build efi fat32 package
mkdir -p ${1}/EnhancedFAT/Root
mkdir -p ${1}/EnhancedFAT/Scripts/Tools
cp -f ${pkgroot}/Scripts/FAT/* ${1}/EnhancedFAT/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedFAT/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedFAT" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['EnhancedHFS'])\""
# build efi hfs package
mkdir -p ${1}/EnhancedHFS/Root
mkdir -p ${1}/EnhancedHFS/Scripts/Tools
cp -f ${pkgroot}/Scripts/HFS/* ${1}/EnhancedHFS/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedHFS/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedHFS" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build PrefPanel package
#mkdir -p ${1}/PrefPanel/Root
#mkdir -p ${1}/PrefPanel/Root/Library/PreferencePanes
#cp -Rf ${pkgroot}/Configuration/Chameleon.prefPane ${1}/PrefPanel/Root/Library/PreferencePanes
#buildpackage "${1}/PrefPanel" "/" "${coresize}" "start_visible=\"true\" start_selected=\"false\""
# build utility package
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Utility\">"
choices[$((choicescount++))]="<choice\n\tid=\"Utility\"\n\ttitle=\"Utility_title\"\n\tdescription=\"Utility_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
# build package for bdmesg
#mkdir -p "${1}/bdmesg/Root"
#ditto --noextattr --noqtn "${1%/*}/i386/bdmesg" "${1}/bdmesg/Root"
#echo "Building bdmesg package"
#buildpackage "${1}/bdmesg" "/usr/sbin" "" "start_selected=\"false\""
# End build package for bdmesg
# build core package
mkdir -p ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot0hfs ${1}/Core/Root/i386
cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/i386
cp -f ${pkgroot}/fdisk440 ${1}/Core/Root/i386
cp -f ${pkgroot}/fdisk ${1}/Core/Root/i386
fixperms "${1}/Core/Root/i386"
local coresize=$( du -hkc "${1}/Core/Root/i386" | tail -n1 | awk {'print $1'} )
echo "Building core package"
buildpackage "${1}/Core" "/binaries" "0" "start_visible=\"false\" start_selected=\"true\""
# build package for Chameleon PrefPanel
mkdir -p "${1}/PrefPanel/Root/"
ditto --noextattr --noqtn "${pkgroot}/Configuration/PrefPanel/Chameleon.prefPane" "${1}/PrefPanel/Root"
echo "Building Chameleon Preference Panel package"
buildpackage "${1}/PrefPanel" "/Library/PreferencePanes/Chameleon.prefPane" "" "start_selected=\"false\""
# End build package for Chameleon PrefPanel
# build package for SMBIOSDefault
mkdir -p "${1}/SMBIOSDefault/Root/"
ditto --noextattr --noqtn "${pkgroot}/Configuration/SMBIOSDefault/smbios.plist" "${1}/SMBIOSDefault/Root"
echo "Building SMBIOSDefault package"
buildpackage "${1}/SMBIOSDefault" "/Extra/Example" "" "start_selected=\"false\""
# End build package for SMBIOSDefault
# build package for EFIMounter
mkdir -p "${1}/EFIMounter/Root/"
ditto --noextattr --noqtn "${pkgroot}/Configuration/EFIMounter/EFI Mounter.app" "${1}/EFIMounter/Root"
echo "Building EFIMounter package"
buildpackage "${1}/EFIMounter" "/Applications/EFI Mounter.app" "" "start_selected=\"false\""
# End build package for EFIMounter
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# End utility package
# End build core package
# build Documentation package
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Documentation\">"
#choices[$((choicescount++))]="<choice\n\tid=\"Documentation\"\n\ttitle=\"Documentation_title\"\n\tdescription=\"Documentation_description\"\n>\n</choice>\n"
#((xmlindent++))
#packagesidentity="org.chameleon"
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts
cp -f ${pkgroot}/Scripts/Standard/postinstall ${1}/Standard/Scripts
ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile
echo "Building boot0 package"
buildpackage "${1}/Standard" "/binaries" "${coresize}" "start_enabled=\"true\" start_selected=\"true\" selected=\"exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['noboot'])\""
# End build standard package
# build package for Documentation
#mkdir -p "${1}/Documentation/Root"
#cp -f ${pkgroot}/doc/BootHelp.txt ${1}/Documentation/Root
#cp -f ${pkgroot}/doc/README ${1}/Documentation/Root
#cp -f ${pkgroot}/doc/Users_Guide0.5.pdf ${1}/Documentation/Root
#echo "Building Documentation package"
#buildpackage "${1}/Documentation" "/Documentation/Chameleon2RC5" "" "start_selected=\"false\""
# End build package for bdmesg
#((xmlindent--))
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# End utility package
# build standard package with boot0hfs
mkdir -p ${1}/Standardhfs/Root
mkdir -p ${1}/Standardhfs/Scripts
cp -f ${pkgroot}/Scripts/Standardhfs/postinstall ${1}/Standardhfs/Scripts
ditto --arch i386 `which SetFile` ${1}/Standardhfs/Scripts/Tools/SetFile
echo "Building boot0hfs package"
buildpackage "${1}/Standardhfs" "/binaries" "${coresize}" "start_enabled=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\""
# End build standard package with boot0hfs
ß# build options packages
# build reset choice package
mkdir -p ${1}/noboot/Root
#echo "Building reset choice package"
buildpackage "${1}/noboot" "/binaries" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['Standardhfs'])\""
# End build reset choice package
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"
choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
options=($( find "${pkgroot}/Scripts/Options" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#options[@]} ; i++ ))
do
mkdir -p "${1}/${options[$i]##*/}/Root"
mkdir -p "${1}/${options[$i]##*/}/Scripts"
ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall"
buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\""
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>" # End Chameleon pakage
# build resolution packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Resolution\">"
choices[$((choicescount++))]="<choice\n\tid=\"Resolution\"\n\ttitle=\"Resolution_title\"\n\tdescription=\"Resolution_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.resolution"
resolutions=($( find "${pkgroot}/Scripts/Resolutions" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#resolutions[@]} ; i++ ))
do
mkdir -p "${1}/${resolutions[$i]##*/}/Root/"
mkdir -p "${1}/${resolutions[$i]##*/}/Scripts/"
ditto --noextattr --noqtn "${resolutions[$i]}/postinstall" "${1}/${resolutions[$i]##*/}/Scripts/postinstall"
buildpackage "${1}/${resolutions[$i]##*/}" "/" "" "start_selected=\"false\""
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build theme packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"
choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.theme"
artwork="${1%/*}"
themes=($( find "${artwork%/*}/artwork/themes" -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/"
ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}"
find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+
packagesidentity="org.chameleon.theme"
artwork="${1%/*}"
buildpackage "${1}/${theme}" "/.Chameleon/Extra/Themes" "" "start_selected=\"false\""
rm -R -f "${1}/${i##*/}"
done
# Embed
mkdir -p ${1}/Embed/Root
ditto --noextattr --noqtn ${artwork%/*}/artwork/themes/embed ${1}/Embed/Root/Embed
find ${1}/Embed/ -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
find ${1}/Embed/ -type f -exec chmod 644 {} \+
buildpackage "${1}/Embed" "/Extra/Themes" "" "start_selected=\"false\""
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# Legacy
mkdir -p ${1}/Embed/Root
ditto --noextattr --noqtn ${artwork%/*}/artwork/themes/legacy ${1}/Legacy/Root/Legacy
find ${1}/Legacy/ -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
find ${1}/Legacy/ -type f -exec chmod 644 {} \+
buildpackage "${1}/Legacy" "/Extra/Themes" "" "start_selected=\"false\""
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Extras\">"
choices[$((choicescount++))]="<choice\n\tid=\"Extras\"\n\ttitle=\"Extras_title\"\n\tdescription=\"Extras_description\"\n>\n</choice>\n"
# Default
mkdir -p ${1}/Default/Root
ditto --noextattr --noqtn ${artwork%/*}/artwork/themes/default ${1}/Default/Root/Default
find ${1}/Default/ -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
find ${1}/Default/ -type f -exec chmod 644 {} \+
buildpackage "${1}/Default" "/Extra/Themes" "" "start_selected=\"false\""
((xmlindent++))
# build kext packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Kexts\">"
choices[$((choicescount++))]="<choice\n\tid=\"Kexts\"\n\ttitle=\"Kexts_title\"\n\tdescription=\"Kexts_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
kexts=($( find "${pkgroot}/Kexts" -type d -name '*.kext' -depth 1 ))
for (( i = 0 ; i < ${#kexts[@]} ; i++ ))
do
filename="${kexts[$i]##*/}"
mkdir -p "${1}/${filename%.kext}/Root/"
ditto --noextattr --noqtn --arch i386 "${kexts[$i]}" "${1}/${filename%.kext}/Root/${filename}"
find "${1}/${filename%.kext}" -name '.DS_Store' -or -name '.svn' -exec rm -R -f {} \; 2>/dev/null
fixperms "${1}/${filename%.kext}/Root/"
chown 501:20 "${1}/${filename%.kext}/Root/"
buildpackage "${1}/${filename%.kext}" "/.Chameleon/Extra/Extensions" "" "start_selected=\"false\""
rm -R -f "${1}/${filename%.kext}"
done
echo "Building themes package"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>" # End build theme packages
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build post install package
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts
buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\""
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
cp -f ${pkgroot}/Scripts/Post/postinstall ${1}/Post/Scripts
ditto --arch i386 `which SetFile` ${1}/Post/Scripts/Tools/SetFile
buildpackage "${1}/Post" "/binaries" "" "start_visible=\"false\" start_selected=\"true\""
echo "Building post package" # End post install package
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>" # End main package
# build meta package
makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
makedistribution ()
{
rm -f "${1%/*}/${packagename// /}"*.pkg
rm -f "${1%/*}/${packagename// /}"-Standard.pkg
find "${1}" -type f -name '*.pkg' -depth 1 | while read component
do
ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
echo "Building Resources..."
find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
for (( i=0; i < ${#outline[*]} ; i++));
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/%PKGTYPE%/Standard/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`
find "${1}/${packagename}" -name '.DS_Store' -delete
pushd "${1}/${packagename}" >/dev/null
xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .
xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}-Standard.pkg" --compression none .
popd >/dev/null
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"
md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}-Standard.pkg" | awk {'print $4'} )
echo "MD5 (${packagename// /}-${version}-r${revision}-Standard.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}-Standard.pkg.md5"
cp -R -f "${1}/${packagename}/Resources" ${1%/*}/Resources
echo "Finish! $packagename Install Package (Standard) v${version%%-*} $stage r$revision was created"
}
main "${1}" "${2}" "${3}" "${4}" "${5}"
branches/iFabio/Test/package/efipkg
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
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
280
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
306
307
308
309
310
311
312
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
392
393
394
395
396
397
398
399
400
401
402
#!/bin/bash
# $1 Path to store built package
packagesidentity="org.chameleon"
packagename="Chameleon"
pkgroot="${0%/*}"
#version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
version=$( cat version )
stage=${version##*-}
revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
distributioncount=0
xmlindent=0
indent[0]="\t"
indent[1]="\t\t"
indent[2]="\t\t\t"
indent[3]="\t\t\t\t"
main ()
{
# clean up the destination path
rm -R -f "${1}"
echo "Building $packagename Install Package v${version%%-*} $stage r$revision $builddate"
outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
# build core package
((xmlindent++))
packagesidentity="org.chameleon"
mkdir -p ${1}/Core/Root/usr/sbin
#mkdir -p ${1}/Core/Root/usr/local/bin
mkdir -p ${1}/Core/Root/usr/standalone/i386
#mkdir -p ${1}/Core/Root/Extra
cp -f ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot0hfs ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386
cp -f ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/sbin
fixperms "${1}/Core/Root/"
#cp -Rf ${pkgroot}/Configuration/Chameleon.prefPane ${1}/Core/Root/Library/PreferencePanes
#cp -f ${pkgroot}/Configuration/smbios.plist ${1}/Core/Root/Extra
cp -f ${pkgroot}/fdisk440 ${1}/Core/Root/usr/sbin
local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\""
# build Chameleon package
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"
choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"
# build standard package
mkdir -p ${1}/Standard/Root
mkdir -p ${1}/Standard/Scripts/Tools
cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts
ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile
buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build standard package with boot0hfs
mkdir -p ${1}/Standardhfs/Root
mkdir -p ${1}/Standardhfs/Scripts/Tools
cp -f ${pkgroot}/Scripts/Standardhfs/* ${1}/Standardhfs/Scripts
ditto --arch i386 `which SetFile` ${1}/Standardhfs/Scripts/Tools/SetFile
buildpackage "${1}/Standardhfs" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"false\" selected=\"exclusive(choices['EnhancedHFS']) &amp;&amp; exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
# build efi fat32 package
mkdir -p ${1}/EnhancedFAT/Root
mkdir -p ${1}/EnhancedFAT/Scripts/Tools
cp -f ${pkgroot}/Scripts/FAT/* ${1}/EnhancedFAT/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedFAT/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedFAT" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['EnhancedHFS'])\""
# build efi hfs package
mkdir -p ${1}/EnhancedHFS/Root
mkdir -p ${1}/EnhancedHFS/Scripts/Tools
cp -f ${pkgroot}/Scripts/HFS/* ${1}/EnhancedHFS/Scripts
ditto --arch i386 `which SetFile` ${1}/EnhancedHFS/Scripts/Tools/SetFile
buildpackage "${1}/EnhancedHFS" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['Standardhfs']) &amp;&amp; exclusive(choices['EnhancedFAT'])\""
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build PrefPanel package
#mkdir -p ${1}/PrefPanel/Root
#mkdir -p ${1}/PrefPanel/Root/Library/PreferencePanes
#cp -Rf ${pkgroot}/Configuration/Chameleon.prefPane ${1}/PrefPanel/Root/Library/PreferencePanes
#buildpackage "${1}/PrefPanel" "/" "${coresize}" "start_visible=\"true\" start_selected=\"false\""
# build utility package
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Utility\">"
choices[$((choicescount++))]="<choice\n\tid=\"Utility\"\n\ttitle=\"Utility_title\"\n\tdescription=\"Utility_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
# build package for bdmesg
#mkdir -p "${1}/bdmesg/Root"
#ditto --noextattr --noqtn "${1%/*}/i386/bdmesg" "${1}/bdmesg/Root"
#echo "Building bdmesg package"
#buildpackage "${1}/bdmesg" "/usr/sbin" "" "start_selected=\"false\""
# End build package for bdmesg
# build package for Chameleon PrefPanel
mkdir -p "${1}/PrefPanel/Root/"
ditto --noextattr --noqtn "${pkgroot}/Configuration/PrefPanel/Chameleon.prefPane" "${1}/PrefPanel/Root"
echo "Building Chameleon Preference Panel package"
buildpackage "${1}/PrefPanel" "/Library/PreferencePanes/Chameleon.prefPane" "" "start_selected=\"false\""
# End build package for Chameleon PrefPanel
# build package for SMBIOSDefault
mkdir -p "${1}/SMBIOSDefault/Root/"
ditto --noextattr --noqtn "${pkgroot}/Configuration/SMBIOSDefault/smbios.plist" "${1}/SMBIOSDefault/Root"
echo "Building SMBIOSDefault package"
buildpackage "${1}/SMBIOSDefault" "/Extra/Example" "" "start_selected=\"false\""
# End build package for SMBIOSDefault
# build package for EFIMounter
mkdir -p "${1}/EFIMounter/Root/"
ditto --noextattr --noqtn "${pkgroot}/Configuration/EFIMounter/EFI Mounter.app" "${1}/EFIMounter/Root"
echo "Building EFIMounter package"
buildpackage "${1}/EFIMounter" "/Applications/EFI Mounter.app" "" "start_selected=\"false\""
# End build package for EFIMounter
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# End utility package
# build Documentation package
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Documentation\">"
#choices[$((choicescount++))]="<choice\n\tid=\"Documentation\"\n\ttitle=\"Documentation_title\"\n\tdescription=\"Documentation_description\"\n>\n</choice>\n"
#((xmlindent++))
#packagesidentity="org.chameleon"
# build package for Documentation
#mkdir -p "${1}/Documentation/Root"
#cp -f ${pkgroot}/doc/BootHelp.txt ${1}/Documentation/Root
#cp -f ${pkgroot}/doc/README ${1}/Documentation/Root
#cp -f ${pkgroot}/doc/Users_Guide0.5.pdf ${1}/Documentation/Root
#echo "Building Documentation package"
#buildpackage "${1}/Documentation" "/Documentation/Chameleon2RC5" "" "start_selected=\"false\""
# End build package for bdmesg
#((xmlindent--))
#outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# End utility package
ß# build options packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"
choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
options=($( find "${pkgroot}/Scripts/Options" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#options[@]} ; i++ ))
do
mkdir -p "${1}/${options[$i]##*/}/Root"
mkdir -p "${1}/${options[$i]##*/}/Scripts"
ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall"
buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\""
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build resolution packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Resolution\">"
choices[$((choicescount++))]="<choice\n\tid=\"Resolution\"\n\ttitle=\"Resolution_title\"\n\tdescription=\"Resolution_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.resolution"
resolutions=($( find "${pkgroot}/Scripts/Resolutions" -type d -depth 1 -not -name '.svn' ))
for (( i = 0 ; i < ${#resolutions[@]} ; i++ ))
do
mkdir -p "${1}/${resolutions[$i]##*/}/Root/"
mkdir -p "${1}/${resolutions[$i]##*/}/Scripts/"
ditto --noextattr --noqtn "${resolutions[$i]}/postinstall" "${1}/${resolutions[$i]##*/}/Scripts/postinstall"
buildpackage "${1}/${resolutions[$i]##*/}" "/" "" "start_selected=\"false\""
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build theme packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"
choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon.theme"
artwork="${1%/*}"
themes=($( find "${artwork%/*}/artwork/themes" -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/"
ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}"
find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+
buildpackage "${1}/${theme}" "/.Chameleon/Extra/Themes" "" "start_selected=\"false\""
rm -R -f "${1}/${i##*/}"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Extras\">"
choices[$((choicescount++))]="<choice\n\tid=\"Extras\"\n\ttitle=\"Extras_title\"\n\tdescription=\"Extras_description\"\n>\n</choice>\n"
((xmlindent++))
# build kext packages
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Kexts\">"
choices[$((choicescount++))]="<choice\n\tid=\"Kexts\"\n\ttitle=\"Kexts_title\"\n\tdescription=\"Kexts_description\"\n>\n</choice>\n"
((xmlindent++))
packagesidentity="org.chameleon"
kexts=($( find "${pkgroot}/Kexts" -type d -name '*.kext' -depth 1 ))
for (( i = 0 ; i < ${#kexts[@]} ; i++ ))
do
filename="${kexts[$i]##*/}"
mkdir -p "${1}/${filename%.kext}/Root/"
ditto --noextattr --noqtn --arch i386 "${kexts[$i]}" "${1}/${filename%.kext}/Root/${filename}"
find "${1}/${filename%.kext}" -name '.DS_Store' -or -name '.svn' -exec rm -R -f {} \; 2>/dev/null
fixperms "${1}/${filename%.kext}/Root/"
chown 501:20 "${1}/${filename%.kext}/Root/"
buildpackage "${1}/${filename%.kext}" "/.Chameleon/Extra/Extensions" "" "start_selected=\"false\""
rm -R -f "${1}/${filename%.kext}"
done
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
((xmlindent--))
outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
# build post install package
mkdir -p ${1}/Post/Root
mkdir -p ${1}/Post/Scripts
cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts
buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\""
outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
# build meta package
makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
# clean up
rm -R -f "${1}"
}
fixperms ()
{
# $1 path
find "${1}" -type f -exec chmod 644 {} \;
find "${1}" -type d -exec chmod 755 {} \;
chown -R 0:0 "${1}"
}
buildpackage ()
{
# $1 Path to package to build containing Root and or Scripts
# $2 Install Location
# $3 Size
# $4 Options
if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
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\" "
header+="identifier=\"${identifier}\" "
header+="version=\"${version}\" "
[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
header+="auth=\"root\">\n"
header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
rm -R -f "${1}/Temp"
[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
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}" > "${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
xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
popd >/dev/null
outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
if [ "${4}" ]; then
local choiceoptions="${indent[$xmlindent]}${4}\n"
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}"
fi
}
makedistribution ()
{
rm -f "${1%/*}/${packagename// /}"*.pkg
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
done
ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
for (( i=0; i < ${#outline[*]} ; i++));
do
echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
done
for (( i=0; i < ${#choices[*]} ; i++));
do
echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
done
echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"
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`
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`
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
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"
}
main "${1}" "${2}" "${3}" "${4}" "${5}"
branches/iFabio/Test/package/Scripts/Standard/postinstall
1
1
22
3
4
5
6
37
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
8
9
10
11
12
13
14
5215
16
5317
54
55
56
57
58
59
60
61
62
63
64
65
18
19
20
21
22
23
24
25
26
27
28
29
30
31
6632
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
#!/usr/bin/perl
$destino = $ARGV[1];
$destino =~ s/ /\\ /g;
$volume = $ARGV[2];
my %mapa;
diskloader="boot0"
partitionloader="boot1h"
filesystemloader="boot"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
start ()
{
# 1 volume
bootvolume="${@}"
echo "Volume is $bootvolume"
bootresources="${0%/*}"
echo "$bootresources"
if [ -z "${bootvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
echo
exit
fi
bootdev=$( df "${bootvolume}" | sed -n '2p' | awk '{print $1}' )
bootrdev=${bootdev/disk/rdisk}
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo
exit
fi
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "Volume is ${bootvolume}"
echo "Volume device is ${bootdev}"
echo "Volume raw device is ${bootrdev}"
echo "Volume slice is ${bootslice}"
echo "Disk device is ${bootdisk}"
echo "Disk raw device is ${bootrdisk}"
echo "Disk loader is ${diskloader}"
echo "Partition loader is ${partitionloader}"
echo "Filesystem loader is ${filesystemloader}"
echo "Boot Resources is ${bootresources}"
open (MOUNT, "mount|");
while (<MOUNT>) {
chomp;
$line = $_;
if ($line =~ /^([^ ]+) on ([^(]+) \([^)]*\)$/) {
$mapa{$2}=$1;
}
}
close (MOUNT);
checkdiskmicrocodetype ()
{
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
fi
done
if ($mapa{$volume}) {
if ($mapa{$volume} =~ /^\/dev\/(disk\d)s(\d)$/) {
$disk = $1;
$partition = $2;
$volume =~ s/ /\\ /g;
system ($destino."/i386/fdisk -f ".$destino."/i386/boot0 -u -y /dev/r".$disk);
system ("dd if=".$destino."/i386/boot1h of=/dev/r".$disk."s".$partition);
system ("cp ".$destino."/i386/boot ".$volume);
open (PIPE, "|fdisk -e /dev/".$disk."|");
print PIPE "f ".$partition."\n";
print PIPE "write\n";
print PIPE "y\n";
print PIPE "exit\n";
}
}
checkdiskmicrocode ()
{
# 1 action ( check or set )
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
else
echo "No disk microcode found."
fi
else
if [ ${1} = set ]; then
echo "Disk microcode found. Preserving."
else
echo "Disk microcode found."
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
}
checkdisksignature ()
{
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then
echo "No disk signature found."
else
echo "Disk signature found."
echo "Disk signature is 0x${disksignature}"
fi
}
checkpartitionbootcode ()
{
# 1 action ( check or set )
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
}
checkpartitionactive ()
{
partitionactive=$( fdisk440 -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
if [ -n "${partitionactive}" ]; then
echo "Partition flagged active is ${partitionactive}"
else
echo "No partition flagged active."
fi
}
start ${3}
#partitiontable=$( diskutil list ${bootdisk} | sed -n '3p' | awk '{print $2}' )
#[ "${partitiontable}" = "GUID_partition_scheme" ] && echo "GPT found."
#[ "${partitiontable}" = "FDisk_partition_scheme" ] && echo "MBR found."
#[ "${partitiontable}" = "Apple_partition_scheme" ] && echo "APT found." && exit
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:0:16}" == "4546492050415254" ]; then
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:8:2}" == "ee" ]; then
if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then
partitiontable="GPT"
else
partitiontable="GPT/MBR"
fi
fi
else
partitiontable="MBR"
fi
echo "${partitiontable} found."
diskupdate=false
checkdiskmicrocodetype
checkdiskmicrocode set
checkdisksignature
checkpartitionbootcode set
checkpartitionactive
if ${diskupdate}; then
echo "Executing command: fdisk -u -f /usr/standalone/i386/${diskloader} -y ${bootdisk}"
fdisk -u -f "${bootvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}
fi
echo "Executing command: dd if=/usr/standalone/i386/${partitionloader} of=${bootrdev}"
dd if="${bootvolume}/usr/standalone/i386/${partitionloader}" of=${bootrdev}
echo "Executing command: cp /usr/standalone/i386/${filesystemloader} ${bootvolume}"
cp "${bootvolume}/usr/standalone/i386/${filesystemloader}" "${bootvolume}"
echo "Executing command: ${bootresources}/Tools/SetFile -a V ${bootvolume}/${filesystemloader}"
"${bootresources}/Tools/SetFile" -a V "${bootvolume}/${filesystemloader}"
# If table is GPT make the first partition active (BadAxe compatibility).
#[ "${partitiontable}" = "GPT" ] && bootslice=1
fdisk440 -e ${bootdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
checkdiskmicrocode check
checkdisksignature
checkpartitionbootcode check
checkpartitionactive
# Check efi partition
if [ -d /Volumes/EFI ]; then
umount -f /Volumes/EFI
rm -R -f /Volumes/EFI
fi
if [ -d "${bootvolume}/Extra/Extensions" ]; then
#echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions"
mkdir -p "${bootvolume}/ExtraBackup"
cp -f -R "${bootvolume}/Extra" "${bootvolume}/ExtraBackup"
rm -f -R "${bootvolume}/Extra"
fi
# unpack any existing Extensions.mkext already on the booter volume
if [ -f "${2}/ExtraBackup/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/ExtraBackup/Extensions.mkext"
mkextunpack -d "${2}/.Chameleon/Extra/Extensions" "${2}/.Chameleon/ExtraBackup/Extensions.mkext"
echo "Executing command: rm -R -f ${2}/ExtraBackup/Extensions.mkext"
rm -R -f "${2}/ExtraBackup/Extensions.mkext"
fi
# setup link for extras
#[ -h "${2}/.Chameleon" ] && unlink "${2}/.Chameleon"
#echo "Executing command: ln -s . ${2}/.Chameleon"
#ln -s "${2}" "${2}/.Chameleon"
exit
branches/iFabio/Test/package/Scripts/Standardhfs/postinstall
1
1
22
3
4
5
6
37
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
8
9
10
11
12
13
14
5215
16
5317
54
55
56
57
58
59
60
61
62
63
64
65
18
19
20
21
22
23
24
25
26
6627
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
#!/usr/bin/perl
$destino = $ARGV[1];
$destino =~ s/ /\\ /g;
$volume = $ARGV[2];
my %mapa;
diskloader="boot0hfs"
partitionloader="boot1h"
filesystemloader="boot"
diskmicrocodetype[1]="GRUB,47525542"
diskmicrocodetype[2]="LILO,4c494c4f"
start ()
{
# 1 volume
bootvolume="${@}"
echo "Volume is $bootvolume"
bootresources="${0%/*}"
echo "$bootresources"
if [ -z "${bootvolume}" ]; then
echo
echo "Cannot find the volume. Exiting."
echo
exit
fi
bootdev=$( df "${bootvolume}" | sed -n '2p' | awk '{print $1}' )
bootrdev=${bootdev/disk/rdisk}
if [ "${bootdev}" = "${bootdev#*disk*s}" ]; then
echo
echo "ERROR Volume does not use slices."
echo
exit
fi
bootdisk=${bootdev%s*}
bootrdisk=${bootdisk/disk/rdisk}
bootslice=${bootdev#*disk*s}
echo "Volume is ${bootvolume}"
echo "Volume device is ${bootdev}"
echo "Volume raw device is ${bootrdev}"
echo "Volume slice is ${bootslice}"
echo "Disk device is ${bootdisk}"
echo "Disk raw device is ${bootrdisk}"
echo "Disk loader is ${diskloader}"
echo "Partition loader is ${partitionloader}"
echo "Filesystem loader is ${filesystemloader}"
echo "Boot Resources is ${bootresources}"
open (MOUNT, "mount|");
while (<MOUNT>) {
chomp;
$line = $_;
if ($line =~ /^([^ ]+) on ([^(]+) \([^)]*\)$/) {
$mapa{$2}=$1;
}
}
close (MOUNT);
checkdiskmicrocodetype ()
{
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodetypecounter=0
while [ ${diskmicrocodetypecounter} -lt ${#diskmicrocodetype[@]} ]; do
diskmicrocodetypecounter=$(( ${diskmicrocodetypecounter} + 1 ))
diskmicrocodetypeid=${diskmicrocodetype[${diskmicrocodetypecounter}]#*,}
if [ ! "${diskmicrocode}" = "${diskmicrocode/${diskmicrocodetypeid}/}" ]; then
echo "${diskmicrocodetype[${diskmicrocodetypecounter}]%,*} found."
fi
done
if ($mapa{$volume}) {
if ($mapa{$volume} =~ /^\/dev\/(disk\d)s(\d)$/) {
$disk = $1;
$partition = $2;
$volume =~ s/ /\\ /g;
system ($destino."/i386/fdisk440 -f ".$destino."/i386/boot0hfs -u -y /dev/r".$disk);
system ("dd if=".$destino."/i386/boot1h of=/dev/r".$disk."s".$partition);
system ("cp ".$destino."/i386/boot ".$volume);
}
}
checkdiskmicrocode ()
{
# 1 action ( check or set )
diskmicrocode=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
diskmicrocodemd5=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=1 bs=437 | md5 )
if [ $( echo "${diskmicrocode}" | awk -F0 '{print NF-1}' ) = 874 ]; then
if [ "${1}" = "set" ]; then
echo "No disk microcode found. Updating."
diskupdate=true
else
echo "No disk microcode found."
fi
else
if [ ${1} = set ]; then
echo "Disk microcode found. Preserving."
else
echo "Disk microcode found."
fi
echo "Disk microcode MD5 is ${diskmicrocodemd5}"
fi
}
checkdisksignature ()
{
disksignature=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=4 bs=1 skip=440 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${disksignature}" | awk -F0 '{print NF-1}' ) = 8 ]; then
echo "No disk signature found."
else
echo "Disk signature found."
echo "Disk signature is 0x${disksignature}"
fi
}
checkpartitionbootcode ()
{
# 1 action ( check or set )
partitionbootcode=$( dd if=${bootrdev} count=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
partitionbootcodeextended=$( dd if=${bootrdev} count=1 skip=1 2>/dev/null | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ $( echo "${partitionbootcode}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
if [ "${1}" = "set" ]; then
echo "No partition bootcode found. Updating."
else
echo "No partition bootcode found."
fi
else
if [ "${1}" = "set" ]; then
echo "Partition bootcode found. Overwriting."
else
echo "Partition bootcode found."
fi
if [ $( echo "${partitionbootcodeextended}" | awk -F0 '{print NF-1}' ) = 1024 ]; then
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=1 | md5 )
else
partitionbootcodemd5=$( dd 2>/dev/null if=${bootrdev} count=2 | md5 )
echo "Partition bootcode is dual sector."
fi
echo "Partition bootcode MD5 is ${partitionbootcodemd5}"
fi
}
checkpartitionactive ()
{
partitionactive=$( fdisk440 -d ${bootrdisk} | grep -n "*" | awk -F: '{print $1}')
if [ -n "${partitionactive}" ]; then
echo "Partition flagged active is ${partitionactive}"
else
echo "No partition flagged active."
fi
}
start ${3}
#partitiontable=$( diskutil list ${bootdisk} | sed -n '3p' | awk '{print $2}' )
#[ "${partitiontable}" = "GUID_partition_scheme" ] && echo "GPT found."
#[ "${partitiontable}" = "FDisk_partition_scheme" ] && echo "MBR found."
#[ "${partitiontable}" = "Apple_partition_scheme" ] && echo "APT found." && exit
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 skip=1 | dd 2>/dev/null count=8 bs=1 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:0:16}" == "4546492050415254" ]; then
partitiontable=$( dd 2>/dev/null if=${bootdisk} count=1 | dd 2>/dev/null count=64 bs=1 skip=446 | perl -ne '@a=split"";for(@a){printf"%02x",ord}' )
if [ "${partitiontable:8:2}" == "ee" ]; then
if [ "${partitiontable:40:2}" == "00" ] && [ "${partitiontable:72:2}" == "00" ] && [ "${partitiontable:104:2}" == "00" ]; then
partitiontable="GPT"
else
partitiontable="GPT/MBR"
fi
fi
else
partitiontable="MBR"
fi
echo "${partitiontable} found."
diskupdate=false
checkdiskmicrocodetype
checkdiskmicrocode set
checkdisksignature
checkpartitionbootcode set
checkpartitionactive
if ${diskupdate}; then
echo "Executing command: fdisk -u -f /usr/standalone/i386/${diskloader} -y ${bootdisk}"
fdisk -u -f "${bootvolume}/usr/standalone/i386/${diskloader}" -y ${bootdisk}
fi
echo "Executing command: dd if=/usr/standalone/i386/${partitionloader} of=${bootrdev}"
dd if="${bootvolume}/usr/standalone/i386/${partitionloader}" of=${bootrdev}
echo "Executing command: cp /usr/standalone/i386/${filesystemloader} ${bootvolume}"
cp "${bootvolume}/usr/standalone/i386/${filesystemloader}" "${bootvolume}"
echo "Executing command: ${bootresources}/Tools/SetFile -a V ${bootvolume}/${filesystemloader}"
"${bootresources}/Tools/SetFile" -a V "${bootvolume}/${filesystemloader}"
# If table is GPT make the first partition active (BadAxe compatibility).
[ "${partitiontable}" = "GPT" ] && bootslice=1
fdisk440 -e ${bootdisk} <<-MAKEACTIVE
print
flag ${bootslice}
write
y
quit
MAKEACTIVE
checkdiskmicrocode check
checkdisksignature
checkpartitionbootcode check
checkpartitionactive
# Check efi partition
if [ -d /Volumes/EFI ]; then
umount -f /Volumes/EFI
rm -R -f /Volumes/EFI
fi
if ! [ -d "${bootvolume}/Extra/Extensions" ]; then
#echo "Executing command: mkdir -p ${bootvolume}/Extra/Extensions"
mkdir -p "${bootvolume}/ExtraBackup"
cp -f -R "${bootvolume}/Extra" "${bootvolume}/ExtraBackup"
rm -f -R "${bootvolume}/Extra"
fi
# unpack any existing Extensions.mkext already on the booter volume
if [ -f "${2}/ExtraBackup/Extensions.mkext" ]; then
echo "Executing command: mkextunpack -d ${2}/Extra/Extensions ${2}/ExtraBackup/Extensions.mkext"
mkextunpack -d "${2}/.Chameleon/Extra/Extensions" "${2}/.Chameleon/ExtraBackup/Extensions.mkext"
echo "Executing command: rm -R -f ${2}/ExtraBackup/Extensions.mkext"
rm -R -f "${2}/ExtraBackup/Extensions.mkext"
fi
# setup link for extras
#[ -h "${2}/.Chameleon" ] && unlink "${2}/.Chameleon"
#echo "Executing command: ln -s . ${2}/.Chameleon"
#ln -s "${2}" "${2}/.Chameleon"
exit
branches/iFabio/Test/package/Scripts/Post/postinstall
1
1
22
3
3
44
5
6
7
8
9
10
5
116
12
13
14
15
7
168
17
18
19
20
21
22
23
24
25
26
27
9
2810
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
11
#!/bin/bash
#! /bin/sh
temp="/private/tmp/Chameleon"
#SCRIPT="Chameleon postinstall Script"
#source com.apple.boot.plist
if ! [ -f "${2}/.Chameleon/Extra/com.apple.Boot.plist" ]; then
if [ -f "${2}/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" ]; then
cp -f "${2}/Library/Preferences/SystemConfiguration/com.apple.Boot.plist" "${2}/.Chameleon/Extra"
fi
fi
targetVolume="$3"
# fix kext permissions
find "${2}/.Chameleon/Extra/Extensions" -type f -exec chmod 644 {} \;
find "${2}/.Chameleon/Extra/Extensions" -type d -exec chmod 755 {} \;
chown -R 0:0 "${2}/.Chameleon/Extra/Extensions"
rm -rf "$3/binaries"
# build mkext for extras
[ -d "${temp}" ] && rm -R -f "${temp}"
mkdir -p "${temp}/Extensions"
ditto --noextattr --noqtn --arch i386 "${2}/.Chameleon/Extra/Extensions" "${temp}/Extensions"
find "${temp}" -type f -exec chmod 644 {} \;
find "${temp}" -type d -exec chmod 755 {} \;
chown -R 0:0 "${temp}"
kextcache -m "${temp}/Extensions.mkext" "${temp}/Extensions"
cp -f "${temp}/Extensions.mkext" "${2}/.Chameleon/Extra"
#cp -f "${temp}/Extensions.mkext" "${2}/Extra"
rm -f -R "${temp}"
echo "Done..."
# Check efi partition
if [ -d /Volumes/EFI ]; then
# remove link for extras install
#unlink -r "${2}/.Chameleon"
cp -R -f "${2}/.Chameleon/Extra" /Volumes/EFI/
umount -f /Volumes/EFI
rm -R -f /Volumes/EFI
rm -R -f "${2}/.Chameleon"
fi
cp -R -f "${2}/.Chameleon/Extra" "${2}/"
rm -R -f "${2}/.Chameleon"
exit 0
exit 0
branches/iFabio/Test/revision
1
1
516:535
155
branches/iFabio/Test/Makefile
107107
108108
109109
110
110
111111
112
112
113113
114114
115
115
116116
117
117
118118
119119
120120
sudo `pwd`/package/buildpkg `pwd`/sym/package; \
fi;
advanced installer: embedtheme
efi installer: embedtheme
@if [ -e "$(SYMROOT)" ]; then \
sudo `pwd`/package/advanced `pwd`/sym/package; \
sudo `pwd`/package/efipkg `pwd`/sym/package; \
fi;
basic installer: embedtheme
advanced installer: embedtheme
@if [ -e "$(SYMROOT)" ]; then \
sudo `pwd`/package/basic `pwd`/sym/package; \
sudo `pwd`/package/advpkg `pwd`/sym/package; \
fi;
release: $(SYMROOT)

Archive Download the corresponding diff file

Revision: 156