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