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