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