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