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