Chameleon

Chameleon Svn Source Tree

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

Archive Download this file

Revision: 1622