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