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 | ␊ |
13 | if [[ $# -lt 3 ]];then␊ |
14 | echo "Too few arguments. Aborting..." >&2 && exit 1␊ |
15 | fi␊ |
16 | ␊ |
17 | if [[ ! -d "$SYMROOT" ]];then␊ |
18 | echo "Directory ${SYMROOT} doesn't exit. Aborting..." >&2 && exit 1␊ |
19 | fi␊ |
20 | ␊ |
21 | # Prevent the script from doing bad things␊ |
22 | set -u # Abort with unset variables␊ |
23 | #set -e # Abort with any error can be suppressed locally using EITHER cmd||true OR set -e;cmd;set +e␊ |
24 | ␊ |
25 | # ====== CONFIGURATION ======␊ |
26 | CONFIG_MODULES=""␊ |
27 | CONFIG_KLIBC_MODULE=""␊ |
28 | CONFIG_UCLIBCXX_MODULE=""␊ |
29 | CONFIG_RESOLUTION_MODULE=""␊ |
30 | CONFIG_AMDGRAPHICSENABLER_MODULE=""␊ |
31 | CONFIG_ATIGRAPHICSENABLER_MODULE=""␊ |
32 | CONFIG_INTELGRAPHICSENABLER_MODULE=""␊ |
33 | CONFIG_NVIDIAGRAPHICSENABLER_MODULE=""␊ |
34 | CONFIG_KEYLAYOUT_MODULE=""␊ |
35 | source "${SRCROOT}/auto.conf"␊ |
36 | ␊ |
37 | # ====== COLORS ======␊ |
38 | ␊ |
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 | ␊ |
51 | declare -r version=$( cat version )␊ |
52 | ␊ |
53 | # stage␊ |
54 | stage=${version##*-}␊ |
55 | stage=${stage/RC/Release Candidate }␊ |
56 | stage=${stage/FINAL/2.1 Final}␊ |
57 | declare -r stage␊ |
58 | ␊ |
59 | declare -r revision=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )␊ |
60 | declare -r builddate=$( grep I386BOOT_BUILDDATE vers.h | awk '{ print $3,$4 }' | tr -d '\"' )␊ |
61 | declare -r timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )␊ |
62 | ␊ |
63 | # ====== CREDITS ======␊ |
64 | ␊ |
65 | declare -r develop=$(awk "NR==6{print;exit}" ${PKGROOT}/../CREDITS)␊ |
66 | declare -r credits=$(awk "NR==10{print;exit}" ${PKGROOT}/../CREDITS)␊ |
67 | declare -r pkgdev=$(awk "NR==14{print;exit}" ${PKGROOT}/../CREDITS)␊ |
68 | declare -r whobuild=$(whoami | awk '{print $1}' | cut -d ":" -f3)␊ |
69 | ␊ |
70 | # ====== GLOBAL VARIABLES ======␊ |
71 | declare -a pkgrefs␊ |
72 | declare -a choice_key␊ |
73 | declare -a choice_options␊ |
74 | declare -a choice_pkgrefs␊ |
75 | declare -a choice_parent_group_index␊ |
76 | declare -a choice_group_items␊ |
77 | declare -a choice_group_exclusive␊ |
78 | ␊ |
79 | # Init Main Group␊ |
80 | choice_key[0]=""␊ |
81 | choice_options[0]=""␊ |
82 | choices_pkgrefs[0]=""␊ |
83 | choice_group_items[0]=""␊ |
84 | choice_group_exclusive[0]=""␊ |
85 | ␊ |
86 | # Package name␊ |
87 | declare -r packagename="Chameleon"␊ |
88 | ␊ |
89 | # Package identifiers␊ |
90 | declare -r chameleon_package_identity="org.chameleon"␊ |
91 | declare -r modules_packages_identity="${chameleon_package_identity}.modules"␊ |
92 | declare -r chamTemp="usr/local/chamTemp"␊ |
93 | ␊ |
94 | # ====== FUNCTIONS ======␊ |
95 | ␊ |
96 | trim () {␊ |
97 | local result="${1#"${1%%[![:space:]]*}"}" # remove leading whitespace characters␊ |
98 | echo "${result%"${result##*[![:space:]]}"}" # remove trailing whitespace characters␊ |
99 | }␊ |
100 | ␊ |
101 | getPackageRefId () {␊ |
102 | echo ${1//_/.}.${2//_/.} | tr [:upper:] [:lower:]␊ |
103 | }␊ |
104 | ␊ |
105 | # Return index of a choice␊ |
106 | getChoiceIndex () {␊ |
107 | # $1 Choice Id␊ |
108 | local found=0␊ |
109 | for (( idx=0 ; idx < ${#choice_key[*]}; idx++ ));do␊ |
110 | if [[ "${1}" == "${choice_key[$idx]}" ]];then␊ |
111 | found=1␊ |
112 | break␊ |
113 | fi␊ |
114 | done␊ |
115 | echo "$idx"␊ |
116 | return $found␊ |
117 | }␊ |
118 | ␊ |
119 | # Add a new choice␊ |
120 | addChoice () {␊ |
121 | # Optionnal arguments:␊ |
122 | # --group=<group> : Group Choice Id␊ |
123 | # --start-selected=<javascript code> : Specifies whether this choice is initially selected or unselected␊ |
124 | # --start-enabled=<javascript code> : Specifies the initial enabled state of this choice␊ |
125 | # --start-visible=<javascript code> : Specifies whether this choice is initially visible␊ |
126 | # --pkg-refs=<pkgrefs> : List of package reference(s) id (separate by spaces)␊ |
127 | #␊ |
128 | # $1 Choice Id␊ |
129 | ␊ |
130 | local option␊ |
131 | local groupChoice=""␊ |
132 | local choiceOptions=""␊ |
133 | local pkgrefs=""␊ |
134 | ␊ |
135 | # Check the arguments.␊ |
136 | for option in "${@}";do␊ |
137 | case "$option" in␊ |
138 | --group=*)␊ |
139 | shift; groupChoice=${option#*=} ;;␊ |
140 | --start-selected=*)␊ |
141 | shift; choiceOptions="$choiceOptions start_selected=\"${option#*=}\"" ;;␊ |
142 | --start-enabled=*)␊ |
143 | shift; choiceOptions="$choiceOptions start_enabled=\"${option#*=}\"" ;;␊ |
144 | --start-visible=*)␊ |
145 | shift; choiceOptions="$choiceOptions start_visible=\"${option#*=}\"" ;;␊ |
146 | --pkg-refs=*)␊ |
147 | shift; pkgrefs=${option#*=} ;;␊ |
148 | -*)␊ |
149 | echo "Unrecognized addChoice option '$option'" >&2␊ |
150 | exit 1␊ |
151 | ;;␊ |
152 | *) break ;;␊ |
153 | esac␊ |
154 | done␊ |
155 | ␊ |
156 | if [[ $# -ne 1 ]];then␊ |
157 | echo "addChoice invalid number of arguments: ${@}" >&2␊ |
158 | exit 1␊ |
159 | fi␊ |
160 | ␊ |
161 | local choiceId="${1}"␊ |
162 | ␊ |
163 | # Add choice in the group␊ |
164 | idx_group=$(getChoiceIndex "$groupChoice")␊ |
165 | found_group=$?␊ |
166 | if [[ $found_group -ne 1 ]];then␊ |
167 | # No group exist␊ |
168 | echo "Error can't add choice '$choiceId' to group '$groupChoice': group choice '$groupChoice' doesn't exists." >&2␊ |
169 | exit 1␊ |
170 | else␊ |
171 | set +u; oldItems=${choice_group_items[$idx_group]}; set -u␊ |
172 | choice_group_items[$idx_group]="$oldItems $choiceId"␊ |
173 | fi␊ |
174 | ␊ |
175 | # Check that the choice doesn't already exists␊ |
176 | idx=$(getChoiceIndex "$choiceId")␊ |
177 | found=$?␊ |
178 | if [[ $found -ne 0 ]];then␊ |
179 | # Choice already exists␊ |
180 | echo "Error can't add choice '$choiceId': a choice with same name already exists." >&2␊ |
181 | exit 1␊ |
182 | fi␊ |
183 | ␊ |
184 | # Record new node␊ |
185 | choice_key[$idx]="$choiceId"␊ |
186 | choice_options[$idx]=$(trim "${choiceOptions}") # Removing leading and trailing whitespace(s)␊ |
187 | choice_parent_group_index[$idx]=$idx_group␊ |
188 | choice_pkgrefs[$idx]="$pkgrefs"␊ |
189 | ␊ |
190 | return $idx␊ |
191 | }␊ |
192 | ␊ |
193 | # Add a group choice␊ |
194 | addGroupChoices() {␊ |
195 | # Optionnal arguments:␊ |
196 | # --parent=<parent> : parent group choice id␊ |
197 | # --exclusive_zero_or_one_choice : only zero or one choice can be selected in the group␊ |
198 | # --exclusive_one_choice : only one choice can be selected in the group␊ |
199 | #␊ |
200 | # $1 Choice Id␊ |
201 | ␊ |
202 | local option␊ |
203 | local groupChoice=""␊ |
204 | local exclusive_function=""␊ |
205 | ␊ |
206 | for option in "${@}";do␊ |
207 | case "$option" in␊ |
208 | --exclusive_zero_or_one_choice)␊ |
209 | shift; exclusive_function="exclusive_zero_or_one_choice" ;;␊ |
210 | --exclusive_one_choice)␊ |
211 | shift; exclusive_function="exclusive_one_choice" ;;␊ |
212 | --parent=*)␊ |
213 | shift; groupChoice=${option#*=} ;;␊ |
214 | -*)␊ |
215 | echo "Unrecognized addGroupChoices option '$option'" >&2␊ |
216 | exit 1␊ |
217 | ;;␊ |
218 | *) break ;;␊ |
219 | esac␊ |
220 | done␊ |
221 | ␊ |
222 | if [[ $# -ne 1 ]];then␊ |
223 | echo "addGroupChoices invalid number of arguments: ${@}" >&2␊ |
224 | exit 1␊ |
225 | fi␊ |
226 | ␊ |
227 | addChoice --group="$groupChoice" "${1}"␊ |
228 | local idx=$? # index of the new created choice␊ |
229 | ␊ |
230 | choice_group_exclusive[$idx]="$exclusive_function"␊ |
231 | }␊ |
232 | ␊ |
233 | exclusive_one_choice () {␊ |
234 | # $1 Current choice (ie: test1)␊ |
235 | # $2..$n Others choice(s) (ie: "test2" "test3"). Current can or can't be in the others choices␊ |
236 | local myChoice="${1}"␊ |
237 | local result="";␊ |
238 | local separator=' || ';␊ |
239 | for choice in ${@:2};do␊ |
240 | if [[ "$choice" != "$myChoice" ]];then␊ |
241 | result="${result}choices['$choice'].selected${separator}";␊ |
242 | fi␊ |
243 | done␊ |
244 | if [[ -n "$result" ]];then␊ |
245 | echo "!(${result%$separator})"␊ |
246 | fi␊ |
247 | }␊ |
248 | ␊ |
249 | exclusive_zero_or_one_choice () {␊ |
250 | # $1 Current choice (ie: test1)␊ |
251 | # $2..$n Others choice(s) (ie: "test2" "test3"). Current can or can't be in the others choices␊ |
252 | local myChoice="${1}"␊ |
253 | local result;␊ |
254 | echo "(my.choice.selected && $(exclusive_one_choice ${@}))"␊ |
255 | }␊ |
256 | ␊ |
257 | main ()␊ |
258 | {␊ |
259 | ␊ |
260 | # clean up the destination path␊ |
261 | ␊ |
262 | rm -R -f "${PKG_BUILD_DIR}"␊ |
263 | echo ""␊ |
264 | echo -e $COL_CYAN" ----------------------------------"$COL_RESET␊ |
265 | echo -e $COL_CYAN" Building $packagename Install Package"$COL_RESET␊ |
266 | echo -e $COL_CYAN" ----------------------------------"$COL_RESET␊ |
267 | echo ""␊ |
268 | ␊ |
269 | # build pre install package␊ |
270 | echo "================= Preinstall ================="␊ |
271 | packagesidentity="${chameleon_package_identity}"␊ |
272 | choiceId="Pre"␊ |
273 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
274 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
275 | ditto --noextattr --noqtn ${SRCROOT}/revision ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/revision␊ |
276 | ditto --noextattr --noqtn ${SRCROOT}/version ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/version␊ |
277 | cp -f ${PKGROOT}/Scripts/Main/preinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
278 | cp -f ${PKGROOT}/Scripts/Sub/InstallLog.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
279 | ␊ |
280 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
281 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
282 | addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"␊ |
283 | # End build pre install package␊ |
284 | ␊ |
285 | # build core package␊ |
286 | echo "================= Core ================="␊ |
287 | packagesidentity="${chameleon_package_identity}"␊ |
288 | choiceId="Core"␊ |
289 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
290 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
291 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
292 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
293 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot0md ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
294 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot1f32 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
295 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot1h ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
296 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot1he ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
297 | ditto --noextattr --noqtn ${SYMROOT}/i386/boot1hp ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
298 | ditto --noextattr --noqtn ${SYMROOT}/i386/cdboot ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
299 | ditto --noextattr --noqtn ${SYMROOT}/i386/chain0 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/standalone/i386␊ |
300 | ditto --noextattr --noqtn ${SYMROOT}/i386/fdisk440 ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
301 | ditto --noextattr --noqtn ${SYMROOT}/i386/bdmesg ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
302 | ␊ |
303 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
304 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
305 | addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"␊ |
306 | # End build core package␊ |
307 | ␊ |
308 | # build install type␊ |
309 | echo "================= Chameleon ================="␊ |
310 | addGroupChoices --exclusive_one_choice "InstallType"␊ |
311 | packagesidentity="${chameleon_package_identity}.type"␊ |
312 | ␊ |
313 | # build new install package␊ |
314 | choiceId="New"␊ |
315 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
316 | echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/install_type_new"␊ |
317 | ␊ |
318 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
319 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp"␊ |
320 | addChoice --group="InstallType" --start-selected="!choices['Upgrade'].selected" --pkg-refs="$packageRefId" "${choiceId}"␊ |
321 | # End build new install package␊ |
322 | ␊ |
323 | # build upgrade package␊ |
324 | choiceId="Upgrade"␊ |
325 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
326 | echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/install_type_upgrade"␊ |
327 | ␊ |
328 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
329 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp"␊ |
330 | addChoice --group="InstallType" --start-selected="chameleon_boot_plist_exists()" --pkg-refs="$packageRefId" "${choiceId}"␊ |
331 | # End build upgrade package␊ |
332 | ␊ |
333 | # End build install type␊ |
334 | ␊ |
335 | # build Chameleon package␊ |
336 | echo "================= Chameleon ================="␊ |
337 | addGroupChoices --exclusive_one_choice "Chameleon"␊ |
338 | ␊ |
339 | # build standard package␊ |
340 | choiceId="Standard"␊ |
341 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
342 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources␊ |
343 | cp -f ${PKGROOT}/Scripts/Main/${choiceId}postinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall␊ |
344 | cp -f ${PKGROOT}/Scripts/Sub/* ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
345 | ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile␊ |
346 | ␊ |
347 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
348 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
349 | addChoice --group="Chameleon" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"␊ |
350 | # End build standard package␊ |
351 | ␊ |
352 | # build efi package␊ |
353 | choiceId="EFI"␊ |
354 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
355 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources␊ |
356 | cp -f ${PKGROOT}/Scripts/Main/ESPpostinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts/postinstall␊ |
357 | cp -f ${PKGROOT}/Scripts/Sub/* ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
358 | ditto --arch i386 `which SetFile` ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/SetFile␊ |
359 | ␊ |
360 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
361 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
362 | addChoice --group="Chameleon" --start-visible="systemHasGPT()" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
363 | # End build efi package␊ |
364 | ␊ |
365 | # build no bootloader choice package␊ |
366 | choiceId="noboot"␊ |
367 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
368 | ␊ |
369 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
370 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
371 | addChoice --group="Chameleon" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
372 | # End build no bootloader choice package␊ |
373 | ␊ |
374 | # End build Chameleon package␊ |
375 | ␊ |
376 | if [[ "${CONFIG_MODULES}" == 'y' ]];then␊ |
377 | # build Modules package␊ |
378 | echo "================= Modules ================="␊ |
379 | ###############################␊ |
380 | # Supported Modules #␊ |
381 | ###############################␊ |
382 | # AMDGraphicsEnabler.dylib #␊ |
383 | # ATiGraphicsEnabler.dylib #␊ |
384 | # IntelGraphicsEnabler.dylib #␊ |
385 | # klibc.dylib #␊ |
386 | # NVIDIAGraphicsEnabler.dylib #␊ |
387 | # Resolution.dylib #␊ |
388 | # uClibcxx.dylib #␊ |
389 | # Keylayout.dylib #␊ |
390 | ###############################␊ |
391 | if [ "$(ls -A "${SYMROOT}/i386/modules")" ]; then␊ |
392 | {␊ |
393 | addGroupChoices "Module"␊ |
394 | ␊ |
395 | # -␊ |
396 | if [[ "${CONFIG_KLIBC_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/klibc.dylib" ]]; then␊ |
397 | {␊ |
398 | # Start build klibc package module␊ |
399 | choiceId="klibc"␊ |
400 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
401 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/${choiceId}.dylib" ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
402 | ␊ |
403 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
404 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" >/dev/null 2>&1␊ |
405 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
406 | # End build klibc package module␊ |
407 | }␊ |
408 | fi␊ |
409 | ␊ |
410 | # -␊ |
411 | if [[ "${CONFIG_UCLIBCXX_MODULE}" = 'm' && -n "${CONFIG_KLIBC_MODULE}" && \␊ |
412 | -f "${SYMROOT}/i386/modules/uClibcxx.dylib" ]]; then␊ |
413 | {␊ |
414 | klibcPackageRefId=""␊ |
415 | if [[ "${CONFIG_KLIBC_MODULE}" == 'm' ]];then␊ |
416 | klibcPackageRefId=$(getPackageRefId "${modules_packages_identity}" "klibc")␊ |
417 | fi␊ |
418 | # Start build uClibc package module␊ |
419 | choiceId="uClibc"␊ |
420 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
421 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/uClibcxx.dylib" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
422 | ␊ |
423 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
424 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" >/dev/null 2>&1␊ |
425 | # Add the klibc package because the uClibc module is dependent of klibc module␊ |
426 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId $klibcPackageRefId" "${choiceId}"␊ |
427 | # End build uClibc package module␊ |
428 | }␊ |
429 | fi␊ |
430 | ␊ |
431 | # -␊ |
432 | if [[ "${CONFIG_RESOLUTION_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/Resolution.dylib" ]]; then␊ |
433 | {␊ |
434 | # Start build Resolution package module␊ |
435 | choiceId="AutoReso"␊ |
436 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
437 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/Resolution.dylib" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
438 | ␊ |
439 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
440 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" >/dev/null 2>&1␊ |
441 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
442 | # End build Resolution package module␊ |
443 | }␊ |
444 | fi␊ |
445 | ␊ |
446 | # -␊ |
447 | # Warning Keylayout module need additional files␊ |
448 | if [[ "${CONFIG_KEYLAYOUT_MODULE}" = 'm' && -f "${SYMROOT}/i386/modules/Keylayout.dylib" ]]; then␊ |
449 | {␊ |
450 | # Start build Keylayout package module␊ |
451 | choiceId="Keylayout"␊ |
452 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/{modules,Keymaps}␊ |
453 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
454 | layout_src_dir="${SRCROOT}/i386/modules/Keylayout/layouts/layouts-src"␊ |
455 | if [ -d "$layout_src_dir" ];then␊ |
456 | # Create a tar.gz from layout sources␊ |
457 | (cd "$layout_src_dir"; \␊ |
458 | tar czf "${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps/layouts-src.tar.gz" README *.slt)␊ |
459 | fi␊ |
460 | # Adding module␊ |
461 | ditto --noextattr --noqtn ${SYMROOT}/i386/modules/${choiceId}.dylib ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/modules␊ |
462 | # Adding Keymaps␊ |
463 | ditto --noextattr --noqtn ${SRCROOT}/Keymaps ${PKG_BUILD_DIR}/${choiceId}/Root/Extra/Keymaps␊ |
464 | # Adding tools␊ |
465 | ditto --noextattr --noqtn ${SYMROOT}/i386/cham-mklayout ${PKG_BUILD_DIR}/${choiceId}/Root/usr/local/bin␊ |
466 | ␊ |
467 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
468 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp" >/dev/null 2>&1␊ |
469 | ␊ |
470 | # Don't add a choice for Keylayout module␊ |
471 | # addChoice "${choiceId}" "Module" --start-selected="false" "$packageRefId"␊ |
472 | # End build Keylayout package module␊ |
473 | }␊ |
474 | fi␊ |
475 | ␊ |
476 | # -␊ |
477 | ␊ |
478 | if [[ "${CONFIG_AMDGRAPHICSENABLER_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/AMDGraphicsEnabler.dylib" ]]; then␊ |
479 | {␊ |
480 | # Start build AMDGraphicsEnabler package module␊ |
481 | choiceId="AMDGraphicsEnabler"␊ |
482 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
483 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/AMDGraphicsEnabler.dylib" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
484 | ␊ |
485 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
486 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" >/dev/null 2>&1␊ |
487 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
488 | # End build AMDGraphicsEnabler package module␊ |
489 | }␊ |
490 | fi␊ |
491 | ␊ |
492 | # -␊ |
493 | ␊ |
494 | if [[ "${CONFIG_ATIGRAPHICSENABLER_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/ATiGraphicsEnabler.dylib" ]]; then␊ |
495 | {␊ |
496 | # Start build ATiGraphicsEnabler package module␊ |
497 | choiceId="AMDGraphicsEnabler"␊ |
498 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
499 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/ATiGraphicsEnabler.dylib" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
500 | echo -e "\t[BUILD] ${choiceId} "␊ |
501 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
502 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" >/dev/null 2>&1␊ |
503 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
504 | # End build ATiGraphicsEnabler package module␊ |
505 | }␊ |
506 | fi␊ |
507 | ␊ |
508 | # -␊ |
509 | ␊ |
510 | if [[ "${CONFIG_INTELGRAPHICSENABLER_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/IntelGraphicsEnabler.dylib" ]]; then␊ |
511 | {␊ |
512 | # Start build IntelGraphicsEnabler package module␊ |
513 | choiceId="IntelGraphicsEnabler"␊ |
514 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
515 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/IntelGraphicsEnabler.dylib" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
516 | echo -e "\t[BUILD] ${choiceId} "␊ |
517 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
518 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" >/dev/null 2>&1␊ |
519 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
520 | # End build IntelGraphicsEnabler package module␊ |
521 | }␊ |
522 | fi␊ |
523 | ␊ |
524 | # -␊ |
525 | ␊ |
526 | if [[ "${CONFIG_NVIDIAGRAPHICSENABLER_MODULE}" == 'm' && -f "${SYMROOT}/i386/modules/NVIDIAGraphicsEnabler.dylib" ]]; then␊ |
527 | {␊ |
528 | # Start build NVIDIAGraphicsEnabler package module␊ |
529 | choiceId="NVIDIAGraphicsEnabler"␊ |
530 | mkdir -p "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
531 | ditto --noextattr --noqtn "${SYMROOT}/i386/modules/NVIDIAGraphicsEnabler.dylib" "${PKG_BUILD_DIR}/${choiceId}/Root"␊ |
532 | echo -e "\t[BUILD] ${choiceId} "␊ |
533 | packageRefId=$(getPackageRefId "${modules_packages_identity}" "${choiceId}")␊ |
534 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/Extra/modules" >/dev/null 2>&1␊ |
535 | addChoice --group="Module" --start-selected="false" --pkg-refs="$packageRefId" "${choiceId}"␊ |
536 | # End build NVIDIAGraphicsEnabler package module␊ |
537 | }␊ |
538 | fi␊ |
539 | ␊ |
540 | }␊ |
541 | else␊ |
542 | {␊ |
543 | echo " -= no modules to include =-"␊ |
544 | }␊ |
545 | fi␊ |
546 | # End build Modules packages␊ |
547 | fi␊ |
548 | ␊ |
549 | # build Options packages␊ |
550 | ␊ |
551 | addGroupChoices "Options"␊ |
552 | ␊ |
553 | # ------------------------------------------------------␊ |
554 | # parse OptionalSettings folder to find files of boot options.␊ |
555 | # ------------------------------------------------------␊ |
556 | OptionalSettingsFolder="${PKGROOT}/OptionalSettings"␊ |
557 | OptionalSettingsFiles=($( find "${OptionalSettingsFolder}" -depth 1 ! -name '.svn' ! -name '.DS_Store' ))␊ |
558 | ␊ |
559 | for (( i = 0 ; i < ${#OptionalSettingsFiles[@]} ; i++ ))␊ |
560 | do␊ |
561 | ␊ |
562 | # Take filename and Strip .txt from end and path from front␊ |
563 | builtOptionsList=$( echo ${OptionalSettingsFiles[$i]%.txt} )␊ |
564 | builtOptionsList=$( echo ${builtOptionsList##*/} )␊ |
565 | ␊ |
566 | echo "================= $builtOptionsList ================="␊ |
567 | ␊ |
568 | # ------------------------------------------------------␊ |
569 | # Read boot option file into an array.␊ |
570 | # ------------------------------------------------------␊ |
571 | availableOptions=() # array to hold the list of boot options, per 'section'.␊ |
572 | exclusiveFlag="" # used to indicate list has exclusive options␊ |
573 | while read textLine; do␊ |
574 | # ignore lines in the file beginning with a # and Exclusive=False␊ |
575 | if [[ ${textLine} != \#* ]] && [[ ${textLine} != "Exclusive=False" ]];then␊ |
576 | # check for 'Exclusive=True' option in file␊ |
577 | if [[ ${textLine} == "Exclusive=True" ]];then␊ |
578 | exclusiveFlag="--exclusive_zero_or_one_choice"␊ |
579 | else␊ |
580 | availableOptions[${#availableOptions[@]}]=$textLine␊ |
581 | fi␊ |
582 | fi␊ |
583 | done < ${OptionalSettingsFiles[$i]}␊ |
584 | ␊ |
585 | addGroupChoices --parent="Options" $exclusiveFlag "${builtOptionsList}"␊ |
586 | packagesidentity="${chameleon_package_identity}.options.$builtOptionsList"␊ |
587 | ␊ |
588 | # ------------------------------------------------------␊ |
589 | # Loop through options in array and process each in turn␊ |
590 | # ------------------------------------------------------␊ |
591 | for (( c = 0 ; c < ${#availableOptions[@]} ; c++ )); do␊ |
592 | textLine=${availableOptions[c]}␊ |
593 | # split line - taking all before ':' as option name␊ |
594 | # and all after ':' as key/value␊ |
595 | optionName=${textLine%%:*}␊ |
596 | keyValue=${textLine##*:}␊ |
597 | key=${keyValue%%=*}␊ |
598 | value=${keyValue#*=}␊ |
599 | ␊ |
600 | # create folders required for each boot option␊ |
601 | mkdir -p "${PKG_BUILD_DIR}/$optionName/Root/"␊ |
602 | ␊ |
603 | # create dummy file with name of key/value␊ |
604 | echo "" > "${PKG_BUILD_DIR}/$optionName/Root/${keyValue}"␊ |
605 | ␊ |
606 | packageRefId=$(getPackageRefId "${packagesidentity}" "${optionName}")␊ |
607 | buildpackage "$packageRefId" "${optionName}" "${PKG_BUILD_DIR}/${optionName}" "/$chamTemp/options"␊ |
608 | addChoice --group="${builtOptionsList}" \␊ |
609 | --start-selected="check_chameleon_option('$key','$value')" \␊ |
610 | --pkg-refs="$packageRefId" "${optionName}"␊ |
611 | done␊ |
612 | ␊ |
613 | done␊ |
614 | ␊ |
615 | # End build options packages␊ |
616 | ␊ |
617 | if [[ -n "${CONFIG_KEYLAYOUT_MODULE}" ]];then␊ |
618 | # build KeyLayout options packages␊ |
619 | echo "================= Keymaps Options ================="␊ |
620 | addGroupChoices --exclusive_zero_or_one_choice "KeyLayout"␊ |
621 | packagesidentity="${chameleon_package_identity}.options.keylayout"␊ |
622 | keylayoutPackageRefId=""␊ |
623 | if [[ "${CONFIG_MODULES}" == 'y' && "${CONFIG_KEYLAYOUT_MODULE}" = 'm' ]];then␊ |
624 | keylayoutPackageRefId=$(getPackageRefId "${modules_packages_identity}" "Keylayout")␊ |
625 | fi␊ |
626 | ␊ |
627 | chameleon_keylayout_key="KeyLayout"␊ |
628 | # ------------------------------------------------------␊ |
629 | # Available Keylayout boot options are discovered by␊ |
630 | # reading contents of /Keymaps folder after compilation␊ |
631 | # ------------------------------------------------------␊ |
632 | availableOptions=($( find "${SRCROOT}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))␊ |
633 | # Adjust array contents to match expected format␊ |
634 | # for boot options which is: name:key=value␊ |
635 | for (( i = 0 ; i < ${#availableOptions[@]} ; i++ )); do␊ |
636 | # Start build of a keymap package module␊ |
637 | choiceId="${availableOptions[i]}"␊ |
638 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
639 | ␊ |
640 | # create dummy file with name of key/value␊ |
641 | echo "" > "${PKG_BUILD_DIR}/${choiceId}/Root/${chameleon_keylayout_key}=${availableOptions[i]}"␊ |
642 | ␊ |
643 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
644 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/$chamTemp/options"␊ |
645 | # Add the Keylayout package because the Keylayout module is needed␊ |
646 | addChoice --group="KeyLayout" \␊ |
647 | --start-selected="check_chameleon_option('${chameleon_keylayout_key}','${choiceId}')" \␊ |
648 | --pkg-refs="$packageRefId $keylayoutPackageRefId" "${choiceId}"␊ |
649 | done␊ |
650 | ␊ |
651 | # End build KeyLayout options packages␊ |
652 | fi␊ |
653 | ␊ |
654 | # build theme packages␊ |
655 | echo "================= Themes ================="␊ |
656 | addGroupChoices "Themes"␊ |
657 | ␊ |
658 | # Using themes section from Azi's/package branch.␊ |
659 | packagesidentity="${chameleon_package_identity}.themes"␊ |
660 | artwork="${SRCROOT}/artwork/themes"␊ |
661 | themes=($( find "${artwork}" -type d -depth 1 -not -name '.svn' ))␊ |
662 | for (( i = 0 ; i < ${#themes[@]} ; i++ )); do␊ |
663 | theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )␊ |
664 | mkdir -p "${PKG_BUILD_DIR}/${theme}/Root/"␊ |
665 | rsync -r --exclude=.svn "${themes[$i]}/" "${PKG_BUILD_DIR}/${theme}/Root/${theme}"␊ |
666 | ␊ |
667 | packageRefId=$(getPackageRefId "${packagesidentity}" "${theme}")␊ |
668 | buildpackage "$packageRefId" "${theme}" "${PKG_BUILD_DIR}/${theme}" "/$chamTemp/Extra/Themes"␊ |
669 | addChoice --group="Themes" --start-selected="false" --pkg-refs="$packageRefId" "${theme}"␊ |
670 | done␊ |
671 | # End build theme packages# End build Extras package␊ |
672 | ␊ |
673 | # build post install package␊ |
674 | echo "================= Post ================="␊ |
675 | packagesidentity="${chameleon_package_identity}"␊ |
676 | choiceId="Post"␊ |
677 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Root␊ |
678 | mkdir -p ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
679 | cp -f ${PKGROOT}/Scripts/Main/postinstall ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
680 | cp -f ${PKGROOT}/Scripts/Sub/InstallLog.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
681 | cp -f ${PKGROOT}/Scripts/Sub/UnMountEFIvolumes.sh ${PKG_BUILD_DIR}/${choiceId}/Scripts␊ |
682 | ditto --noextattr --noqtn ${SRCROOT}/revision ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/revision␊ |
683 | ditto --noextattr --noqtn ${SRCROOT}/version ${PKG_BUILD_DIR}/${choiceId}/Scripts/Resources/version␊ |
684 | ␊ |
685 | packageRefId=$(getPackageRefId "${packagesidentity}" "${choiceId}")␊ |
686 | buildpackage "$packageRefId" "${choiceId}" "${PKG_BUILD_DIR}/${choiceId}" "/"␊ |
687 | addChoice --start-visible="false" --start-selected="true" --pkg-refs="$packageRefId" "${choiceId}"␊ |
688 | # End build post install package␊ |
689 | ␊ |
690 | }␊ |
691 | ␊ |
692 | buildpackage ()␊ |
693 | {␊ |
694 | # $1 Package Reference Id (ie: org.chameleon.themes.default)␊ |
695 | # $2 Package Name (ie: Default)␊ |
696 | # $3 Path to package to build containing Root and/or Scripts␊ |
697 | # $4 Target install location␊ |
698 | # $5 Size (optional)␊ |
699 | if [[ -d "${3}/Root" ]]; then␊ |
700 | local packageRefId="$1"␊ |
701 | local packageName="$2"␊ |
702 | local packagePath="$3"␊ |
703 | local targetPath="$4"␊ |
704 | set +u # packageSize is optional␊ |
705 | local packageSize="$5"␊ |
706 | set -u␊ |
707 | ␊ |
708 | echo -e "\t[BUILD] ${packageName}"␊ |
709 | ␊ |
710 | find "${packagePath}" -name '.DS_Store' -delete␊ |
711 | local filecount=$( find "${packagePath}/Root" | wc -l )␊ |
712 | if [ "${packageSize}" ]; then␊ |
713 | local installedsize="${packageSize}"␊ |
714 | else␊ |
715 | local installedsize=$( du -hkc "${packagePath}/Root" | tail -n1 | awk {'print $1'} )␊ |
716 | fi␊ |
717 | local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "␊ |
718 | ␊ |
719 | #[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "␊ |
720 | ␊ |
721 | header+="identifier=\"${packageRefId}\" "␊ |
722 | header+="version=\"${version}\" "␊ |
723 | ␊ |
724 | [ "${targetPath}" != "relocatable" ] && header+="install-location=\"${targetPath}\" "␊ |
725 | ␊ |
726 | header+="auth=\"root\">\n"␊ |
727 | header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"␊ |
728 | rm -R -f "${packagePath}/Temp"␊ |
729 | ␊ |
730 | [ -d "${packagePath}/Temp" ] || mkdir -m 777 "${packagePath}/Temp"␊ |
731 | [ -d "${packagePath}/Root" ] && mkbom "${packagePath}/Root" "${packagePath}/Temp/Bom"␊ |
732 | ␊ |
733 | if [ -d "${packagePath}/Scripts" ]; then␊ |
734 | header+="\t<scripts>\n"␊ |
735 | for script in $( find "${packagePath}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) ); do␊ |
736 | header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"␊ |
737 | done␊ |
738 | header+="\t</scripts>\n"␊ |
739 | # Create the Script archive file (cpio format)␊ |
740 | (cd "${packagePath}/Scripts" && find . -print | cpio -o -z -R 0:0 --format cpio > "${packagePath}/Temp/Scripts") 2>&1 | \␊ |
741 | grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages␊ |
742 | fi␊ |
743 | ␊ |
744 | header+="</pkg-info>"␊ |
745 | echo -e "${header}" > "${packagePath}/Temp/PackageInfo"␊ |
746 | ␊ |
747 | # Create the Payload file (cpio format)␊ |
748 | (cd "${packagePath}/Root" && find . -print | cpio -o -z -R 0:0 --format cpio > "${packagePath}/Temp/Payload") 2>&1 | \␊ |
749 | grep -vE '^[0-9]+\s+blocks?$' # to remove cpio stderr messages␊ |
750 | ␊ |
751 | # Create the package␊ |
752 | (cd "${packagePath}/Temp" && xar -c -f "${packagePath}/../${packageName}.pkg" --compression none .)␊ |
753 | ␊ |
754 | # Add the package to the list of build packages␊ |
755 | pkgrefs[${#pkgrefs[*]}]="\t<pkg-ref id=\"${packageRefId}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}'>#${packageName}.pkg</pkg-ref>"␊ |
756 | ␊ |
757 | rm -rf "${packagePath}"␊ |
758 | fi␊ |
759 | }␊ |
760 | ␊ |
761 | generateOutlineChoices() {␊ |
762 | # $1 Main Choice␊ |
763 | # $2 indent level␊ |
764 | local idx=$(getChoiceIndex "$1")␊ |
765 | local indentLevel="$2"␊ |
766 | local indentString=""␊ |
767 | for ((level=1; level <= $indentLevel ; level++)); do␊ |
768 | indentString="\t$indentString"␊ |
769 | done␊ |
770 | set +u; subChoices="${choice_group_items[$idx]}"; set -u␊ |
771 | if [[ -n "${subChoices}" ]]; then␊ |
772 | # Sub choices exists␊ |
773 | echo -e "$indentString<line choice=\"$1\">"␊ |
774 | for subChoice in $subChoices;do␊ |
775 | generateOutlineChoices $subChoice $(($indentLevel+1))␊ |
776 | done␊ |
777 | echo -e "$indentString</line>"␊ |
778 | else␊ |
779 | echo -e "$indentString<line choice=\"$1\"/>"␊ |
780 | fi␊ |
781 | }␊ |
782 | ␊ |
783 | generateChoices() {␊ |
784 | for (( idx=1; idx < ${#choice_key[*]} ; idx++)); do␊ |
785 | local choiceId=${choice_key[$idx]}␊ |
786 | local choiceOptions=${choice_options[$idx]}␊ |
787 | local choiceParentGroupIndex=${choice_parent_group_index[$idx]}␊ |
788 | set +u; local group_exclusive=${choice_group_exclusive[$choiceParentGroupIndex]}; set -u␊ |
789 | ␊ |
790 | # Create the node and standard attributes␊ |
791 | local choiceNode="\t<choice\n\t\tid=\"${choiceId}\"\n\t\ttitle=\"${choiceId}_title\"\n\t\tdescription=\"${choiceId}_description\""␊ |
792 | ␊ |
793 | # Add options like start_selected, etc...␊ |
794 | [[ -n "${choiceOptions}" ]] && choiceNode="${choiceNode}\n\t\t${choiceOptions}"␊ |
795 | ␊ |
796 | # Add the selected attribute if options are mutually exclusive␊ |
797 | if [[ -n "$group_exclusive" ]];then␊ |
798 | local group_items="${choice_group_items[$choiceParentGroupIndex]}"␊ |
799 | case $group_exclusive in␊ |
800 | exclusive_one_choice)␊ |
801 | local selected_option=$(exclusive_one_choice "$choiceId" "$group_items") ;;␊ |
802 | exclusive_zero_or_one_choice)␊ |
803 | local selected_option=$(exclusive_zero_or_one_choice "$choiceId" "$group_items") ;;␊ |
804 | *) echo "Error: unknown function to generate exclusive mode '$group_exclusive' for group '${choice_key[$choiceParentGroupIndex]}'" >&2␊ |
805 | exit 1␊ |
806 | ;;␊ |
807 | esac␊ |
808 | choiceNode="${choiceNode}\n\t\tselected=\"$selected_option\""␊ |
809 | fi␊ |
810 | ␊ |
811 | choiceNode="${choiceNode}>"␊ |
812 | ␊ |
813 | # Add the package references␊ |
814 | for pkgRefId in ${choice_pkgrefs[$idx]};do␊ |
815 | choiceNode="${choiceNode}\n\t\t<pkg-ref id=\"${pkgRefId}\"/>"␊ |
816 | done␊ |
817 | ␊ |
818 | # Close the node␊ |
819 | choiceNode="${choiceNode}\n\t</choice>\n"␊ |
820 | ␊ |
821 | echo -e "$choiceNode"␊ |
822 | done␊ |
823 | }␊ |
824 | ␊ |
825 | makedistribution ()␊ |
826 | {␊ |
827 | declare -r distributionDestDir="${SYMROOT}"␊ |
828 | declare -r distributionFilename="${packagename// /}-${version}-r${revision}.pkg"␊ |
829 | declare -r distributionFilePath="${distributionDestDir}/${distributionFilename}"␊ |
830 | ␊ |
831 | rm -f "${distributionDestDir}/${packagename// /}"*.pkg␊ |
832 | ␊ |
833 | mkdir -p "${PKG_BUILD_DIR}/${packagename}"␊ |
834 | ␊ |
835 | find "${PKG_BUILD_DIR}" -type f -name '*.pkg' -depth 1 | while read component␊ |
836 | do␊ |
837 | pkg="${component##*/}" # ie: EFI.pkg␊ |
838 | pkgdir="${PKG_BUILD_DIR}/${packagename}/${pkg}"␊ |
839 | # expand individual packages␊ |
840 | pkgutil --expand "${PKG_BUILD_DIR}/${pkg}" "$pkgdir"␊ |
841 | rm -f "${PKG_BUILD_DIR}/${pkg}"␊ |
842 | done␊ |
843 | ␊ |
844 | # Create the Distribution file␊ |
845 | ditto --noextattr --noqtn "${PKGROOT}/Distribution" "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
846 | ␊ |
847 | local start_indent_level=2␊ |
848 | echo -e "\n\t<choices-outline>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
849 | for main_choice in ${choice_group_items[0]};do␊ |
850 | generateOutlineChoices $main_choice $start_indent_level >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
851 | done␊ |
852 | echo -e "\t</choices-outline>\n" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
853 | ␊ |
854 | generateChoices >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
855 | ␊ |
856 | for (( i=0; i < ${#pkgrefs[*]} ; i++)); do␊ |
857 | echo -e "${pkgrefs[$i]}" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
858 | done␊ |
859 | ␊ |
860 | echo -e "\n</installer-gui-script>" >> "${PKG_BUILD_DIR}/${packagename}/Distribution"␊ |
861 | ␊ |
862 | # Create the Resources directory␊ |
863 | ditto --noextattr --noqtn "${PKGROOT}/Resources" "${PKG_BUILD_DIR}/${packagename}/Resources"␊ |
864 | ␊ |
865 | # CleanUp the directory␊ |
866 | find "${PKG_BUILD_DIR}/${packagename}" \( -type d -name '.svn' \) -o -name '.DS_Store' -exec rm -rf {} \;␊ |
867 | ␊ |
868 | # Add Chameleon Version and Revision␊ |
869 | perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )␊ |
870 | perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )␊ |
871 | ␊ |
872 | # Add Chameleon Stage␊ |
873 | perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )␊ |
874 | ␊ |
875 | # Adding Developer and credits␊ |
876 | perl -i -p -e "s/%DEVELOP%/${develop}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )␊ |
877 | perl -i -p -e "s/%CREDITS%/${credits}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )␊ |
878 | perl -i -p -e "s/%PKGDEV%/${pkgdev}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )␊ |
879 | ␊ |
880 | # Adding whoami␊ |
881 | perl -i -p -e "s/%WHOBUILD%/${whobuild}/g" $( find "${PKG_BUILD_DIR}/${packagename}/Resources" -type f )␊ |
882 | ␊ |
883 | # Create the final package␊ |
884 | pkgutil --flatten "${PKG_BUILD_DIR}/${packagename}" "${distributionFilePath}"␊ |
885 | ␊ |
886 | ##################################################################␊ |
887 | # Here is the place for assign a Icon to the pkg #␊ |
888 | # command use to generate the file: #␊ |
889 | # ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip #␊ |
890 | ##################################################################␊ |
891 | ditto -xk "${PKGROOT}/Icons/pkg.zip" "${PKG_BUILD_DIR}/Icons/"␊ |
892 | DeRez -only icns "${PKG_BUILD_DIR}/Icons/Icons/pkg.icns" > "${PKG_BUILD_DIR}/Icons/tempicns.rsrc"␊ |
893 | Rez -append "${PKG_BUILD_DIR}/Icons/tempicns.rsrc" -o "${distributionFilePath}"␊ |
894 | SetFile -a C "${distributionFilePath}"␊ |
895 | rm -rf "${PKG_BUILD_DIR}/Icons"␊ |
896 | ␊ |
897 | # End␊ |
898 | ␊ |
899 | md5=$( md5 "${distributionFilePath}" | awk {'print $4'} )␊ |
900 | echo "MD5 (${distributionFilePath}) = ${md5}" > "${distributionFilePath}.md5"␊ |
901 | echo ""␊ |
902 | ␊ |
903 | echo -e $COL_GREEN" --------------------------"$COL_RESET␊ |
904 | echo -e $COL_GREEN" Building process complete!"$COL_RESET␊ |
905 | echo -e $COL_GREEN" --------------------------"$COL_RESET␊ |
906 | echo ""␊ |
907 | echo -e $COL_GREEN" Build info."␊ |
908 | echo -e $COL_GREEN" ==========="␊ |
909 | echo -e $COL_BLUE" Package name: "$COL_RESET"${distributionFilename}"␊ |
910 | echo -e $COL_BLUE" MD5: "$COL_RESET"$md5"␊ |
911 | echo -e $COL_BLUE" Version: "$COL_RESET"$version"␊ |
912 | echo -e $COL_BLUE" Stage: "$COL_RESET"$stage"␊ |
913 | echo -e $COL_BLUE" Date/Time: "$COL_RESET"$builddate"␊ |
914 | echo -e $COL_BLUE" Builded by: "$COL_RESET"$whobuild"␊ |
915 | echo ""␊ |
916 | ␊ |
917 | }␊ |
918 | ␊ |
919 | # build packages␊ |
920 | main␊ |
921 | ␊ |
922 | # build meta package␊ |
923 | makedistribution␊ |
924 | |