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/boot1f32 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
479 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot1h ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
480 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot1x ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
481 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot1he ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
482 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot1hp ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
483 | ditto --noextattr --noqtn ${SYMROOT}/i386/cdboot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
484 | ditto --noextattr --noqtn ${SYMROOT}/i386/chain0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
485 | ditto --noextattr --noqtn ${SYMROOT}/i386/fdisk440 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
486 | ditto --noextattr --noqtn ${SYMROOT}/i386/sectorsize ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
487 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot1-install ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
488 | ditto --noextattr --noqtn ${SYMROOT}/i386/bdmesg ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
489 | ␊ |
490 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
491 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
492 | addChoice --start-visible="false" --selected="choices['boot'].selected" --pkg-refs="$packageRefId" "${choiceId}"␊ |
493 | # End build core package␊ |
494 | ␊ |
495 | # build boot choice package␊ |
496 | choiceId="boot"␊ |
497 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
498 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
499 | cp -f ${PKGROOT}/Scripts/Main/BootYES ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall␊ |
500 | ␊ |
501 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
502 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
503 | addChoice --start-visible="false" --selected="!choices['noboot'].selected" \␊ |
504 | --pkg-refs="$packageRefId" "${choiceId}"␊ |
505 | # End build boot choice package␊ |
506 | ␊ |
507 | # build Chameleon package␊ |
508 | echo "================= Chameleon ================="␊ |
509 | addGroupChoices "Chameleon"␊ |
510 | ␊ |
511 | # build noboot choice package␊ |
512 | choiceId="noboot"␊ |
513 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
514 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
515 | cp -f ${PKGROOT}/Scripts/Main/BootNO ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall␊ |
516 | ␊ |
517 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
518 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
519 | addChoice --group="Chameleon" --selected="!choices['boot'].selected" \␊ |
520 | --pkg-refs="$packageRefId" "${choiceId}"␊ |
521 | # End build noboot choice package␊ |
522 | ␊ |
523 | # End build Chameleon package␊ |
524 | ␊ |
525 | if [[ "${CONFIG_MODULES}" == 'y' ]];then␊ |
526 | # build Modules package␊ |
527 | echo "================= Modules ================="␊ |
528 | ###############################␊ |
529 | # Supported Modules #␊ |
530 | ###############################␊ |
531 | # ACPICodec.dylib #␊ |
532 | # AMDGraphicsEnabler.dylib #␊ |
533 | # GraphicsEnabler.dylib #␊ |
534 | # ATiGraphicsEnabler.dylib #␊ |
535 | # FileNVRAM.dylib #␊ |
536 | # HDAEnabler.dylib #␊ |
537 | # HelloWorld.dylib #␊ |
538 | # IntelGraphicsEnabler.dylib #␊ |
539 | # KernelPatcher.dylib #␊ |
540 | # KextPatcher.dylib #␊ |
541 | # Keylayout.dylib #␊ |
542 | # klibc.dylib #␊ |
543 | # NVDIAGraphicEnabler.dylib #␊ |
544 | # Resolution.dylib #␊ |
545 | # Sata.dylib #␊ |
546 | # uClibcxx.dylib #␊ |
547 | ###############################␊ |
548 | if [ "$(ls -A "${SYMROOT}/i386/modules")" ]; then␊ |
549 | {␊ |
550 | addGroupChoices "Module"␊ |
551 | ␊ |
552 | # -␊ |
553 | if [[ "${CONFIG_ACPICODEC_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/ACPICodec.dylib" ]]; then␊ |
554 | {␊ |
555 | # Start build ACPICodec package module␊ |
556 | choiceId="ACPICodec"␊ |
557 | moduleFile="ACPICodec.dylib"␊ |
558 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
559 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
560 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
561 | --subst="moduleName=$choiceId" \␊ |
562 | --subst="moduleFile=$moduleFile" \␊ |
563 | InstallModule␊ |
564 | ␊ |
565 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
566 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
567 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
568 | # End build ACPICodec package module␊ |
569 | }␊ |
570 | fi␊ |
571 | # -␊ |
572 | if [[ "${CONFIG_GRAPHICSENABLER_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/GraphicsEnabler.dylib" ]]; then␊ |
573 | {␊ |
574 | # Start build GraphicsEnabler package module␊ |
575 | choiceId="GraphicsEnablerModule"␊ |
576 | moduleFile="GraphicsEnabler.dylib"␊ |
577 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
578 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
579 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
580 | --subst="moduleName=$choiceId" \␊ |
581 | --subst="moduleFile=$moduleFile" \␊ |
582 | InstallModule␊ |
583 | ␊ |
584 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
585 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
586 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
587 | # End build GraphicsEnabler package module␊ |
588 | }␊ |
589 | fi␊ |
590 | # -␊ |
591 | if [[ "${CONFIG_NVIDIAGE_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/NVIDIAGraphicsEnabler.dylib" ]]; then␊ |
592 | {␊ |
593 | # Start build NvidiaGraphicsEnabler package module␊ |
594 | choiceId="NVIDIAGraphicsEnabler"␊ |
595 | moduleFile="NVIDIAGraphicEnabler.dylib"␊ |
596 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
597 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
598 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
599 | --subst="moduleName=$choiceId" \␊ |
600 | --subst="moduleFile=$moduleFile" \␊ |
601 | InstallModule␊ |
602 | ␊ |
603 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
604 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
605 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
606 | # End build NvidiaGraphicsEnabler package module␊ |
607 | }␊ |
608 | fi␊ |
609 | # -␊ |
610 | if [[ "${CONFIG_AMDGE_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/AMDGraphicsEnabler.dylib" ]]; then␊ |
611 | {␊ |
612 | # Start build AMDGraphicsEnabler package module␊ |
613 | choiceId="AMDGraphicsEnabler"␊ |
614 | moduleFile="AMDGraphicsEnabler.dylib"␊ |
615 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
616 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
617 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
618 | --subst="moduleName=$choiceId" \␊ |
619 | --subst="moduleFile=$moduleFile" \␊ |
620 | InstallModule␊ |
621 | ␊ |
622 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
623 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
624 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
625 | # End build AMDGraphicsEnabler package module␊ |
626 | }␊ |
627 | fi␊ |
628 | # -␊ |
629 | if [[ "${CONFIG_GMAGE_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/IntelGraphicsEnabler.dylib" ]]; then␊ |
630 | {␊ |
631 | # Start build IntelGraphicsEnabler package module␊ |
632 | choiceId="IntelGraphicsEnabler"␊ |
633 | moduleFile="IntelGraphicsEnabler.dylib"␊ |
634 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
635 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
636 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
637 | --subst="moduleName=$choiceId" \␊ |
638 | --subst="moduleFile=$moduleFile" \␊ |
639 | InstallModule␊ |
640 | ␊ |
641 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
642 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
643 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
644 | # End build IntelGraphicsEnabler package module␊ |
645 | }␊ |
646 | fi␊ |
647 | # -␊ |
648 | if [[ "${CONFIG_KERNELPATCHER_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/KernelPatcher.dylib" ]]; then␊ |
649 | {␊ |
650 | # Start build KernelPatcher package module␊ |
651 | choiceId="KernelPatcher"␊ |
652 | moduleFile="KernelPatcher.dylib"␊ |
653 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
654 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
655 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
656 | --subst="moduleName=$choiceId" \␊ |
657 | --subst="moduleFile=$moduleFile" \␊ |
658 | InstallModule␊ |
659 | ␊ |
660 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
661 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
662 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
663 | # End build KernelPatcher package module␊ |
664 | }␊ |
665 | fi␊ |
666 | # -␊ |
667 | if [[ "${CONFIG_KEXTPATCHER_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/KextPatcher.dylib" ]]; then␊ |
668 | {␊ |
669 | # Start build KextPatcher package module␊ |
670 | choiceId="KextPatcher"␊ |
671 | moduleFile="KextPatcher.dylib"␊ |
672 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
673 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
674 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
675 | --subst="moduleName=$choiceId" \␊ |
676 | --subst="moduleFile=$moduleFile" \␊ |
677 | InstallModule␊ |
678 | ␊ |
679 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
680 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
681 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
682 | # End build KextPatcher package module␊ |
683 | }␊ |
684 | fi␊ |
685 | # -␊ |
686 | # Warning Keylayout module need additional files␊ |
687 | if [[ "${CONFIG_KEYLAYOUT_MODULE}" = 'm' && -f "${SYMROOT}/i386/modules/Keylayout.dylib" ]]; then␊ |
688 | {␊ |
689 | # Start build Keylayout package module␊ |
690 | choiceId="Keylayout"␊ |
691 | moduleFile="${choiceId}.dylib"␊ |
692 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/{modules,Keymaps}␊ |
693 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
694 | layout_src_dir="${SRCROOT}/i386/modules/Keylayout/layouts/layouts-src"␊ |
695 | if [ -d "$layout_src_dir" ];then␊ |
696 | # Create a tar.gz from layout sources␊ |
697 | (cd "$layout_src_dir"; \␊ |
698 | tar czf "${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/Keymaps/layouts-src.tar.gz" README *.slt)␊ |
699 | fi␊ |
700 | # Adding module␊ |
701 | ditto --noextattr --noqtn ${SYMROOT}/i386/modules/$moduleFile ${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/modules␊ |
702 | # Adding Keymaps␊ |
703 | ditto --noextattr --noqtn ${SRCROOT}/Keymaps ${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/Keymaps␊ |
704 | # Adding tools␊ |
705 | ditto --noextattr --noqtn ${SYMROOT}/i386/cham-mklayout ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
706 | # Adding scripts␊ |
707 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
708 | --subst="moduleName=$choiceId" \␊ |
709 | --subst="moduleFile=$moduleFile" \␊ |
710 | InstallModule␊ |
711 | ␊ |
712 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
713 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
714 | ␊ |
715 | # Don't add a choice for Keylayout module␊ |
716 | # addChoice "${choiceId}" "Module" --start-selected="false" "$packageRefId"␊ |
717 | # End build Keylayout package module␊ |
718 | }␊ |
719 | fi␊ |
720 | # -␊ |
721 | if [[ "${CONFIG_KLIBC_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/klibc.dylib" ]]; then␊ |
722 | {␊ |
723 | # Start build klibc package module␊ |
724 | choiceId="klibc"␊ |
725 | moduleFile="${choiceId}.dylib"␊ |
726 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
727 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
728 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
729 | --subst="moduleName=$choiceId" \␊ |
730 | --subst="moduleFile=$moduleFile" \␊ |
731 | InstallModule␊ |
732 | ␊ |
733 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
734 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
735 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
736 | # End build klibc package module␊ |
737 | }␊ |
738 | fi␊ |
739 | # -␊ |
740 | if [[ "${CONFIG_RESOLUTION_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/Resolution.dylib" ]]; then␊ |
741 | {␊ |
742 | # Start build Resolution package module␊ |
743 | choiceId="AutoReso"␊ |
744 | moduleFile="Resolution.dylib"␊ |
745 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
746 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
747 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
748 | --subst="moduleName=$choiceId" \␊ |
749 | --subst="moduleFile=$moduleFile" \␊ |
750 | InstallModule␊ |
751 | ␊ |
752 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
753 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
754 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
755 | # End build Resolution package module␊ |
756 | }␊ |
757 | fi␊ |
758 | # -␊ |
759 | if [[ "${CONFIG_HDAENABLER_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/HDAEnabler.dylib" ]]; then␊ |
760 | {␊ |
761 | # Start build HDAEnabler package module␊ |
762 | choiceId="HDAEnabler"␊ |
763 | moduleFile="HDAEnabler.dylib"␊ |
764 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
765 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
766 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
767 | --subst="moduleName=$choiceId" \␊ |
768 | --subst="moduleFile=$moduleFile" \␊ |
769 | InstallModule␊ |
770 | ␊ |
771 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
772 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
773 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
774 | # End build HDAEnabler package module␊ |
775 | }␊ |
776 | fi␊ |
777 | # -␊ |
778 | if [[ "${CONFIG_FILENVRAM_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/FileNVRAM.dylib" ]]; then␊ |
779 | {␊ |
780 | # Start build FileNVRAM package module␊ |
781 | choiceId="FileNVRAM"␊ |
782 | moduleFile="FileNVRAM.dylib"␊ |
783 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
784 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
785 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
786 | --subst="moduleName=$choiceId" \␊ |
787 | --subst="moduleFile=$moduleFile" \␊ |
788 | InstallModule␊ |
789 | ␊ |
790 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
791 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
792 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
793 | # End build FileNVRAM package module␊ |
794 | }␊ |
795 | fi␊ |
796 | # -␊ |
797 | if [[ "${CONFIG_SATA_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/Sata.dylib" ]]; then␊ |
798 | {␊ |
799 | # Start build Sata package module␊ |
800 | choiceId="Sata"␊ |
801 | moduleFile="Sata.dylib"␊ |
802 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
803 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
804 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
805 | --subst="moduleName=$choiceId" \␊ |
806 | --subst="moduleFile=$moduleFile" \␊ |
807 | InstallModule␊ |
808 | ␊ |
809 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
810 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
811 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
812 | # End build Sata package module␊ |
813 | }␊ |
814 | fi␊ |
815 | # -␊ |
816 | if [[ "${CONFIG_UCLIBCXX_MODULE}" = 'm' && -n "${CONFIG_KLIBC_MODULE}" && \␊ |
817 | -f "${SYMROOT}/i386/modules/uClibcxx.dylib" ]]; then␊ |
818 | {␊ |
819 | klibcPackageRefId=""␊ |
820 | if [[ "${CONFIG_KLIBC_MODULE}" == 'm' ]];then␊ |
821 | klibcPackageRefId=$(getPackageRefId "${modules_packages_identity}" "klibc")␊ |
822 | fi␊ |
823 | # Start build uClibc package module␊ |
824 | choiceId="uClibc"␊ |
825 | moduleFile="uClibcxx.dylib"␊ |
826 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
827 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
828 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
829 | --subst="moduleName=$choiceId" \␊ |
830 | --subst="moduleFile=$moduleFile" \␊ |
831 | InstallModule␊ |
832 | ␊ |
833 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
834 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
835 | # Add the klibc package because the uClibc module is dependent of klibc module␊ |
836 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId $klibcPackageRefId" "${choiceId}"␊ |
837 | # End build uClibc package module␊ |
838 | }␊ |
839 | fi␊ |
840 | # -␊ |
841 | }␊ |
842 | else␊ |
843 | {␊ |
844 | echo " -= no modules to include =-"␊ |
845 | }␊ |
846 | fi␊ |
847 | # End build Modules packages␊ |
848 | fi␊ |
849 | ␊ |
850 | # build Options packages␊ |
851 | ␊ |
852 | addGroupChoices "Options"␊ |
853 | ␊ |
854 | # ------------------------------------------------------␊ |
855 | # parse OptionalSettings folder to find files of boot options.␊ |
856 | # ------------------------------------------------------␊ |
857 | OptionalSettingsFolder="${PKGROOT}/OptionalSettings"␊ |
858 | ␊ |
859 | while IFS= read -r -d '' OptionsFile; do␊ |
860 | ␊ |
861 | # Take filename and strip .txt from end and path from front␊ |
862 | builtOptionsList=${OptionsFile%.txt}␊ |
863 | builtOptionsList=${builtOptionsList##*/}␊ |
864 | packagesidentity="${chameleon_package_identity}.options.$builtOptionsList"␊ |
865 | ␊ |
866 | echo "================= $builtOptionsList ================="␊ |
867 | ␊ |
868 | # ------------------------------------------------------␊ |
869 | # Read boot option file into an array.␊ |
870 | # ------------------------------------------------------␊ |
871 | availableOptions=() # array to hold the list of boot options, per 'section'.␊ |
872 | exclusiveFlag="" # used to indicate list has exclusive options␊ |
873 | while read textLine; do␊ |
874 | # ignore lines in the file beginning with a #␊ |
875 | [[ $textLine = \#* ]] && continue␊ |
876 | local optionName="" key="" value=""␊ |
877 | case "$textLine" in␊ |
878 | Exclusive=[Tt][Rr][Uu][Ee]) exclusiveFlag="--exclusive_zero_or_one_choice" ;;␊ |
879 | Exclusive=*) continue ;;␊ |
880 | *@*:*=*)␊ |
881 | availableOptions[${#availableOptions[*]}]="$textLine" ;;␊ |
882 | *) echo "Error: invalid line '$textLine' in file '$OptionsFile'" >&2␊ |
883 | exit 1␊ |
884 | ;;␊ |
885 | esac␊ |
886 | done < "$OptionsFile"␊ |
887 | ␊ |
888 | addGroupChoices --parent="Options" $exclusiveFlag "${builtOptionsList}"␊ |
889 | ␊ |
890 | # ------------------------------------------------------␊ |
891 | # Loop through options in array and process each in turn␊ |
892 | # ------------------------------------------------------␊ |
893 | for textLine in "${availableOptions[@]}"; do␊ |
894 | # split line - taking all before ':' as option name␊ |
895 | # and all after ':' as key/value␊ |
896 | type=$( echo "${textLine%%@*}" | tr '[:upper:]' '[:lower:]' )␊ |
897 | tmp=${textLine#*@}␊ |
898 | optionName=${tmp%%:*}␊ |
899 | keyValue=${tmp##*:}␊ |
900 | key=${keyValue%%=*}␊ |
901 | value=${keyValue#*=}␊ |
902 | ␊ |
903 | # create folders required for each boot option␊ |
904 | mkdir -p "${PKG_BUILD_DIR}/$optionName/Root/"␊ |
905 | ␊ |
906 | case "$type" in␊ |
907 | bool) startSelected="check_chameleon_bool_option('$key','$value')" ;;␊ |
908 | text) startSelected="check_chameleon_text_option('$key','$value')" ;;␊ |
909 | list) startSelected="check_chameleon_list_option('$key','$value')" ;;␊ |
910 | *) echo "Error: invalid type '$type' in line '$textLine' in '$OptionsFile'" >&2␊ |
911 | exit 1␊ |
912 | ;;␊ |
913 | esac␊ |
914 | recordChameleonOption "$type" "$key" "$value"␊ |
915 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/$optionName" \␊ |
916 | --subst="optionType=$type" \␊ |
917 | --subst="optionKey=$key" \␊ |
918 | --subst="optionValue=$value" \␊ |
919 | AddOption␊ |
920 | packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}")␊ |
921 | buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/"␊ |
922 | addChoice --group="${builtOptionsList}" \␊ |
923 | --start-selected="$startSelected" \␊ |
924 | --pkg-refs="$packageRefId" "${optionName}"␊ |
925 | done␊ |
926 | ␊ |
927 | done < <( find "${OptionalSettingsFolder}" -depth 1 -type f -name '*.txt' -print0 )␊ |
928 | ␊ |
929 | # End build options packages␊ |
930 | ␊ |
931 | if [[ -n "${CONFIG_KEYLAYOUT_MODULE}" ]];then␊ |
932 | # build Keymaps options packages␊ |
933 | echo "================= Keymaps Options ================="␊ |
934 | addGroupChoices --exclusive_zero_or_one_choice "Keymaps"␊ |
935 | packagesidentity="${chameleon_package_identity}.options.keymaps"␊ |
936 | keylayoutPackageRefId=""␊ |
937 | if [[ "${CONFIG_MODULES}" == 'y' && "${CONFIG_KEYLAYOUT_MODULE}" = 'm' ]];then␊ |
938 | keylayoutPackageRefId=$(getPackageRefId "${modules_packages_identity}" "Keylayout")␊ |
939 | fi␊ |
940 | ␊ |
941 | chameleon_keylayout_key="KeyLayout"␊ |
942 | # ------------------------------------------------------␊ |
943 | # Available Keylayout boot options are discovered by␊ |
944 | # reading contents of /Keymaps folder after compilation␊ |
945 | # ------------------------------------------------------␊ |
946 | availableOptions=($( find "${SRCROOT}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))␊ |
947 | # Adjust array contents to match expected format␊ |
948 | # for boot options which is: name:key=value␊ |
949 | for (( i = 0 ; i < ${#availableOptions[@]} ; i++ )); do␊ |
950 | # Start build of a keymap package module␊ |
951 | choiceId="${availableOptions[i]}"␊ |
952 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
953 | ␊ |
954 | recordChameleonOption "text" "$chameleon_keylayout_key" "$choiceId"␊ |
955 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
956 | --subst="optionType=text" \␊ |
957 | --subst="optionKey=$chameleon_keylayout_key" \␊ |
958 | --subst="optionValue=$choiceId" \␊ |
959 | AddOption␊ |
960 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
961 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
962 | # Add the Keylayout package because the Keylayout module is needed␊ |
963 | addChoice --group="Keymaps" \␊ |
964 | --start-selected="check_chameleon_text_option('${chameleon_keylayout_key}','${choiceId}')" \␊ |
965 | --pkg-refs="$packageRefId $keylayoutPackageRefId" "${choiceId}"␊ |
966 | done␊ |
967 | ␊ |
968 | # End build Keymaps options packages␊ |
969 | fi␊ |
970 | ␊ |
971 | # build theme packages␊ |
972 | echo "================= Themes ================="␊ |
973 | addGroupChoices "Themes"␊ |
974 | ␊ |
975 | # Using themes section from Azi's/package branch.␊ |
976 | packagesidentity="${chameleon_package_identity}.themes"␊ |
977 | artwork="${SRCROOT}/artwork/themes"␊ |
978 | themes=($( find "${artwork}" -type d -depth 1 -not -name '.svn' ))␊ |
979 | for (( i = 0 ; i < ${#themes[@]} ; i++ )); do␊ |
980 | themeName=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )␊ |
981 | themeDir="$themeName"␊ |
982 | mkdir -p "${PKG_BUILD_DIR}/${themeName}/Root/"␊ |
983 | rsync -r --exclude=.svn --exclude="*~" "${themes[$i]}/" "${PKG_BUILD_DIR}/${themeName}/Root/${themeName}"␊ |
984 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${themeName}" \␊ |
985 | --subst="themeName=$themeName" \␊ |
986 | --subst="themeDir=$themeDir" \␊ |
987 | InstallTheme␊ |
988 | ␊ |
989 | packageRefId=$(getPackageRefId "${packagesidentity}" "${themeName}")␊ |
990 | buildpackage "$packageRefId" "${themeName}" "${PKG_BUILD_DIR}/${themeName}" "/EXTRAROOTDIR/Extra/Themes"␊ |
991 | addChoice --group="Themes" --start-selected="false" --pkg-refs="$packageRefId" "${themeName}"␊ |
992 | done␊ |
993 | # End build theme packages# End build Extras package␊ |
994 | ␊ |
995 | # build standard package␊ |
996 | echo "================ standard ================"␊ |
997 | packagesidentity="${chameleon_package_identity}"␊ |
998 | choiceId="Standard"␊ |
999 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
1000 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources␊ |
1001 | local yamlFile="Resources/chameleon_options.yaml"␊ |
1002 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
1003 | --subst="YAML_FILE=${yamlFile}" CleanOptions␊ |
1004 | generate_options_yaml_file "${PKG_BUILD_DIR}/${choiceId}/Scripts/$yamlFile"␊ |
1005 | cp -f ${PKGROOT}/Scripts/Main/${choiceId}postinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall␊ |
1006 | ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile␊ |
1007 | ␊ |
1008 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
1009 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
1010 | addChoice --group="Chameleon" --start-selected="true" --selected="!choices['EFI'].selected" \␊ |
1011 | --pkg-refs="$packageRefId" "${choiceId}"␊ |
1012 | # End build standard package␊ |
1013 | ␊ |
1014 | # build efi package␊ |
1015 | echo "================== EFI =================="␊ |
1016 | packagesidentity="${chameleon_package_identity}"␊ |
1017 | choiceId="EFI"␊ |
1018 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
1019 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources␊ |
1020 | local yamlFile="Resources/chameleon_options.yaml"␊ |
1021 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
1022 | --subst="YAML_FILE=${yamlFile}" CleanOptions␊ |
1023 | generate_options_yaml_file "${PKG_BUILD_DIR}/${choiceId}/Scripts/$yamlFile"␊ |
1024 | cp -f ${PKGROOT}/Scripts/Main/ESPpostinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall␊ |
1025 | ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile␊ |
1026 | ␊ |
1027 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
1028 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
1029 | addChoice --group="Chameleon" --enabled="systemHasGPT()" --start-selected="false" \␊ |
1030 | --selected="!choices['Standard'].selected" \␊ |
1031 | --pkg-refs="$packageRefId" "${choiceId}"␊ |
1032 | # End build efi package␊ |
1033 | ␊ |
1034 | # build pre install package␊ |
1035 | echo "================= Pre ================="␊ |
1036 | packagesidentity="${chameleon_package_identity}"␊ |
1037 | choiceId="Pre"␊ |
1038 | ␊ |
1039 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
1040 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
1041 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId}␊ |
1042 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
1043 | # End build pre install package␊ |
1044 | ␊ |
1045 | # build post install package␊ |
1046 | echo "================= Post ================="␊ |
1047 | packagesidentity="${chameleon_package_identity}"␊ |
1048 | choiceId="Post"␊ |
1049 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
1050 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId}␊ |
1051 | ␊ |
1052 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
1053 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
1054 | addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"␊ |
1055 | # End build post install package␊ |
1056 | ␊ |
1057 | }␊ |
1058 | ␊ |
1059 | buildpackage ()␊ |
1060 | {␊ |
1061 | # $1 Package Reference Id (ie: org.chameleon.themes.default)␊ |
1062 | # $2 Package Name (ie: Default)␊ |
1063 | # $3 Path to package to build containing Root and/or Scripts␊ |
1064 | # $4 Target install location␊ |
1065 | # $5 Size (optional)␊ |
1066 | if [[ -d "${3}/Root" ]]; then␊ |
1067 | local packageRefId="$1"␊ |
1068 | local packageName="$2"␊ |
1069 | local packagePath="$3"␊ |
1070 | local targetPath="$4"␊ |
1071 | set +u # packageSize is optional␊ |
1072 | local packageSize="$5"␊ |
1073 | set -u␊ |
1074 | ␊ |
1075 | echo -e "\t[BUILD] ${packageName}"␊ |
1076 | ␊ |
1077 | find "${packagePath}" -name '.DS_Store' -delete␊ |
1078 | local filecount=$( find "${packagePath}/Root" | wc -l )␊ |
1079 | if [ "${packageSize}" ]; then␊ |
1080 | local installedsize="${packageSize}"␊ |
1081 | else␊ |
1082 | local installedsize=$( du -hkc "${packagePath}/Root" | tail -n1 | awk {'print $1'} )␊ |
1083 | fi␊ |
1084 | local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "␊ |
1085 | ␊ |
1086 | #[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "␊ |
1087 | ␊ |
1088 | header+="identifier=\"${packageRefId}\" "␊ |
1089 | header+="version=\"${CHAMELEON_VERSION}\" "␊ |
1090 | ␊ |
1091 | [ "${targetPath}" != "relocatable" ] && header+="install-location=\"${targetPath}\" "␊ |
1092 | ␊ |
1093 | header+="auth=\"root\">\n"␊ |
1094 | header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"␊ |
1095 | rm -R -f "${packagePath}/Temp"␊ |
1096 | ␊ |
1097 | [ -d "${packagePath}/Temp" ] || mkdir -m 777 "${packagePath}/Temp"␊ |
1098 | [ -d "${packagePath}/Root" ] && mkbom "${packagePath}/Root" "${packagePath}/Temp/Bom"␊ |
1099 | ␊ |
1100 | if [ -d "${packagePath}/Scripts" ]; then␊ |
1101 | header+="\t<scripts>\n"␊ |
1102 | for script in $( find "${packagePath}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) ); do␊ |
1103 | header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"␊ |
1104 | done␊ |
1105 | header+="\t</scripts>\n"␊ |
1106 | # Create the Script archive file (cpio format)␊ |
1107 | (cd "${packagePath}/Scripts" && find . -print | \␊ |
1108 | cpio -o -z -R root:wheel --format cpio > "${packagePath}/Temp/Scripts") 2>&1 | \␊ |
1109 | grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages␊ |
1110 | fi␊ |
1111 | ␊ |
1112 | header+="</pkg-info>"␊ |
1113 | echo -e "${header}" > "${packagePath}/Temp/PackageInfo"␊ |
1114 | ␊ |
1115 | # Create the Payload file (cpio format)␊ |
1116 | (cd "${packagePath}/Root" && find . -print | \␊ |
1117 | cpio -o -z -R root:wheel --format cpio > "${packagePath}/Temp/Payload") 2>&1 | \␊ |
1118 | grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages␊ |
1119 | ␊ |
1120 | # Create the package␊ |
1121 | (cd "${packagePath}/Temp" && xar -c -f "${packagePath}/../${packageName}.pkg" --compression none .)␊ |
1122 | ␊ |
1123 | # Add the package to the list of build packages␊ |
1124 | pkgrefs[${#pkgrefs[*]}]="\t<pkg-ref id=\"${packageRefId}\" installKBytes='${installedsize}' version='${CHAMELEON_VERSION}.0.0.${CHAMELEON_TIMESTAMP}'>#${packageName}.pkg</pkg-ref>"␊ |
1125 | ␊ |
1126 | rm -rf "${packagePath}"␊ |
1127 | fi␊ |
1128 | }␊ |
1129 | ␊ |
1130 | generateOutlineChoices() {␊ |
1131 | # $1 Main Choice␊ |
1132 | # $2 indent level␊ |
1133 | local idx=$(getChoiceIndex "$1")␊ |
1134 | local indentLevel="$2"␊ |
1135 | local indentString=""␊ |
1136 | for ((level=1; level <= $indentLevel ; level++)); do␊ |
1137 | indentString="\t$indentString"␊ |
1138 | done␊ |
1139 | set +u; subChoices="${choice_group_items[$idx]}"; set -u␊ |
1140 | if [[ -n "${subChoices}" ]]; then␊ |
1141 | # Sub choices exists␊ |
1142 | echo -e "$indentString<line choice=\"$1\">"␊ |
1143 | for subChoice in $subChoices;do␊ |
1144 | generateOutlineChoices $subChoice $(($indentLevel+1))␊ |
1145 | done␊ |
1146 | echo -e "$indentString</line>"␊ |
1147 | else␊ |
1148 | echo -e "$indentString<line choice=\"$1\"/>"␊ |
1149 | fi␊ |
1150 | }␊ |
1151 | ␊ |
1152 | generateChoices() {␊ |
1153 | ␊ |
1154 | for (( idx=1; idx < ${#choice_key[*]} ; idx++)); do␊ |
1155 | local choiceId=${choice_key[$idx]}␊ |
1156 | local choiceOptions=${choice_options[$idx]}␊ |
1157 | local choiceParentGroupIndex=${choice_parent_group_index[$idx]}␊ |
1158 | set +u; local group_exclusive=${choice_group_exclusive[$choiceParentGroupIndex]}; set -u␊ |
1159 | ␊ |
1160 | # Create the node and standard attributes␊ |
1161 | local choiceNode="\t<choice\n\t\tid=\"${choiceId}\"\n\t\ttitle=\"${choiceId}_title\"\n\t\tdescription=\"${choiceId}_description\""␊ |
1162 | ␊ |
1163 | # Add options like start_selected, etc...␊ |
1164 | [[ -n "${choiceOptions}" ]] && choiceNode="${choiceNode}\n\t\t${choiceOptions}"␊ |
1165 | ␊ |
1166 | # Add the selected attribute if options are mutually exclusive␊ |
1167 | if [[ -n "$group_exclusive" ]];then␊ |
1168 | local group_items="${choice_group_items[$choiceParentGroupIndex]}"␊ |
1169 | case $group_exclusive in␊ |
1170 | exclusive_one_choice)␊ |
1171 | local selected_option=$(exclusive_one_choice "$choiceId" "$group_items") ;;␊ |
1172 | exclusive_zero_or_one_choice)␊ |
1173 | local selected_option=$(exclusive_zero_or_one_choice "$choiceId" "$group_items") ;;␊ |
1174 | *) echo "Error: unknown function to generate exclusive mode '$group_exclusive' for group '${choice_key[$choiceParentGroupIndex]}'" >&2␊ |
1175 | exit 1␊ |
1176 | ;;␊ |
1177 | esac␊ |
1178 | choiceNode="${choiceNode}\n\t\tselected=\"$selected_option\""␊ |
1179 | fi␊ |
1180 | ␊ |
1181 | choiceNode="${choiceNode}>"␊ |
1182 | ␊ |
1183 | # Add the package references␊ |
1184 | for pkgRefId in ${choice_pkgrefs[$idx]};do␊ |
1185 | choiceNode="${choiceNode}\n\t\t<pkg-ref id=\"${pkgRefId}\"/>"␊ |
1186 | done␊ |
1187 | ␊ |
1188 | # Close the node␊ |
1189 | choiceNode="${choiceNode}\n\t</choice>\n"␊ |
1190 | ␊ |
1191 | echo -e "$choiceNode"␊ |
1192 | done␊ |
1193 | }␊ |
1194 | ␊ |
1195 | makedistribution ()␊ |
1196 | {␊ |
1197 | declare -r distributionDestDir="${SYMROOT}"␊ |
1198 | declare -r distributionFilename="${packagename// /}-${CHAMELEON_VERSION}-r${CHAMELEON_REVISION}.pkg"␊ |
1199 | declare -r distributionFilePath="${distributionDestDir}/${distributionFilename}"␊ |
1200 | ␊ |
1201 | rm -f "${distributionDestDir}/${packagename// /}"*.pkg␊ |
1202 | ␊ |
1203 | mkdir -p "${PKG_BUILD_DIR}/${packagename}"␊ |
1204 | ␊ |
1205 | find "${PKG_BUILD_DIR}" -type f -name '*.pkg' -depth 1 | while read component␊ |
1206 | do␊ |
1207 | pkg="${component##*/}" # ie: EFI.pkg␊ |
1208 | pkgdir="${PKG_BUILD_DIR}/${packagename}/${pkg}"␊ |
1209 | # expand individual packages␊ |
1210 | pkgutil --expand "${PKG_BUILD_DIR}/${pkg}" "$pkgdir"␊ |
1211 | rm -f "${PKG_BUILD_DIR}/${pkg}"␊ |
1212 | done␊ |
1213 | ␊ |
1214 | # Create the Distribution file␊ |
1215 | ditto --noextattr --noqtn "${PKGROOT}/Distribution" "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1216 | ␊ |
1217 | local start_indent_level=2␊ |
1218 | echo -e "\n\t<choices-outline>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1219 | ␊ |
1220 | for main_choice in ${choice_group_items[0]};do␊ |
1221 | generateOutlineChoices $main_choice $start_indent_level >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1222 | done␊ |
1223 | echo -e "\t</choices-outline>\n" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1224 | ␊ |
1225 | generateChoices >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1226 | ␊ |
1227 | for (( i=0; i < ${#pkgrefs[*]} ; i++)); do␊ |
1228 | echo -e "${pkgrefs[$i]}" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1229 | done␊ |
1230 | ␊ |
1231 | echo -e "\n</installer-gui-script>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1232 | ␊ |
1233 | # Create the Resources directory␊ |
1234 | ditto --noextattr --noqtn "${PKGROOT}/Resources/distribution" "${PKG_BUILD_DIR}/${packagename}/Resources"␊ |
1235 | ␊ |
1236 | # Make the translation␊ |
1237 | echo ""␊ |
1238 | echo "========= Translating Resources ========"␊ |
1239 | (cd "${PKGROOT}" && PERLLIB=${PKGROOT}/bin/po4a/lib \␊ |
1240 | bin/po4a/po4a \␊ |
1241 | --package-name 'Chameleon' \␊ |
1242 | --package-version "${CHAMELEON_VERSION}-r${CHAMELEON_REVISION}" \␊ |
1243 | --msgmerge-opt '--lang=$lang' \␊ |
1244 | --variable PODIR="po" \␊ |
1245 | --variable TEMPLATES_DIR="Resources/templates" \␊ |
1246 | --variable OUTPUT_DIR="${PKG_BUILD_DIR}/${packagename}/Resources" \␊ |
1247 | ${PKGROOT}/po4a-chameleon.cfg)␊ |
1248 | ␊ |
1249 | # Copy common files in english localisation directory␊ |
1250 | ditto --noextattr --noqtn "${PKGROOT}/Resources/common" "${PKG_BUILD_DIR}/${packagename}/Resources/en.lproj"␊ |
1251 | ␊ |
1252 | # CleanUp the directory␊ |
1253 | find "${PKG_BUILD_DIR}/${packagename}" \( -type d -name '.svn' \) -o -name '.DS_Store' -depth -exec rm -rf {} \;␊ |
1254 | find "${PKG_BUILD_DIR}/${packagename}" -type d -depth -empty -exec rmdir {} \; # Remove empty directories␊ |
1255 | ␊ |
1256 | # Make substitutions for version, revision, stage, developers, credits, etc..␊ |
1257 | makeSubstitutions $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )␊ |
1258 | ␊ |
1259 | # Create the final package␊ |
1260 | pkgutil --flatten "${PKG_BUILD_DIR}/${packagename}" "${distributionFilePath}"␊ |
1261 | ␊ |
1262 | ##################################################################␊ |
1263 | # Here is the place to assign an icon to the pkg #␊ |
1264 | # command used to generate the file: #␊ |
1265 | # ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip #␊ |
1266 | ##################################################################␊ |
1267 | ditto -xk "${PKGROOT}/Icons/pkg.zip" "${PKG_BUILD_DIR}/Icons/"␊ |
1268 | DeRez -only icns "${PKG_BUILD_DIR}/Icons/Icons/pkg.icns" > "${PKG_BUILD_DIR}/Icons/tempicns.rsrc"␊ |
1269 | Rez -append "${PKG_BUILD_DIR}/Icons/tempicns.rsrc" -o "${distributionFilePath}"␊ |
1270 | SetFile -a C "${distributionFilePath}"␊ |
1271 | rm -rf "${PKG_BUILD_DIR}/Icons"␊ |
1272 | ␊ |
1273 | # End␊ |
1274 | ␊ |
1275 | md5=$( md5 "${distributionFilePath}" | awk {'print $4'} )␊ |
1276 | echo "MD5 (${distributionFilePath}) = ${md5}" > "${distributionFilePath}.md5"␊ |
1277 | echo ""␊ |
1278 | ␊ |
1279 | echo -e $COL_GREEN" --------------------------"$COL_RESET␊ |
1280 | echo -e $COL_GREEN" Building process complete!"$COL_RESET␊ |
1281 | echo -e $COL_GREEN" --------------------------"$COL_RESET␊ |
1282 | echo ""␊ |
1283 | echo -e $COL_GREEN" Build info."␊ |
1284 | echo -e $COL_GREEN" ==========="␊ |
1285 | echo -e $COL_BLUE" Package name: "$COL_RESET"${distributionFilename}"␊ |
1286 | echo -e $COL_BLUE" MD5: "$COL_RESET"$md5"␊ |
1287 | echo -e $COL_BLUE" Version: "$COL_RESET"$CHAMELEON_VERSION"␊ |
1288 | echo -e $COL_BLUE" Stage: "$COL_RESET"$CHAMELEON_STAGE"␊ |
1289 | echo -e $COL_BLUE" Date/Time: "$COL_RESET"$CHAMELEON_BUILDDATE"␊ |
1290 | echo -e $COL_BLUE" Built by: "$COL_RESET"$CHAMELEON_WHOBUILD"␊ |
1291 | echo -e $COL_BLUE" Copyright $CHAMELEON_CPRYEAR "$COL_RESET␊ |
1292 | echo ""␊ |
1293 | ␊ |
1294 | }␊ |
1295 | ␊ |
1296 | # build packages␊ |
1297 | main␊ |
1298 | ␊ |
1299 | # build meta package␊ |
1300 | makedistribution␊ |
1301 | |