Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/Test/buildpkg.txt

  • Property svn:executable set to *
Source at commit 151 created 13 years 7 months ago.
By ifabio, create test and Original-package folders in my branch, the original contain the "original" package from chameleon trunk, the test folder contains my actual version of the package, I start from here... sorry... now I have more feeling with SVN.
1#!/bin/bash
2
3# $1 Path to store built package
4
5packagesidentity="org.chameleon"
6
7packagename="Chameleon"
8
9pkgroot="${0%/*}"
10
11#version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
12version=$( cat version )
13stage=${version##*-}
14revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
15builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
16timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
17
18distributioncount=0
19xmlindent=0
20
21indent[0]="\t"
22indent[1]="\t\t"
23indent[2]="\t\t\t"
24indent[3]="\t\t\t\t"
25
26main ()
27{
28
29# clean up the destination path
30
31rm -R -f "${1}"
32
33echo "Building $packagename Install Package v${version%%-*} $stage r$revision $builddate"
34
35outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
36
37# Start
38
39
40
41# build Chameleon metapackages
42outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"
43choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"
44((xmlindent++))
45
46# build core package
47mkdir -p ${1}/Core/Root/i386
48cp -f ${1%/*}/i386/boot ${1}/Core/Root/i386
49cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/i386
50cp -f ${1%/*}/i386/boot0hfs ${1}/Core/Root/i386
51cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/i386
52cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/i386
53cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/i386
54cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/i386
55cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/i386
56cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/i386
57cp -f ${pkgroot}/fdisk440 ${1}/Core/Root/i386
58fixperms "${1}/Core/Root/i386"
59local coresize=$( du -hkc "${1}/Core/Root/i386" | tail -n1 | awk {'print $1'} )
60echo "Building core package"
61buildpackage "${1}/Core" "/binaries" "0" "start_visible=\"false\" start_selected=\"true\""
62
63# End build core package
64
65# build standard package
66mkdir -p ${1}/boot0/Root
67mkdir -p ${1}/boot0/Scripts
68cp -f ${pkgroot}/Scripts/boot0/postinstall ${1}/boot0/Scripts
69echo "Building boot0 package"
70buildpackage "${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'])\""
71# End build standard package
72
73# build standard package with boot0hfs
74mkdir -p ${1}/boot0hfs/Root
75mkdir -p ${1}/boot0hfs/Scripts
76cp -f ${pkgroot}/Scripts/boot0hfs/postinstall ${1}/boot0hfs/Scripts
77echo "Building boot0hfs package"
78buildpackage "${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'])\""
79# End build standard package with boot0hfs
80
81# build efi fat32 package
82mkdir -p ${1}/EnhancedFAT/Root
83mkdir -p ${1}/EnhancedFAT/Scripts/Tools
84cp -f ${pkgroot}/Scripts/FAT/postinstall ${1}/EnhancedFAT/Scripts
85ditto --arch i386 `which SetFile` ${1}/EnhancedFAT/Scripts/Tools/SetFile
86echo "Building EnhacedFAT package"
87buildpackage "${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'])\""
88# End build efi fat32 package
89
90# build efi hfs package
91mkdir -p ${1}/EnhancedHFS/Root
92mkdir -p ${1}/EnhancedHFS/Scripts/Tools
93cp -f ${pkgroot}/Scripts/HFS/postinstall ${1}/EnhancedHFS/Scripts
94ditto --arch i386 `which SetFile` ${1}/EnhancedHFS/Scripts/Tools/SetFile
95echo "Building EnhacedHFS package"
96buildpackage "${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'])\""
97# End build efi hfs package
98
99# build reset choice package
100mkdir -p ${1}/noboot/Root
101echo "Building reset choice package"
102buildpackage "${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'])\""
103# End build reset choice package
104
105((xmlindent--))
106 outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
107# End Chameleon metapakage
108
109# build utility package
110outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Utility\">"
111choices[$((choicescount++))]="<choice\n\tid=\"Utility\"\n\ttitle=\"Utility_title\"\n\tdescription=\"Utility_description\"\n>\n</choice>\n"
112((xmlindent++))
113packagesidentity="org.chameleon"
114
115# build package for bdmesg
116mkdir -p "${1}/bdmesg/Root"
117ditto --noextattr --noqtn "${1%/*}/i386/bdmesg" "${1}/bdmesg/Root"
118echo "Building bdmesg package"
119buildpackage "${1}/bdmesg" "/Extra/Util" "" "start_selected=\"false\""
120# End build package for bdmesg
121
122# build package for Chameleon PrefPanel
123mkdir -p "${1}/prefPane/Root/"
124ditto --noextattr --noqtn "${pkgroot}/Configuration" "${1}/prefPane/Root"
125echo "Building Chameleon Preference Panel package"
126buildpackage "${1}/prefPane" "/Library/PreferencePanes" "" "start_selected=\"false\""
127# End build package for Chameleon PrefPanel
128
129((xmlindent--))
130outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
131# End utility package
132
133# build options packages
134
135outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"
136choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"
137((xmlindent++))
138packagesidentity="org.chameleon.options"
139options=($( find "${pkgroot}/Scripts/Options" -type d -depth 1 -not -name '.svn' ))
140for (( i = 0 ; i < ${#options[@]} ; i++))
141do
142packagesidentity="org.chameleon.flags"
143flagname=($( find "${options[$i]}" -type d -depth 1 -not -name '.svn' ))
144outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${options[$i]##*/}\">"
145choices[$((choicescount++))]="<choice\n\tid=\"${options[$i]##*/}\"\n\ttitle=\"${options[$i]##*/}\"\n\tdescription=\"${options[$i]##*/}_description\"\n>\n</choice>\n"
146((xmlindent++))
147for (( j = 0 ; j < ${#flagname[@]} ; j++ ))
148do
149outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${options[$i]##*/}_${flagname[$j]##*/}\">"
150choices[$((choicescount++))]="<choice\n\tid=\"${options[$i]##*/}_${flagname[$j]##*/}\"\n\ttitle=\"${options[$i]##*/}_${flagname[$j]##*/}\"\n\tdescription=\"${options[$i]##*/}_${flagname[$j]##*/}_description\"\n>\n</choice>\n"
151((xmlindent++))
152mkdir -p "${1}/${flagname[$j]##*/}/Root"
153mkdir -p "${1}/${flagname[$j]##*/}/Scripts"
154ditto --noextattr --noqtn "${options[$i]}/${flagname[$j]##*/}/postinstall" "${1}/${options[$i]##*/}${flagname[$j]##*/}/Scripts/postinstall"
155#cp -f "${options[$i]}/${flagname[$j]##*/}/*" "${1}/${options[$i]##*/}${flagname[$j]##*/}/Scripts/postinstall"
156#echo "Building ${options[$i]##*/}${flagname[$j]##*/} package"
157buildpackage "${1}/${options[$i]##*/}_${flagname[$j]##*/}" "/" "${coresize}" "start_selected=\"false\""
158rm -R -f "${1}/${j##*/}"
159((xmlindent--))
160outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
161done
162((xmlindent--))
163outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
164echo "Building ${options[$i]##*/} package"
165buildpackage "${1}/${options[$i]##*/}" "/" "${coresize}" "start_selected=\"false\""
166rm -R -f "${1}/${i##*/}"
167done
168((xmlindent--))
169outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
170# End build options packages
171
172# build theme packages
173
174outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"
175choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"
176((xmlindent++))
177packagesidentity="org.chameleon.theme"
178artwork="${1%/*}"
179themes=($( find "${artwork%/*}/artwork/themes" -type d -depth 1 -not -name '.svn' ))
180for (( i = 0 ; i < ${#themes[@]} ; i++ ))
181do
182theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )
183mkdir -p "${1}/${theme}/Root/"
184ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}"
185find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
186find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+
187buildpackage "${1}/${theme}" "/Extra/Themes" "" "start_selected=\"false\""
188rm -R -f "${1}/${i##*/}"
189done
190((xmlindent--))
191outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
192# End build theme packages
193
194
195
196# build kext packages
197outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Extras\">"
198choices[$((choicescount++))]="<choice\n\tid=\"Extras\"\n\ttitle=\"Extras_title\"\n\tdescription=\"Extras_description\"\n>\n</choice>\n"
199((xmlindent++))
200outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Kexts\">"
201choices[$((choicescount++))]="<choice\n\tid=\"Kexts\"\n\ttitle=\"Kexts_title\"\n\tdescription=\"Kexts_description\"\n>\n</choice>\n"
202((xmlindent++))
203packagesidentity="org.chameleon"
204kexts=($( find "${pkgroot}/Kexts" -type d -name '*.kext' -depth 1 ))
205for (( i = 0 ; i < ${#kexts[@]} ; i++ ))
206do
207filename="${kexts[$i]##*/}"
208mkdir -p "${1}/${filename%.kext}/Root/"
209ditto --noextattr --noqtn --arch i386 "${kexts[$i]}" "${1}/${filename%.kext}/Root/${filename}"
210find "${1}/${filename%.kext}" -name '.DS_Store' -or -name '.svn' -exec rm -R -f {} \; 2>/dev/null
211fixperms "${1}/${filename%.kext}/Root/"
212chown 501:20 "${1}/${filename%.kext}/Root/"
213buildpackage "${1}/${filename%.kext}" "/Extra/Extensions" "" "start_selected=\"false\""
214rm -R -f "${1}/${filename%.kext}"
215done
216((xmlindent--))
217outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
218((xmlindent--))
219outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
220# End build kext packages
221
222# build post install package
223mkdir -p ${1}/Post/Root
224mkdir -p ${1}/Post/Scripts
225cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts
226buildpackage "${1}/Post" "/binaries" "" "start_visible=\"false\" start_selected=\"true\""
227# End post install package
228
229outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
230# End main package
231
232
233# build meta package
234
235makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
236
237# clean up
238
239rm -R -f "${1}"
240
241}
242
243fixperms ()
244{
245# $1 path
246find "${1}" -type f -exec chmod 644 {} \;
247find "${1}" -type d -exec chmod 755 {} \;
248chown -R 0:0 "${1}"
249}
250
251buildpackage ()
252{
253# $1 Path to package to build containing Root and or Scripts
254# $2 Install Location
255# $3 Size
256# $4 Options
257
258if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
259
260local packagename="${1##*/}"
261local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )
262find "${1}" -name '.DS_Store' -delete
263local filecount=$( find "${1}/Root" | wc -l )
264if [ "${3}" ]; then
265local installedsize="${3}"
266else
267local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )
268fi
269local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
270
271#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
272
273header+="identifier=\"${identifier}\" "
274header+="version=\"${version}\" "
275
276[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
277
278header+="auth=\"root\">\n"
279header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
280rm -R -f "${1}/Temp"
281
282[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
283[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
284
285if [ -d "${1}/Scripts" ]; then
286header+="\t<scripts>\n"
287for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )
288do
289header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
290done
291header+="\t</scripts>\n"
292chown -R 0:0 "${1}/Scripts"
293pushd "${1}/Scripts" >/dev/null
294find . -print | cpio -o -z -H cpio > "../Temp/Scripts"
295popd >/dev/null
296fi
297
298header+="</pkg-info>"
299echo -e "${header}" > "${1}/Temp/PackageInfo"
300pushd "${1}/Root" >/dev/null
301find . -print | cpio -o -z -H cpio > "../Temp/Payload"
302popd >/dev/null
303pushd "${1}/Temp" >/dev/null
304
305xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
306
307popd >/dev/null
308
309outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
310
311if [ "${4}" ]; then
312local choiceoptions="${indent[$xmlindent]}${4}\n"
313fi
314choices[$((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"
315
316rm -R -f "${1}"
317fi
318}
319
320makedistribution ()
321{
322rm -f "${1%/*}/${packagename// /}"*.pkg
323
324find "${1}" -type f -name '*.pkg' -depth 1 | while read component
325do
326mkdir -p "${1}/${packagename}/${component##*/}"
327pushd "${1}/${packagename}/${component##*/}" >/dev/null
328xar -x -f "${1%}/${component##*/}"
329popd >/dev/null
330done
331
332ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
333ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
334
335find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
336
337for (( i=0; i < ${#outline[*]} ; i++));
338do
339echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
340done
341
342for (( i=0; i < ${#choices[*]} ; i++));
343do
344echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
345done
346
347echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"
348
349perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f`
350perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f`
351
352stage=${stage/RC/Release Candidate }
353stage=${stage/FINAL/2.0 Final}
354perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f`
355
356find "${1}/${packagename}" -name '.DS_Store' -delete
357pushd "${1}/${packagename}" >/dev/null
358xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .
359popd >/dev/null
360
361md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" | awk {'print $4'} )
362echo "MD5 (${packagename// /}-${version}-r${revision}.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}.pkg.md5"
363 cp -R -f "${1}/${packagename}/Resources" ${1%/*}/Resources
364}
365
366main "${1}" "${2}" "${3}" "${4}" "${5}"
367
368

Archive Download this file

Revision: 151