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

Archive Download this file

Revision: 1731