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

Archive Download this file

Revision: 1626