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