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