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