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