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 | COL_BLACK="\x1b[30;01m"␊ |
12 | COL_RED="\x1b[31;01m"␊ |
13 | COL_GREEN="\x1b[32;01m"␊ |
14 | COL_YELLOW="\x1b[33;01m"␊ |
15 | COL_MAGENTA="\x1b[35;01m"␊ |
16 | COL_CYAN="\x1b[36;01m"␊ |
17 | COL_WHITE="\x1b[37;01m"␊ |
18 | COL_BLUE="\x1b[34;01m"␊ |
19 | COL_RESET="\x1b[39;49;00m"␊ |
20 | ␊ |
21 | #version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )␊ |
22 | version=$( cat version )␊ |
23 | stage=${version##*-}␊ |
24 | revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )␊ |
25 | builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' )␊ |
26 | timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )␊ |
27 | ␊ |
28 | # =================␊ |
29 | ␊ |
30 | develop=$(awk "NR==6{print;exit}" ${pkgroot}/../CREDITS)␊ |
31 | credits=$(awk "NR==10{print;exit}" ${pkgroot}/../CREDITS)␊ |
32 | pkgdev=$(awk "NR==14{print;exit}" ${pkgroot}/../CREDITS)␊ |
33 | # =================␊ |
34 | ␊ |
35 | distributioncount=0␊ |
36 | xmlindent=0␊ |
37 | ␊ |
38 | indent[0]="\t"␊ |
39 | indent[1]="\t\t"␊ |
40 | indent[2]="\t\t\t"␊ |
41 | indent[3]="\t\t\t\t"␊ |
42 | ␊ |
43 | main ()␊ |
44 | {␊ |
45 | ␊ |
46 | # clean up the destination path␊ |
47 | ␊ |
48 | rm -R -f "${1}"␊ |
49 | echo ""␉␊ |
50 | echo -e $COL_BLACK"␉----------------------------------"$COL_RESET␊ |
51 | echo -e $COL_BLACK"␉Building $packagename Install Package"$COL_RESET␊ |
52 | echo -e $COL_BLACK"␉----------------------------------"$COL_RESET␊ |
53 | echo ""␊ |
54 | ␊ |
55 | outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"␊ |
56 | ␊ |
57 | # build core package␊ |
58 | ␉echo "================= Core ================="␊ |
59 | ␉((xmlindent++))␊ |
60 | ␉packagesidentity="org.chameleon.core"␊ |
61 | #␉mkdir -p ${1}/Core/Root/usr/sbin␊ |
62 | ␉mkdir -p ${1}/Core/Root/usr/local/bin␊ |
63 | ␉mkdir -p ${1}/Core/Root/usr/standalone/i386␊ |
64 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386␊ |
65 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386␊ |
66 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot0md ${1}/Core/Root/usr/standalone/i386␊ |
67 | #␉ditto --noextattr --noqtn ${1%/*}/i386/boot0hf ${1}/Core/Root/usr/standalone/i386␊ |
68 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386␊ |
69 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386␊ |
70 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386␊ |
71 | ␉ditto --noextattr --noqtn ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386␊ |
72 | ␉ditto --noextattr --noqtn ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386␊ |
73 | ␉ditto --noextattr --noqtn ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386␊ |
74 | # fixperms "${1}/Core/Root/"␊ |
75 | ␉ditto --noextattr --noqtn ${1%/*}/i386/fdisk440 ${1}/Core/Root/usr/sbin␊ |
76 | ␉ditto --noextattr --noqtn ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/sbin␊ |
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/Tools␊ |
89 | ␉␉cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts␊ |
90 | ␉␉# ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile␊ |
91 | ␉␉echo "␉[BUILD] Standard "␊ |
92 | ␉␉buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EFI']) && exclusive(choices['noboot'])\"" >/dev/null 2>&1␊ |
93 | ␉# End build standard package ␊ |
94 | ␊ |
95 | ␉# build efi package ␊ |
96 | ␉␉mkdir -p ${1}/EFI/Root␊ |
97 | ␉␉mkdir -p ${1}/EFI/Scripts/Tools␊ |
98 | ␉␉cp -f ${pkgroot}/Scripts/EFI/* ${1}/EFI/Scripts␊ |
99 | ␉␉# ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Tools/SetFile␊ |
100 | ␉␉echo "␉[BUILD] EFI "␊ |
101 | ␉␉buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['noboot'])\"" >/dev/null 2>&1␊ |
102 | ␉# End build efi package␊ |
103 | ␊ |
104 | ␉# build reset choice package ␊ |
105 | ␉␉mkdir -p ${1}/noboot/Root␊ |
106 | ␉␉echo "␉[BUILD] Reset choice "␊ |
107 | ␉␉buildpackage "${1}/noboot" "/tmpcham" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['EFI'])\"" >/dev/null 2>&1␊ |
108 | ␉# End build reset choice package ␊ |
109 | ␊ |
110 | ␉# build Modules package␊ |
111 | echo "================= Modules ================="␊ |
112 | ###############################␊ |
113 | # Supported Modules #␊ |
114 | ###############################␊ |
115 | # AMDGraphicsEnabler.dylib #␊ |
116 | # ATiGraphicsEnabler.dylib #␊ |
117 | # IntelGraphicsEnabler.dylib #␊ |
118 | # klibc.dylib #␊ |
119 | # NVIDIAGraphicsEnabler.dylib #␊ |
120 | # Resolution.dylib #␊ |
121 | # uClibcxx.dylib #␊ |
122 | ###############################␊ |
123 | if [ "$(ls -A "${1%/*}/i386/modules")" ]; then␊ |
124 | {␊ |
125 | outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Module\">"␊ |
126 | choices[$((choicescount++))]="<choice\n\tid=\"Module\"\n\ttitle=\"Module_title\"\n\tdescription=\"Module_description\"\n>\n</choice>\n"␊ |
127 | ((xmlindent++))␊ |
128 | packagesidentity="org.chameleon.modules"␊ |
129 | # -␊ |
130 | if [ -e ${1%/*}/i386/modules/AMDGraphicsEnabler.dylib ]; then␊ |
131 | {␊ |
132 | mkdir -p ${1}/AMDGraphicsEnabler/Root␊ |
133 | ditto --noextattr --noqtn ${1%/*}/i386/modules/AMDGraphicsEnabler.dylib ${1}/AMDGraphicsEnabler/Root␊ |
134 | echo "␉[BUILD] AMDGraphicsEnabler "␊ |
135 | buildpackage "${1}/AMDGraphicsEnabler" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
136 | }␊ |
137 | fi␊ |
138 | # -␊ |
139 | if [ -e ${1%/*}/i386/modules/ATiGraphicsEnabler.dylib ]; then␊ |
140 | {␊ |
141 | mkdir -p ${1}/ATiGraphicsEnabler/Root␊ |
142 | ditto --noextattr --noqtn ${1%/*}/i386/modules/ATiGraphicsEnabler.dylib ${1}/ATiGraphicsEnabler/Root␊ |
143 | echo "␉[BUILD] ATiGraphicsEnabler "␊ |
144 | buildpackage "${1}/ATiGraphicsEnabler" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
145 | }␊ |
146 | fi␊ |
147 | # -␊ |
148 | if [ -e ${1%/*}/i386/modules/IntelGraphicsEnabler.dylib ]; then␊ |
149 | {␊ |
150 | mkdir -p ${1}/IntelGraphicsEnabler/Root␊ |
151 | ditto --noextattr --noqtn ${1%/*}/i386/modules/IntelGraphicsEnabler.dylib ${1}/IntelGraphicsEnabler/Root␊ |
152 | echo "␉[BUILD] IntelGraphicsEnabler "␊ |
153 | buildpackage "${1}/IntelGraphicsEnabler" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
154 | }␊ |
155 | fi␊ |
156 | # -␊ |
157 | if [ -e ${1%/*}/i386/modules/klibc.dylib ]; then␊ |
158 | {␊ |
159 | mkdir -p ${1}/klibc/Root␊ |
160 | ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/klibc/Root␊ |
161 | echo "␉[BUILD] klibc "␊ |
162 | buildpackage "${1}/klibc" "/Extra/modules" "" "start_selected=\"true\"" >/dev/null 2>&1␊ |
163 | }␊ |
164 | fi␊ |
165 | # -␊ |
166 | if [ -e ${1%/*}/i386/modules/NVIDIAGraphicsEnabler.dylib ]; then␊ |
167 | {␊ |
168 | mkdir -p ${1}/NVIDIAGraphicsEnabler/Root␊ |
169 | ditto --noextattr --noqtn ${1%/*}/i386/modules/NVIDIAGraphicsEnabler.dylib ${1}/NVIDIAGraphicsEnabler/Root␊ |
170 | echo "␉[BUILD] NVIDIAGraphicsEnabler "␊ |
171 | buildpackage "${1}/NVIDIAGraphicsEnabler" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
172 | }␊ |
173 | fi␊ |
174 | # -␊ |
175 | if [ -e ${1%/*}/i386/modules/Resolution.dylib ]; then␊ |
176 | {␊ |
177 | mkdir -p ${1}/AutoReso/Root␊ |
178 | ditto --noextattr --noqtn ${1%/*}/i386/modules/Resolution.dylib ${1}/AutoReso/Root␊ |
179 | echo "␉[BUILD] Resolution "␊ |
180 | buildpackage "${1}/AutoReso" "/Extra/modules" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
181 | }␊ |
182 | fi␊ |
183 | # -␊ |
184 | if [ -e ${1%/*}/i386/modules/uClibcxx.dylib ]; then␊ |
185 | {␊ |
186 | mkdir -p ${1}/uClibc/Root␊ |
187 | ditto --noextattr --noqtn ${1%/*}/i386/modules/uClibcxx.dylib ${1}/uClibc/Root␊ |
188 | ditto --noextattr --noqtn ${1%/*}/i386/modules/klibc.dylib ${1}/uClibc/Root␊ |
189 | echo "␉[BUILD] uClibc++ "␊ |
190 | buildpackage "${1}/uClibc" "/Extra/modules" "" "start_selected=\"true\"" >/dev/null 2>&1␊ |
191 | }␊ |
192 | fi␊ |
193 | ((xmlindent--))␊ |
194 | outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
195 | }␊ |
196 | else␊ |
197 | {␊ |
198 | echo " -= no modules to include =-"␊ |
199 | }␊ |
200 | fi␊ |
201 | ␉# End build Modules packages␊ |
202 | ((xmlindent--))␊ |
203 | outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
204 | # End build Chameleon package␊ |
205 | ␊ |
206 | # build Extras package␊ |
207 | ␉echo "================= Extras ================="␊ |
208 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Extras\">"␊ |
209 | ␉choices[$((choicescount++))]="<choice\n\tid=\"Extras\"\n\ttitle=\"Extras_title\"\n\tdescription=\"Extras_description\"\n>\n</choice>\n"␊ |
210 | ␉((xmlindent++))␊ |
211 | ␉packagesidentity="org.chameleon.extras"␊ |
212 | ␊ |
213 | ␉# build utility package␊ |
214 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Utility\">"␊ |
215 | ␉␉choices[$((choicescount++))]="<choice\n\tid=\"Utility\"\n\ttitle=\"Utility_title\"\n\tdescription=\"Utility_description\"\n>\n</choice>\n"␊ |
216 | ␉␉((xmlindent++))␊ |
217 | ␉␉packagesidentity="org.chameleon.utilities"␊ |
218 | ␊ |
219 | ␉␉# build package for Chameleon PrefPanel␊ |
220 | ␉␉␉mkdir -p "${1}/PrefPanel/Root"␊ |
221 | ␉␉␉ditto --noextattr --noqtn "${pkgroot}/Configuration/PrefPanel/Chameleon.prefPane" "${1}/PrefPanel/Root"␊ |
222 | ␉␉␉echo "␉[BUILD] Chameleon Preference Panel "␊ |
223 | ␉␉␉buildpackage "${1}/PrefPanel" "/Library/PreferencePanes/Chameleon.prefPane" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
224 | ␉␉# End build package for Chameleon PrefPanel␊ |
225 | ␉␉␊ |
226 | ␉␉# build package for SMBIOSDefault␊ |
227 | ␉␉␉mkdir -p "${1}/SMBIOSDefault/Root"␊ |
228 | ␉␉␉ditto --noextattr --noqtn "${pkgroot}/Configuration/SMBIOSDefault/smbios.plist" "${1}/SMBIOSDefault/Root"␊ |
229 | ␉␉␉echo "␉[BUILD] SMBIOSDefault "␊ |
230 | ␉␉␉buildpackage "${1}/SMBIOSDefault" "/Extra/Example" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
231 | ␉␉# End build package for SMBIOSDefault␊ |
232 | ␉␉␊ |
233 | ␉␉# build package for Documentation␊ |
234 | ␉␉␉mkdir -p "${1}/Documentation/Root"␊ |
235 | ␉␉␉cp -f ${pkgroot}/../doc/BootHelp.txt ${1}/Documentation/Root␊ |
236 | ␉␉␉cp -f ${pkgroot}/../doc/README ${1}/Documentation/Root␊ |
237 | ␉␉␉cp -f ${pkgroot}/../doc/Users_Guide0.5.pdf ${1}/Documentation/Root␊ |
238 | ␉␉␉echo "␉[BUILD] Documentation "␊ |
239 | ␉␉␉buildpackage "${1}/Documentation" "/Library/Documentation/Chameleon2" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
240 | ␉␉# End build package for Documentation␊ |
241 | ␊ |
242 | ␉␉((xmlindent--))␊ |
243 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
244 | ␉# End utility package␊ |
245 | ␉␉␊ |
246 | ␉# build options packages␊ |
247 | ␉echo "================= Options ================="␊ |
248 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"␊ |
249 | ␉␉choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"␊ |
250 | ␉␉((xmlindent++))␊ |
251 | ␊ |
252 | ␉␉# build base options packages␊ |
253 | ␉␉packagesidentity="org.chameleon.options"␊ |
254 | ␉␉␊ |
255 | ␉␉options=($( find "${pkgroot}/Scripts/BaseOptions" -type d -depth 1 -not -name '.svn' ))␊ |
256 | ␉␉for (( i = 0 ; i < ${#options[@]} ; i++ )) ␊ |
257 | ␉␉do␊ |
258 | ␉␉␉mkdir -p "${1}/${options[$i]##*/}/Root"␊ |
259 | ␉␉␉mkdir -p "${1}/${options[$i]##*/}/Scripts"␊ |
260 | ␉␉␉ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall"␊ |
261 | ␉␉␉echo "␉[BUILD] ${options[$i]##*/} "␊ |
262 | ␉␉␉buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
263 | ␉␉done␊ |
264 | ␉␉# End build base options packages␊ |
265 | ␊ |
266 | ␉␉# build resolution packages␊ |
267 | ␉␉␉echo "================= Res. Options ================="␊ |
268 | ␉␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Resolution\">"␊ |
269 | ␉␉␉choices[$((choicescount++))]="<choice\n\tid=\"Resolution\"\n\ttitle=\"Resolution_title\"\n\tdescription=\"Resolution_description\"\n>\n</choice>\n"␊ |
270 | ␉␉␉((xmlindent++))␊ |
271 | ␉␉␉packagesidentity="org.chameleon.options.resolution"␊ |
272 | ␉␉␉resolutions=($( find "${pkgroot}/Scripts/Resolutions" -type d -depth 1 -not -name '.svn' ))␊ |
273 | ␉␉␉for (( i = 0 ; i < ${#resolutions[@]} ; i++ )) ␊ |
274 | ␉␉␉do␊ |
275 | ␉␉␉␉mkdir -p "${1}/${resolutions[$i]##*/}/Root/"␊ |
276 | ␉␉␉␉mkdir -p "${1}/${resolutions[$i]##*/}/Scripts/"␊ |
277 | ␉␉␉␉ditto --noextattr --noqtn "${resolutions[$i]}/postinstall" "${1}/${resolutions[$i]##*/}/Scripts/postinstall"␊ |
278 | ␉␉␉␉echo "␉[BUILD] ${resolutions[$i]##*/} "␊ |
279 | ␉␉␉␉buildpackage "${1}/${resolutions[$i]##*/}" "/tmpcham" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
280 | ␉␉␉done␊ |
281 | ␊ |
282 | ␉␉␉((xmlindent--))␊ |
283 | ␉␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
284 | ␉␉# End build resolution packages␊ |
285 | ␉␊ |
286 | ␉␉# build Advanced packages␊ |
287 | ␉␉␉echo "================= Adv. Options ================="␊ |
288 | ␉␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Advanced\">"␊ |
289 | ␉␉␉choices[$((choicescount++))]="<choice\n\tid=\"Advanced\"\n\ttitle=\"Advanced_title\"\n\tdescription=\"Advanced_description\"\n>\n</choice>\n"␊ |
290 | ␉␉␉((xmlindent++))␊ |
291 | ␊ |
292 | ␉␉␉packagesidentity="org.chameleon.options.advanced"␊ |
293 | ␉␉␉optionsadv=($( find "${pkgroot}/Scripts/Advanced" -type d -depth 1 -not -name '.svn' ))␊ |
294 | ␉␉␉for (( i = 0 ; i < ${#optionsadv[@]} ; i++ )) ␊ |
295 | ␉␉␉do␊ |
296 | ␉␉␉␉mkdir -p "${1}/${optionsadv[$i]##*/}/Root"␊ |
297 | ␉␉␉␉mkdir -p "${1}/${optionsadv[$i]##*/}/Scripts"␊ |
298 | ␉␉␉␉ditto --noextattr --noqtn "${optionsadv[$i]}/postinstall" "${1}/${optionsadv[$i]##*/}/Scripts/postinstall"␊ |
299 | ␉␉␉␉echo "␉[BUILD] ${optionsadv[$i]##*/} "␊ |
300 | ␉␉␉␉buildpackage "${1}/${optionsadv[$i]##*/}" "/" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
301 | ␉␉␉done␊ |
302 | ␉␉␊ |
303 | ␉␉␉((xmlindent--))␊ |
304 | ␉␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
305 | ␉␉# End build Advanced packages␊ |
306 | ␊ |
307 | ␉␉((xmlindent--))␊ |
308 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
309 | ␊ |
310 | ␉# End build options packages␊ |
311 | ␉␊ |
312 | ␉# build theme packages␊ |
313 | ␉␉echo "================= Themes ================="␊ |
314 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"␊ |
315 | ␉␉choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"␊ |
316 | ␉␉((xmlindent++))␊ |
317 | ␉␉packagesidentity="org.chameleon.themes"␊ |
318 | ␉␉artwork="${1%/*}"␊ |
319 | ␉␉themes=($( find "${artwork%/*}/artwork/themes" -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}/${themes[$i]##*/}/Root/${theme}"␊ |
325 | # #### Comment out thx meklort␊ |
326 | # ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}" ␊ |
327 | # ####␊ |
328 | find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+␊ |
329 | ␉␉␉find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+␊ |
330 | ␉␉␉echo "␉[BUILD] ${themes[$i]##*/} "␊ |
331 | ␉␉␉buildpackage "${1}/${theme}" "/Extra/Themes" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
332 | ␉␉␉rm -R -f "${1}/${i##*/}"␊ |
333 | ␉␉done␊ |
334 | ␊ |
335 | ␉␉((xmlindent--))␊ |
336 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
337 | ␉# End build theme packages␊ |
338 | ␊ |
339 | ␉((xmlindent--))␊ |
340 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
341 | # End build Extras package␊ |
342 | ␊ |
343 | # build post install package␊ |
344 | ␉echo "================= Post ================="␊ |
345 | ␉mkdir -p ${1}/Post/Root␊ |
346 | ␉mkdir -p ${1}/Post/Scripts␊ |
347 | ␉cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts␊ |
348 | ␉echo "␉[BUILD] Post "␊ |
349 | ␉buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1␊ |
350 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"␊ |
351 | ␊ |
352 | # build meta package␊ |
353 | ␊ |
354 | ␉makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"␊ |
355 | ␊ |
356 | # clean up ␊ |
357 | ␊ |
358 | ␉rm -R -f "${1}"␊ |
359 | ␊ |
360 | }␊ |
361 | ␊ |
362 | fixperms ()␊ |
363 | {␊ |
364 | ␉# $1 path␊ |
365 | ␉find "${1}" -type f -exec chmod 644 {} \;␊ |
366 | ␉find "${1}" -type d -exec chmod 755 {} \;␊ |
367 | ␉chown -R 0:0 "${1}"␊ |
368 | }␊ |
369 | ␊ |
370 | buildpackage ()␊ |
371 | {␊ |
372 | # $1 Path to package to build containing Root and or Scripts␊ |
373 | # $2 Install Location␊ |
374 | # $3 Size␊ |
375 | # $4 Options␊ |
376 | ␊ |
377 | if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then␊ |
378 | ␊ |
379 | ␉local packagename="${1##*/}"␊ |
380 | ␉local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )␊ |
381 | ␉find "${1}" -name '.DS_Store' -delete␊ |
382 | ␉local filecount=$( find "${1}/Root" | wc -l )␊ |
383 | ␉if [ "${3}" ]; then␊ |
384 | ␉␉local installedsize="${3}"␊ |
385 | ␉else␊ |
386 | ␉␉local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )␊ |
387 | ␉fi␊ |
388 | ␉local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "␊ |
389 | ␊ |
390 | ␉#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "␉␉␊ |
391 | ␊ |
392 | ␉header+="identifier=\"${identifier}\" "␊ |
393 | ␉header+="version=\"${version}\" "␊ |
394 | ␊ |
395 | ␉[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "␊ |
396 | ␊ |
397 | ␉header+="auth=\"root\">\n"␊ |
398 | ␉header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"␊ |
399 | ␉rm -R -f "${1}/Temp"␊ |
400 | ␊ |
401 | ␉[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"␊ |
402 | ␉[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"␊ |
403 | ␊ |
404 | ␉if [ -d "${1}/Scripts" ]; then ␊ |
405 | ␉␉header+="\t<scripts>\n"␊ |
406 | ␉␉for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )␊ |
407 | ␉␉do␊ |
408 | ␉␉␉header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"␊ |
409 | ␉␉done␊ |
410 | ␉␉header+="\t</scripts>\n"␊ |
411 | ␉␉chown -R 0:0 "${1}/Scripts"␊ |
412 | ␉␉pushd "${1}/Scripts" >/dev/null␊ |
413 | ␉␉find . -print | cpio -o -z -H cpio > "../Temp/Scripts"␊ |
414 | ␉␉popd >/dev/null␊ |
415 | ␉fi␊ |
416 | ␊ |
417 | ␉header+="</pkg-info>"␊ |
418 | ␉echo -e "${header}" > "${1}/Temp/PackageInfo"␊ |
419 | ␉pushd "${1}/Root" >/dev/null␊ |
420 | ␉find . -print | cpio -o -z -H cpio > "../Temp/Payload"␊ |
421 | ␉popd >/dev/null␊ |
422 | ␉pushd "${1}/Temp" >/dev/null␊ |
423 | ␊ |
424 | ␉xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .␊ |
425 | ␊ |
426 | ␉popd >/dev/null␊ |
427 | ␊ |
428 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"␊ |
429 | ␊ |
430 | ␉if [ "${4}" ]; then␊ |
431 | ␉␉local choiceoptions="${indent[$xmlindent]}${4}\n"␉␊ |
432 | ␉fi␊ |
433 | ␉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"␊ |
434 | ␊ |
435 | ␉rm -R -f "${1}"␊ |
436 | fi␊ |
437 | }␊ |
438 | ␊ |
439 | makedistribution ()␊ |
440 | {␊ |
441 | ␉rm -f "${1%/*}/${packagename// /}"*.pkg␊ |
442 | ␊ |
443 | ␉find "${1}" -type f -name '*.pkg' -depth 1 | while read component␊ |
444 | ␉do␊ |
445 | ␉␉mkdir -p "${1}/${packagename}/${component##*/}"␊ |
446 | ␉␉pushd "${1}/${packagename}/${component##*/}" >/dev/null␊ |
447 | ␉␉xar -x -f "${1%}/${component##*/}"␊ |
448 | ␉␉popd >/dev/null␊ |
449 | ␉done␊ |
450 | ␊ |
451 | ␉ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"␊ |
452 | ␉ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"␊ |
453 | ␊ |
454 | ␉find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null␊ |
455 | ␊ |
456 | ␉for (( i=0; i < ${#outline[*]} ; i++));␊ |
457 | ␉␉do␊ |
458 | ␉␉␉echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"␊ |
459 | ␉␉done␊ |
460 | ␊ |
461 | ␉for (( i=0; i < ${#choices[*]} ; i++));␊ |
462 | ␉␉do␊ |
463 | ␉␉␉echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"␊ |
464 | ␉␉done␊ |
465 | ␊ |
466 | ␉echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"␊ |
467 | ␊ |
468 | ␉perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
469 | ␉perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
470 | ␊ |
471 | # Adding Developer and credits␊ |
472 | ␉perl -i -p -e "s/%DEVELOP%/${develop}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
473 | ␉perl -i -p -e "s/%CREDITS%/${credits}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
474 | ␉perl -i -p -e "s/%PKGDEV%/${pkgdev}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
475 | ␊ |
476 | ␉stage=${stage/RC/Release Candidate }␊ |
477 | ␉stage=${stage/FINAL/2.0 Final}␊ |
478 | ␉perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
479 | ␊ |
480 | ␉find "${1}/${packagename}" -name '.DS_Store' -delete␊ |
481 | ␉pushd "${1}/${packagename}" >/dev/null␊ |
482 | ␉xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .␊ |
483 | ␉popd >/dev/null␊ |
484 | ␊ |
485 | # Here is the place for assign a Icon to the pkg␊ |
486 | # command use to generate the file:␊ |
487 | # ditto -c -k --sequesterRsrc --keepParent Icon.icns Icon.zip␊ |
488 | # ----␊ |
489 | # ditto -xk "${pkgroot}/Icons/pkg.zip" "${pkgroot}/Icons/"␊ |
490 | # DeRez -only icns "${pkgroot}/Icons/Icons/pkg.icns" > tempicns.rsrc␊ |
491 | # Rez -append tempicns.rsrc -o "${1%/*}/${packagename// /}-${version}-r${revision}.pkg"␊ |
492 | # SetFile -a C "${1%/*}/${packagename// /}-${version}-r${revision}.pkg"␊ |
493 | # rm -f tempicns.rsrc␊ |
494 | # rm -rf "${pkgroot}/Icons/Icons"␊ |
495 | # End␊ |
496 | ␊ |
497 | ␉md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" | awk {'print $4'} )␊ |
498 | ␉echo "MD5 (${packagename// /}-${version}-r${revision}.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}.pkg.md5"␊ |
499 | ␉echo ""␉␊ |
500 | ␊ |
501 | ␉echo -e $COL_BLACK"␉--------------------------"$COL_RESET␊ |
502 | ␉echo -e $COL_BLACK"␉Building process complete!"$COL_RESET␊ |
503 | ␉echo -e $COL_BLACK"␉--------------------------"$COL_RESET␊ |
504 | ␉echo ""␉␊ |
505 | ␉echo -e $COL_BLACK"␉Build info."␊ |
506 | ␉echo -e $COL_BLACK"␉==========="␊ |
507 | ␉echo -e $COL_BLUE"␉Package name:␉"$COL_BLACK"$packagename-${version}-r$revision.pkg"$COL_RESET␊ |
508 | ␉echo -e $COL_BLUE"␉MD5:␉␉"$COL_BLACK"$md5"$COL_RESET␊ |
509 | ␉echo -e $COL_BLUE"␉Version:␉"$COL_BLACK"$version"$COL_RESET␊ |
510 | ␉echo -e $COL_BLUE"␉Stage:␉␉"$COL_BLACK"$stage"$COL_RESET␊ |
511 | ␉echo -e $COL_BLUE"␉Date/Time:␉"$COL_BLACK"$builddate"$COL_RESET␊ |
512 | ␉echo ""␊ |
513 | ␊ |
514 | }␊ |
515 | ␊ |
516 | main "${1}" "${2}" "${3}" "${4}" "${5}"␊ |
517 | ␊ |
518 | |