Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/package/buildpkg.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3# $1 Path to store built package
4
5packagesidentity="org.chameleon"
6
7packagename="Chameleon"
8
9pkgroot="${0%/*}"
10
11COL_BLACK="\x1b[30;01m"
12COL_RED="\x1b[31;01m"
13COL_GREEN="\x1b[32;01m"
14COL_YELLOW="\x1b[33;01m"
15COL_MAGENTA="\x1b[35;01m"
16COL_CYAN="\x1b[36;01m"
17COL_WHITE="\x1b[37;01m"
18COL_BLUE="\x1b[34;01m"
19COL_RESET="\x1b[39;49;00m"
20
21#version=$( grep I386BOOT_CHAMELEONVERSION vers.h | awk '{ print $3 }' | tr -d '\"' )
22version=$( cat version )
23stage=${version##*-}
24revision=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )
25builddate=$( grep I386BOOT_BUILDDATE vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
26timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
27
28# =================
29
30develop=$(awk "NR==6{print;exit}" ${pkgroot}/../CREDITS)
31credits=$(awk "NR==10{print;exit}" ${pkgroot}/../CREDITS)
32pkgdev=$(awk "NR==14{print;exit}" ${pkgroot}/../CREDITS)
33# =================
34
35distributioncount=0
36xmlindent=0
37
38indent[0]="\t"
39indent[1]="\t\t"
40indent[2]="\t\t\t"
41indent[3]="\t\t\t\t"
42
43main ()
44{
45
46# clean up the destination path
47
48rm -R -f "${1}"
49echo ""
50echo -e $COL_CYAN"----------------------------------"$COL_RESET
51echo -e $COL_CYAN"Building $packagename Install Package"$COL_RESET
52echo -e $COL_CYAN"----------------------------------"$COL_RESET
53echo ""
54
55outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
56
57# build core package
58echo "================= Core ================="
59((xmlindent++))
60packagesidentity="org.chameleon.core"
61mkdir -p ${1}/Core/Root/usr/local/bin
62mkdir -p ${1}/Core/Root/usr/standalone/i386
63ditto --noextattr --noqtn ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
64ditto --noextattr --noqtn ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386
65ditto --noextattr --noqtn ${1%/*}/i386/boot0md ${1}/Core/Root/usr/standalone/i386
66#ditto --noextattr --noqtn ${1%/*}/i386/boot0hf ${1}/Core/Root/usr/standalone/i386
67ditto --noextattr --noqtn ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386
68ditto --noextattr --noqtn ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386
69ditto --noextattr --noqtn ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386
70ditto --noextattr --noqtn ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386
71ditto --noextattr --noqtn ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386
72ditto --noextattr --noqtn ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386
73# fixperms "${1}/Core/Root/"
74ditto --noextattr --noqtn ${1%/*}/i386/fdisk440 ${1}/Core/Root/usr/sbin
75ditto --noextattr --noqtn ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/sbin
76local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
77echo "[BUILD] i386 "
78buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
79
80# build Chameleon package
81echo "================= Chameleon ================="
82outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"
83choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"
84
85# build standard package
86mkdir -p ${1}/Standard/Root
87mkdir -p ${1}/Standard/Scripts/Tools
88cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts
89ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile
90ditto --noextattr --noqtn ${1%/*}/i386/fdisk440 ${1}/Standard/Scripts/Tools
91echo "[BUILD] Standard "
92buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
93# End build standard package
94
95# build efi package
96mkdir -p ${1}/EFI/Root
97mkdir -p ${1}/EFI/Scripts/Tools
98cp -f ${pkgroot}/Scripts/EFI/* ${1}/EFI/Scripts
99ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Tools/SetFile
100ditto --noextattr --noqtn ${1%/*}/i386/fdisk440 ${1}/Standard/Scripts/Tools
101echo "[BUILD] EFI "
102buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
103# End build efi package
104
105# build reset choice package
106mkdir -p ${1}/noboot/Root
107echo "[BUILD] Reset choice "
108buildpackage "${1}/noboot" "/tmpcham" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
109# End build reset choice package
110
111# build Modules package
112 echo "================= Modules ================="
113 ###############################
114 # Supported Modules #
115 ###############################
116 # AMDGraphicsEnabler.dylib #
117 # ATiGraphicsEnabler.dylib #
118 # IntelGraphicsEnabler.dylib #
119 # klibc.dylib #
120 # NVIDIAGraphicsEnabler.dylib #
121 # Resolution.dylib #
122 # uClibcxx.dylib #
123 # Keylayout.dylib #
124 ###############################
125 if [ "$(ls -A "${1%/*}/i386/modules")" ]; then
126 {
127 outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Module\">"
128 choices[$((choicescount++))]="<choice\n\tid=\"Module\"\n\ttitle=\"Module_title\"\n\tdescription=\"Module_description\"\n>\n</choice>\n"
129 ((xmlindent++))
130 packagesidentity="org.chameleon.modules"
131# -
132 if [ -e ${1%/*}/i386/modules/AMDGraphicsEnabler.dylib ]; then
133 {
134 mkdir -p ${1}/AMDGraphicsEnabler/Root
135 ditto --noextattr --noqtn ${1%/*}/i386/modules/AMDGraphicsEnabler.dylib ${1}/AMDGraphicsEnabler/Root
136 echo "[BUILD] AMDGraphicsEnabler "
137 buildpackage "${1}/AMDGraphicsEnabler" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
138 }
139 fi
140# -
141 if [ -e ${1%/*}/i386/modules/ATiGraphicsEnabler.dylib ]; then
142 {
143 mkdir -p ${1}/ATiGraphicsEnabler/Root
144 ditto --noextattr --noqtn ${1%/*}/i386/modules/ATiGraphicsEnabler.dylib ${1}/ATiGraphicsEnabler/Root
145 echo "[BUILD] ATiGraphicsEnabler "
146 buildpackage "${1}/ATiGraphicsEnabler" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
147 }
148 fi
149# -
150 if [ -e ${1%/*}/i386/modules/IntelGraphicsEnabler.dylib ]; then
151 {
152 mkdir -p ${1}/IntelGraphicsEnabler/Root
153 ditto --noextattr --noqtn ${1%/*}/i386/modules/IntelGraphicsEnabler.dylib ${1}/IntelGraphicsEnabler/Root
154 echo "[BUILD] IntelGraphicsEnabler "
155 buildpackage "${1}/IntelGraphicsEnabler" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
156 }
157 fi
158# -
159 if [ -e ${1%/*}/i386/modules/klibc.dylib ]; then
160 {
161 mkdir -p ${1}/klibc/Root
162 ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/klibc/Root
163 echo "[BUILD] klibc "
164 buildpackage "${1}/klibc" "/Extra/modules" "" "start_selected=\"true\"" >/dev/null 2>&1
165 }
166 fi
167# -
168 if [ -e ${1%/*}/i386/modules/NVIDIAGraphicsEnabler.dylib ]; then
169 {
170 mkdir -p ${1}/NVIDIAGraphicsEnabler/Root
171 ditto --noextattr --noqtn ${1%/*}/i386/modules/NVIDIAGraphicsEnabler.dylib ${1}/NVIDIAGraphicsEnabler/Root
172 echo "[BUILD] NVIDIAGraphicsEnabler "
173 buildpackage "${1}/NVIDIAGraphicsEnabler" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
174 }
175 fi
176# -
177 if [ -e ${1%/*}/i386/modules/Resolution.dylib ]; then
178 {
179 mkdir -p ${1}/AutoReso/Root
180 ditto --noextattr --noqtn ${1%/*}/i386/modules/Resolution.dylib ${1}/AutoReso/Root
181 echo "[BUILD] Resolution "
182 buildpackage "${1}/AutoReso" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
183 }
184 fi
185# -
186 if [ -e ${1%/*}/i386/modules/Keylayout.dylib ]; then
187 {
188mkdir -p ${1}/Keylayout/Root/Extra/{modules,Keymaps}
189mkdir -p ${1}/Keylayout/Root/usr/bin
190layout_src_dir="${1%/sym/*}/i386/modules/Keylayout/layouts/layouts-src"
191if [ -d "$layout_src_dir" ];then
192# Create a tar.gz from layout sources
193(cd "$layout_src_dir"; \
194 tar czf "${1}/Keylayout/Root/Extra/Keymaps/layouts-src.tar.gz" README *.slt)
195fi
196# Adding module
197 ditto --noextattr --noqtn ${1%/*}/i386/modules/Keylayout.dylib ${1}/Keylayout/Root/Extra/modules
198# Adding Keymaps
199ditto --noextattr --noqtn ${1%/sym/*}/Keymaps ${1}/Keylayout/Root/Extra/Keymaps
200# Adding tools
201ditto --noextattr --noqtn ${1%/*}/i386/cham-mklayout ${1}/Keylayout/Root/usr/bin
202 echo "[BUILD] Keylayout "
203 buildpackage "${1}/Keylayout" "/" "" "start_selected=\"true\"" >/dev/null 2>&1
204 }
205 fi
206# -
207 if [ -e ${1%/*}/i386/modules/uClibcxx.dylib ]; then
208 {
209 mkdir -p ${1}/uClibc/Root
210 ditto --noextattr --noqtn ${1%/*}/i386/modules/uClibcxx.dylib ${1}/uClibc/Root
211 ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/uClibc/Root
212 echo "[BUILD] uClibc++ "
213 buildpackage "${1}/uClibc" "/Extra/modules" "" "start_selected=\"true\"" >/dev/null 2>&1
214 }
215 fi
216 ((xmlindent--))
217 outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
218 }
219 else
220 {
221 echo " -= no modules to include =-"
222 }
223 fi
224# End build Modules packages
225 ((xmlindent--))
226 outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
227# End build Chameleon package
228
229# build Extras package
230#echo "================= Extras ================="
231#outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Extras\">"
232#choices[$((choicescount++))]="<choice\n\tid=\"Extras\"\n\ttitle=\"Extras_title\"\n\tdescription=\"Extras_description\"\n>\n</choice>\n"
233#((xmlindent++))
234#packagesidentity="org.chameleon.extras"
235
236# build utility package
237#outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Utility\">"
238#choices[$((choicescount++))]="<choice\n\tid=\"Utility\"\n\ttitle=\"Utility_title\"\n\tdescription=\"Utility_description\"\n>\n</choice>\n"
239#((xmlindent++))
240#packagesidentity="org.chameleon.utilities"
241
242## build package for Chameleon PrefPanel
243#mkdir -p "${1}/PrefPanel/Root"
244#ditto --noextattr --noqtn "${pkgroot}/Configuration/PrefPanel/Chameleon.prefPane" "${1}/PrefPanel/Root"
245#echo "[BUILD] Chameleon Preference Panel "
246#buildpackage "${1}/PrefPanel" "/Library/PreferencePanes/Chameleon.prefPane" "" "start_selected=\"false\"" >/dev/null 2>&1
247## End build package for Chameleon PrefPanel
248
249## build package for SMBIOSDefault
250#mkdir -p "${1}/SMBIOSDefault/Root"
251#ditto --noextattr --noqtn "${pkgroot}/Configuration/SMBIOSDefault/smbios.plist" "${1}/SMBIOSDefault/Root"
252#echo "[BUILD] SMBIOSDefault "
253#buildpackage "${1}/SMBIOSDefault" "/Extra/Example" "" "start_selected=\"false\"" >/dev/null 2>&1
254## End build package for SMBIOSDefault
255
256## build package for Documentation
257#mkdir -p "${1}/Documentation/Root"
258#cp -f ${pkgroot}/../doc/BootHelp.txt ${1}/Documentation/Root
259#cp -f ${pkgroot}/../doc/README ${1}/Documentation/Root
260#cp -f ${pkgroot}/../doc/Users_Guide0.5.pdf ${1}/Documentation/Root
261#echo "[BUILD] Documentation "
262#buildpackage "${1}/Documentation" "/Library/Documentation/Chameleon2" "" "start_selected=\"false\"" >/dev/null 2>&1
263## End build package for Documentation
264
265#((xmlindent--))
266#outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
267# End utility package
268
269# build options packages
270echo "================= Options ================="
271outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"
272choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"
273((xmlindent++))
274
275# build base options packages
276packagesidentity="org.chameleon.options"
277
278options=($( find "${pkgroot}/Scripts/BaseOptions" -type d -depth 1 -not -name '.svn' ))
279for (( i = 0 ; i < ${#options[@]} ; i++ ))
280do
281mkdir -p "${1}/${options[$i]##*/}/Root"
282mkdir -p "${1}/${options[$i]##*/}/Scripts"
283ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall"
284echo "[BUILD] ${options[$i]##*/} "
285buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\"" >/dev/null 2>&1
286done
287# End build base options packages
288
289# build KeyLayout option packages
290echo "================= Keymaps Options ================="
291outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"KeyLayout\">"
292choices[$((choicescount++))]="<choice\n\tid=\"KeyLayout\"\n\ttitle=\"KeyLayout_title\"\n\tdescription=\"KeyLayout_description\"\n>\n</choice>\n"
293((xmlindent++))
294packagesidentity="org.chameleon.options.keylayout"
295keymaps=($( find "${1%/sym/*}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))
296for (( i = 0 ; i < ${#keymaps[@]} ; i++ ))
297do
298mkdir -p "${1}/${keymaps[$i]}/Root/"
299mkdir -p "${1}/${keymaps[$i]}/Scripts/"
300sed "s/@@KEYMAP@@/${keymaps[$i]}/g" "${pkgroot}/Scripts/Keymaps/postinstall" > "${1}/${keymaps[$i]}/Scripts/postinstall" && \
301chmod +rx "${1}/${keymaps[$i]}/Scripts/postinstall"
302echo "[BUILD] ${keymaps[$i]} "
303buildpackage "${1}/${keymaps[$i]}" "/tmpcham" "" "start_selected=\"false\"" >/dev/null 2>&1
304done
305((xmlindent--))
306outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
307# End build KeyLayout option packages
308
309# build resolution packages
310echo "================= Res. Options ================="
311outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Resolution\">"
312choices[$((choicescount++))]="<choice\n\tid=\"Resolution\"\n\ttitle=\"Resolution_title\"\n\tdescription=\"Resolution_description\"\n>\n</choice>\n"
313((xmlindent++))
314packagesidentity="org.chameleon.options.resolution"
315resolutions=($( find "${pkgroot}/Scripts/Resolutions" -type d -depth 1 -not -name '.svn' ))
316for (( i = 0 ; i < ${#resolutions[@]} ; i++ ))
317do
318mkdir -p "${1}/${resolutions[$i]##*/}/Root/"
319mkdir -p "${1}/${resolutions[$i]##*/}/Scripts/"
320ditto --noextattr --noqtn "${resolutions[$i]}/postinstall" "${1}/${resolutions[$i]##*/}/Scripts/postinstall"
321echo "[BUILD] ${resolutions[$i]##*/} "
322buildpackage "${1}/${resolutions[$i]##*/}" "/tmpcham" "" "start_selected=\"false\"" >/dev/null 2>&1
323done
324
325((xmlindent--))
326outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
327# End build resolution packages
328
329# build Advanced packages
330echo "================= Adv. Options ================="
331outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Advanced\">"
332choices[$((choicescount++))]="<choice\n\tid=\"Advanced\"\n\ttitle=\"Advanced_title\"\n\tdescription=\"Advanced_description\"\n>\n</choice>\n"
333((xmlindent++))
334
335packagesidentity="org.chameleon.options.advanced"
336optionsadv=($( find "${pkgroot}/Scripts/Advanced" -type d -depth 1 -not -name '.svn' ))
337for (( i = 0 ; i < ${#optionsadv[@]} ; i++ ))
338do
339mkdir -p "${1}/${optionsadv[$i]##*/}/Root"
340mkdir -p "${1}/${optionsadv[$i]##*/}/Scripts"
341ditto --noextattr --noqtn "${optionsadv[$i]}/postinstall" "${1}/${optionsadv[$i]##*/}/Scripts/postinstall"
342echo "[BUILD] ${optionsadv[$i]##*/} "
343buildpackage "${1}/${optionsadv[$i]##*/}" "/" "" "start_selected=\"false\"" >/dev/null 2>&1
344done
345
346((xmlindent--))
347outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
348# End build Advanced packages
349
350((xmlindent--))
351outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
352
353# End build options packages
354
355# build theme packages
356echo "================= Themes ================="
357outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"
358choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"
359((xmlindent++))
360packagesidentity="org.chameleon.themes"
361artwork="${1%/*}"
362themes=($( find "${artwork%/*}/artwork/themes" -type d -depth 1 -not -name '.svn' ))
363for (( i = 0 ; i < ${#themes[@]} ; i++ ))
364do
365theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )
366mkdir -p "${1}/${themes[$i]##*/}/Root/"
367 rsync -r --exclude=.svn "${themes[$i]}/" "${1}/${themes[$i]##*/}/Root/${theme}"
368 # #### Comment out thx meklort
369 # ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}"
370 # ####
371 find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+
372find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+
373echo "[BUILD] ${themes[$i]##*/} "
374buildpackage "${1}/${theme}" "/Extra/Themes" "" "start_selected=\"false\"" >/dev/null 2>&1
375rm -R -f "${1}/${i##*/}"
376done
377
378((xmlindent--))
379outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
380# End build theme packages
381
382#((xmlindent--))
383#outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
384# End build Extras package
385
386# build post install package
387echo "================= Post ================="
388mkdir -p ${1}/Post/Root
389mkdir -p ${1}/Post/Scripts
390cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts
391echo "[BUILD] Post "
392buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
393outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
394
395# build meta package
396
397makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
398
399# clean up
400
401rm -R -f "${1}"
402
403}
404
405fixperms ()
406{
407# $1 path
408find "${1}" -type f -exec chmod 644 {} \;
409find "${1}" -type d -exec chmod 755 {} \;
410chown -R 0:0 "${1}"
411}
412
413buildpackage ()
414{
415# $1 Path to package to build containing Root and or Scripts
416# $2 Install Location
417# $3 Size
418# $4 Options
419
420if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
421
422local packagename="${1##*/}"
423local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )
424find "${1}" -name '.DS_Store' -delete
425local filecount=$( find "${1}/Root" | wc -l )
426if [ "${3}" ]; then
427local installedsize="${3}"
428else
429local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )
430fi
431local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
432
433#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
434
435header+="identifier=\"${identifier}\" "
436header+="version=\"${version}\" "
437
438[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
439
440header+="auth=\"root\">\n"
441header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
442rm -R -f "${1}/Temp"
443
444[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
445[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
446
447if [ -d "${1}/Scripts" ]; then
448header+="\t<scripts>\n"
449for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )
450do
451header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
452done
453header+="\t</scripts>\n"
454chown -R 0:0 "${1}/Scripts"
455pushd "${1}/Scripts" >/dev/null
456find . -print | cpio -o -z -H cpio > "../Temp/Scripts"
457popd >/dev/null
458fi
459
460header+="</pkg-info>"
461echo -e "${header}" > "${1}/Temp/PackageInfo"
462pushd "${1}/Root" >/dev/null
463find . -print | cpio -o -z -H cpio > "../Temp/Payload"
464popd >/dev/null
465pushd "${1}/Temp" >/dev/null
466
467xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
468
469popd >/dev/null
470
471outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
472
473if [ "${4}" ]; then
474local choiceoptions="${indent[$xmlindent]}${4}\n"
475fi
476choices[$((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"
477
478rm -R -f "${1}"
479fi
480}
481
482makedistribution ()
483{
484rm -f "${1%/*}/${packagename// /}"*.pkg
485
486find "${1}" -type f -name '*.pkg' -depth 1 | while read component
487do
488mkdir -p "${1}/${packagename}/${component##*/}"
489pushd "${1}/${packagename}/${component##*/}" >/dev/null
490xar -x -f "${1%}/${component##*/}"
491popd >/dev/null
492done
493
494ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
495ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
496
497find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
498
499for (( i=0; i < ${#outline[*]} ; i++));
500do
501echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
502done
503
504for (( i=0; i < ${#choices[*]} ; i++));
505do
506echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
507done
508
509echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"
510
511perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f`
512perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f`
513
514# Adding Developer and credits
515perl -i -p -e "s/%DEVELOP%/${develop}/g" `find "${1}/${packagename}/Resources" -type f`
516perl -i -p -e "s/%CREDITS%/${credits}/g" `find "${1}/${packagename}/Resources" -type f`
517perl -i -p -e "s/%PKGDEV%/${pkgdev}/g" `find "${1}/${packagename}/Resources" -type f`
518
519stage=${stage/RC/Release Candidate }
520stage=${stage/FINAL/2.0 Final}
521perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f`
522
523find "${1}/${packagename}" -name '.DS_Store' -delete
524pushd "${1}/${packagename}" >/dev/null
525xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .
526popd >/dev/null
527
528# Here is the place for assign a Icon to the pkg
529# command use to generate the file:
530# ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip
531# ----
532 ditto -xk "${pkgroot}/Icons/pkg.zip" "${pkgroot}/Icons/"
533 DeRez -only icns "${pkgroot}/Icons/Icons/pkg.icns" > tempicns.rsrc
534 Rez -append tempicns.rsrc -o "${1%/*}/$packagename-${version}-r$revision.pkg"
535 SetFile -a C "${1%/*}/$packagename-${version}-r$revision.pkg"
536 rm -f tempicns.rsrc
537 rm -rf "${pkgroot}/Icons/Icons"
538# End
539
540md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" | awk {'print $4'} )
541echo "MD5 (${packagename// /}-${version}-r${revision}.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}.pkg.md5"
542echo ""
543
544echo -e $COL_GREEN"--------------------------"$COL_RESET
545echo -e $COL_GREEN"Building process complete!"$COL_RESET
546echo -e $COL_GREEN"--------------------------"$COL_RESET
547echo ""
548echo -e $COL_GREEN"Build info."
549echo -e $COL_GREEN"==========="
550echo -e $COL_BLUE"Package name:"$COL_RESET"$packagename-${version}-r$revision.pkg"
551echo -e $COL_BLUE"MD5:"$COL_RESET"$md5"
552echo -e $COL_BLUE"Version:"$COL_RESET"$version"
553echo -e $COL_BLUE"Stage:"$COL_RESET"$stage"
554echo -e $COL_BLUE"Date/Time:"$COL_RESET"$builddate"
555echo ""
556
557}
558
559main "${1}" "${2}" "${3}" "${4}" "${5}"
560
561

Archive Download this file

Revision: 1531