Chameleon

Chameleon Svn Source Tree

Root/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="Chameleon"
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_RESOLUTION_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/Resolution.dylib" ]]; then
537 {
538 # Start build Resolution package module
539 choiceId="AutoReso"
540 moduleFile="Resolution.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 Resolution package module
552 }
553 fi
554
555# -
556 if [[ "${CONFIG_KLIBC_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/klibc.dylib" ]]; then
557 {
558 # Start build klibc package module
559 choiceId="klibc"
560 moduleFile="${choiceId}.dylib"
561 mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"
562 ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" ${PKG_BUILD_DIR}/${choiceId}/Root
563 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
564 --subst="moduleName=$choiceId" \
565 --subst="moduleFile=$moduleFile" \
566 InstallModule
567
568 packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
569 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/Extra/modules"
570 addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"
571 # End build klibc package module
572 }
573 fi
574
575# -
576 if [[ "${CONFIG_UCLIBCXX_MODULE}" = 'm' && -n "${CONFIG_KLIBC_MODULE}" && \
577 -f "${SYMROOT}/i386/modules/uClibcxx.dylib" ]]; then
578 {
579 klibcPackageRefId=""
580 if [[ "${CONFIG_KLIBC_MODULE}" == 'm' ]];then
581 klibcPackageRefId=$(getPackageRefId "${modules_packages_identity}" "klibc")
582 fi
583 # Start build uClibc package module
584 choiceId="uClibc"
585 moduleFile="uClibcxx.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 # Add the klibc package because the uClibc module is dependent of klibc module
596 addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId $klibcPackageRefId" "${choiceId}"
597 # End build uClibc package module
598 }
599 fi
600# -
601 if [[ "${CONFIG_SATA_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/Sata.dylib" ]]; then
602 {
603 # Start build Sata package module
604 choiceId="Sata"
605 moduleFile="Sata.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 Sata package module
617 }
618 fi
619
620# -
621 if [[ "${CONFIG_ACPICODEC_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/ACPICodec.dylib" ]]; then
622 {
623 # Start build ACPICodec package module
624 choiceId="ACPICodec"
625 moduleFile="ACPICodec.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 ACPICodec package module
637 }
638 fi
639
640# - # Warning Keylayout module need additional files
641 if [[ "${CONFIG_KEYLAYOUT_MODULE}" = 'm' && -f "${SYMROOT}/i386/modules/Keylayout.dylib" ]]; then
642 {
643 # Start build Keylayout package module
644 choiceId="Keylayout"
645 moduleFile="${choiceId}.dylib"
646 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/{modules,Keymaps}
647 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
648 layout_src_dir="${SRCROOT}/i386/modules/Keylayout/layouts/layouts-src"
649 if [ -d "$layout_src_dir" ];then
650 # Create a tar.gz from layout sources
651 (cd "$layout_src_dir"; \
652 tar czf "${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps/layouts-src.tar.gz" README *.slt)
653 fi
654 # Adding module
655 ditto --noextattr --noqtn ${SYMROOT}/i386/modules/$moduleFile ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/modules
656 # Adding Keymaps
657 ditto --noextattr --noqtn ${SRCROOT}/Keymaps ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps
658 # Adding tools
659 ditto --noextattr --noqtn ${SYMROOT}/i386/cham-mklayout ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin
660 # Adding scripts
661 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
662 --subst="moduleName=$choiceId" \
663 --subst="moduleFile=$moduleFile" \
664 InstallModule
665
666 packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")
667 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
668
669 # Don't add a choice for Keylayout module
670 # addChoice "${choiceId}" "Module" --start-selected="false" "$packageRefId"
671 # End build Keylayout package module
672 }
673 fi
674
675 }
676 else
677 {
678 echo " -= no modules to include =-"
679 }
680 fi
681# End build Modules packages
682fi
683
684# build Options packages
685
686 addGroupChoices "Options"
687
688 # ------------------------------------------------------
689 # parse OptionalSettings folder to find files of boot options.
690 # ------------------------------------------------------
691 OptionalSettingsFolder="${PKGROOT}/OptionalSettings"
692
693 while IFS= read -r -d '' OptionsFile; do
694
695 # Take filename and strip .txt from end and path from front
696 builtOptionsList=${OptionsFile%.txt}
697 builtOptionsList=${builtOptionsList##*/}
698 packagesidentity="${chameleon_package_identity}.options.$builtOptionsList"
699
700 echo "================= $builtOptionsList ================="
701
702 # ------------------------------------------------------
703 # Read boot option file into an array.
704 # ------------------------------------------------------
705 availableOptions=() # array to hold the list of boot options, per 'section'.
706 exclusiveFlag="" # used to indicate list has exclusive options
707 while read textLine; do
708 # ignore lines in the file beginning with a #
709 [[ $textLine = \#* ]] && continue
710 local optionName="" key="" value=""
711 case "$textLine" in
712 Exclusive=[Tt][Rr][Uu][Ee]) exclusiveFlag="--exclusive_zero_or_one_choice" ;;
713 Exclusive=*) continue ;;
714 *@*:*=*)
715 availableOptions[${#availableOptions[*]}]="$textLine" ;;
716 *) echo "Error: invalid line '$textLine' in file '$OptionsFile'" >&2
717 exit 1
718 ;;
719 esac
720 done < "$OptionsFile"
721
722 addGroupChoices --parent="Options" $exclusiveFlag "${builtOptionsList}"
723
724 # ------------------------------------------------------
725 # Loop through options in array and process each in turn
726 # ------------------------------------------------------
727 for textLine in "${availableOptions[@]}"; do
728 # split line - taking all before ':' as option name
729 # and all after ':' as key/value
730 type=$( echo "${textLine%%@*}" | tr '[:upper:]' '[:lower:]' )
731 tmp=${textLine#*@}
732 optionName=${tmp%%:*}
733 keyValue=${tmp##*:}
734 key=${keyValue%%=*}
735 value=${keyValue#*=}
736
737 # create folders required for each boot option
738 mkdir -p "${PKG_BUILD_DIR}/$optionName/Root/"
739
740 case "$type" in
741 bool) startSelected="check_chameleon_bool_option('$key','$value')" ;;
742 text) startSelected="check_chameleon_text_option('$key','$value')" ;;
743 list) startSelected="check_chameleon_list_option('$key','$value')" ;;
744 *) echo "Error: invalid type '$type' in line '$textLine' in '$OptionsFile'" >&2
745 exit 1
746 ;;
747 esac
748 recordChameleonOption "$type" "$key" "$value"
749 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/$optionName" \
750 --subst="optionType=$type" \
751 --subst="optionKey=$key" \
752 --subst="optionValue=$value" \
753 AddOption
754 packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}")
755 buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/"
756 addChoice --group="${builtOptionsList}" \
757 --start-selected="$startSelected" \
758 --pkg-refs="$packageRefId" "${optionName}"
759 done
760
761 done < <( find "${OptionalSettingsFolder}" -depth 1 -type f -name '*.txt' -print0 )
762
763# End build options packages
764
765if [[ -n "${CONFIG_KEYLAYOUT_MODULE}" ]];then
766# build Keymaps options packages
767 echo "================= Keymaps Options ================="
768 addGroupChoices --exclusive_zero_or_one_choice "Keymaps"
769 packagesidentity="${chameleon_package_identity}.options.keymaps"
770 keylayoutPackageRefId=""
771 if [[ "${CONFIG_MODULES}" == 'y' && "${CONFIG_KEYLAYOUT_MODULE}" = 'm' ]];then
772 keylayoutPackageRefId=$(getPackageRefId "${modules_packages_identity}" "Keylayout")
773 fi
774
775 chameleon_keylayout_key="KeyLayout"
776 # ------------------------------------------------------
777 # Available Keylayout boot options are discovered by
778 # reading contents of /Keymaps folder after compilation
779 # ------------------------------------------------------
780 availableOptions=($( find "${SRCROOT}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))
781 # Adjust array contents to match expected format
782 # for boot options which is: name:key=value
783 for (( i = 0 ; i < ${#availableOptions[@]} ; i++ )); do
784 # Start build of a keymap package module
785 choiceId="${availableOptions[i]}"
786 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
787
788 recordChameleonOption "text" "$chameleon_keylayout_key" "$choiceId"
789 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
790 --subst="optionType=text" \
791 --subst="optionKey=$chameleon_keylayout_key" \
792 --subst="optionValue=$choiceId" \
793 AddOption
794 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
795 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
796 # Add the Keylayout package because the Keylayout module is needed
797 addChoice --group="Keymaps" \
798 --start-selected="check_chameleon_text_option('${chameleon_keylayout_key}','${choiceId}')" \
799 --pkg-refs="$packageRefId $keylayoutPackageRefId" "${choiceId}"
800 done
801
802# End build Keymaps options packages
803fi
804
805# build theme packages
806 echo "================= Themes ================="
807 addGroupChoices "Themes"
808
809 # Using themes section from Azi's/package branch.
810 packagesidentity="${chameleon_package_identity}.themes"
811 artwork="${SRCROOT}/artwork/themes"
812 themes=($( find "${artwork}" -type d -depth 1 -not -name '.svn' ))
813 for (( i = 0 ; i < ${#themes[@]} ; i++ )); do
814 themeName=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )
815 themeDir="$themeName"
816 mkdir -p "${PKG_BUILD_DIR}/${themeName}/Root/"
817 rsync -r --exclude=.svn --exclude="*~" "${themes[$i]}/" "${PKG_BUILD_DIR}/${themeName}/Root/${themeName}"
818 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${themeName}" \
819 --subst="themeName=$themeName" \
820 --subst="themeDir=$themeDir" \
821 InstallTheme
822
823 packageRefId=$(getPackageRefId "${packagesidentity}" "${themeName}")
824 buildpackage "$packageRefId" "${themeName}" "${PKG_BUILD_DIR}/${themeName}" "/Extra/Themes"
825 addChoice --group="Themes" --start-selected="false" --pkg-refs="$packageRefId" "${themeName}"
826 done
827# End build theme packages# End build Extras package
828
829# build pre install package
830 echo "================= Pre ================="
831 packagesidentity="${chameleon_package_identity}"
832 choiceId="Pre"
833
834 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
835 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
836 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources
837 local yamlFile="Resources/chameleon_options.yaml"
838 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \
839 --subst="YAML_FILE=${yamlFile}" ${choiceId}
840 generate_options_yaml_file "${PKG_BUILD_DIR}/${choiceId}/Scripts/$yamlFile"
841 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
842# End build pre install package
843
844# build post install package
845 echo "================= Post ================="
846 packagesidentity="${chameleon_package_identity}"
847 choiceId="Post"
848 mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root
849 addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId}
850 cp -f ${PKGROOT}/Scripts/Sub/UnMountEFIvolumes.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts
851
852 packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")
853 buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"
854 addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"
855# End build post install package
856
857}
858
859buildpackage ()
860{
861 # $1 Package Reference Id (ie: org.chameleon.themes.default)
862 # $2 Package Name (ie: Default)
863 # $3 Path to package to build containing Root and/or Scripts
864 # $4 Target install location
865 # $5 Size (optional)
866 if [[ -d "${3}/Root" ]]; then
867 local packageRefId="$1"
868 local packageName="$2"
869 local packagePath="$3"
870 local targetPath="$4"
871 set +u # packageSize is optional
872 local packageSize="$5"
873 set -u
874
875 echo -e "\t[BUILD] ${packageName}"
876
877 find "${packagePath}" -name '.DS_Store' -delete
878 local filecount=$( find "${packagePath}/Root" | wc -l )
879 if [ "${packageSize}" ]; then
880 local installedsize="${packageSize}"
881 else
882 local installedsize=$( du -hkc "${packagePath}/Root" | tail -n1 | awk {'print $1'} )
883 fi
884 local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
885
886 #[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
887
888 header+="identifier=\"${packageRefId}\" "
889 header+="version=\"${CHAMELEON_VERSION}\" "
890
891 [ "${targetPath}" != "relocatable" ] && header+="install-location=\"${targetPath}\" "
892
893 header+="auth=\"root\">\n"
894 header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
895 rm -R -f "${packagePath}/Temp"
896
897 [ -d "${packagePath}/Temp" ] || mkdir -m 777 "${packagePath}/Temp"
898 [ -d "${packagePath}/Root" ] && mkbom "${packagePath}/Root" "${packagePath}/Temp/Bom"
899
900 if [ -d "${packagePath}/Scripts" ]; then
901 header+="\t<scripts>\n"
902 for script in $( find "${packagePath}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) ); do
903 header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
904 done
905 header+="\t</scripts>\n"
906 # Create the Script archive file (cpio format)
907 (cd "${packagePath}/Scripts" && find . -print | \
908 cpio -o -z -R root:wheel --format cpio > "${packagePath}/Temp/Scripts") 2>&1 | \
909 grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages
910 fi
911
912 header+="</pkg-info>"
913 echo -e "${header}" > "${packagePath}/Temp/PackageInfo"
914
915 # Create the Payload file (cpio format)
916 (cd "${packagePath}/Root" && find . -print | \
917 cpio -o -z -R root:wheel --format cpio > "${packagePath}/Temp/Payload") 2>&1 | \
918 grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages
919
920 # Create the package
921 (cd "${packagePath}/Temp" && xar -c -f "${packagePath}/../${packageName}.pkg" --compression none .)
922
923 # Add the package to the list of build packages
924 pkgrefs[${#pkgrefs[*]}]="\t<pkg-ref id=\"${packageRefId}\" installKBytes='${installedsize}' version='${CHAMELEON_VERSION}.0.0.${CHAMELEON_TIMESTAMP}'>#${packageName}.pkg</pkg-ref>"
925
926 rm -rf "${packagePath}"
927 fi
928}
929
930generateOutlineChoices() {
931 # $1 Main Choice
932 # $2 indent level
933 local idx=$(getChoiceIndex "$1")
934 local indentLevel="$2"
935 local indentString=""
936 for ((level=1; level <= $indentLevel ; level++)); do
937 indentString="\t$indentString"
938 done
939 set +u; subChoices="${choice_group_items[$idx]}"; set -u
940 if [[ -n "${subChoices}" ]]; then
941 # Sub choices exists
942 echo -e "$indentString<line choice=\"$1\">"
943 for subChoice in $subChoices;do
944 generateOutlineChoices $subChoice $(($indentLevel+1))
945 done
946 echo -e "$indentString</line>"
947 else
948 echo -e "$indentString<line choice=\"$1\"/>"
949 fi
950}
951
952generateChoices() {
953 for (( idx=1; idx < ${#choice_key[*]} ; idx++)); do
954 local choiceId=${choice_key[$idx]}
955 local choiceOptions=${choice_options[$idx]}
956 local choiceParentGroupIndex=${choice_parent_group_index[$idx]}
957 set +u; local group_exclusive=${choice_group_exclusive[$choiceParentGroupIndex]}; set -u
958
959 # Create the node and standard attributes
960 local choiceNode="\t<choice\n\t\tid=\"${choiceId}\"\n\t\ttitle=\"${choiceId}_title\"\n\t\tdescription=\"${choiceId}_description\""
961
962 # Add options like start_selected, etc...
963 [[ -n "${choiceOptions}" ]] && choiceNode="${choiceNode}\n\t\t${choiceOptions}"
964
965 # Add the selected attribute if options are mutually exclusive
966 if [[ -n "$group_exclusive" ]];then
967 local group_items="${choice_group_items[$choiceParentGroupIndex]}"
968 case $group_exclusive in
969 exclusive_one_choice)
970 local selected_option=$(exclusive_one_choice "$choiceId" "$group_items") ;;
971 exclusive_zero_or_one_choice)
972 local selected_option=$(exclusive_zero_or_one_choice "$choiceId" "$group_items") ;;
973 *) echo "Error: unknown function to generate exclusive mode '$group_exclusive' for group '${choice_key[$choiceParentGroupIndex]}'" >&2
974 exit 1
975 ;;
976 esac
977 choiceNode="${choiceNode}\n\t\tselected=\"$selected_option\""
978 fi
979
980 choiceNode="${choiceNode}>"
981
982 # Add the package references
983 for pkgRefId in ${choice_pkgrefs[$idx]};do
984 choiceNode="${choiceNode}\n\t\t<pkg-ref id=\"${pkgRefId}\"/>"
985 done
986
987 # Close the node
988 choiceNode="${choiceNode}\n\t</choice>\n"
989
990 echo -e "$choiceNode"
991 done
992}
993
994makedistribution ()
995{
996 declare -r distributionDestDir="${SYMROOT}"
997 declare -r distributionFilename="${packagename// /}-${CHAMELEON_VERSION}-r${CHAMELEON_REVISION}.pkg"
998 declare -r distributionFilePath="${distributionDestDir}/${distributionFilename}"
999
1000 rm -f "${distributionDestDir}/${packagename// /}"*.pkg
1001
1002 mkdir -p "${PKG_BUILD_DIR}/${packagename}"
1003
1004 find "${PKG_BUILD_DIR}" -type f -name '*.pkg' -depth 1 | while read component
1005 do
1006 pkg="${component##*/}" # ie: EFI.pkg
1007 pkgdir="${PKG_BUILD_DIR}/${packagename}/${pkg}"
1008 # expand individual packages
1009 pkgutil --expand "${PKG_BUILD_DIR}/${pkg}" "$pkgdir"
1010 rm -f "${PKG_BUILD_DIR}/${pkg}"
1011 done
1012
1013# Create the Distribution file
1014 ditto --noextattr --noqtn "${PKGROOT}/Distribution" "${PKG_BUILD_DIR}/${packagename}/Distribution"
1015
1016 local start_indent_level=2
1017 echo -e "\n\t<choices-outline>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1018 for main_choice in ${choice_group_items[0]};do
1019 generateOutlineChoices $main_choice $start_indent_level >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1020 done
1021 echo -e "\t</choices-outline>\n" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1022
1023 generateChoices >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1024
1025 for (( i=0; i < ${#pkgrefs[*]} ; i++)); do
1026 echo -e "${pkgrefs[$i]}" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1027 done
1028
1029 echo -e "\n</installer-gui-script>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"
1030
1031# Create the Resources directory
1032 ditto --noextattr --noqtn "${PKGROOT}/Resources/distribution" "${PKG_BUILD_DIR}/${packagename}/Resources"
1033
1034# Make the translation
1035 echo ""
1036 echo "========= Translating Resources ========"
1037 (cd "${PKGROOT}" && PERLLIB=${PKGROOT}/bin/po4a/lib \
1038 bin/po4a/po4a \
1039 --package-name 'Chameleon' \
1040 --package-version "${CHAMELEON_VERSION}-r${CHAMELEON_REVISION}" \
1041 --msgmerge-opt '--lang=$lang' \
1042 --variable PODIR="po" \
1043 --variable TEMPLATES_DIR="Resources/templates" \
1044 --variable OUTPUT_DIR="${PKG_BUILD_DIR}/${packagename}/Resources" \
1045 ${PKGROOT}/po4a-chameleon.cfg)
1046
1047 # Copy common files in english localisation directory
1048 ditto --noextattr --noqtn "${PKGROOT}/Resources/common" "${PKG_BUILD_DIR}/${packagename}/Resources/en.lproj"
1049
1050 # CleanUp the directory
1051 find "${PKG_BUILD_DIR}/${packagename}" \( -type d -name '.svn' \) -o -name '.DS_Store' -depth -exec rm -rf {} \;
1052 find "${PKG_BUILD_DIR}/${packagename}" -type d -depth -empty -exec rmdir {} \; # Remove empty directories
1053
1054 # Make substitutions for version, revision, stage, developers, credits, etc..
1055 makeSubstitutions $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )
1056
1057# Create the final package
1058 pkgutil --flatten "${PKG_BUILD_DIR}/${packagename}" "${distributionFilePath}"
1059
1060# Here is the place to assign an icon to the pkg
1061 ditto -xk "${PKGROOT}/Icons/pkg.zip" "${PKG_BUILD_DIR}/Icons/"
1062 DeRez -only icns "${PKG_BUILD_DIR}/Icons/Icons/pkg.icns" > "${PKG_BUILD_DIR}/Icons/tempicns.rsrc"
1063 Rez -append "${PKG_BUILD_DIR}/Icons/tempicns.rsrc" -o "${distributionFilePath}"
1064 SetFile -a C "${distributionFilePath}"
1065 rm -rf "${PKG_BUILD_DIR}/Icons"
1066
1067# End
1068
1069 md5=$( md5 "${distributionFilePath}" | awk {'print $4'} )
1070 echo "MD5 (${distributionFilePath}) = ${md5}" > "${distributionFilePath}.md5"
1071 echo ""
1072
1073 echo -e $COL_GREEN" --------------------------"$COL_RESET
1074 echo -e $COL_GREEN" Building process complete!"$COL_RESET
1075 echo -e $COL_GREEN" --------------------------"$COL_RESET
1076 echo ""
1077 echo -e $COL_GREEN" Build info."
1078 echo -e $COL_GREEN" ==========="
1079 echo -e $COL_BLUE" Package name: "$COL_RESET"${distributionFilename}"
1080 echo -e $COL_BLUE" MD5: "$COL_RESET"$md5"
1081 echo -e $COL_BLUE" Version: "$COL_RESET"$CHAMELEON_VERSION"
1082 echo -e $COL_BLUE" Stage: "$COL_RESET"$CHAMELEON_STAGE"
1083 echo -e $COL_BLUE" Date/Time: "$COL_RESET"$CHAMELEON_BUILDDATE"
1084 echo -e $COL_BLUE" Built by: "$COL_RESET"$CHAMELEON_WHOBUILD"
1085 echo -e $COL_BLUE" Copyright $CHAMELEON_CPRYEAR ""$COL_RESET"
1086 echo ""
1087
1088}
1089
1090# build packages
1091main
1092
1093# build meta package
1094makedistribution
1095

Archive Download this file

Revision: 2033