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