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