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