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