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