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