Chameleon

Chameleon Svn Source Tree

Root/branches/ErmaC/Trunk/package/buildpkg.sh

  • Property svn:executable set to *
1#!/bin/bash
2
3# $0 SRCROOT directory
4# $1 SYMROOT directory
5# $2 directory where pkgs will be created
6
7# Directory paths
8declare -r PKGROOT="${0%/*}"
9declare -r SRCROOT="$1"
10declare -r SYMROOT="$2"
11declare -r PKG_BUILD_DIR="$3"
12declare -r SCPT_TPL_DIR="${PKGROOT}/Scripts.templates"
13
14if [[ $# -lt 3 ]];then
15 echo "Too few arguments. Aborting..." >&2 && exit 1
16fi
17
18if [[ ! -d "$SYMROOT" ]];then
19 echo "Directory ${SYMROOT} doesn't exit. Aborting..." >&2 && exit 1
20fi
21
22# Prevent the script from doing bad things
23set -u # Abort with unset variables
24#set -e # Abort with any error can be suppressed locally using EITHER cmd||true OR set -e;cmd;set +e
25
26# ====== CONFIGURATION ======
27CONFIG_MODULES=""
28CONFIG_KLIBC_MODULE=""
29CONFIG_UCLIBCXX_MODULE=""
30CONFIG_SATA_MODULE=""
31CONFIG_ACPICODEC_MODULE=""
32CONFIG_RESOLUTION_MODULE=""
33CONFIG_KEYLAYOUT_MODULE=""
34source "${SRCROOT}/auto.conf"
35
36# ====== COLORS ======
37declare -r COL_BLACK="\x1b[30;01m"
38declare -r COL_RED="\x1b[31;01m"
39declare -r COL_GREEN="\x1b[32;01m"
40declare -r COL_YELLOW="\x1b[33;01m"
41declare -r COL_MAGENTA="\x1b[35;01m"
42declare -r COL_CYAN="\x1b[36;01m"
43declare -r COL_WHITE="\x1b[37;01m"
44declare -r COL_BLUE="\x1b[34;01m"
45declare -r COL_RESET="\x1b[39;49;00m"
46
47# ====== REVISION/VERSION ======
48declare -r CHAMELEON_VERSION=$( cat version )
49
50# stage
51CHAMELEON_STAGE=${CHAMELEON_VERSION##*-}
52CHAMELEON_STAGE=${CHAMELEON_STAGE/RC/Release Candidate }
53CHAMELEON_STAGE=${CHAMELEON_STAGE/FINAL/2.1 Final}
54declare -r CHAMELEON_STAGE
55
56declare -r CHAMELEON_REVISION=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )
57declare -r CHAMELEON_BUILDDATE=$( grep I386BOOT_BUILDDATE vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
58declare -r CHAMELEON_TIMESTAMP=$( date -j -f "%Y-%m-%d %H:%M:%S" "${CHAMELEON_BUILDDATE}" "+%s" )
59
60# ====== CREDITS ======
61declare -r CHAMELEON_DEVELOP=$(awk "NR==6{print;exit}" ${PKGROOT}/../CREDITS)
62declare -r CHAMELEON_CREDITS=$(awk "NR==10{print;exit}" ${PKGROOT}/../CREDITS)
63declare -r CHAMELEON_PKGDEV=$(awk "NR==14{print;exit}" ${PKGROOT}/../CREDITS)
64declare -r CHAMELEON_CPRYEAR=$(awk "NR==18{print;exit}" ${PKGROOT}/../CREDITS)
65if [[ $(whoami | awk '{print $1}' | cut -d ":" -f3) == "admin" ]];then
66 declare -r CHAMELEON_WHOBUILD="VoodooLabs BuildBot"
67else
68 declare -r CHAMELEON_WHOBUILD=$(whoami | awk '{print $1}' | cut -d ":" -f3)
69fi
70
71# ====== GLOBAL VARIABLES ======
72declare -r LOG_FILENAME="Chameleon_Installer_Log.txt"
73
74declare -a chameleonOptionType
75declare -a chameleonOptionKey
76declare -a chameleonOptionValues
77
78declare -a pkgrefs
79declare -a choice_key
80declare -a choice_options
81declare -a choice_pkgrefs
82declare -a choice_parent_group_index
83declare -a choice_group_items
84declare -a choice_group_exclusive
85
86# Init Main Group
87choice_key[0]=""
88choice_options[0]=""
89choices_pkgrefs[0]=""
90choice_group_items[0]=""
91choice_group_exclusive[0]=""
92
93# Package name
94declare -r packagename="Enoch"
95
96# Package identifiers
97declare -r chameleon_package_identity="org.chameleon"
98declare -r modules_packages_identity="${chameleon_package_identity}.modules"
99
100# ====== FUNCTIONS ======
101trim () {
102 local result="${1#"${1%%[![:space:]]*}"}" # remove leading whitespace characters
103 echo "${result%"${result##*[![:space:]]}"}" # remove trailing whitespace characters
104}
105
106function makeSubstitutions () {
107 # Substition is like: Key=Value
108 #
109 # Optional arguments:
110 # --subst=<substition> : add a new substitution
111 #
112 # Last argument(s) is/are file(s) where substitutions must be made
113
114 local ownSubst=""
115
116 function addSubst () {
117 local mySubst="$1"
118 case "$mySubst" in
119*=*) keySubst=${mySubst%%=*}
120 valSubst=${mySubst#*=}
121 ownSubst=$(printf "%s\n%s" "$ownSubst" "s&@$keySubst@&$valSubst&g;t t")
122 ;;
123*) echo "Invalid substitution $mySubst" >&2
124 exit 1
125 ;;
126esac
127 }
128
129 # Check the arguments.
130 while [[ $# -gt 0 ]];do
131 local option="$1"
132 case "$option" in
133 --subst=*) shift; addSubst "${option#*=}" ;;
134 -*)
135 echo "Unrecognized makeSubstitutions option '$option'" >&2
136 exit 1
137 ;;
138 *) break ;;
139 esac
140 done
141
142 if [[ $# -lt 1 ]];then
143 echo "makeSubstitutions invalid number of arguments: at least one file needed" >&2
144 exit 1
145 fi
146
147 local chameleonSubsts="
148s&%CHAMELEONVERSION%&${CHAMELEON_VERSION%%-*}&g
149s&%CHAMELEONREVISION%&${CHAMELEON_REVISION}&g
150s&%CHAMELEONSTAGE%&${CHAMELEON_STAGE}&g
151s&%DEVELOP%&${CHAMELEON_DEVELOP}&g
152s&%CREDITS%&${CHAMELEON_CREDITS}&g
153s&%PKGDEV%&${CHAMELEON_PKGDEV}&g
154s&%CPRYEAR%&${CHAMELEON_CPRYEAR}&g
155s&%WHOBUILD%&${CHAMELEON_WHOBUILD}&g
156:t
157/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
158s&@LOG_FILENAME@&${LOG_FILENAME}&g;t t"
159
160 local allSubst="
161$chameleonSubsts
162$ownSubst"
163
164 for file in "$@";do
165 cp -pf "$file" "${file}.in"
166 sed "$allSubst" "${file}.in" > "${file}"
167 rm -f "${file}.in"
168 done
169}
170
171addTemplateScripts () {
172 # Arguments:
173 # --pkg-rootdir=<pkg_rootdir> : path of the pkg root dir
174 #
175 # Optional arguments:
176 # --subst=<substition> : add a new substitution
177 #
178 # Substition is like: Key=Value
179 #
180 # $n : Name of template(s) (templates are in package/Scripts.templates
181
182 local pkgRootDir=""
183 declare -a allSubst
184
185 # Check the arguments.
186 while [[ $# -gt 0 ]];do
187 local option="$1"
188 case "$option" in
189 --pkg-rootdir=*) shift; pkgRootDir="${option#*=}" ;;
190 --subst=*) shift; allSubst[${#allSubst[*]}]="${option}" ;;
191 -*)
192 echo "Unrecognized addTemplateScripts option '$option'" >&2
193 exit 1
194 ;;
195 *) break ;;
196 esac
197 done
198 if [[ $# -lt 1 ]];then
199 echo "addTemplateScripts invalid number of arguments: you must specify a template name" >&2
200 exit 1
201 fi
202 [[ -z "$pkgRootDir" ]] && { echo "Error addTemplateScripts: --pkg-rootdir option is needed" >&2 ; exit 1; }
203 [[ ! -d "$pkgRootDir" ]] && { echo "Error addTemplateScripts: directory '$pkgRootDir' doesn't exists" >&2 ; exit 1; }
204
205 for templateName in "$@";do
206 local templateRootDir="${SCPT_TPL_DIR}/${templateName}"
207 [[ ! -d "$templateRootDir" ]] && {
208 echo "Error addTemplateScripts: template '$templateName' doesn't exists" >&2; exit 1; }
209
210 # Copy files to destination
211 rsync -pr --exclude=.svn --exclude="*~" "$templateRootDir/" "$pkgRootDir/Scripts/"
212 done
213
214 files=$( find "$pkgRootDir/Scripts/" -type f )
215 if [[ ${#allSubst[*]} -gt 0 ]];then
216 makeSubstitutions "${allSubst[@]}" $files
217 else
218 makeSubstitutions $files
219 fi
220}
221
222getPackageRefId () {
223 echo ${1//_/.}.${2//_/.} | tr [:upper:] [:lower:]
224}
225
226# Return index of a choice
227getChoiceIndex () {
228 # $1 Choice Id
229 local found=0
230 for (( idx=0 ; idx < ${#choice_key[*]}; idx++ ));do
231 if [[ "${1}" == "${choice_key[$idx]}" ]];then
232 found=1
233 break
234 fi
235 done
236 echo "$idx"
237 return $found
238}
239
240# Add a new choice
241addChoice () {
242 # Optional arguments:
243 # --group=<group> : Group Choice Id
244 # --start-selected=<javascript code> : Specifies whether this choice is initially selected or unselected
245 # --start-enabled=<javascript code> : Specifies the initial enabled state of this choice
246 # --start-visible=<javascript code> : Specifies whether this choice is initially visible
247 # --pkg-refs=<pkgrefs> : List of package reference(s) id (separate by spaces)
248 #
249 # $1 Choice Id
250
251 local option
252 local groupChoice=""
253 local choiceOptions=""
254 local pkgrefs=""
255
256 # Check the arguments.
257 for option in "${@}";do
258 case "$option" in
259 --group=*)
260 shift; groupChoice=${option#*=} ;;
261 --start-selected=*)
262 shift; choiceOptions="$choiceOptions start_selected=\"${option#*=}\"" ;;
263 --start-enabled=*)
264 shift; choiceOptions="$choiceOptions start_enabled=\"${option#*=}\"" ;;
265 --start-visible=*)
266 shift; choiceOptions="$choiceOptions start_visible=\"${option#*=}\"" ;;
267 --pkg-refs=*)
268 shift; pkgrefs=${option#*=} ;;
269 -*)
270 echo "Unrecognized addChoice option '$option'" >&2
271 exit 1
272 ;;
273 *) break ;;
274 esac
275 done
276
277 if [[ $# -ne 1 ]];then
278 echo "addChoice invalid number of arguments: ${@}" >&2
279 exit 1
280 fi
281
282 local choiceId="${1}"
283
284 # Add choice in the group
285 idx_group=$(getChoiceIndex "$groupChoice")
286 found_group=$?
287 if [[ $found_group -ne 1 ]];then
288 # No group exist
289 echo "Error can't add choice '$choiceId' to group '$groupChoice': group choice '$groupChoice' doesn't exists." >&2
290 exit 1
291 else
292 set +u; oldItems=${choice_group_items[$idx_group]}; set -u
293 choice_group_items[$idx_group]="$oldItems $choiceId"
294 fi
295
296 # Check that the choice doesn't already exists
297 idx=$(getChoiceIndex "$choiceId")
298 found=$?
299 if [[ $found -ne 0 ]];then
300 # Choice already exists
301 echo "Error can't add choice '$choiceId': a choice with same name already exists." >&2
302 exit 1
303 fi
304
305 # Record new node
306 choice_key[$idx]="$choiceId"
307 choice_options[$idx]=$(trim "${choiceOptions}") # Removing leading and trailing whitespace(s)
308 choice_parent_group_index[$idx]=$idx_group
309 choice_pkgrefs[$idx]="$pkgrefs"
310
311 return $idx
312}
313
314# Add a group choice
315addGroupChoices() {
316 # Optional arguments:
317 # --parent=<parent> : parent group choice id
318 # --exclusive_zero_or_one_choice : only zero or one choice can be selected in the group
319 # --exclusive_one_choice : only one choice can be selected in the group
320 #
321 # $1 Choice Id
322
323 local option
324 local groupChoice=""
325 local exclusive_function=""
326
327 for option in "${@}";do
328 case "$option" in
329 --exclusive_zero_or_one_choice)
330 shift; exclusive_function="exclusive_zero_or_one_choice" ;;
331 --exclusive_one_choice)
332 shift; exclusive_function="exclusive_one_choice" ;;
333 --parent=*)
334 shift; groupChoice=${option#*=} ;;
335 -*)
336 echo "Unrecognized addGroupChoices option '$option'" >&2
337 exit 1
338 ;;
339 *) break ;;
340 esac
341 done
342
343 if [[ $# -ne 1 ]];then
344 echo "addGroupChoices invalid number of arguments: ${@}" >&2
345 exit 1
346 fi
347
348 addChoice --group="$groupChoice" "${1}"
349 local idx=$? # index of the new created choice
350
351 choice_group_exclusive[$idx]="$exclusive_function"
352}
353
354exclusive_one_choice () {
355 # $1 Current choice (ie: test1)
356 # $2..$n Others choice(s) (ie: "test2" "test3"). Current can or can't be in the others choices
357 local myChoice="${1}"
358 local result="";
359 local separator=' || ';
360 for choice in ${@:2};do
361 if [[ "$choice" != "$myChoice" ]];then
362 result="${result}choices['$choice'].selected${separator}";
363 fi
364 done
365 if [[ -n "$result" ]];then
366 echo "!(${result%$separator})"
367 fi
368}
369
370exclusive_zero_or_one_choice () {
371 # $1 Current choice (ie: test1)
372 # $2..$n Others choice(s) (ie: "test2" "test3"). Current can or can't be in the others choices
373 local myChoice="${1}"
374 local result;
375 echo "(my.choice.selected &amp;&amp; $(exclusive_one_choice ${@}))"
376}
377
378recordChameleonOption () {
379 local type="$1"
380 local key="$2"
381 local value="$3"
382
383 # Search for an existing key
384 local found=0
385 for (( idx=0 ; idx < ${#chameleonOptionKey[@]}; idx++ ));do
386 if [[ "$key" == "${chameleonOptionKey[$idx]}" ]];then
387 found=1
388 break
389 fi
390 done
391
392 # idx contain the index of a new key or an existing one
393 if [[ $found -eq 0 ]]; then
394 # Create a new one
395 chameleonOptionKey[$idx]="$key"
396 chameleonOptionType[$idx]="$type"
397 chameleonOptionValues[$idx]=""
398 fi
399
400 case "$type" in
401 bool) ;;
402 text|list) chameleonOptionValues[$idx]="${chameleonOptionValues[$idx]} $value" ;;
403 *) echo "Error unknown type '$type' for '$key'" >&2
404 exit 1
405 ;;
406 esac
407}
408
409generate_options_yaml_file () {
410 local yamlFile="$1"
411 echo "---" > $yamlFile
412 for (( idx=0; idx < ${#chameleonOptionKey[@]}; idx++ ));do
413 printf "%s:\n type: %s\n" "${chameleonOptionKey[$idx]}" "${chameleonOptionType[$idx]}" >> $yamlFile
414 case ${chameleonOptionType[$idx]} in
415 text|list)
416 printf " values:\n" >> $yamlFile
417 for value in ${chameleonOptionValues[$idx]};do
418 printf " - %s\n" "$value" >> $yamlFile
419 done
420 ;;
421 esac
422 done
423}
424
425main ()
426{
427
428# clean up the destination path
429
430 rm -R -f "${PKG_BUILD_DIR}"
431 echo ""
432 echo -e $COL_CYAN" ----------------------------------"$COL_RESET
433 echo -e $COL_CYAN" Building $packagename Install Package"$COL_RESET
434 echo -e $COL_CYAN" ----------------------------------"$COL_RESET
435 echo ""
436
437# Add pre install choice
438 echo "================= Preinstall ================="
439 packagesidentity="${chameleon_package_identity}"
440 choiceId="Pre"
441
442 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
443 addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"
444
445 # Package will be built at the end
446# End pre install choice
447
448# build core package
449 echo "================= Core ================="
450 packagesidentity="${chameleon_package_identity}"
451 choiceId="Core"
452 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
453 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
454 ditto --noextattr --noqtn ${SYMROOT}/i386/boot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
455 ditto --noextattr --noqtn ${SYMROOT}/i386/boot0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
456 ditto --noextattr --noqtn ${SYMROOT}/i386/boot0md ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
457 ditto --noextattr --noqtn ${SYMROOT}/i386/boot1f32 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
458 ditto --noextattr --noqtn ${SYMROOT}/i386/boot1h ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
459 ditto --noextattr --noqtn ${SYMROOT}/i386/boot1he ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
460 ditto --noextattr --noqtn ${SYMROOT}/i386/boot1hp ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
461 ditto --noextattr --noqtn ${SYMROOT}/i386/cdboot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
462 ditto --noextattr --noqtn ${SYMROOT}/i386/chain0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386
463 ditto --noextattr --noqtn ${SYMROOT}/i386/fdisk440 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
464 ditto --noextattr --noqtn ${SYMROOT}/i386/bdmesg ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
465
466 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
467 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
468 addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"
469# End build core package
470
471# build Chameleon package
472 echo "================= Chameleon ================="
473 addGroupChoices --exclusive_one_choice "Chameleon"
474
475 # build standard package
476 choiceId="Standard"
477 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
478 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources
479 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" InstallerLog
480 cp -f ${PKGROOT}/Scripts/Main/${choiceId}postinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall
481 cp -f ${PKGROOT}/Scripts/Sub/* ${PKG_BUILD_DIR}/${choiceId}/Scripts
482 ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile
483
484 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
485 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
486 addChoice --group="Chameleon" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"
487 # End build standard package
488
489 # build efi package
490if [[ 1 -eq 0 ]];then
491 # Only standard installation is currently supported
492 # We need to update the script to be able to install
493 # Chameleon on EFI partition
494 choiceId="EFI"
495 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
496 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources
497 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" InstallerLog
498 cp -f ${PKGROOT}/Scripts/Main/ESPpostinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall
499 cp -f ${PKGROOT}/Scripts/Sub/* ${PKG_BUILD_DIR}/${choiceId}/Scripts
500 ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile
501
502 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
503 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
504 addChoice --group="Chameleon" --start-visible="systemHasGPT()" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"
505 # End build efi package
506fi
507 # build no bootloader choice package
508 choiceId="noboot"
509 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
510
511 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
512 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
513 addChoice --group="Chameleon" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"
514 # End build no bootloader choice package
515
516# End build Chameleon package
517
518if [[ "${CONFIG_MODULES}" == 'y' ]];then
519# build Modules package
520 echo "================= Modules ================="
521 ###############################
522 # Supported Modules #
523 ###############################
524 # klibc.dylib #
525 # Resolution.dylib #
526 # uClibcxx.dylib #
527 # Sata.dylib #
528 # ACPICodec.dylib #
529 # Keylayout.dylib #
530 ###############################
531 if [ "$(ls -A "${SYMROOT}/i386/modules")" ]; then
532 {
533 addGroupChoices "Module"
534
535# -
536 if [[ "${CONFIG_KLIBC_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/klibc.dylib" ]]; then
537 {
538 # Start build klibc package module
539 choiceId="klibc"
540 moduleFile="${choiceId}.dylib"
541 mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"
542 ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" ${PKG_BUILD_DIR}/${choiceId}/Root
543 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
544 --subst="moduleName=$choiceId" \
545 --subst="moduleFile=$moduleFile" \
546 InstallModule
547
548 packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
549 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules"
550 addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"
551 # End build klibc package module
552 }
553 fi
554
555# -
556 if [[ "${CONFIG_UCLIBCXX_MODULE}" = 'm' && -n "${CONFIG_KLIBC_MODULE}" && \
557 -f "${SYMROOT}/i386/modules/uClibcxx.dylib" ]]; then
558 {
559 klibcPackageRefId=""
560 if [[ "${CONFIG_KLIBC_MODULE}" == 'm' ]];then
561 klibcPackageRefId=$(getPackageRefId "${modules_packages_identity}" "klibc")
562 fi
563 # Start build uClibc package module
564 choiceId="uClibc"
565 moduleFile="uClibcxx.dylib"
566 mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"
567 ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"
568 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
569 --subst="moduleName=$choiceId" \
570 --subst="moduleFile=$moduleFile" \
571 InstallModule
572
573 packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
574 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules"
575 # Add the klibc package because the uClibc module is dependent of klibc module
576 addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId $klibcPackageRefId" "${choiceId}"
577 # End build uClibc package module
578 }
579 fi
580# -
581 if [[ "${CONFIG_SATA_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/Sata.dylib" ]]; then
582 {
583 # Start build Sata package module
584 choiceId="Sata"
585 moduleFile="Sata.dylib"
586 mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"
587 ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"
588 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
589 --subst="moduleName=$choiceId" \
590 --subst="moduleFile=$moduleFile" \
591 InstallModule
592
593 packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
594 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules"
595 addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"
596 # End build Sata package module
597 }
598 fi
599
600# -
601 if [[ "${CONFIG_ACPICODEC_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/ACPICodec.dylib" ]]; then
602 {
603 # Start build ACPICodec package module
604 choiceId="ACPICodec"
605 moduleFile="ACPICodec.dylib"
606 mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"
607 ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"
608 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
609 --subst="moduleName=$choiceId" \
610 --subst="moduleFile=$moduleFile" \
611 InstallModule
612
613 packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
614 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules"
615 addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"
616 # End build ACPICodec package module
617 }
618 fi
619
620# -
621 if [[ "${CONFIG_RESOLUTION_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/Resolution.dylib" ]]; then
622 {
623 # Start build Resolution package module
624 choiceId="AutoReso"
625 moduleFile="Resolution.dylib"
626 mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"
627 ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"
628 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
629 --subst="moduleName=$choiceId" \
630 --subst="moduleFile=$moduleFile" \
631 InstallModule
632
633 packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
634 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules"
635 addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"
636 # End build Resolution package module
637 }
638 fi
639
640# -
641 # Warning Keylayout module need additional files
642 if [[ "${CONFIG_KEYLAYOUT_MODULE}" = 'm' && -f "${SYMROOT}/i386/modules/Keylayout.dylib" ]]; then
643 {
644 # Start build Keylayout package module
645 choiceId="Keylayout"
646 moduleFile="${choiceId}.dylib"
647 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/{modules,Keymaps}
648 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
649 layout_src_dir="${SRCROOT}/i386/modules/Keylayout/layouts/layouts-src"
650 if [ -d "$layout_src_dir" ];then
651 # Create a tar.gz from layout sources
652 (cd "$layout_src_dir"; \
653 tar czf "${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps/layouts-src.tar.gz" README *.slt)
654 fi
655 # Adding module
656 ditto --noextattr --noqtn ${SYMROOT}/i386/modules/$moduleFile ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/modules
657 # Adding Keymaps
658 ditto --noextattr --noqtn ${SRCROOT}/Keymaps ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps
659 # Adding tools
660 ditto --noextattr --noqtn ${SYMROOT}/i386/cham-mklayout ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
661 # Adding scripts
662 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
663 --subst="moduleName=$choiceId" \
664 --subst="moduleFile=$moduleFile" \
665 InstallModule
666
667 packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
668 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
669
670 # Don't add a choice for Keylayout module
671 # addChoice "${choiceId}" "Module" --start-selected="false" "$packageRefId"
672 # End build Keylayout package module
673 }
674 fi
675
676 }
677 else
678 {
679 echo " -= no modules to include =-"
680 }
681 fi
682# End build Modules packages
683fi
684
685# build Options packages
686
687 addGroupChoices "Options"
688
689 # ------------------------------------------------------
690 # parse OptionalSettings folder to find files of boot options.
691 # ------------------------------------------------------
692 OptionalSettingsFolder="${PKGROOT}/OptionalSettings"
693
694 while IFS= read -r -d '' OptionsFile; do
695
696 # Take filename and strip .txt from end and path from front
697 builtOptionsList=${OptionsFile%.txt}
698 builtOptionsList=${builtOptionsList##*/}
699 packagesidentity="${chameleon_package_identity}.options.$builtOptionsList"
700
701 echo "================= $builtOptionsList ================="
702
703 # ------------------------------------------------------
704 # Read boot option file into an array.
705 # ------------------------------------------------------
706 availableOptions=() # array to hold the list of boot options, per 'section'.
707 exclusiveFlag="" # used to indicate list has exclusive options
708 while read textLine; do
709 # ignore lines in the file beginning with a #
710 [[ $textLine = \#* ]] && continue
711 local optionName="" key="" value=""
712 case "$textLine" in
713 Exclusive=[Tt][Rr][Uu][Ee]) exclusiveFlag="--exclusive_zero_or_one_choice" ;;
714 Exclusive=*) continue ;;
715 *@*:*=*)
716 availableOptions[${#availableOptions[*]}]="$textLine" ;;
717 *) echo "Error: invalid line '$textLine' in file '$OptionsFile'" >&2
718 exit 1
719 ;;
720 esac
721 done < "$OptionsFile"
722
723 addGroupChoices --parent="Options" $exclusiveFlag "${builtOptionsList}"
724
725 # ------------------------------------------------------
726 # Loop through options in array and process each in turn
727 # ------------------------------------------------------
728 for textLine in "${availableOptions[@]}"; do
729 # split line - taking all before ':' as option name
730 # and all after ':' as key/value
731 type=$( echo "${textLine%%@*}" | tr '[:upper:]' '[:lower:]' )
732 tmp=${textLine#*@}
733 optionName=${tmp%%:*}
734 keyValue=${tmp##*:}
735 key=${keyValue%%=*}
736 value=${keyValue#*=}
737
738 # create folders required for each boot option
739 mkdir -p "${PKG_BUILD_DIR}/$optionName/Root/"
740
741 case "$type" in
742 bool) startSelected="check_chameleon_bool_option('$key','$value')" ;;
743 text) startSelected="check_chameleon_text_option('$key','$value')" ;;
744 list) startSelected="check_chameleon_list_option('$key','$value')" ;;
745 *) echo "Error: invalid type '$type' in line '$textLine' in '$OptionsFile'" >&2
746 exit 1
747 ;;
748 esac
749 recordChameleonOption "$type" "$key" "$value"
750 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/$optionName" \
751 --subst="optionType=$type" \
752 --subst="optionKey=$key" \
753 --subst="optionValue=$value" \
754 AddOption
755 packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}")
756 buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/"
757 addChoice --group="${builtOptionsList}" \
758 --start-selected="$startSelected" \
759 --pkg-refs="$packageRefId" "${optionName}"
760 done
761
762 done < <( find "${OptionalSettingsFolder}" -depth 1 -type f -name '*.txt' -print0 )
763
764# End build options packages
765
766if [[ -n "${CONFIG_KEYLAYOUT_MODULE}" ]];then
767# build Keymaps options packages
768 echo "================= Keymaps Options ================="
769 addGroupChoices --exclusive_zero_or_one_choice "Keymaps"
770 packagesidentity="${chameleon_package_identity}.options.keymaps"
771 keylayoutPackageRefId=""
772 if [[ "${CONFIG_MODULES}" == 'y' && "${CONFIG_KEYLAYOUT_MODULE}" = 'm' ]];then
773 keylayoutPackageRefId=$(getPackageRefId "${modules_packages_identity}" "Keylayout")
774 fi
775
776 chameleon_keylayout_key="KeyLayout"
777 # ------------------------------------------------------
778 # Available Keylayout boot options are discovered by
779 # reading contents of /Keymaps folder after compilation
780 # ------------------------------------------------------
781 availableOptions=($( find "${SRCROOT}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))
782 # Adjust array contents to match expected format
783 # for boot options which is: name:key=value
784 for (( i = 0 ; i < ${#availableOptions[@]} ; i++ )); do
785 # Start build of a keymap package module
786 choiceId="${availableOptions[i]}"
787 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
788
789 recordChameleonOption "text" "$chameleon_keylayout_key" "$choiceId"
790 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
791 --subst="optionType=text" \
792 --subst="optionKey=$chameleon_keylayout_key" \
793 --subst="optionValue=$choiceId" \
794 AddOption
795 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
796 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
797 # Add the Keylayout package because the Keylayout module is needed
798 addChoice --group="Keymaps" \
799 --start-selected="check_chameleon_text_option('${chameleon_keylayout_key}','${choiceId}')" \
800 --pkg-refs="$packageRefId $keylayoutPackageRefId" "${choiceId}"
801 done
802
803# End build Keymaps options packages
804fi
805
806# build theme packages
807 echo "================= Themes ================="
808 addGroupChoices "Themes"
809
810 # Using themes section from Azi's/package branch.
811 packagesidentity="${chameleon_package_identity}.themes"
812 artwork="${SRCROOT}/artwork/themes"
813 themes=($( find "${artwork}" -type d -depth 1 -not -name '.svn' ))
814 for (( i = 0 ; i < ${#themes[@]} ; i++ )); do
815 themeName=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )
816 themeDir="$themeName"
817 mkdir -p "${PKG_BUILD_DIR}/${themeName}/Root/"
818 rsync -r --exclude=.svn --exclude="*~" "${themes[$i]}/" "${PKG_BUILD_DIR}/${themeName}/Root/${themeName}"
819 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${themeName}" \
820 --subst="themeName=$themeName" \
821 --subst="themeDir=$themeDir" \
822 InstallTheme
823
824 packageRefId=$(getPackageRefId "${packagesidentity}" "${themeName}")
825 buildpackage "$packageRefId" "${themeName}" "${PKG_BUILD_DIR}/${themeName}" "/Extra/Themes"
826 addChoice --group="Themes" --start-selected="false" --pkg-refs="$packageRefId" "${themeName}"
827 done
828# End build theme packages# End build Extras package
829
830# build pre install package
831 echo "================= Pre ================="
832 packagesidentity="${chameleon_package_identity}"
833 choiceId="Pre"
834
835 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
836 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
837 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources
838 local yamlFile="Resources/chameleon_options.yaml"
839 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
840 --subst="YAML_FILE=${yamlFile}" ${choiceId}
841 generate_options_yaml_file "${PKG_BUILD_DIR}/${choiceId}/Scripts/$yamlFile"
842 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
843# End build pre install package
844
845# build post install package
846 echo "================= Post ================="
847 packagesidentity="${chameleon_package_identity}"
848 choiceId="Post"
849 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
850 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId}
851 cp -f ${PKGROOT}/Scripts/Sub/UnMountEFIvolumes.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts
852
853 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
854 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
855 addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"
856# End build post install package
857
858}
859
860buildpackage ()
861{
862 # $1 Package Reference Id (ie: org.chameleon.themes.default)
863 # $2 Package Name (ie: Default)
864 # $3 Path to package to build containing Root and/or Scripts
865 # $4 Target install location
866 # $5 Size (optional)
867 if [[ -d "${3}/Root" ]]; then
868 local packageRefId="$1"
869 local packageName="$2"
870 local packagePath="$3"
871 local targetPath="$4"
872 set +u # packageSize is optional
873 local packageSize="$5"
874 set -u
875
876 echo -e "\t[BUILD] ${packageName}"
877
878 find "${packagePath}" -name '.DS_Store' -delete
879 local filecount=$( find "${packagePath}/Root" | wc -l )
880 if [ "${packageSize}" ]; then
881 local installedsize="${packageSize}"
882 else
883 local installedsize=$( du -hkc "${packagePath}/Root" | tail -n1 | awk {'print $1'} )
884 fi
885 local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
886
887 #[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
888
889 header+="identifier=\"${packageRefId}\" "
890 header+="version=\"${CHAMELEON_VERSION}\" "
891
892 [ "${targetPath}" != "relocatable" ] && header+="install-location=\"${targetPath}\" "
893
894 header+="auth=\"root\">\n"
895 header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
896 rm -R -f "${packagePath}/Temp"
897
898 [ -d "${packagePath}/Temp" ] || mkdir -m 777 "${packagePath}/Temp"
899 [ -d "${packagePath}/Root" ] && mkbom "${packagePath}/Root" "${packagePath}/Temp/Bom"
900
901 if [ -d "${packagePath}/Scripts" ]; then
902 header+="\t<scripts>\n"
903 for script in $( find "${packagePath}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) ); do
904 header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
905 done
906 header+="\t</scripts>\n"
907 # Create the Script archive file (cpio format)
908 (cd "${packagePath}/Scripts" && find . -print | \
909 cpio -o -z -R root:wheel --format cpio > "${packagePath}/Temp/Scripts") 2>&1 | \
910 grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages
911 fi
912
913 header+="</pkg-info>"
914 echo -e "${header}" > "${packagePath}/Temp/PackageInfo"
915
916 # Create the Payload file (cpio format)
917 (cd "${packagePath}/Root" && find . -print | \
918 cpio -o -z -R root:wheel --format cpio > "${packagePath}/Temp/Payload") 2>&1 | \
919 grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages
920
921 # Create the package
922 (cd "${packagePath}/Temp" && xar -c -f "${packagePath}/../${packageName}.pkg" --compression none .)
923
924 # Add the package to the list of build packages
925 pkgrefs[${#pkgrefs[*]}]="\t<pkg-ref id=\"${packageRefId}\" installKBytes='${installedsize}' version='${CHAMELEON_VERSION}.0.0.${CHAMELEON_TIMESTAMP}'>#${packageName}.pkg</pkg-ref>"
926
927 rm -rf "${packagePath}"
928 fi
929}
930
931generateOutlineChoices() {
932 # $1 Main Choice
933 # $2 indent level
934 local idx=$(getChoiceIndex "$1")
935 local indentLevel="$2"
936 local indentString=""
937 for ((level=1; level <= $indentLevel ; level++)); do
938 indentString="\t$indentString"
939 done
940 set +u; subChoices="${choice_group_items[$idx]}"; set -u
941 if [[ -n "${subChoices}" ]]; then
942 # Sub choices exists
943 echo -e "$indentString<line choice=\"$1\">"
944 for subChoice in $subChoices;do
945 generateOutlineChoices $subChoice $(($indentLevel+1))
946 done
947 echo -e "$indentString</line>"
948 else
949 echo -e "$indentString<line choice=\"$1\"/>"
950 fi
951}
952
953generateChoices() {
954 for (( idx=1; idx < ${#choice_key[*]} ; idx++)); do
955 local choiceId=${choice_key[$idx]}
956 local choiceOptions=${choice_options[$idx]}
957 local choiceParentGroupIndex=${choice_parent_group_index[$idx]}
958 set +u; local group_exclusive=${choice_group_exclusive[$choiceParentGroupIndex]}; set -u
959
960 # Create the node and standard attributes
961 local choiceNode="\t<choice\n\t\tid=\"${choiceId}\"\n\t\ttitle=\"${choiceId}_title\"\n\t\tdescription=\"${choiceId}_description\""
962
963 # Add options like start_selected, etc...
964 [[ -n "${choiceOptions}" ]] && choiceNode="${choiceNode}\n\t\t${choiceOptions}"
965
966 # Add the selected attribute if options are mutually exclusive
967 if [[ -n "$group_exclusive" ]];then
968 local group_items="${choice_group_items[$choiceParentGroupIndex]}"
969 case $group_exclusive in
970 exclusive_one_choice)
971 local selected_option=$(exclusive_one_choice "$choiceId" "$group_items") ;;
972 exclusive_zero_or_one_choice)
973 local selected_option=$(exclusive_zero_or_one_choice "$choiceId" "$group_items") ;;
974 *) echo "Error: unknown function to generate exclusive mode '$group_exclusive' for group '${choice_key[$choiceParentGroupIndex]}'" >&2
975 exit 1
976 ;;
977 esac
978 choiceNode="${choiceNode}\n\t\tselected=\"$selected_option\""
979 fi
980
981 choiceNode="${choiceNode}>"
982
983 # Add the package references
984 for pkgRefId in ${choice_pkgrefs[$idx]};do
985 choiceNode="${choiceNode}\n\t\t<pkg-ref id=\"${pkgRefId}\"/>"
986 done
987
988 # Close the node
989 choiceNode="${choiceNode}\n\t</choice>\n"
990
991 echo -e "$choiceNode"
992 done
993}
994
995makedistribution ()
996{
997 declare -r distributionDestDir="${SYMROOT}"
998 declare -r distributionFilename="${packagename// /}-rev.${CHAMELEON_REVISION}.pkg"
999 declare -r distributionFilePath="${distributionDestDir}/${distributionFilename}"
1000
1001 rm -f "${distributionDestDir}/${packagename// /}"*.pkg
1002
1003 mkdir -p "${PKG_BUILD_DIR}/${packagename}"
1004
1005 find "${PKG_BUILD_DIR}" -type f -name '*.pkg' -depth 1 | while read component
1006 do
1007 pkg="${component##*/}" # ie: EFI.pkg
1008 pkgdir="${PKG_BUILD_DIR}/${packagename}/${pkg}"
1009 # expand individual packages
1010 pkgutil --expand "${PKG_BUILD_DIR}/${pkg}" "$pkgdir"
1011 rm -f "${PKG_BUILD_DIR}/${pkg}"
1012 done
1013
1014# Create the Distribution file
1015 ditto --noextattr --noqtn "${PKGROOT}/Distribution" "${PKG_BUILD_DIR}/${packagename}/Distribution"
1016
1017 local start_indent_level=2
1018 echo -e "\n\t<choices-outline>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1019 for main_choice in ${choice_group_items[0]};do
1020 generateOutlineChoices $main_choice $start_indent_level >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1021 done
1022 echo -e "\t</choices-outline>\n" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1023
1024 generateChoices >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1025
1026 for (( i=0; i < ${#pkgrefs[*]} ; i++)); do
1027 echo -e "${pkgrefs[$i]}" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1028 done
1029
1030 echo -e "\n</installer-gui-script>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1031
1032# Create the Resources directory
1033 ditto --noextattr --noqtn "${PKGROOT}/Resources/distribution" "${PKG_BUILD_DIR}/${packagename}/Resources"
1034
1035# Make the translation
1036 echo ""
1037 echo "========= Translating Resources ========"
1038 (cd "${PKGROOT}" && PERLLIB=${PKGROOT}/bin/po4a/lib \
1039 bin/po4a/po4a \
1040 --package-name 'Chameleon' \
1041 --package-version "${CHAMELEON_VERSION}-r${CHAMELEON_REVISION}" \
1042 --msgmerge-opt '--lang=$lang' \
1043 --variable PODIR="po" \
1044 --variable TEMPLATES_DIR="Resources/templates" \
1045 --variable OUTPUT_DIR="${PKG_BUILD_DIR}/${packagename}/Resources" \
1046 ${PKGROOT}/po4a-chameleon.cfg)
1047
1048 # Copy common files in english localisation directory
1049 ditto --noextattr --noqtn "${PKGROOT}/Resources/common" "${PKG_BUILD_DIR}/${packagename}/Resources/en.lproj"
1050
1051 # CleanUp the directory
1052 find "${PKG_BUILD_DIR}/${packagename}" \( -type d -name '.svn' \) -o -name '.DS_Store' -depth -exec rm -rf {} \;
1053 find "${PKG_BUILD_DIR}/${packagename}" -type d -depth -empty -exec rmdir {} \; # Remove empty directories
1054
1055 # Make substitutions for version, revision, stage, developers, credits, etc..
1056 makeSubstitutions $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )
1057
1058# Create the final package
1059 pkgutil --flatten "${PKG_BUILD_DIR}/${packagename}" "${distributionFilePath}"
1060
1061##################################################################
1062# Here is the place to assign an icon to the pkg #
1063# command used to generate the file: #
1064# ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip #
1065##################################################################
1066 ditto -xk "${PKGROOT}/Icons/pkg.zip" "${PKG_BUILD_DIR}/Icons/"
1067 DeRez -only icns "${PKG_BUILD_DIR}/Icons/Icons/pkg.icns" > "${PKG_BUILD_DIR}/Icons/tempicns.rsrc"
1068 Rez -append "${PKG_BUILD_DIR}/Icons/tempicns.rsrc" -o "${distributionFilePath}"
1069 SetFile -a C "${distributionFilePath}"
1070 rm -rf "${PKG_BUILD_DIR}/Icons"
1071
1072# End
1073
1074 md5=$( md5 "${distributionFilePath}" | awk {'print $4'} )
1075 echo "MD5 (${distributionFilePath}) = ${md5}" > "${distributionFilePath}.md5"
1076 echo ""
1077
1078 echo -e $COL_GREEN" --------------------------"$COL_RESET
1079 echo -e $COL_GREEN" Building process complete!"$COL_RESET
1080 echo -e $COL_GREEN" --------------------------"$COL_RESET
1081 echo ""
1082 echo -e $COL_GREEN" Build info."
1083 echo -e $COL_GREEN" ==========="
1084 echo -e $COL_CYAN" Package name: "$COL_RESET"${distributionFilename}"
1085 echo -e $COL_CYAN" MD5: "$COL_RESET"$md5"
1086 echo -e $COL_CYAN" Version: "$COL_RESET"$CHAMELEON_VERSION"
1087 echo -e $COL_CYAN" Stage: "$COL_RESET"$CHAMELEON_STAGE"
1088 echo -e $COL_CYAN" Date/Time: "$COL_RESET"$CHAMELEON_BUILDDATE"
1089 echo -e $COL_CYAN" Built by: "$COL_RESET"$CHAMELEON_WHOBUILD"
1090 echo -e $COL_CYAN" Copyright $CHAMELEON_CPRYEAR ""$COL_RESET"
1091 echo ""
1092
1093}
1094
1095# build packages
1096main
1097
1098# build meta package
1099makedistribution
1100

Archive Download this file

Revision: 2034