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