Root/
| |
---|---|
Source at commit 330 created 12 years 8 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" #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 Slim 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"␊ |
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 | ␉fixperms "${1}/Core/Root/"␊ |
75 | ␉cp -f ${1%/*}/i386/fdisk440 ${1}/Core/Root/usr/sbin␊ |
76 | ␉cp -f ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/sbin␊ |
77 | ␉local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )␊ |
78 | ␉echo "␉[BUILD] i386 "␊ |
79 | ␉buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1␊ |
80 | ␊ |
81 | # build Chameleon package␊ |
82 | ␉echo "================= Chameleon ================="␊ |
83 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"␊ |
84 | ␉choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"␊ |
85 | ␊ |
86 | ␉# build standard package ␊ |
87 | ␉␉mkdir -p ${1}/Standard/Root␊ |
88 | ␉␉mkdir -p ${1}/Standard/Scripts/Tools␊ |
89 | ␉␉cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts␊ |
90 | ␉␉# ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile␊ |
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/Tools␊ |
98 | ␉␉cp -f ${pkgroot}/Scripts/EFI/* ${1}/EFI/Scripts␊ |
99 | ␉␉# ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Tools/SetFile␊ |
100 | ␉␉echo "␉[BUILD] EFI "␊ |
101 | ␉␉buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['noboot'])\"" >/dev/null 2>&1␊ |
102 | ␉# End build efi package␊ |
103 | ␊ |
104 | ␉# build reset choice package ␊ |
105 | ␉␉mkdir -p ${1}/noboot/Root␊ |
106 | ␉␉echo "␉[BUILD] Reset choice "␊ |
107 | ␉␉buildpackage "${1}/noboot" "/tmpcham" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['EFI'])\"" >/dev/null 2>&1␊ |
108 | ␉# End build reset choice package ␊ |
109 | ␊ |
110 | ␉# build Modules package␊ |
111 | ␉␉echo "================= Modules ================="␊ |
112 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Module\">"␊ |
113 | ␉␉choices[$((choicescount++))]="<choice\n\tid=\"Module\"\n\ttitle=\"Module_title\"\n\tdescription=\"Module_description\"\n>\n</choice>\n"␊ |
114 | ␉␉((xmlindent++))␊ |
115 | ␉␉packagesidentity="org.chameleon.module"␊ |
116 | ␉␉modules=($( find "${pkgroot}/Scripts/Modules" -type d -depth 1 -not -name '.svn' ))␊ |
117 | ␉␉for (( i = 0 ; i < ${#modules[@]} ; i++ )) ␊ |
118 | ␉␉do␊ |
119 | ␉␉␉mkdir -p "${1}/${modules[$i]##*/}/Root"␊ |
120 | ␉␉␉mkdir -p "${1}/${modules[$i]##*/}/Scripts"␊ |
121 | ␉␉␉ditto --noextattr --noqtn "${modules[$i]}/postinstall" "${1}/${modules[$i]##*/}/Scripts/postinstall"␊ |
122 | ␉␉␉echo "␉[BUILD] ${modules[$i]##*/} "␊ |
123 | ␉␉␉buildpackage "${1}/${modules[$i]##*/}" "/" "" "start_selected=\"false\"" >/dev/null 2>&1␊ |
124 | ␉␉␉rm -R -f "${1}/${i##*/}"␊ |
125 | ␉␉done␊ |
126 | ␉␉((xmlindent--))␊ |
127 | ␉␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
128 | ␉# End build Modules packages␊ |
129 | ␊ |
130 | ␉((xmlindent--))␊ |
131 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
132 | # End build Chameleon package␊ |
133 | ␊ |
134 | # build post install package␊ |
135 | ␉echo "================= Post ================="␊ |
136 | ␉mkdir -p ${1}/Post/Root␊ |
137 | ␉mkdir -p ${1}/Post/Scripts␊ |
138 | ␉cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts␊ |
139 | ␉echo "␉[BUILD] Post "␊ |
140 | ␉buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1␊ |
141 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"␊ |
142 | ␊ |
143 | # build meta package␊ |
144 | ␉makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"␊ |
145 | ␊ |
146 | # clean up ␊ |
147 | ␉rm -R -f "${1}"␊ |
148 | ␊ |
149 | }␊ |
150 | ␊ |
151 | fixperms ()␊ |
152 | {␊ |
153 | ␉# $1 path␊ |
154 | ␉find "${1}" -type f -exec chmod 644 {} \;␊ |
155 | ␉find "${1}" -type d -exec chmod 755 {} \;␊ |
156 | ␉chown -R 0:0 "${1}"␊ |
157 | }␊ |
158 | ␊ |
159 | buildpackage ()␊ |
160 | {␊ |
161 | # $1 Path to package to build containing Root and or Scripts␊ |
162 | # $2 Install Location␊ |
163 | # $3 Size␊ |
164 | # $4 Options␊ |
165 | ␊ |
166 | if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then␊ |
167 | ␊ |
168 | ␉local packagename="${1##*/}"␊ |
169 | ␉local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )␊ |
170 | ␉find "${1}" -name '.DS_Store' -delete␊ |
171 | ␉local filecount=$( find "${1}/Root" | wc -l )␊ |
172 | ␉if [ "${3}" ]; then␊ |
173 | ␉␉local installedsize="${3}"␊ |
174 | ␉else␊ |
175 | ␉␉local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )␊ |
176 | ␉fi␊ |
177 | ␉local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "␊ |
178 | ␊ |
179 | ␉#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "␉␉␊ |
180 | ␊ |
181 | ␉header+="identifier=\"${identifier}\" "␊ |
182 | ␉header+="version=\"${version}\" "␊ |
183 | ␊ |
184 | ␉[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "␊ |
185 | ␊ |
186 | ␉header+="auth=\"root\">\n"␊ |
187 | ␉header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"␊ |
188 | ␉rm -R -f "${1}/Temp"␊ |
189 | ␊ |
190 | ␉[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"␊ |
191 | ␉[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"␊ |
192 | ␊ |
193 | ␉if [ -d "${1}/Scripts" ]; then ␊ |
194 | ␉␉header+="\t<scripts>\n"␊ |
195 | ␉␉for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )␊ |
196 | ␉␉do␊ |
197 | ␉␉␉header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"␊ |
198 | ␉␉done␊ |
199 | ␉␉header+="\t</scripts>\n"␊ |
200 | ␉␉chown -R 0:0 "${1}/Scripts"␊ |
201 | ␉␉pushd "${1}/Scripts" >/dev/null␊ |
202 | ␉␉find . -print | cpio -o -z -H cpio > "../Temp/Scripts"␊ |
203 | ␉␉popd >/dev/null␊ |
204 | ␉fi␊ |
205 | ␊ |
206 | ␉header+="</pkg-info>"␊ |
207 | ␉echo -e "${header}" > "${1}/Temp/PackageInfo"␊ |
208 | ␉pushd "${1}/Root" >/dev/null␊ |
209 | ␉find . -print | cpio -o -z -H cpio > "../Temp/Payload"␊ |
210 | ␉popd >/dev/null␊ |
211 | ␉pushd "${1}/Temp" >/dev/null␊ |
212 | ␊ |
213 | ␉xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .␊ |
214 | ␊ |
215 | ␉popd >/dev/null␊ |
216 | ␊ |
217 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"␊ |
218 | ␊ |
219 | ␉if [ "${4}" ]; then␊ |
220 | ␉␉local choiceoptions="${indent[$xmlindent]}${4}\n"␉␊ |
221 | ␉fi␊ |
222 | ␉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"␊ |
223 | ␊ |
224 | ␉rm -R -f "${1}"␊ |
225 | fi␊ |
226 | }␊ |
227 | ␊ |
228 | makedistribution ()␊ |
229 | {␊ |
230 | ␉rm -f "${1%/*}/${packagename// /}"*.pkg␊ |
231 | ␊ |
232 | ␉find "${1}" -type f -name '*.pkg' -depth 1 | while read component␊ |
233 | ␉do␊ |
234 | ␉␉mkdir -p "${1}/${packagename}/${component##*/}"␊ |
235 | ␉␉pushd "${1}/${packagename}/${component##*/}" >/dev/null␊ |
236 | ␉␉xar -x -f "${1%}/${component##*/}"␊ |
237 | ␉␉popd >/dev/null␊ |
238 | ␉done␊ |
239 | ␊ |
240 | ␉ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"␊ |
241 | ␉ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"␊ |
242 | ␊ |
243 | ␉find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null␊ |
244 | ␊ |
245 | ␉for (( i=0; i < ${#outline[*]} ; i++));␊ |
246 | ␉␉do␊ |
247 | ␉␉␉echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"␊ |
248 | ␉␉done␊ |
249 | ␊ |
250 | ␉for (( i=0; i < ${#choices[*]} ; i++));␊ |
251 | ␉␉do␊ |
252 | ␉␉␉echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"␊ |
253 | ␉␉done␊ |
254 | ␊ |
255 | ␉echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"␊ |
256 | ␊ |
257 | ␉perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
258 | ␉perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
259 | ␊ |
260 | # Adding Developer and credits␊ |
261 | perl -i -p -e "s/%DEVELOP%/${develop}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
262 | perl -i -p -e "s/%CREDITS%/${credits}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
263 | #␊ |
264 | ␊ |
265 | ␉stage=${stage/RC/Release Candidate }␊ |
266 | ␉stage=${stage/FINAL/2.0 Final}␊ |
267 | ␉perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
268 | ␊ |
269 | ␉find "${1}/${packagename}" -name '.DS_Store' -delete␊ |
270 | ␉pushd "${1}/${packagename}" >/dev/null␊ |
271 | ␉xar -c -f "${1%/*}/$packagename.pkg" --compression none .␊ |
272 | ␉popd >/dev/null␊ |
273 | ␊ |
274 | # Here is the place for assign a Icon to the pkg␊ |
275 | ditto -xk "${pkgroot}/Icons/pkg.zip" "${pkgroot}/Icons/"␊ |
276 | DeRez -only icns "${pkgroot}/Icons/Icons/pkg.icns" > tempicns.rsrc␊ |
277 | Rez -append tempicns.rsrc -o "${1%/*}/$packagename.pkg"␊ |
278 | SetFile -a C "${1%/*}/$packagename.pkg"␊ |
279 | rm -f tempicns.rsrc␊ |
280 | rm -rf "${pkgroot}/Icons/Icons"␊ |
281 | # End␊ |
282 | ␊ |
283 | }␊ |
284 | ␊ |
285 | main "${1}" "${2}" "${3}" "${4}" "${5}"␊ |
286 | ␊ |
287 |