Root/
| |
---|---|
Source at commit HEAD created 5 years 6 days ago. By ifabio, Few update to kernelPatcher (Credits to CrazyBirdy) | |
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.3 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="Chameleon"␊ |
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 | # build Patches packages␊ |
575 | ␊ |
576 | addGroupChoices "Patches"␊ |
577 | ␊ |
578 | # ------------------------------------------------------␊ |
579 | # parse Patches folder to find files of patches options.␊ |
580 | # ------------------------------------------------------␊ |
581 | KernelSettingsFolder="${PKGROOT}/Patches"␊ |
582 | ␊ |
583 | while IFS= read -r -d '' OptionsFile; do␊ |
584 | ␊ |
585 | # Take filename and strip .txt from end and path from front␊ |
586 | builtKPsList=${OptionsFile%.txt}␊ |
587 | builtKPsList=${builtKPsList##*/}␊ |
588 | packagesidentity="${chameleon_package_identity}.kernel.$builtKPsList"␊ |
589 | ␊ |
590 | echo "================= $builtKPsList ================="␊ |
591 | ␊ |
592 | # ------------------------------------------------------␊ |
593 | # Read kernel patcher option file into an array.␊ |
594 | # ------------------------------------------------------␊ |
595 | availableOptions=() # array to hold the list of patches options, per 'section'.␊ |
596 | exclusiveFlag="" # used to indicate list has exclusive options␊ |
597 | while read textLine; do␊ |
598 | # ignore lines in the file beginning with a #␊ |
599 | [[ $textLine = \#* ]] && continue␊ |
600 | local optionName="" key="" value=""␊ |
601 | case "$textLine" in␊ |
602 | Exclusive=[Tt][Rr][Uu][Ee]) exclusiveFlag="--exclusive_zero_or_one_choice" ;;␊ |
603 | Exclusive=*) continue ;;␊ |
604 | *@*:*=*)␊ |
605 | availableOptions[${#availableOptions[*]}]="$textLine" ;;␊ |
606 | *) echo "Error: invalid line '$textLine' in file '$OptionsFile'" >&2␊ |
607 | exit 1␊ |
608 | ;;␊ |
609 | esac␊ |
610 | done < "$OptionsFile"␊ |
611 | ␊ |
612 | addGroupChoices --parent="Patches" $exclusiveFlag "${builtKPsList}"␊ |
613 | ␊ |
614 | # ------------------------------------------------------␊ |
615 | # Loop through options in array and process each in turn␊ |
616 | # ------------------------------------------------------␊ |
617 | for textLine in "${availableOptions[@]}"; do␊ |
618 | # split line - taking all before ':' as option name␊ |
619 | # and all after ':' as key/value␊ |
620 | type=$( echo "${textLine%%@*}" | tr '[:upper:]' '[:lower:]' )␊ |
621 | tmp=${textLine#*@}␊ |
622 | optionName=${tmp%%:*}␊ |
623 | keyValue=${tmp##*:}␊ |
624 | key=${keyValue%%=*}␊ |
625 | value=${keyValue#*=}␊ |
626 | ␊ |
627 | # create folders required for each boot option␊ |
628 | mkdir -p "${PKG_BUILD_DIR}/$optionName/Root/"␊ |
629 | ␊ |
630 | case "$type" in␊ |
631 | bool) startSelected="check_kernel_bool_option('$key','$value')" ;;␊ |
632 | text) startSelected="check_kernel_text_option('$key','$value')" ;;␊ |
633 | list) startSelected="check_kernel_list_option('$key','$value')" ;;␊ |
634 | *) echo "Error: invalid type '$type' in line '$textLine' in '$OptionsFile'" >&2␊ |
635 | exit 1␊ |
636 | ;;␊ |
637 | esac␊ |
638 | recordChameleonOption "$type" "$key" "$value"␊ |
639 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/$optionName" \␊ |
640 | --subst="optionType=$type" \␊ |
641 | --subst="optionKey=$key" \␊ |
642 | --subst="optionValue=$value" \␊ |
643 | AddKernelOption␊ |
644 | packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}")␊ |
645 | buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/"␊ |
646 | addChoice --group="${builtKPsList}" \␊ |
647 | --start-selected="$startSelected" \␊ |
648 | --pkg-refs="$packageRefId" "${optionName}"␊ |
649 | done␊ |
650 | ␊ |
651 | done < <( find "${KernelSettingsFolder}" -depth 1 -type f -name '*.txt' -print0 )␊ |
652 | ␊ |
653 | # End build Patches packages␊ |
654 | ␊ |
655 | if [[ "${CONFIG_MODULES}" == 'y' ]];then␊ |
656 | # build Modules package␊ |
657 | echo "================= Modules ================="␊ |
658 | ###############################␊ |
659 | # Supported Modules #␊ |
660 | ###############################␊ |
661 | # ACPICodec.dylib #␊ |
662 | # AMDGraphicsEnabler.dylib #␊ |
663 | # GraphicsEnabler.dylib #␊ |
664 | # ATiGraphicsEnabler.dylib #␊ |
665 | # FileNVRAM.dylib #␊ |
666 | # HDAEnabler.dylib #␊ |
667 | # HelloWorld.dylib #␊ |
668 | # IntelGraphicsEnabler.dylib #␊ |
669 | # KernelPatcher.dylib #␊ |
670 | # KextPatcher.dylib #␊ |
671 | # Keylayout.dylib #␊ |
672 | # klibc.dylib #␊ |
673 | # NVDIAGraphicEnabler.dylib #␊ |
674 | # Resolution.dylib #␊ |
675 | # Sata.dylib #␊ |
676 | # uClibcxx.dylib #␊ |
677 | ###############################␊ |
678 | if [ "$(ls -A "${SYMROOT}/i386/modules")" ]; then␊ |
679 | {␊ |
680 | addGroupChoices "Module"␊ |
681 | ␊ |
682 | # -␊ |
683 | if [[ "${CONFIG_ACPICODEC_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/ACPICodec.dylib" ]]; then␊ |
684 | {␊ |
685 | # Start build ACPICodec package module␊ |
686 | choiceId="ACPICodec"␊ |
687 | moduleFile="ACPICodec.dylib"␊ |
688 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
689 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
690 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
691 | --subst="moduleName=$choiceId" \␊ |
692 | --subst="moduleFile=$moduleFile" \␊ |
693 | InstallModule␊ |
694 | ␊ |
695 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
696 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
697 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
698 | # End build ACPICodec package module␊ |
699 | }␊ |
700 | fi␊ |
701 | # -␊ |
702 | if [[ "${CONFIG_GRAPHICSENABLER_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/GraphicsEnabler.dylib" ]]; then␊ |
703 | {␊ |
704 | # Start build GraphicsEnabler package module␊ |
705 | choiceId="GraphicsEnablerModule"␊ |
706 | moduleFile="GraphicsEnabler.dylib"␊ |
707 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
708 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
709 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
710 | --subst="moduleName=$choiceId" \␊ |
711 | --subst="moduleFile=$moduleFile" \␊ |
712 | InstallModule␊ |
713 | ␊ |
714 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
715 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
716 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
717 | # End build GraphicsEnabler package module␊ |
718 | }␊ |
719 | fi␊ |
720 | # -␊ |
721 | if [[ "${CONFIG_NVIDIAGE_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/NVIDIAGraphicsEnabler.dylib" ]]; then␊ |
722 | {␊ |
723 | # Start build NvidiaGraphicsEnabler package module␊ |
724 | choiceId="NVIDIAGraphicsEnabler"␊ |
725 | moduleFile="NVIDIAGraphicEnabler.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 NvidiaGraphicsEnabler package module␊ |
737 | }␊ |
738 | fi␊ |
739 | # -␊ |
740 | if [[ "${CONFIG_AMDGE_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/AMDGraphicsEnabler.dylib" ]]; then␊ |
741 | {␊ |
742 | # Start build AMDGraphicsEnabler package module␊ |
743 | choiceId="AMDGraphicsEnabler"␊ |
744 | moduleFile="AMDGraphicsEnabler.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 AMDGraphicsEnabler package module␊ |
756 | }␊ |
757 | fi␊ |
758 | # -␊ |
759 | if [[ "${CONFIG_GMAGE_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/IntelGraphicsEnabler.dylib" ]]; then␊ |
760 | {␊ |
761 | # Start build IntelGraphicsEnabler package module␊ |
762 | choiceId="IntelGraphicsEnabler"␊ |
763 | moduleFile="IntelGraphicsEnabler.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 IntelGraphicsEnabler package module␊ |
775 | }␊ |
776 | fi␊ |
777 | # -␊ |
778 | if [[ "${CONFIG_KERNELPATCHER_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/KernelPatcher.dylib" ]]; then␊ |
779 | {␊ |
780 | # Start build KernelPatcher package module␊ |
781 | choiceId="KernelPatcher"␊ |
782 | moduleFile="KernelPatcher.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 KernelPatcher package module␊ |
794 | }␊ |
795 | fi␊ |
796 | # -␊ |
797 | if [[ "${CONFIG_KEXTPATCHER_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/KextPatcher.dylib" ]]; then␊ |
798 | {␊ |
799 | # Start build KextPatcher package module␊ |
800 | choiceId="KextPatcher"␊ |
801 | moduleFile="KextPatcher.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 KextPatcher package module␊ |
813 | }␊ |
814 | fi␊ |
815 | # -␊ |
816 | # Warning Keylayout module need additional files␊ |
817 | if [[ "${CONFIG_KEYLAYOUT_MODULE}" = 'm' && -f "${SYMROOT}/i386/modules/Keylayout.dylib" ]]; then␊ |
818 | {␊ |
819 | # Start build Keylayout package module␊ |
820 | choiceId="Keylayout"␊ |
821 | moduleFile="${choiceId}.dylib"␊ |
822 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/{modules,Keymaps}␊ |
823 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
824 | layout_src_dir="${SRCROOT}/i386/modules/Keylayout/layouts/layouts-src"␊ |
825 | if [ -d "$layout_src_dir" ];then␊ |
826 | # Create a tar.gz from layout sources␊ |
827 | (cd "$layout_src_dir"; \␊ |
828 | tar czf "${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/Keymaps/layouts-src.tar.gz" README *.slt)␊ |
829 | fi␊ |
830 | # Adding module␊ |
831 | ditto --noextattr --noqtn ${SYMROOT}/i386/modules/$moduleFile ${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/modules␊ |
832 | # Adding Keymaps␊ |
833 | ditto --noextattr --noqtn ${SRCROOT}/Keymaps ${PKG_BUILD_DIR}/${choiceId}/Root/EXTRAROOTDIR/Extra/Keymaps␊ |
834 | # Adding tools␊ |
835 | ditto --noextattr --noqtn ${SYMROOT}/i386/cham-mklayout ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
836 | # Adding scripts␊ |
837 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
838 | --subst="moduleName=$choiceId" \␊ |
839 | --subst="moduleFile=$moduleFile" \␊ |
840 | InstallModule␊ |
841 | ␊ |
842 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
843 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
844 | ␊ |
845 | # Don't add a choice for Keylayout module␊ |
846 | # addChoice "${choiceId}" "Module" --start-selected="false" "$packageRefId"␊ |
847 | # End build Keylayout package module␊ |
848 | }␊ |
849 | fi␊ |
850 | # -␊ |
851 | if [[ "${CONFIG_KLIBC_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/klibc.dylib" ]]; then␊ |
852 | {␊ |
853 | # Start build klibc package module␊ |
854 | choiceId="klibc"␊ |
855 | moduleFile="${choiceId}.dylib"␊ |
856 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
857 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
858 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
859 | --subst="moduleName=$choiceId" \␊ |
860 | --subst="moduleFile=$moduleFile" \␊ |
861 | InstallModule␊ |
862 | ␊ |
863 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
864 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
865 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
866 | # End build klibc package module␊ |
867 | }␊ |
868 | fi␊ |
869 | # -␊ |
870 | if [[ "${CONFIG_RESOLUTION_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/Resolution.dylib" ]]; then␊ |
871 | {␊ |
872 | # Start build Resolution package module␊ |
873 | choiceId="AutoReso"␊ |
874 | moduleFile="Resolution.dylib"␊ |
875 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
876 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
877 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
878 | --subst="moduleName=$choiceId" \␊ |
879 | --subst="moduleFile=$moduleFile" \␊ |
880 | InstallModule␊ |
881 | ␊ |
882 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
883 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
884 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
885 | # End build Resolution package module␊ |
886 | }␊ |
887 | fi␊ |
888 | # -␊ |
889 | if [[ "${CONFIG_HDAENABLER_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/HDAEnabler.dylib" ]]; then␊ |
890 | {␊ |
891 | # Start build HDAEnabler package module␊ |
892 | choiceId="HDAEnabler"␊ |
893 | moduleFile="HDAEnabler.dylib"␊ |
894 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
895 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
896 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
897 | --subst="moduleName=$choiceId" \␊ |
898 | --subst="moduleFile=$moduleFile" \␊ |
899 | InstallModule␊ |
900 | ␊ |
901 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
902 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
903 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
904 | # End build HDAEnabler package module␊ |
905 | }␊ |
906 | fi␊ |
907 | # -␊ |
908 | if [[ "${CONFIG_FILENVRAM_MODULE}" == 'y' && -f "${SYMROOT}/i386/modules/FileNVRAM.dylib" ]]; then␊ |
909 | {␊ |
910 | # Start build FileNVRAM package module␊ |
911 | choiceId="FileNVRAM"␊ |
912 | moduleFile="FileNVRAM.dylib"␊ |
913 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
914 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
915 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
916 | --subst="moduleName=$choiceId" \␊ |
917 | --subst="moduleFile=$moduleFile" \␊ |
918 | InstallModule␊ |
919 | ␊ |
920 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
921 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
922 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
923 | # End build FileNVRAM package module␊ |
924 | }␊ |
925 | fi␊ |
926 | # -␊ |
927 | if [[ "${CONFIG_SATA_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/Sata.dylib" ]]; then␊ |
928 | {␊ |
929 | # Start build Sata package module␊ |
930 | choiceId="Sata"␊ |
931 | moduleFile="Sata.dylib"␊ |
932 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
933 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
934 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
935 | --subst="moduleName=$choiceId" \␊ |
936 | --subst="moduleFile=$moduleFile" \␊ |
937 | InstallModule␊ |
938 | ␊ |
939 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
940 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
941 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
942 | # End build Sata package module␊ |
943 | }␊ |
944 | fi␊ |
945 | # -␊ |
946 | if [[ "${CONFIG_UCLIBCXX_MODULE}" = 'm' && -n "${CONFIG_KLIBC_MODULE}" && \␊ |
947 | -f "${SYMROOT}/i386/modules/uClibcxx.dylib" ]]; then␊ |
948 | {␊ |
949 | klibcPackageRefId=""␊ |
950 | if [[ "${CONFIG_KLIBC_MODULE}" == 'm' ]];then␊ |
951 | klibcPackageRefId=$(getPackageRefId "${modules_packages_identity}" "klibc")␊ |
952 | fi␊ |
953 | # Start build uClibc package module␊ |
954 | choiceId="uClibc"␊ |
955 | moduleFile="uClibcxx.dylib"␊ |
956 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
957 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/$moduleFile" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
958 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
959 | --subst="moduleName=$choiceId" \␊ |
960 | --subst="moduleFile=$moduleFile" \␊ |
961 | InstallModule␊ |
962 | ␊ |
963 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
964 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/EXTRAROOTDIR/Extra/modules"␊ |
965 | # Add the klibc package because the uClibc module is dependent of klibc module␊ |
966 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId $klibcPackageRefId" "${choiceId}"␊ |
967 | # End build uClibc package module␊ |
968 | }␊ |
969 | fi␊ |
970 | # -␊ |
971 | }␊ |
972 | else␊ |
973 | {␊ |
974 | echo " -= no modules to include =-"␊ |
975 | }␊ |
976 | fi␊ |
977 | # End build Modules packages␊ |
978 | fi␊ |
979 | ␊ |
980 | # build Options packages␊ |
981 | ␊ |
982 | addGroupChoices "Options"␊ |
983 | ␊ |
984 | # ------------------------------------------------------␊ |
985 | # parse OptionalSettings folder to find files of boot options.␊ |
986 | # ------------------------------------------------------␊ |
987 | OptionalSettingsFolder="${PKGROOT}/OptionalSettings"␊ |
988 | ␊ |
989 | while IFS= read -r -d '' OptionsFile; do␊ |
990 | ␊ |
991 | # Take filename and strip .txt from end and path from front␊ |
992 | builtOptionsList=${OptionsFile%.txt}␊ |
993 | builtOptionsList=${builtOptionsList##*/}␊ |
994 | packagesidentity="${chameleon_package_identity}.options.$builtOptionsList"␊ |
995 | ␊ |
996 | echo "================= $builtOptionsList ================="␊ |
997 | ␊ |
998 | # ------------------------------------------------------␊ |
999 | # Read boot option file into an array.␊ |
1000 | # ------------------------------------------------------␊ |
1001 | availableOptions=() # array to hold the list of boot options, per 'section'.␊ |
1002 | exclusiveFlag="" # used to indicate list has exclusive options␊ |
1003 | while read textLine; do␊ |
1004 | # ignore lines in the file beginning with a #␊ |
1005 | [[ $textLine = \#* ]] && continue␊ |
1006 | local optionName="" key="" value=""␊ |
1007 | case "$textLine" in␊ |
1008 | Exclusive=[Tt][Rr][Uu][Ee]) exclusiveFlag="--exclusive_zero_or_one_choice" ;;␊ |
1009 | Exclusive=*) continue ;;␊ |
1010 | *@*:*=*)␊ |
1011 | availableOptions[${#availableOptions[*]}]="$textLine" ;;␊ |
1012 | *) echo "Error: invalid line '$textLine' in file '$OptionsFile'" >&2␊ |
1013 | exit 1␊ |
1014 | ;;␊ |
1015 | esac␊ |
1016 | done < "$OptionsFile"␊ |
1017 | ␊ |
1018 | addGroupChoices --parent="Options" $exclusiveFlag "${builtOptionsList}"␊ |
1019 | ␊ |
1020 | # ------------------------------------------------------␊ |
1021 | # Loop through options in array and process each in turn␊ |
1022 | # ------------------------------------------------------␊ |
1023 | for textLine in "${availableOptions[@]}"; do␊ |
1024 | # split line - taking all before ':' as option name␊ |
1025 | # and all after ':' as key/value␊ |
1026 | type=$( echo "${textLine%%@*}" | tr '[:upper:]' '[:lower:]' )␊ |
1027 | tmp=${textLine#*@}␊ |
1028 | optionName=${tmp%%:*}␊ |
1029 | keyValue=${tmp##*:}␊ |
1030 | key=${keyValue%%=*}␊ |
1031 | value=${keyValue#*=}␊ |
1032 | ␊ |
1033 | # create folders required for each boot option␊ |
1034 | mkdir -p "${PKG_BUILD_DIR}/$optionName/Root/"␊ |
1035 | ␊ |
1036 | case "$type" in␊ |
1037 | bool) startSelected="check_chameleon_bool_option('$key','$value')" ;;␊ |
1038 | text) startSelected="check_chameleon_text_option('$key','$value')" ;;␊ |
1039 | list) startSelected="check_chameleon_list_option('$key','$value')" ;;␊ |
1040 | *) echo "Error: invalid type '$type' in line '$textLine' in '$OptionsFile'" >&2␊ |
1041 | exit 1␊ |
1042 | ;;␊ |
1043 | esac␊ |
1044 | recordChameleonOption "$type" "$key" "$value"␊ |
1045 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/$optionName" \␊ |
1046 | --subst="optionType=$type" \␊ |
1047 | --subst="optionKey=$key" \␊ |
1048 | --subst="optionValue=$value" \␊ |
1049 | AddOption␊ |
1050 | packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}")␊ |
1051 | buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/"␊ |
1052 | addChoice --group="${builtOptionsList}" \␊ |
1053 | --start-selected="$startSelected" \␊ |
1054 | --pkg-refs="$packageRefId" "${optionName}"␊ |
1055 | done␊ |
1056 | ␊ |
1057 | done < <( find "${OptionalSettingsFolder}" -depth 1 -type f -name '*.txt' -print0 )␊ |
1058 | ␊ |
1059 | # End build options packages␊ |
1060 | ␊ |
1061 | if [[ -n "${CONFIG_KEYLAYOUT_MODULE}" ]];then␊ |
1062 | # build Keymaps options packages␊ |
1063 | echo "================= Keymaps Options ================="␊ |
1064 | addGroupChoices --exclusive_zero_or_one_choice "Keymaps"␊ |
1065 | packagesidentity="${chameleon_package_identity}.options.keymaps"␊ |
1066 | keylayoutPackageRefId=""␊ |
1067 | if [[ "${CONFIG_MODULES}" == 'y' && "${CONFIG_KEYLAYOUT_MODULE}" = 'm' ]];then␊ |
1068 | keylayoutPackageRefId=$(getPackageRefId "${modules_packages_identity}" "Keylayout")␊ |
1069 | fi␊ |
1070 | ␊ |
1071 | chameleon_keylayout_key="KeyLayout"␊ |
1072 | # ------------------------------------------------------␊ |
1073 | # Available Keylayout boot options are discovered by␊ |
1074 | # reading contents of /Keymaps folder after compilation␊ |
1075 | # ------------------------------------------------------␊ |
1076 | availableOptions=($( find "${SRCROOT}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))␊ |
1077 | # Adjust array contents to match expected format␊ |
1078 | # for boot options which is: name:key=value␊ |
1079 | for (( i = 0 ; i < ${#availableOptions[@]} ; i++ )); do␊ |
1080 | # Start build of a keymap package module␊ |
1081 | choiceId="${availableOptions[i]}"␊ |
1082 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
1083 | ␊ |
1084 | recordChameleonOption "text" "$chameleon_keylayout_key" "$choiceId"␊ |
1085 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
1086 | --subst="optionType=text" \␊ |
1087 | --subst="optionKey=$chameleon_keylayout_key" \␊ |
1088 | --subst="optionValue=$choiceId" \␊ |
1089 | AddOption␊ |
1090 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
1091 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
1092 | # Add the Keylayout package because the Keylayout module is needed␊ |
1093 | addChoice --group="Keymaps" \␊ |
1094 | --start-selected="check_chameleon_text_option('${chameleon_keylayout_key}','${choiceId}')" \␊ |
1095 | --pkg-refs="$packageRefId $keylayoutPackageRefId" "${choiceId}"␊ |
1096 | done␊ |
1097 | ␊ |
1098 | # End build Keymaps options packages␊ |
1099 | fi␊ |
1100 | ␊ |
1101 | # build theme packages␊ |
1102 | echo "================= Themes ================="␊ |
1103 | addGroupChoices "Themes"␊ |
1104 | ␊ |
1105 | # Using themes section from Azi's/package branch.␊ |
1106 | packagesidentity="${chameleon_package_identity}.themes"␊ |
1107 | artwork="${SRCROOT}/artwork/themes"␊ |
1108 | themes=($( find "${artwork}" -type d -depth 1 -not -name '.svn' ))␊ |
1109 | for (( i = 0 ; i < ${#themes[@]} ; i++ )); do␊ |
1110 | themeName=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )␊ |
1111 | themeDir="$themeName"␊ |
1112 | mkdir -p "${PKG_BUILD_DIR}/${themeName}/Root/"␊ |
1113 | rsync -r --exclude=.svn --exclude="*~" "${themes[$i]}/" "${PKG_BUILD_DIR}/${themeName}/Root/${themeName}"␊ |
1114 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${themeName}" \␊ |
1115 | --subst="themeName=$themeName" \␊ |
1116 | --subst="themeDir=$themeDir" \␊ |
1117 | InstallTheme␊ |
1118 | ␊ |
1119 | packageRefId=$(getPackageRefId "${packagesidentity}" "${themeName}")␊ |
1120 | buildpackage "$packageRefId" "${themeName}" "${PKG_BUILD_DIR}/${themeName}" "/EXTRAROOTDIR/Extra/Themes"␊ |
1121 | addChoice --group="Themes" --start-selected="false" --pkg-refs="$packageRefId" "${themeName}"␊ |
1122 | done␊ |
1123 | # End build theme packages# End build Extras package␊ |
1124 | ␊ |
1125 | # build standard package␊ |
1126 | echo "================ standard ================"␊ |
1127 | packagesidentity="${chameleon_package_identity}"␊ |
1128 | choiceId="Standard"␊ |
1129 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
1130 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources␊ |
1131 | local yamlFile="Resources/chameleon_options.yaml"␊ |
1132 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
1133 | --subst="YAML_FILE=${yamlFile}" CleanOptions␊ |
1134 | generate_options_yaml_file "${PKG_BUILD_DIR}/${choiceId}/Scripts/$yamlFile"␊ |
1135 | cp -f ${PKGROOT}/Scripts/Main/${choiceId}postinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall␊ |
1136 | # ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile␊ |
1137 | ␊ |
1138 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
1139 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
1140 | addChoice --group="Chameleon" --start-selected="true" --selected="!choices['EFI'].selected" \␊ |
1141 | --pkg-refs="$packageRefId" "${choiceId}"␊ |
1142 | # End build standard package␊ |
1143 | ␊ |
1144 | # build efi package␊ |
1145 | echo "================== EFI =================="␊ |
1146 | packagesidentity="${chameleon_package_identity}"␊ |
1147 | choiceId="EFI"␊ |
1148 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
1149 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources␊ |
1150 | local yamlFile="Resources/chameleon_options.yaml"␊ |
1151 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" \␊ |
1152 | --subst="YAML_FILE=${yamlFile}" CleanOptions␊ |
1153 | generate_options_yaml_file "${PKG_BUILD_DIR}/${choiceId}/Scripts/$yamlFile"␊ |
1154 | cp -f ${PKGROOT}/Scripts/Main/ESPpostinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall␊ |
1155 | # ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile␊ |
1156 | ␊ |
1157 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
1158 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
1159 | addChoice --group="Chameleon" --enabled="systemHasGPT()" --start-selected="false" \␊ |
1160 | --selected="!choices['Standard'].selected" \␊ |
1161 | --pkg-refs="$packageRefId" "${choiceId}"␊ |
1162 | # End build efi package␊ |
1163 | ␊ |
1164 | # build pre install package␊ |
1165 | echo "================= Pre ================="␊ |
1166 | packagesidentity="${chameleon_package_identity}"␊ |
1167 | choiceId="Pre"␊ |
1168 | ␊ |
1169 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
1170 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
1171 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId}␊ |
1172 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
1173 | # End build pre install package␊ |
1174 | ␊ |
1175 | # build post install package␊ |
1176 | echo "================= Post ================="␊ |
1177 | packagesidentity="${chameleon_package_identity}"␊ |
1178 | choiceId="Post"␊ |
1179 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
1180 | addTemplateScripts --pkg-rootdir="${PKG_BUILD_DIR}/${choiceId}" ${choiceId}␊ |
1181 | ␊ |
1182 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
1183 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
1184 | addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"␊ |
1185 | # End build post install package␊ |
1186 | ␊ |
1187 | }␊ |
1188 | ␊ |
1189 | buildpackage ()␊ |
1190 | {␊ |
1191 | # $1 Package Reference Id (ie: org.chameleon.themes.default)␊ |
1192 | # $2 Package Name (ie: Default)␊ |
1193 | # $3 Path to package to build containing Root and/or Scripts␊ |
1194 | # $4 Target install location␊ |
1195 | # $5 Size (optional)␊ |
1196 | if [[ -d "${3}/Root" ]]; then␊ |
1197 | local packageRefId="$1"␊ |
1198 | local packageName="$2"␊ |
1199 | local packagePath="$3"␊ |
1200 | local targetPath="$4"␊ |
1201 | set +u # packageSize is optional␊ |
1202 | local packageSize="$5"␊ |
1203 | set -u␊ |
1204 | ␊ |
1205 | echo -e "\t[BUILD] ${packageName}"␊ |
1206 | ␊ |
1207 | find "${packagePath}" -name '.DS_Store' -delete␊ |
1208 | local filecount=$( find "${packagePath}/Root" | wc -l )␊ |
1209 | if [ "${packageSize}" ]; then␊ |
1210 | local installedsize="${packageSize}"␊ |
1211 | else␊ |
1212 | local installedsize=$( du -hkc "${packagePath}/Root" | tail -n1 | awk {'print $1'} )␊ |
1213 | fi␊ |
1214 | local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "␊ |
1215 | ␊ |
1216 | #[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "␊ |
1217 | ␊ |
1218 | header+="identifier=\"${packageRefId}\" "␊ |
1219 | header+="version=\"${CHAMELEON_VERSION}\" "␊ |
1220 | ␊ |
1221 | [ "${targetPath}" != "relocatable" ] && header+="install-location=\"${targetPath}\" "␊ |
1222 | ␊ |
1223 | header+="auth=\"root\">\n"␊ |
1224 | header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"␊ |
1225 | rm -R -f "${packagePath}/Temp"␊ |
1226 | ␊ |
1227 | [ -d "${packagePath}/Temp" ] || mkdir -m 777 "${packagePath}/Temp"␊ |
1228 | [ -d "${packagePath}/Root" ] && mkbom "${packagePath}/Root" "${packagePath}/Temp/Bom"␊ |
1229 | ␊ |
1230 | if [ -d "${packagePath}/Scripts" ]; then␊ |
1231 | header+="\t<scripts>\n"␊ |
1232 | for script in $( find "${packagePath}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) ); do␊ |
1233 | header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"␊ |
1234 | done␊ |
1235 | header+="\t</scripts>\n"␊ |
1236 | # Create the Script archive file (cpio format)␊ |
1237 | (cd "${packagePath}/Scripts" && find . -print | \␊ |
1238 | cpio -o -z -R root:wheel --format cpio > "${packagePath}/Temp/Scripts") 2>&1 | \␊ |
1239 | grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages␊ |
1240 | fi␊ |
1241 | ␊ |
1242 | header+="</pkg-info>"␊ |
1243 | echo -e "${header}" > "${packagePath}/Temp/PackageInfo"␊ |
1244 | ␊ |
1245 | # Create the Payload file (cpio format)␊ |
1246 | (cd "${packagePath}/Root" && find . -print | \␊ |
1247 | cpio -o -z -R root:wheel --format cpio > "${packagePath}/Temp/Payload") 2>&1 | \␊ |
1248 | grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages␊ |
1249 | ␊ |
1250 | # Create the package␊ |
1251 | (cd "${packagePath}/Temp" && xar -c -f "${packagePath}/../${packageName}.pkg" --compression none .)␊ |
1252 | ␊ |
1253 | # Add the package to the list of build packages␊ |
1254 | pkgrefs[${#pkgrefs[*]}]="\t<pkg-ref id=\"${packageRefId}\" installKBytes='${installedsize}' version='${CHAMELEON_VERSION}.0.0.${CHAMELEON_TIMESTAMP}'>#${packageName}.pkg</pkg-ref>"␊ |
1255 | ␊ |
1256 | rm -rf "${packagePath}"␊ |
1257 | fi␊ |
1258 | }␊ |
1259 | ␊ |
1260 | generateOutlineChoices() {␊ |
1261 | # $1 Main Choice␊ |
1262 | # $2 indent level␊ |
1263 | local idx=$(getChoiceIndex "$1")␊ |
1264 | local indentLevel="$2"␊ |
1265 | local indentString=""␊ |
1266 | for ((level=1; level <= $indentLevel ; level++)); do␊ |
1267 | indentString="\t$indentString"␊ |
1268 | done␊ |
1269 | set +u; subChoices="${choice_group_items[$idx]}"; set -u␊ |
1270 | if [[ -n "${subChoices}" ]]; then␊ |
1271 | # Sub choices exists␊ |
1272 | echo -e "$indentString<line choice=\"$1\">"␊ |
1273 | for subChoice in $subChoices;do␊ |
1274 | case "$subChoice" in␊ |
1275 | BootNo)␊ |
1276 | echo -e "$indentString<line choice=\"${stages}\">"␊ |
1277 | ;;␊ |
1278 | Standard)␊ |
1279 | echo -e "$indentString</line>"␊ |
1280 | ;;␊ |
1281 | esac␊ |
1282 | generateOutlineChoices $subChoice $(($indentLevel+1))␊ |
1283 | done␊ |
1284 | echo -e "$indentString</line>"␊ |
1285 | else␊ |
1286 | echo -e "$indentString<line choice=\"$1\"/>"␊ |
1287 | fi␊ |
1288 | }␊ |
1289 | ␊ |
1290 | generateChoices() {␊ |
1291 | ␊ |
1292 | for (( idx=1; idx < ${#choice_key[*]} ; idx++)); do␊ |
1293 | local choiceId=${choice_key[$idx]}␊ |
1294 | local choiceOptions=${choice_options[$idx]}␊ |
1295 | local choiceParentGroupIndex=${choice_parent_group_index[$idx]}␊ |
1296 | set +u; local group_exclusive=${choice_group_exclusive[$choiceParentGroupIndex]}; set -u␊ |
1297 | ␊ |
1298 | # Create the node and standard attributes␊ |
1299 | local choiceNode="\t<choice\n\t\tid=\"${choiceId}\"\n\t\ttitle=\"${choiceId}_title\"\n\t\tdescription=\"${choiceId}_description\""␊ |
1300 | ␊ |
1301 | # Add options like start_selected, etc...␊ |
1302 | [[ -n "${choiceOptions}" ]] && choiceNode="${choiceNode}\n\t\t${choiceOptions}"␊ |
1303 | ␊ |
1304 | # Add the selected attribute if options are mutually exclusive␊ |
1305 | if [[ -n "$group_exclusive" ]];then␊ |
1306 | local group_items="${choice_group_items[$choiceParentGroupIndex]}"␊ |
1307 | case $group_exclusive in␊ |
1308 | exclusive_one_choice)␊ |
1309 | local selected_option=$(exclusive_one_choice "$choiceId" "$group_items") ;;␊ |
1310 | exclusive_zero_or_one_choice)␊ |
1311 | local selected_option=$(exclusive_zero_or_one_choice "$choiceId" "$group_items") ;;␊ |
1312 | *) echo "Error: unknown function to generate exclusive mode '$group_exclusive' for group '${choice_key[$choiceParentGroupIndex]}'" >&2␊ |
1313 | exit 1␊ |
1314 | ;;␊ |
1315 | esac␊ |
1316 | choiceNode="${choiceNode}\n\t\tselected=\"$selected_option\""␊ |
1317 | fi␊ |
1318 | ␊ |
1319 | choiceNode="${choiceNode}>"␊ |
1320 | ␊ |
1321 | # Add the package references␊ |
1322 | for pkgRefId in ${choice_pkgrefs[$idx]};do␊ |
1323 | choiceNode="${choiceNode}\n\t\t<pkg-ref id=\"${pkgRefId}\"/>"␊ |
1324 | done␊ |
1325 | ␊ |
1326 | # Close the node␊ |
1327 | choiceNode="${choiceNode}\n\t</choice>\n"␊ |
1328 | # Adding Stages subgroup␊ |
1329 | if [[ "${choiceId}" = "Chameleon" ]];then␊ |
1330 | choiceNode="${choiceNode}\t<choice\n\t\tid=\"${stages}\"\n\t\ttitle=\"${stages}_title\"\n\t\tdescription=\"${stages}_description\">\n\t</choice>\n\n"␊ |
1331 | fi␊ |
1332 | ␊ |
1333 | echo -e "$choiceNode"␊ |
1334 | done␊ |
1335 | }␊ |
1336 | ␊ |
1337 | makedistribution ()␊ |
1338 | {␊ |
1339 | declare -r distributionDestDir="${SYMROOT}"␊ |
1340 | declare -r distributionFilename="${packagename// /}-${CHAMELEON_VERSION}-r${CHAMELEON_REVISION}.pkg"␊ |
1341 | declare -r distributionFilePath="${distributionDestDir}/${distributionFilename}"␊ |
1342 | ␊ |
1343 | rm -f "${distributionDestDir}/${packagename// /}"*.pkg␊ |
1344 | ␊ |
1345 | mkdir -p "${PKG_BUILD_DIR}/${packagename}"␊ |
1346 | ␊ |
1347 | find "${PKG_BUILD_DIR}" -type f -name '*.pkg' -depth 1 | while read component␊ |
1348 | do␊ |
1349 | pkg="${component##*/}" # ie: EFI.pkg␊ |
1350 | pkgdir="${PKG_BUILD_DIR}/${packagename}/${pkg}"␊ |
1351 | # expand individual packages␊ |
1352 | pkgutil --expand "${PKG_BUILD_DIR}/${pkg}" "$pkgdir"␊ |
1353 | rm -f "${PKG_BUILD_DIR}/${pkg}"␊ |
1354 | done␊ |
1355 | ␊ |
1356 | # Create the Distribution file␊ |
1357 | ditto --noextattr --noqtn "${PKGROOT}/Distribution" "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1358 | ␊ |
1359 | local start_indent_level=2␊ |
1360 | echo -e "\n\t<choices-outline>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1361 | ␊ |
1362 | for main_choice in ${choice_group_items[0]};do␊ |
1363 | generateOutlineChoices $main_choice $start_indent_level >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1364 | done␊ |
1365 | echo -e "\t</choices-outline>\n" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1366 | ␊ |
1367 | generateChoices >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1368 | ␊ |
1369 | for (( i=0; i < ${#pkgrefs[*]} ; i++)); do␊ |
1370 | echo -e "${pkgrefs[$i]}" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1371 | done␊ |
1372 | ␊ |
1373 | echo -e "\n</installer-gui-script>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
1374 | ␊ |
1375 | # Create the Resources directory␊ |
1376 | ditto --noextattr --noqtn "${PKGROOT}/Resources/distribution" "${PKG_BUILD_DIR}/${packagename}/Resources"␊ |
1377 | ␊ |
1378 | # Make the translation␊ |
1379 | echo ""␊ |
1380 | echo "========= Translating Resources ========"␊ |
1381 | (cd "${PKGROOT}" && PERLLIB=${PKGROOT}/bin/po4a/lib \␊ |
1382 | bin/po4a/po4a \␊ |
1383 | --package-name 'Chameleon' \␊ |
1384 | --package-version "${CHAMELEON_VERSION}-r${CHAMELEON_REVISION}" \␊ |
1385 | --msgmerge-opt '--lang=$lang' \␊ |
1386 | --variable PODIR="po" \␊ |
1387 | --variable TEMPLATES_DIR="Resources/templates" \␊ |
1388 | --variable OUTPUT_DIR="${PKG_BUILD_DIR}/${packagename}/Resources" \␊ |
1389 | ${PKGROOT}/po4a-chameleon.cfg)␊ |
1390 | ␊ |
1391 | # Copy common files in english localisation directory␊ |
1392 | ditto --noextattr --noqtn "${PKGROOT}/Resources/common" "${PKG_BUILD_DIR}/${packagename}/Resources/en.lproj"␊ |
1393 | ␊ |
1394 | # CleanUp the directory␊ |
1395 | find "${PKG_BUILD_DIR}/${packagename}" -name .svn -print0 | xargs -0 rm -rf␊ |
1396 | find "${PKG_BUILD_DIR}/${packagename}" -name '*.DS_Store' -type f -delete␊ |
1397 | find "${PKG_BUILD_DIR}/${packagename}" -type d -depth -empty -exec rmdir {} \; # Remove empty directories␊ |
1398 | ␊ |
1399 | # Make substitutions for version, revision, stage, developers, credits, etc..␊ |
1400 | makeSubstitutions $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )␊ |
1401 | ␊ |
1402 | # Create the final package␊ |
1403 | pkgutil --flatten "${PKG_BUILD_DIR}/${packagename}" "${distributionFilePath}"␊ |
1404 | ␊ |
1405 | ##################################################################␊ |
1406 | # Here is the place to assign an icon to the pkg #␊ |
1407 | # command used to generate the file: #␊ |
1408 | # ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip #␊ |
1409 | ##################################################################␊ |
1410 | ditto -xk "${PKGROOT}/Icons/pkg.zip" "${PKG_BUILD_DIR}/Icons/"␊ |
1411 | DeRez -only icns "${PKG_BUILD_DIR}/Icons/Icons/pkg.icns" > "${PKG_BUILD_DIR}/Icons/tempicns.rsrc"␊ |
1412 | Rez -append "${PKG_BUILD_DIR}/Icons/tempicns.rsrc" -o "${distributionFilePath}"␊ |
1413 | SetFile -a C "${distributionFilePath}"␊ |
1414 | rm -rf "${PKG_BUILD_DIR}/Icons"␊ |
1415 | ␊ |
1416 | # End␊ |
1417 | ␊ |
1418 | md5=$( md5 "${distributionFilePath}" | awk {'print $4'} )␊ |
1419 | echo "MD5 (${distributionFilePath}) = ${md5}" > "${distributionFilePath}.md5"␊ |
1420 | echo ""␊ |
1421 | ␊ |
1422 | echo -e $COL_GREEN" --------------------------"$COL_RESET␊ |
1423 | echo -e $COL_GREEN" Building process complete!"$COL_RESET␊ |
1424 | echo -e $COL_GREEN" --------------------------"$COL_RESET␊ |
1425 | echo ""␊ |
1426 | echo -e $COL_GREEN" Build info."␊ |
1427 | echo -e $COL_GREEN" ==========="␊ |
1428 | echo -e $COL_BLUE" Package name: "$COL_RESET"${distributionFilename}"␊ |
1429 | echo -e $COL_BLUE" MD5: "$COL_RESET"$md5"␊ |
1430 | echo -e $COL_BLUE" Version: "$COL_RESET"$CHAMELEON_VERSION"␊ |
1431 | echo -e $COL_BLUE" Stage: "$COL_RESET"$CHAMELEON_STAGE"␊ |
1432 | echo -e $COL_BLUE" Date/Time: "$COL_RESET"$CHAMELEON_BUILDDATE"␊ |
1433 | echo -e $COL_BLUE" Built by: "$COL_RESET"$CHAMELEON_WHOBUILD"␊ |
1434 | echo -e $COL_BLUE" Copyright $CHAMELEON_CPRYEAR "$COL_RESET␊ |
1435 | echo ""␊ |
1436 | ␊ |
1437 | }␊ |
1438 | ␊ |
1439 | # build packages␊ |
1440 | main␊ |
1441 | ␊ |
1442 | # build meta package␊ |
1443 | makedistribution␊ |
1444 | ␊ |
1445 | # Remove package stuff␊ |
1446 | rm -rf "${SYMROOT}/package"␊ |
1447 | # End␊ |
1448 |