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
64ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Pre/Scripts/Resources/revision
65ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Pre/Scripts/Resources/version
66cp -f ${pkgroot}/Scripts/Main/preinstall ${1}/Pre/Scripts
67cp -f ${pkgroot}/Scripts/Sub/InstallLog.sh ${1}/Pre/Scripts
68echo "[BUILD] Pre "
69buildpackage "${1}/Pre" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
70# End build pre install package
71
72# build core package
73echo "================= Core ================="
74packagesidentity="org.chameleon"
75mkdir -p ${1}/Core/Root/usr/local/bin
76mkdir -p ${1}/Core/Root/usr/standalone/i386
77ditto --noextattr --noqtn ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
78ditto --noextattr --noqtn ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386
79ditto --noextattr --noqtn ${1%/*}/i386/boot0md ${1}/Core/Root/usr/standalone/i386
80ditto --noextattr --noqtn ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386
81ditto --noextattr --noqtn ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386
82ditto --noextattr --noqtn ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386
83ditto --noextattr --noqtn ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386
84ditto --noextattr --noqtn ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386
85ditto --noextattr --noqtn ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386
86ditto --noextattr --noqtn ${1%/*}/i386/fdisk440 ${1}/Core/Root/usr/local/bin
87ditto --noextattr --noqtn ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/local/bin
88local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
89echo "[BUILD] i386 "
90buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
91# End build core package
92
93# build Chameleon package
94echo "================= Chameleon ================="
95outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Chameleon\">"
96choices[$((choicescount++))]="\t<choice\n\t\tid=\"Chameleon\"\n\t\ttitle=\"Chameleon_title\"\n\t\tdescription=\"Chameleon_description\">\n\t</choice>\n"
97((xmlindent++))
98
99# build standard package
100mkdir -p ${1}/Standard/Root
101mkdir -p ${1}/Standard/Scripts/Resources
102cp -f ${pkgroot}/Scripts/Main/Standard/* ${1}/Standard/Scripts
103cp -f ${pkgroot}/Scripts/Sub/* ${1}/Standard/Scripts
104ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Resources/SetFile
105echo "[BUILD] Standard "
106 buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
107# End build standard package
108
109# build efi package
110mkdir -p ${1}/EFI/Root
111mkdir -p ${1}/EFI/Scripts/Resources
112cp -f ${pkgroot}/Scripts/Main/EFI/* ${1}/EFI/Scripts
113cp -f ${pkgroot}/Scripts/Sub/* ${1}/EFI/Scripts
114ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Resources/SetFile
115echo "[BUILD] EFI "
116buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
117# End build efi package
118
119# build reset choice package
120mkdir -p ${1}/noboot/Root
121echo "[BUILD] Reset choice "
122buildpackage "${1}/noboot" "/$chamTemp" "" "selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
123# End build reset choice package
124
125 ((xmlindent--))
126 outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
127# End build Chameleon package
128
129# build Modules package
130echo "================= Modules ================="
131###############################
132# Supported Modules #
133###############################
134# klibc.dylib #
135# Resolution.dylib #
136# uClibcxx.dylib #
137# Keylayout.dylib #
138###############################
139if [ "$(ls -A "${1%/*}/i386/modules")" ]; then
140{
141outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Module\">"
142choices[$((choicescount++))]="\t<choice\n\t\tid=\"Module\"\n\t\ttitle=\"Module_title\"\n\t\tdescription=\"Module_description\">\n\t</choice>\n"
143((xmlindent++))
144packagesidentity="org.chameleon.modules"
145# -
146if [ -e ${1%/*}/i386/modules/klibc.dylib ]; then
147{
148mkdir -p ${1}/klibc/Root
149ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/klibc/Root
150echo "[BUILD] klibc "
151buildpackage "${1}/klibc" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
152}
153fi
154# -
155if [ -e ${1%/*}/i386/modules/Resolution.dylib ]; then
156{
157mkdir -p ${1}/AutoReso/Root
158ditto --noextattr --noqtn ${1%/*}/i386/modules/Resolution.dylib ${1}/AutoReso/Root
159echo "[BUILD] Resolution "
160buildpackage "${1}/AutoReso" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
161}
162fi
163# -
164if [ -e ${1%/*}/i386/modules/uClibcxx.dylib ]; then
165{
166mkdir -p ${1}/uClibc/Root
167ditto --noextattr --noqtn ${1%/*}/i386/modules/uClibcxx.dylib ${1}/uClibc/Root
168ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/uClibc/Root
169echo "[BUILD] uClibc++ "
170buildpackage "${1}/uClibc" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
171}
172fi
173# -
174if [ -e ${1%/*}/i386/modules/Keylayout.dylib ]; then
175{
176mkdir -p ${1}/Keylayout/Root
177ditto --noextattr --noqtn ${1%/*}/i386/modules/Keylayout.dylib ${1}/Keylayout/Root
178echo "[BUILD] Keylayout "
179buildpackage "${1}/Keylayout" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1
180}
181fi
182
183((xmlindent--))
184outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
185}
186else
187{
188echo " -= no modules to include =-"
189}
190fi
191# End build Modules packages
192
193# build Extras package
194# build options packages
195
196outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Options\">"
197choices[$((choicescount++))]="\t<choice\n\t\tid=\"Options\"\n\t\ttitle=\"Options_title\"\n\t\tdescription=\"Options_description\">\n\t</choice>\n"
198((xmlindent++))
199
200# ------------------------------------------------------
201# parse OptionalSettings folder to find files of boot options.
202# ------------------------------------------------------
203OptionalSettingsFolder="${pkgroot}/OptionalSettings"
204OptionalSettingsFiles=($( find "${OptionalSettingsFolder}" -depth 1 ! -name '.svn' ! -name '.DS_Store' ))
205
206for (( i = 0 ; i < ${#OptionalSettingsFiles[@]} ; i++ ))
207do
208
209# Take filename and Strip .txt from end and path from front
210builtOptionsList=$( echo ${OptionalSettingsFiles[$i]%.txt} )
211builtOptionsList=$( echo ${builtOptionsList##*/} )
212echo "================= $builtOptionsList ================="
213outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"${builtOptionsList}\">"
214choices[$((choicescount++))]="\t<choice\n\t\tid=\"${builtOptionsList}\"\n\t\ttitle=\"${builtOptionsList}_title\"\n\t\tdescription=\"${builtOptionsList}_description\">\n\t</choice>\n"
215((xmlindent++))
216packagesidentity="org.chameleon.options.$builtOptionsList"
217
218# ------------------------------------------------------
219# Read boot option file in to an array.
220# ------------------------------------------------------
221availableOptions=() # array to hold the list of boot options, per 'section'.
222exclusiveFlag=0 # used to indicate list has exclusive options.
223exclusiveName="" # will be appended to exclusive 'none' option name.
224count=0 # used as index for stepping through array.
225while read textLine
226do
227# ignore lines in the file beginning with a # and Exclusive=False
228if [[ ${textLine} != \#* ]] && [[ ${textLine} != "Exclusive=False" ]];then
229# check for 'Exclusive=True' option in file
230if [[ ${textLine} == "Exclusive=True" ]];then
231exclusiveFlag=1
232exclusiveName=$builtOptionsList
233else
234availableOptions[count]=$textLine
235((count++))
236fi
237fi
238done < ${OptionalSettingsFiles[$i]}
239buildoptionalsettings "$1" "${exclusiveFlag}" "${exclusiveName}"
240
241((xmlindent--))
242outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
243done
244
245# build KeyLayout options packages
246echo "================= Keymaps Options ================="
247outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"KeyLayout\">"
248choices[$((choicescount++))]="\t<choice\n\t\tid=\"KeyLayout\"\n\t\ttitle=\"KeyLayout_title\"\n\t\tdescription=\"KeyLayout_description\">\n\t</choice>\n"
249((xmlindent++))
250packagesidentity="org.chameleon.options.keylayout"
251
252# ------------------------------------------------------
253# Available Keylayout boot options are discovered by
254# reading contents of /Keymaps folder after compilation
255# ------------------------------------------------------
256availableOptions=()
257availableOptions=($( find "${1%/sym/*}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))
258# Adjust array contents to match expected format
259# for boot options which is: name:key=value
260for (( i = 0 ; i < ${#availableOptions[@]} ; i++ ))
261do
262availableOptions[i]=${availableOptions[i]}":KeyLayout="${availableOptions[i]}
263done
264
265# to indicate exclusive option, call buildoptionalsettings with the 2nd parameter set to 1 .
266buildoptionalsettings "$1" "1" "keylayout"
267
268((xmlindent--))
269outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
270
271# End build KeyLayout options packages
272
273((xmlindent--))
274outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
275
276# End build options packages
277
278# build theme packages
279echo "================= Themes ================="
280outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"Themes\">"
281choices[$((choicescount++))]="\t<choice\n\t\tid=\"Themes\"\n\t\ttitle=\"Themes_title\"\n\t\tdescription=\"Themes_description\">\n\t</choice>\n"
282((xmlindent++))
283
284# Using themes section from Azi's/package branch.
285packagesidentity="org.chameleon.themes"
286artwork="${1%/sym/package}/artwork/themes"
287themes=($( find "${artwork}" -type d -depth 1 -not -name '.svn' ))
288for (( i = 0 ; i < ${#themes[@]} ; i++ ))
289do
290theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )
291mkdir -p "${1}/${theme}/Root/"
292rsync -r --exclude=.svn "${themes[$i]}/" "${1}/${theme}/Root/${theme}"
293echo "[BUILD] ${theme}"
294buildpackage "${1}/${theme}" "/$chamTemp/Extra/Themes" "" "start_selected=\"false\"" >/dev/null 2>&1
295done
296
297((xmlindent--))
298outline[$((outlinecount++))]="${indent[$xmlindent]}</line>"
299# End build theme packages
300# End build Extras package
301
302# build post install package
303echo "================= Post ================="
304packagesidentity="org.chameleon"
305mkdir -p ${1}/Post/Root
306mkdir -p ${1}/Post/Scripts
307cp -f ${pkgroot}/Scripts/Main/Post/* ${1}/Post/Scripts
308cp -f ${pkgroot}/Scripts/Sub/InstallLog.sh ${1}/Post/Scripts
309cp -f ${pkgroot}/Scripts/Sub/UnMountEFIvolumes.sh ${1}/Post/Scripts
310ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Post/Scripts/Resources/revision
311ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Post/Scripts/Resources/version
312echo "[BUILD] Post "
313buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
314# End build post install package
315
316((xmlindent--))
317outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
318
319# build meta package
320
321makedistribution "${1}" "${2}" "${3}" "${4}" #"${5}"
322
323# clean up
324
325rm -R -f "${1}"
326
327}
328
329fixperms ()
330{
331# $1 path
332find "${1}" -type f -exec chmod 644 {} \;
333find "${1}" -type d -exec chmod 755 {} \;
334chown -R 0:0 "${1}"
335}
336
337buildoptionalsettings()
338{
339# $1 Path to package to build containing Root and or Scripts
340# $2 = exclusiveFlag
341# S3 = exclusiveName
342
343# ------------------------------------------------------
344# if exclusiveFlag=1 then re-build array
345# adding extra boot option at beginning to give
346
347# ------------------------------------------------------
348if [ ${2} = "1" ]; then
349tempArray=("${availableOptions[@]}")
350availableOptions=()
351availableOptions[0]="ChooseNone-"$3":DONT=ADD"
352position=0
353totalItems="${#tempArray[@]}"
354for (( position = 0 ; position < $totalItems ; position++ ))
355do
356availableOptions[$position+1]=${tempArray[${position}]}
357done
358fi
359
360# ------------------------------------------------------
361# Loop through options in array and process each in turn
362# ------------------------------------------------------
363for (( c = 0 ; c < ${#availableOptions[@]} ; c++ ))
364do
365textLine=${availableOptions[c]}
366# split line - taking all before ':' as option name
367# and all after ':' as key/value
368optionName=${textLine%:*}
369keyValue=${textLine##*:}
370
371# create folders required for each boot option
372mkdir -p "${1}/$optionName/Root/"
373
374# create dummy file with name of key/value
375echo "" > "${1}/$optionName/Root/${keyValue}"
376
377echo "[BUILD] ${optionName} "
378
379# ------------------------------------------------------
380# Before calling buildpackage, add exclusive options
381# to buildpackage call if requested.
382# ------------------------------------------------------
383if [ $2 = "1" ]; then
384
385# Prepare individual string parts
386stringStart="selected=\""
387stringBefore="exclusive(choices['"
388stringAfter="']) &amp;&amp; "
389stringEnd="'])\""
390x=${stringStart}${stringBefore}
391
392# build string for sending to buildpackage
393totalItems="${#availableOptions[@]}"
394lastItem=$((totalItems-1))
395
396for (( r = 0 ; r < ${totalItems} ; r++ ))
397do
398textLineTemp=${availableOptions[r]}
399optionNameTemp=${textLineTemp%:*}
400if [ "${optionNameTemp}" != "${optionName}" ]; then
401 x="${x}${optionNameTemp}"
402 # Only add these to end of string up to the one before the last item
403if [ $r -lt $lastItem ]; then
404x="${x}${stringAfter}${stringBefore}"
405fi
406fi
407done
408x="${x}${stringEnd}"
409
410# First exclusive option is the 'no choice' option, so let's make that selected by default.
411if [ $c = 0 ]; then
412initialChoice="true"
413else
414initialChoice="false"
415fi
416
417buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"${initialChoice}\" ${x}" >/dev/null 2>&1
418else
419buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\"" >/dev/null 2>&1
420fi
421done
422}
423
424buildpackage ()
425{
426# $1 Path to package to build containing Root and or Scripts
427# $2 Install Location
428# $3 Size
429# $4 Options
430
431if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
432
433local packagename="${1##*/}"
434local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )
435find "${1}" -name '.DS_Store' -delete
436local filecount=$( find "${1}/Root" | wc -l )
437if [ "${3}" ]; then
438local installedsize="${3}"
439else
440local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )
441fi
442local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
443
444#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
445
446header+="identifier=\"${identifier}\" "
447header+="version=\"${version}\" "
448
449[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
450
451header+="auth=\"root\">\n"
452header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
453rm -R -f "${1}/Temp"
454
455[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
456[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
457
458if [ -d "${1}/Scripts" ]; then
459header+="\t<scripts>\n"
460for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )
461do
462header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
463done
464header+="\t</scripts>\n"
465chown -R 0:0 "${1}/Scripts"
466pushd "${1}/Scripts" >/dev/null
467find . -print | cpio -o -z -H cpio > "../Temp/Scripts"
468popd >/dev/null
469fi
470
471header+="</pkg-info>"
472echo -e "${header}" > "${1}/Temp/PackageInfo"
473pushd "${1}/Root" >/dev/null
474find . -print | cpio -o -z -H cpio > "../Temp/Payload"
475popd >/dev/null
476pushd "${1}/Temp" >/dev/null
477
478xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
479
480popd >/dev/null
481
482outline[$((outlinecount++))]="${indent[$xmlindent]}<line choice=\"${packagename// /}\"/>"
483
484if [ "${4}" ]; then
485local choiceoptions="\t\t${4}"
486fi
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: 1642