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\" 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()\" 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" "" "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" "1" "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
316cp -f ${pkgroot}/Scripts/Sub/UnMountEFIvolumes.sh ${1}/Post/Scripts
317ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Post/Scripts/Resources/revision
318ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Post/Scripts/Resources/version
319echo "[BUILD] Post "
320buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
321# End build post install package
322
323((xmlindent--))
324outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
325
326# build meta package
327
328makedistribution "${1}" "${2}" "${3}" "${4}" #"${5}"
329
330# clean up
331
332rm -R -f "${1}"
333
334}
335
336fixperms ()
337{
338# $1 path
339find "${1}" -type f -exec chmod 644 {} \;
340find "${1}" -type d -exec chmod 755 {} \;
341chown -R 0:0 "${1}"
342}
343
344buildoptionalsettings()
345{
346# $1 Path to package to build containing Root and or Scripts
347# $2 = exclusiveFlag
348# S3 = exclusiveName
349
350# ------------------------------------------------------
351# if exclusiveFlag=1 then re-build array
352# adding extra boot option at beginning to give
353
354# ------------------------------------------------------
355if [ ${2} = "1" ]; then
356tempArray=("${availableOptions[@]}")
357availableOptions=()
358availableOptions[0]="ChooseNone-"$3":DONT=ADD"
359position=0
360totalItems="${#tempArray[@]}"
361for (( position = 0 ; position < $totalItems ; position++ ))
362do
363availableOptions[$position+1]=${tempArray[${position}]}
364done
365fi
366
367# ------------------------------------------------------
368# Loop through options in array and process each in turn
369# ------------------------------------------------------
370for (( c = 0 ; c < ${#availableOptions[@]} ; c++ ))
371do
372textLine=${availableOptions[c]}
373# split line - taking all before ':' as option name
374# and all after ':' as key/value
375optionName=${textLine%:*}
376keyValue=${textLine##*:}
377
378# create folders required for each boot option
379mkdir -p "${1}/$optionName/Root/"
380
381# create dummy file with name of key/value
382echo "" > "${1}/$optionName/Root/${keyValue}"
383
384echo "[BUILD] ${optionName} "
385
386# ------------------------------------------------------
387# Before calling buildpackage, add exclusive options
388# to buildpackage call if requested.
389# ------------------------------------------------------
390if [ $2 = "1" ]; then
391
392# Prepare individual string parts
393stringStart="selected=\""
394stringBefore="exclusive(choices['"
395stringAfter="']) &amp;&amp; "
396stringEnd="'])\""
397x=${stringStart}${stringBefore}
398
399# build string for sending to buildpackage
400totalItems="${#availableOptions[@]}"
401lastItem=$((totalItems-1))
402
403for (( r = 0 ; r < ${totalItems} ; r++ ))
404do
405textLineTemp=${availableOptions[r]}
406optionNameTemp=${textLineTemp%:*}
407if [ "${optionNameTemp}" != "${optionName}" ]; then
408 x="${x}${optionNameTemp}"
409 # Only add these to end of string up to the one before the last item
410if [ $r -lt $lastItem ]; then
411x="${x}${stringAfter}${stringBefore}"
412fi
413fi
414done
415x="${x}${stringEnd}"
416
417# First exclusive option is the 'no choice' option, so let's make that selected by default.
418if [ $c = 0 ]; then
419initialChoice="true"
420else
421initialChoice="false"
422fi
423
424buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"${initialChoice}\" ${x}" >/dev/null 2>&1
425else
426buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\"" >/dev/null 2>&1
427fi
428done
429}
430
431buildpackage ()
432{
433# $1 Path to package to build containing Root and or Scripts
434# $2 Install Location
435# $3 Size
436# $4 Options
437
438if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
439
440local packagename="${1##*/}"
441local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )
442find "${1}" -name '.DS_Store' -delete
443local filecount=$( find "${1}/Root" | wc -l )
444if [ "${3}" ]; then
445local installedsize="${3}"
446else
447local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )
448fi
449local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
450
451#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
452
453header+="identifier=\"${identifier}\" "
454header+="version=\"${version}\" "
455
456[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
457
458header+="auth=\"root\">\n"
459header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
460rm -R -f "${1}/Temp"
461
462[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
463[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
464
465if [ -d "${1}/Scripts" ]; then
466header+="\t<scripts>\n"
467for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )
468do
469header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
470done
471header+="\t</scripts>\n"
472chown -R 0:0 "${1}/Scripts"
473pushd "${1}/Scripts" >/dev/null
474find . -print | cpio -o -z -H cpio > "../Temp/Scripts"
475popd >/dev/null
476fi
477
478header+="</pkg-info>"
479echo -e "${header}" > "${1}/Temp/PackageInfo"
480pushd "${1}/Root" >/dev/null
481find . -print | cpio -o -z -H cpio > "../Temp/Payload"
482popd >/dev/null
483pushd "${1}/Temp" >/dev/null
484
485xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
486
487popd >/dev/null
488
489outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"${packagename// /}\"/>"
490
491if [ "${4}" ]; then
492local choiceoptions="\t\t${4}"
493fi
494#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"
495
496choices[$((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"
497rm -R -f "${1}"
498fi
499}
500
501makedistribution ()
502{
503rm -f "${1%/*}/${packagename// /}"*.pkg
504
505find "${1}" -type f -name '*.pkg' -depth 1 | while read component
506do
507mkdir -p "${1}/${packagename}/${component##*/}"
508pushd "${1}/${packagename}/${component##*/}" >/dev/null
509xar -x -f "${1%}/${component##*/}"
510popd >/dev/null
511done
512
513ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
514ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
515
516find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
517
518for (( i=0; i < ${#outline[*]} ; i++));
519do
520echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
521done
522
523for (( i=0; i < ${#choices[*]} ; i++));
524do
525echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
526done
527
528echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"
529
530perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f`
531perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f`
532
533# Adding Developer and credits
534perl -i -p -e "s/%DEVELOP%/${develop}/g" `find "${1}/${packagename}/Resources" -type f`
535perl -i -p -e "s/%CREDITS%/${credits}/g" `find "${1}/${packagename}/Resources" -type f`
536perl -i -p -e "s/%PKGDEV%/${pkgdev}/g" `find "${1}/${packagename}/Resources" -type f`
537
538stage=${stage/RC/Release Candidate }
539stage=${stage/FINAL/2.0 Final}
540perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f`
541
542find "${1}/${packagename}" -name '.DS_Store' -delete
543pushd "${1}/${packagename}" >/dev/null
544xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .
545popd >/dev/null
546
547# Here is the place for assign a Icon to the pkg
548# command use to generate the file:
549# ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip
550# ----
551 ditto -xk "${pkgroot}/Icons/pkg.zip" "${pkgroot}/Icons/"
552 DeRez -only icns "${pkgroot}/Icons/Icons/pkg.icns" > tempicns.rsrc
553 Rez -append tempicns.rsrc -o "${1%/*}/$packagename-${version}-r$revision.pkg"
554 SetFile -a C "${1%/*}/$packagename-${version}-r$revision.pkg"
555 rm -f tempicns.rsrc
556 rm -rf "${pkgroot}/Icons/Icons"
557# End
558
559md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" | awk {'print $4'} )
560echo "MD5 (${packagename// /}-${version}-r${revision}.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}.pkg.md5"
561echo ""
562
563echo -e $COL_GREEN"--------------------------"$COL_RESET
564echo -e $COL_GREEN"Building process complete!"$COL_RESET
565echo -e $COL_GREEN"--------------------------"$COL_RESET
566echo ""
567echo -e $COL_GREEN"Build info."
568echo -e $COL_GREEN"==========="
569echo -e $COL_BLUE"Package name:"$COL_RESET"$packagename-${version}-r$revision.pkg"
570echo -e $COL_BLUE"MD5:"$COL_RESET"$md5"
571echo -e $COL_BLUE"Version:"$COL_RESET"$version"
572echo -e $COL_BLUE"Stage:"$COL_RESET"$stage"
573echo -e $COL_BLUE"Date/Time:"$COL_RESET"$builddate"
574echo ""
575
576}
577
578main "${1}" "${2}" "${3}" "${4}" "${5}"
579
580

Archive Download this file

Revision: 1634