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