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