Chameleon

Chameleon Svn Source Tree

Root/branches/blackosx/package/buildpkg.sh

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

Archive Download this file

Revision: 1640