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