1 | #!/bin/bash␊ |
2 | ␊ |
3 | # $1 Path to store built package␊ |
4 | ␊ |
5 | packagesidentity="org.chameleon"␊ |
6 | ␊ |
7 | packagename="Chameleon"␊ |
8 | ␊ |
9 | pkgroot="${0%/*}"␊ |
10 | ␊ |
11 | chamTemp="usr/local/chamTemp"␊ |
12 | ␊ |
13 | COL_BLACK="\x1b[30;01m"␊ |
14 | COL_RED="\x1b[31;01m"␊ |
15 | COL_GREEN="\x1b[32;01m"␊ |
16 | COL_YELLOW="\x1b[33;01m"␊ |
17 | COL_MAGENTA="\x1b[35;01m"␊ |
18 | COL_CYAN="\x1b[36;01m"␊ |
19 | COL_WHITE="\x1b[37;01m"␊ |
20 | COL_BLUE="\x1b[34;01m"␊ |
21 | COL_RESET="\x1b[39;49;00m"␊ |
22 | ␊ |
23 | #version=$( grep I386BOOT_CHAMELEONVERSION vers.h | awk '{ print $3 }' | tr -d '\"' )␊ |
24 | version=$( cat version )␊ |
25 | stage=${version##*-}␊ |
26 | revision=$( grep I386BOOT_CHAMELEONREVISION vers.h | awk '{ print $3 }' | tr -d '\"' )␊ |
27 | builddate=$( grep I386BOOT_BUILDDATE vers.h | awk '{ print $3,$4 }' | tr -d '\"' )␊ |
28 | timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )␊ |
29 | ␊ |
30 | # =================␊ |
31 | ␊ |
32 | develop=$(awk "NR==6{print;exit}" ${pkgroot}/../CREDITS)␊ |
33 | credits=$(awk "NR==10{print;exit}" ${pkgroot}/../CREDITS)␊ |
34 | pkgdev=$(awk "NR==14{print;exit}" ${pkgroot}/../CREDITS)␊ |
35 | ␊ |
36 | # =================␊ |
37 | ␊ |
38 | distributioncount=0␊ |
39 | xmlindent=0␊ |
40 | ␊ |
41 | indent[0]="\t"␊ |
42 | indent[1]="\t\t"␊ |
43 | indent[2]="\t\t\t"␊ |
44 | indent[3]="\t\t\t\t"␊ |
45 | ␊ |
46 | main ()␊ |
47 | {␊ |
48 | ␊ |
49 | # clean up the destination path␊ |
50 | ␊ |
51 | rm -R -f "${1}"␊ |
52 | echo ""␉␊ |
53 | echo -e $COL_CYAN"␉----------------------------------"$COL_RESET␊ |
54 | echo -e $COL_CYAN"␉Building $packagename Install Package"$COL_RESET␊ |
55 | echo -e $COL_CYAN"␉----------------------------------"$COL_RESET␊ |
56 | echo ""␊ |
57 | ␊ |
58 | outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"␊ |
59 | ␊ |
60 | # build core package␊ |
61 | ␉echo "================= Core ================="␊ |
62 | ␉((xmlindent++))␊ |
63 | ␉packagesidentity="org.chameleon.core"␊ |
64 | ␉mkdir -p ${1}/Core/Root/usr/local/bin␊ |
65 | ␉mkdir -p ${1}/Core/Root/usr/standalone/i386␊ |
66 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386␊ |
67 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386␊ |
68 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot0md ${1}/Core/Root/usr/standalone/i386␊ |
69 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386␊ |
70 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386␊ |
71 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386␊ |
72 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386␊ |
73 | ␉ditto --noextattr --noqtn ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386␊ |
74 | ␉ditto --noextattr --noqtn ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386␊ |
75 | ␉ditto --noextattr --noqtn ${1%/*}/i386/fdisk440 ${1}/Core/Root/usr/local/bin␊ |
76 | ␉ditto --noextattr --noqtn ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/local/bin␊ |
77 | ␉local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )␊ |
78 | ␉echo "␉[BUILD] i386 "␊ |
79 | ␉buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1␊ |
80 | ␊ |
81 | # build Chameleon package␊ |
82 | ␉echo "================= Chameleon ================="␊ |
83 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"␊ |
84 | ␉choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"␊ |
85 | ␊ |
86 | ␉# build standard package ␊ |
87 | ␉␉mkdir -p ${1}/Standard/Root␊ |
88 | ␉␉mkdir -p ${1}/Standard/Scripts/Resources␊ |
89 | ␉␉cp -f ${pkgroot}/Scripts/Main/Standard/* ${1}/Standard/Scripts␊ |
90 | ␉␉cp -f ${pkgroot}/Scripts/Sub/* ${1}/Standard/Scripts␊ |
91 | ␉␉ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Resources/SetFile␊ |
92 | ␉␉ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Standard/Scripts/Resources/revision␊ |
93 | ␉␉ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Standard/Scripts/Resources/version␊ |
94 | ␉␉echo "␉[BUILD] Standard "␊ |
95 | buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EFI']) && exclusive(choices['noboot'])\"" >/dev/null 2>&1␊ |
96 | ␉# End build standard package ␊ |
97 | ␊ |
98 | ␉# build efi package ␊ |
99 | ␉␉mkdir -p ${1}/EFI/Root␊ |
100 | ␉␉mkdir -p ${1}/EFI/Scripts/Resources␊ |
101 | ␉␉cp -f ${pkgroot}/Scripts/Main/EFI/* ${1}/EFI/Scripts␊ |
102 | ␉␉cp -f ${pkgroot}/Scripts/Sub/* ${1}/EFI/Scripts␊ |
103 | ␉␉ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Resources/SetFile␊ |
104 | ␉␉ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/EFI/Scripts/Resources/revision␊ |
105 | ␉␉ditto --noextattr --noqtn ${1%/*/*}/version ${1}/EFI/Scripts/Resources/version␊ |
106 | ␉␉echo "␉[BUILD] EFI "␊ |
107 | ␉␉buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['noboot'])\"" >/dev/null 2>&1␊ |
108 | ␉# End build efi package␊ |
109 | ␊ |
110 | ␉# build reset choice package ␊ |
111 | ␉␉mkdir -p ${1}/noboot/Root␊ |
112 | ␉␉echo "␉[BUILD] Reset choice "␊ |
113 | ␉␉buildpackage "${1}/noboot" "/$chamTemp" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['EFI'])\"" >/dev/null 2>&1␊ |
114 | ␉# End build reset choice package ␊ |
115 | ␊ |
116 | ((xmlindent--))␊ |
117 | outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
118 | # End build Chameleon package␊ |
119 | ␊ |
120 | # build Modules package␊ |
121 | ␉echo "================= Modules ================="␊ |
122 | ␉###############################␊ |
123 | ␉# Supported Modules #␊ |
124 | ␉###############################␊ |
125 | ␉# AMDGraphicsEnabler.dylib #␊ |
126 | ␉# ATiGraphicsEnabler.dylib #␊ |
127 | ␉# IntelGraphicsEnabler.dylib #␊ |
128 | ␉# klibc.dylib #␊ |
129 | ␉# NVIDIAGraphicsEnabler.dylib #␊ |
130 | ␉# Resolution.dylib #␊ |
131 | ␉# uClibcxx.dylib #␊ |
132 | ␉# Keylayout.dylib #␊ |
133 | ␉###############################␊ |
134 | ␉if [ "$(ls -A "${1%/*}/i386/modules")" ]; then␊ |
135 | ␉{␊ |
136 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Module\">"␊ |
137 | ␉␉choices[$((choicescount++))]="<choice\n\tid=\"Module\"\n\ttitle=\"Module_title\"\n\tdescription=\"Module_description\"\n>\n</choice>\n"␊ |
138 | ␉␉((xmlindent++))␊ |
139 | ␉␉packagesidentity="org.chameleon.modules"␊ |
140 | # -␊ |
141 | ␉␉if [ -e ${1%/*}/i386/modules/klibc.dylib ]; then␊ |
142 | ␉␉{␊ |
143 | ␉␉␉mkdir -p ${1}/klibc/Root␊ |
144 | ␉␉␉ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/klibc/Root␊ |
145 | ␉␉␉echo "␉[BUILD] klibc "␊ |
146 | ␉␉␉buildpackage "${1}/klibc" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
147 | ␉␉}␊ |
148 | ␉␉fi␊ |
149 | # -␊ |
150 | ␉␉if [ -e ${1%/*}/i386/modules/uClibcxx.dylib ]; then␊ |
151 | ␉␉{␊ |
152 | ␉␉␉mkdir -p ${1}/uClibc/Root␊ |
153 | ␉␉␉ditto --noextattr --noqtn ${1%/*}/i386/modules/uClibcxx.dylib ${1}/uClibc/Root␊ |
154 | ␉␉␉ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/uClibc/Root␊ |
155 | ␉␉␉echo "␉[BUILD] uClibc++ "␊ |
156 | ␉␉␉buildpackage "${1}/uClibc" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
157 | ␉␉}␊ |
158 | ␉␉fi␊ |
159 | # -␊ |
160 | ␉␉if [ -e ${1%/*}/i386/modules/Resolution.dylib ]; then␊ |
161 | ␉␉{␊ |
162 | ␉␉␉mkdir -p ${1}/AutoReso/Root␊ |
163 | ␉␉␉ditto --noextattr --noqtn ${1%/*}/i386/modules/Resolution.dylib ${1}/AutoReso/Root␊ |
164 | ␉␉␉echo "␉[BUILD] Resolution "␊ |
165 | ␉␉␉buildpackage "${1}/AutoReso" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
166 | ␉␉}␊ |
167 | ␉␉fi␊ |
168 | # -␊ |
169 | ␉␉if [ -e ${1%/*}/i386/modules/Keylayout.dylib ]; then␊ |
170 | ␉␉{␊ |
171 | ␉␉␉mkdir -p ${1}/Keylayout/Root␊ |
172 | ␉␉␉ditto --noextattr --noqtn ${1%/*}/i386/modules/Keylayout.dylib ${1}/Keylayout/Root␊ |
173 | ␉␉␉echo "␉[BUILD] Keylayout "␊ |
174 | ␉␉␉buildpackage "${1}/Keylayout" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
175 | ␉␉}␊ |
176 | ␉␉fi␊ |
177 | # -␊ |
178 | ␉␉if [ -e ${1%/*}/i386/modules/AMDGraphicsEnabler.dylib ]; then␊ |
179 | ␉␉{␊ |
180 | ␉␉␉mkdir -p ${1}/AMDGraphicsEnabler/Root␊ |
181 | ␉␉␉ditto --noextattr --noqtn ${1%/*}/i386/modules/AMDGraphicsEnabler.dylib ${1}/AMDGraphicsEnabler/Root␊ |
182 | ␉␉␉echo "␉[BUILD] AMDGraphicsEnabler "␊ |
183 | ␉␉␉buildpackage "${1}/AMDGraphicsEnabler" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
184 | ␉␉}␊ |
185 | ␉␉fi␊ |
186 | # -␊ |
187 | ␉␉if [ -e ${1%/*}/i386/modules/ATiGraphicsEnabler.dylib ]; then␊ |
188 | ␉␉{␊ |
189 | ␉␉␉mkdir -p ${1}/ATiGraphicsEnabler/Root␊ |
190 | ␉␉␉ditto --noextattr --noqtn ${1%/*}/i386/modules/ATiGraphicsEnabler.dylib ${1}/ATiGraphicsEnabler/Root␊ |
191 | ␉␉␉echo "␉[BUILD] ATiGraphicsEnabler "␊ |
192 | ␉␉␉buildpackage "${1}/ATiGraphicsEnabler" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
193 | ␉␉}␊ |
194 | ␉␉fi␊ |
195 | # -␊ |
196 | ␉␉if [ -e ${1%/*}/i386/modules/IntelGraphicsEnabler.dylib ]; then␊ |
197 | ␉␉{␊ |
198 | ␉␉␉mkdir -p ${1}/IntelGraphicsEnabler/Root␊ |
199 | ␉␉␉ditto --noextattr --noqtn ${1%/*}/i386/modules/IntelGraphicsEnabler.dylib ${1}/IntelGraphicsEnabler/Root␊ |
200 | ␉␉␉echo "␉[BUILD] IntelGraphicsEnabler "␊ |
201 | ␉␉␉buildpackage "${1}/IntelGraphicsEnabler" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
202 | ␉␉}␊ |
203 | ␉␉fi␊ |
204 | # -␊ |
205 | ␉␉if [ -e ${1%/*}/i386/modules/NVIDIAGraphicsEnabler.dylib ]; then␊ |
206 | ␉␉{␊ |
207 | ␉␉␉mkdir -p ${1}/NVIDIAGraphicsEnabler/Root␊ |
208 | ␉␉␉ditto --noextattr --noqtn ${1%/*}/i386/modules/NVIDIAGraphicsEnabler.dylib ${1}/NVIDIAGraphicsEnabler/Root␊ |
209 | ␉␉␉echo "␉[BUILD] NVIDIAGraphicsEnabler "␊ |
210 | ␉␉␉buildpackage "${1}/NVIDIAGraphicsEnabler" "/$chamTemp/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
211 | ␉␉}␊ |
212 | ␉␉fi␊ |
213 | ␊ |
214 | ␉␉((xmlindent--))␊ |
215 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
216 | ␉}␊ |
217 | ␉else␊ |
218 | ␉{␊ |
219 | ␉␉echo " -= no modules to include =-"␊ |
220 | ␉}␊ |
221 | ␉fi␊ |
222 | # End build Modules packages␊ |
223 | ␊ |
224 | ␊ |
225 | # build Extras package␊ |
226 | ␉# build options packages␊ |
227 | ␊ |
228 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"␊ |
229 | ␉␉choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"␊ |
230 | ␉␉((xmlindent++))␊ |
231 | ␊ |
232 | ␉␉# ------------------------------------------------------␊ |
233 | ␉␉# parse OptionalSettings folder to find files of boot options.␊ |
234 | ␉␉# ------------------------------------------------------␊ |
235 | ␉␉OptionalSettingsFolder="${pkgroot}/OptionalSettings"␊ |
236 | ␉␉OptionalSettingsFiles=($( find "${OptionalSettingsFolder}" -depth 1 ! -name '.svn' ! -name '.DS_Store' ))␊ |
237 | ␊ |
238 | ␉␉for (( i = 0 ; i < ${#OptionalSettingsFiles[@]} ; i++ ))␊ |
239 | ␉␉do␊ |
240 | ␊ |
241 | ␉␉␉# Take filename and Strip .txt from end and path from front␊ |
242 | ␉␉␉builtOptionsList=$( echo ${OptionalSettingsFiles[$i]%.txt} )␊ |
243 | ␉␉␉builtOptionsList=$( echo ${builtOptionsList##*/} )␊ |
244 | ␉␉␉echo "================= $builtOptionsList ================="␊ |
245 | ␉␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${builtOptionsList}\">"␊ |
246 | ␉␉␉choices[$((choicescount++))]="<choice\n\tid=\"${builtOptionsList}\"\n\ttitle=\"${builtOptionsList}_title\"\n\tdescription=\"${builtOptionsList}_description\"\n>\n</choice>\n"␊ |
247 | ␉␉␉((xmlindent++))␊ |
248 | ␉␉␉packagesidentity="org.chameleon.options.$builtOptionsList"␊ |
249 | ␊ |
250 | ␉␉␉# ------------------------------------------------------␊ |
251 | ␉␉␉# Read boot option file in to an array.␊ |
252 | ␉␉␉# ------------------------------------------------------ ␊ |
253 | ␉␉␉availableOptions=() # array to hold the list of boot options, per 'section'.␊ |
254 | ␉␉␉exclusiveFlag=0 # used to indicate list has exclusive options.␊ |
255 | ␉␉␉exclusiveName="" # will be appended to exclusive 'none' option name.␊ |
256 | ␉␉␉count=0 # used as index for stepping through array.␊ |
257 | ␉␉␉while read textLine␊ |
258 | ␉␉␉do␊ |
259 | ␉␉␉␉# ignore lines in the file beginning with a # and Exclusive=False␊ |
260 | ␉␉␉␉if [[ ${textLine} != \#* ]] && [[ ${textLine} != "Exclusive=False" ]];then␊ |
261 | ␉␉␉␉␉# check for 'Exclusive=True' option in file␊ |
262 | ␉␉␉␉␉if [[ ${textLine} == "Exclusive=True" ]];then␊ |
263 | ␉␉␉␉␉␉exclusiveFlag=1␊ |
264 | ␉␉␉␉␉␉exclusiveName=$builtOptionsList␊ |
265 | ␉␉␉␉␉else␊ |
266 | ␉␉␉␉␉␉availableOptions[count]=$textLine␊ |
267 | ␉␉␉␉␉␉((count++))␊ |
268 | ␉␉␉␉␉fi␊ |
269 | ␉␉␉␉fi␊ |
270 | ␉␉␉done < ${OptionalSettingsFiles[$i]}␊ |
271 | ␉␉␉buildoptionalsettings "$1" "${exclusiveFlag}" "${exclusiveName}"␊ |
272 | ␉␉␉␊ |
273 | ␉␉␉((xmlindent--))␊ |
274 | ␉␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
275 | ␉␉done␊ |
276 | ␊ |
277 | ␉␉# build KeyLayout options packages␊ |
278 | ␉␉␉echo "================= Keymaps Options ================="␊ |
279 | ␉␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"KeyLayout\">"␊ |
280 | ␉␉␉choices[$((choicescount++))]="<choice\n\tid=\"KeyLayout\"\n\ttitle=\"KeyLayout_title\"\n\tdescription=\"KeyLayout_description\"\n>\n</choice>\n"␊ |
281 | ␉␉␉((xmlindent++))␊ |
282 | ␉␉␉packagesidentity="org.chameleon.options.keylayout"␊ |
283 | ␉␉␉␊ |
284 | ␉␉␉# ------------------------------------------------------␊ |
285 | ␉␉␉# Available Keylayout boot options are discovered by␊ |
286 | ␉␉␉# reading contents of /Keymaps folder after compilation␊ |
287 | ␉␉␉# ------------------------------------------------------␊ |
288 | ␉␉␉availableOptions=()␊ |
289 | ␉␉␉availableOptions=($( find "${1%/sym/*}/Keymaps" -type f -depth 1 -name '*.lyt' | sed 's|.*/||;s|\.lyt||' ))␊ |
290 | ␉␉␉# Adjust array contents to match expected format␊ |
291 | ␉␉␉# for boot options which is: name:key=value␊ |
292 | ␉␉␉for (( i = 0 ; i < ${#availableOptions[@]} ; i++ )) ␊ |
293 | ␉␉␉do␊ |
294 | ␉␉␉␉availableOptions[i]=${availableOptions[i]}":KeyLayout="${availableOptions[i]}␊ |
295 | ␉␉␉done␊ |
296 | ␉␉␉␊ |
297 | ␉␉␉# to indicate exclusive option, call buildoptionalsettings with the 2nd parameter set to 1 .␊ |
298 | ␉␉␉buildoptionalsettings "$1" "0" "keylayout"␊ |
299 | ␉␉␉␊ |
300 | ␉␉␉((xmlindent--))␊ |
301 | ␉␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
302 | ␊ |
303 | ␉␉# End build KeyLayout options packages␊ |
304 | ␊ |
305 | ␉␉((xmlindent--))␊ |
306 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
307 | ␊ |
308 | ␉# End build options packages␊ |
309 | ␊ |
310 | ␉# build theme packages␊ |
311 | ␉␉echo "================= Themes ================="␊ |
312 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"␊ |
313 | ␉␉choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"␊ |
314 | ␉␉((xmlindent++))␊ |
315 | ␊ |
316 | ␉␉# Using themes section from Azi's/package branch.␊ |
317 | ␉␉packagesidentity="org.chameleon.themes"␊ |
318 | ␉␉artwork="${1%/sym/package}/artwork/themes"␊ |
319 | ␉␉themes=($( find "${artwork}" -type d -depth 1 -not -name '.svn' ))␊ |
320 | ␉␉for (( i = 0 ; i < ${#themes[@]} ; i++ )) ␊ |
321 | ␉␉do␊ |
322 | ␉␉␉theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )␊ |
323 | ␉␉␉mkdir -p "${1}/${theme}/Root/"␊ |
324 | ␉␉␉rsync -r --exclude=.svn "${themes[$i]}/" "${1}/${theme}/Root/${theme}"␊ |
325 | ␉␉␉echo "␉[BUILD] ${theme}"␊ |
326 | ␉␉␉buildpackage "${1}/${theme}" "/$chamTemp/Extra/Themes" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
327 | ␉␉done␊ |
328 | ␊ |
329 | ␉␉((xmlindent--))␊ |
330 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
331 | ␉# End build theme packages␊ |
332 | # End build Extras package␊ |
333 | ␊ |
334 | # build post install package␊ |
335 | ␉echo "================= Post ================="␊ |
336 | ␉mkdir -p ${1}/Post/Root␊ |
337 | ␉mkdir -p ${1}/Post/Scripts␊ |
338 | ␉cp -f ${pkgroot}/Scripts/Main/Post/* ${1}/Post/Scripts␊ |
339 | ␉cp -f ${pkgroot}/Scripts/Sub/InstallLog.sh ${1}/Post/Scripts␊ |
340 | ␉ditto --noextattr --noqtn ${1%/*/*}/revision ${1}/Post/Scripts/Resources/revision␊ |
341 | ␉ditto --noextattr --noqtn ${1%/*/*}/version ${1}/Post/Scripts/Resources/version␊ |
342 | ␉echo "␉[BUILD] Post "␊ |
343 | ␉buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1␊ |
344 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"␊ |
345 | ␊ |
346 | # build meta package␊ |
347 | ␊ |
348 | ␉makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"␊ |
349 | ␊ |
350 | # clean up ␊ |
351 | ␊ |
352 | ␉rm -R -f "${1}"␊ |
353 | ␊ |
354 | }␊ |
355 | ␊ |
356 | fixperms ()␊ |
357 | {␊ |
358 | ␉# $1 path␊ |
359 | ␉find "${1}" -type f -exec chmod 644 {} \;␊ |
360 | ␉find "${1}" -type d -exec chmod 755 {} \;␊ |
361 | ␉chown -R 0:0 "${1}"␊ |
362 | }␊ |
363 | ␊ |
364 | buildoptionalsettings()␊ |
365 | {␊ |
366 | ␉# $1 Path to package to build containing Root and or Scripts␊ |
367 | ␉# $2 = exclusiveFlag␊ |
368 | ␉# S3 = exclusiveName ␊ |
369 | ␉␊ |
370 | ␉# ------------------------------------------------------␊ |
371 | ␉# if exclusiveFlag=1 then re-build array␊ |
372 | ␉# adding extra boot option at beginning to give␊ |
373 | |
374 | ␉# ------------------------------------------------------␊ |
375 | ␉if [ ${2} = "1" ]; then␊ |
376 | ␉␉tempArray=("${availableOptions[@]}")␊ |
377 | ␉␉availableOptions=()␊ |
378 | ␉␉availableOptions[0]="ChooseNone-"$3":DONT=ADD"␊ |
379 | ␉␉position=0␊ |
380 | ␉␉totalItems="${#tempArray[@]}"␉␊ |
381 | ␉␉for (( position = 0 ; position < $totalItems ; position++ ))␊ |
382 | ␉␉do␊ |
383 | ␉␉␉availableOptions[$position+1]=${tempArray[${position}]}␊ |
384 | ␉␉done␊ |
385 | ␉fi␊ |
386 | ␉␊ |
387 | ␉# ------------------------------------------------------␊ |
388 | ␉# Loop through options in array and process each in turn␊ |
389 | ␉# ------------------------------------------------------␊ |
390 | ␉for (( c = 0 ; c < ${#availableOptions[@]} ; c++ ))␊ |
391 | ␉do␊ |
392 | ␉␉textLine=${availableOptions[c]}␊ |
393 | ␉␉# split line - taking all before ':' as option name␊ |
394 | ␉␉# and all after ':' as key/value␊ |
395 | ␉␉optionName=${textLine%:*}␊ |
396 | ␉␉keyValue=${textLine##*:}␊ |
397 | ␊ |
398 | ␉␉# create folders required for each boot option␊ |
399 | ␉␉mkdir -p "${1}/$optionName/Root/"␊ |
400 | ␊ |
401 | ␉␉# create dummy file with name of key/value␊ |
402 | ␉␉echo "" > "${1}/$optionName/Root/${keyValue}"␊ |
403 | ␊ |
404 | ␉␉echo "␉[BUILD] ${optionName} "␊ |
405 | ␊ |
406 | ␉␉# ------------------------------------------------------␊ |
407 | ␉␉# Before calling buildpackage, add exclusive options␊ |
408 | ␉␉# to buildpackage call if requested.␊ |
409 | ␉␉# ------------------------------------------------------␊ |
410 | ␉␉if [ $2 = "1" ]; then␊ |
411 | ␊ |
412 | ␉␉␉# Prepare individual string parts␊ |
413 | ␉␉␉stringStart="selected=\""␊ |
414 | ␉␉␉stringBefore="exclusive(choices['"␊ |
415 | ␉␉␉stringAfter="']) && "␊ |
416 | ␉␉␉stringEnd="'])\""␊ |
417 | ␉␉␉x=${stringStart}${stringBefore}␊ |
418 | ␊ |
419 | ␉␉␉# build string for sending to buildpackage␊ |
420 | ␉␉␉totalItems="${#availableOptions[@]}"␊ |
421 | ␉␉␉lastItem=$((totalItems-1))␊ |
422 | ␊ |
423 | ␉␉␉for (( r = 0 ; r < ${totalItems} ; r++ ))␊ |
424 | ␉␉␉do␊ |
425 | ␉␉␉␉textLineTemp=${availableOptions[r]}␊ |
426 | ␉␉␉␉optionNameTemp=${textLineTemp%:*}␊ |
427 | ␉␉␉␉if [ "${optionNameTemp}" != "${optionName}" ]; then␊ |
428 | ␉␉␉␉␉ x="${x}${optionNameTemp}"␊ |
429 | ␉␉␉␉␉ # Only add these to end of string up to the one before the last item␊ |
430 | ␉␉␉␉␉if [ $r -lt $lastItem ]; then␊ |
431 | ␉␉␉␉␉␉x="${x}${stringAfter}${stringBefore}"␊ |
432 | ␉␉␉␉␉fi␊ |
433 | ␉␉␉␉fi␊ |
434 | ␉␉␉done␊ |
435 | ␉␉␉x="${x}${stringEnd}"␊ |
436 | ␉␉␉buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\" ${x}" >/dev/null 2>&1␊ |
437 | ␉␉else␊ |
438 | ␉␉␉buildpackage "${1}/${optionName}" "/$chamTemp/options" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
439 | ␉␉fi␊ |
440 | ␉done␊ |
441 | }␊ |
442 | ␊ |
443 | buildpackage ()␊ |
444 | {␊ |
445 | # $1 Path to package to build containing Root and or Scripts␊ |
446 | # $2 Install Location␊ |
447 | # $3 Size␊ |
448 | # $4 Options␊ |
449 | ␊ |
450 | if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then␊ |
451 | ␊ |
452 | ␉local packagename="${1##*/}"␊ |
453 | ␉local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )␊ |
454 | ␉find "${1}" -name '.DS_Store' -delete␊ |
455 | ␉local filecount=$( find "${1}/Root" | wc -l )␊ |
456 | ␉if [ "${3}" ]; then␊ |
457 | ␉␉local installedsize="${3}"␊ |
458 | ␉else␊ |
459 | ␉␉local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )␊ |
460 | ␉fi␊ |
461 | ␉local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "␊ |
462 | ␊ |
463 | ␉#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "␉␉␊ |
464 | ␊ |
465 | ␉header+="identifier=\"${identifier}\" "␊ |
466 | ␉header+="version=\"${version}\" "␊ |
467 | ␊ |
468 | ␉[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "␊ |
469 | ␊ |
470 | ␉header+="auth=\"root\">\n"␊ |
471 | ␉header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"␊ |
472 | ␉rm -R -f "${1}/Temp"␊ |
473 | ␊ |
474 | ␉[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"␊ |
475 | ␉[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"␊ |
476 | ␊ |
477 | ␉if [ -d "${1}/Scripts" ]; then ␊ |
478 | ␉␉header+="\t<scripts>\n"␊ |
479 | ␉␉for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )␊ |
480 | ␉␉do␊ |
481 | ␉␉␉header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"␊ |
482 | ␉␉done␊ |
483 | ␉␉header+="\t</scripts>\n"␊ |
484 | ␉␉chown -R 0:0 "${1}/Scripts"␊ |
485 | ␉␉pushd "${1}/Scripts" >/dev/null␊ |
486 | ␉␉find . -print | cpio -o -z -H cpio > "../Temp/Scripts"␊ |
487 | ␉␉popd >/dev/null␊ |
488 | ␉fi␊ |
489 | ␊ |
490 | ␉header+="</pkg-info>"␊ |
491 | ␉echo -e "${header}" > "${1}/Temp/PackageInfo"␊ |
492 | ␉pushd "${1}/Root" >/dev/null␊ |
493 | ␉find . -print | cpio -o -z -H cpio > "../Temp/Payload"␊ |
494 | ␉popd >/dev/null␊ |
495 | ␉pushd "${1}/Temp" >/dev/null␊ |
496 | ␊ |
497 | ␉xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .␊ |
498 | ␊ |
499 | ␉popd >/dev/null␊ |
500 | ␊ |
501 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"␊ |
502 | ␊ |
503 | ␉if [ "${4}" ]; then␊ |
504 | ␉␉local choiceoptions="${indent[$xmlindent]}${4}\n"␉␊ |
505 | ␉fi␊ |
506 | ␉choices[$((choicescount++))]="<choice\n\tid=\"${packagename// /}\"\n\ttitle=\"${packagename}_title\"\n\tdescription=\"${packagename}_description\"\n${choiceoptions}>\n\t<pkg-ref id=\"${identifier}\" installKBytes='${installedsize}' version='${version}.0.0.${timestamp}' auth='root'>#${packagename// /}.pkg</pkg-ref>\n</choice>\n"␊ |
507 | ␊ |
508 | ␉rm -R -f "${1}"␊ |
509 | fi␊ |
510 | }␊ |
511 | ␊ |
512 | makedistribution ()␊ |
513 | {␊ |
514 | ␉rm -f "${1%/*}/${packagename// /}"*.pkg␊ |
515 | ␊ |
516 | ␉find "${1}" -type f -name '*.pkg' -depth 1 | while read component␊ |
517 | ␉do␊ |
518 | ␉␉mkdir -p "${1}/${packagename}/${component##*/}"␊ |
519 | ␉␉pushd "${1}/${packagename}/${component##*/}" >/dev/null␊ |
520 | ␉␉xar -x -f "${1%}/${component##*/}"␊ |
521 | ␉␉popd >/dev/null␊ |
522 | ␉done␊ |
523 | ␊ |
524 | ␉ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"␊ |
525 | ␉ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"␊ |
526 | ␊ |
527 | ␉find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null␊ |
528 | ␊ |
529 | ␉for (( i=0; i < ${#outline[*]} ; i++));␊ |
530 | ␉␉do␊ |
531 | ␉␉␉echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"␊ |
532 | ␉␉done␊ |
533 | ␊ |
534 | ␉for (( i=0; i < ${#choices[*]} ; i++));␊ |
535 | ␉␉do␊ |
536 | ␉␉␉echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"␊ |
537 | ␉␉done␊ |
538 | ␊ |
539 | ␉echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"␊ |
540 | ␊ |
541 | ␉perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
542 | ␉perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
543 | ␊ |
544 | # Adding Developer and credits␊ |
545 | ␉perl -i -p -e "s/%DEVELOP%/${develop}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
546 | ␉perl -i -p -e "s/%CREDITS%/${credits}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
547 | ␉perl -i -p -e "s/%PKGDEV%/${pkgdev}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
548 | ␊ |
549 | ␉stage=${stage/RC/Release Candidate }␊ |
550 | ␉stage=${stage/FINAL/2.0 Final}␊ |
551 | ␉perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
552 | ␊ |
553 | ␉find "${1}/${packagename}" -name '.DS_Store' -delete␊ |
554 | ␉pushd "${1}/${packagename}" >/dev/null␊ |
555 | ␉xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .␊ |
556 | ␉popd >/dev/null␊ |
557 | ␊ |
558 | # Here is the place for assign a Icon to the pkg␊ |
559 | # command use to generate the file:␊ |
560 | # ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip␊ |
561 | # ----␊ |
562 | ditto -xk "${pkgroot}/Icons/pkg.zip" "${pkgroot}/Icons/"␊ |
563 | DeRez -only icns "${pkgroot}/Icons/Icons/pkg.icns" > tempicns.rsrc␊ |
564 | Rez -append tempicns.rsrc -o "${1%/*}/$packagename-${version}-r$revision.pkg"␊ |
565 | SetFile -a C "${1%/*}/$packagename-${version}-r$revision.pkg"␊ |
566 | rm -f tempicns.rsrc␊ |
567 | rm -rf "${pkgroot}/Icons/Icons"␊ |
568 | # End␊ |
569 | ␊ |
570 | ␉md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" | awk {'print $4'} )␊ |
571 | ␉echo "MD5 (${packagename// /}-${version}-r${revision}.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}.pkg.md5"␊ |
572 | ␉echo ""␉␊ |
573 | ␊ |
574 | ␉echo -e $COL_GREEN"␉--------------------------"$COL_RESET␊ |
575 | ␉echo -e $COL_GREEN"␉Building process complete!"$COL_RESET␊ |
576 | ␉echo -e $COL_GREEN"␉--------------------------"$COL_RESET␊ |
577 | ␉echo ""␉␊ |
578 | ␉echo -e $COL_GREEN"␉Build info."␊ |
579 | ␉echo -e $COL_GREEN"␉==========="␊ |
580 | ␉echo -e $COL_BLUE"␉Package name:␉"$COL_RESET"$packagename-${version}-r$revision.pkg"␊ |
581 | ␉echo -e $COL_BLUE"␉MD5:␉␉"$COL_RESET"$md5"␊ |
582 | ␉echo -e $COL_BLUE"␉Version:␉"$COL_RESET"$version"␊ |
583 | ␉echo -e $COL_BLUE"␉Stage:␉␉"$COL_RESET"$stage"␊ |
584 | ␉echo -e $COL_BLUE"␉Date/Time:␉"$COL_RESET"$builddate"␊ |
585 | ␉echo ""␊ |
586 | ␊ |
587 | }␊ |
588 | ␊ |
589 | main "${1}" "${2}" "${3}" "${4}" "${5}"␊ |
590 | ␊ |
591 | |