Chameleon Applications

Chameleon Applications Svn Source Tree

Root/branches/iFabio/Chameleon/package/slimpkg.sh

  • Property svn:executable set to *
Source at commit 334 created 12 years 9 months ago.
By ifabio, Small update and typo fix.
1#!/bin/bash
2
3# $1 Path to store built package
4
5packagesidentity="org.chameleon"
6
7packagename="Chameleon"
8
9pkgroot="${0%/*}"
10
11COL_BLACK="\x1b[30;01m"
12COL_RED="\x1b[31;01m"
13COL_GREEN="\x1b[32;01m"
14COL_YELLOW="\x1b[33;01m"
15COL_MAGENTA="\x1b[35;01m"
16COL_CYAN="\x1b[36;01m"
17COL_WHITE="\x1b[37;01m"
18COL_BLUE="\x1b[34;01m"
19COL_RESET="\x1b[39;49;00m"
20
21#version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
22version=$( cat version )
23stage=${version##*-}
24revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )
25builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' )
26timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )
27
28# =================
29
30develop=" Crazor, Dense, fassl, fxtentacle, iNDi, JrCs, Kabyl, kaitek, mackerintel, mercurysquad, munky, Slice, meklort, mozodojo, rekursor, Turbo, cparm, valv & zef "
31
32credits=" andyvand, asereBLN, Azimut, bumby, cosmo1t, dfe, Galaxy, kalyway, Krazubu, MasterChief, netkas, sckevyn, smith@@, THeKiNG, blackosx, .: ErmaC :., scrax, DutchHockeyPro & Andy"
33
34# =================
35
36distributioncount=0
37xmlindent=0
38
39indent[0]="\t"
40indent[1]="\t\t"
41indent[2]="\t\t\t"
42indent[3]="\t\t\t\t"
43
44main ()
45{
46
47# clean up the destination path
48
49rm -R -f "${1}"
50echo ""
51echo -e $COL_BLACK"---------------------"$COL_RESET
52echo -e $COL_BLACK"Building Slim Package"$COL_RESET
53echo -e $COL_BLACK"---------------------"$COL_RESET
54echo ""
55
56outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"
57
58# build core package
59echo "================= Core ================="
60((xmlindent++))
61packagesidentity="org.chameleon.core"
62mkdir -p ${1}/Core/Root/usr/sbin
63mkdir -p ${1}/Core/Root/usr/local/bin
64mkdir -p ${1}/Core/Root/usr/standalone/i386
65# if [ "$(ls -A "${1%/*}/i386/modules")" ]; then
66# echo "Modules found."
67# mkdir -p ${1}/Core/Root/usr/standalone/i386/modules
68# cp -R ${1%/*}/i386/modules ${1}/Core/Root/usr/standalone/i386
69# else
70# echo "No found modules into dir module"
71# fi
72cp -f ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386
73cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386
74cp -f ${1%/*}/i386/boot0md ${1}/Core/Root/usr/standalone/i386
75cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386
76cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386
77cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386
78cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386
79fixperms "${1}/Core/Root/"
80cp -f ${1%/*}/i386/fdisk440 ${1}/Core/Root/usr/sbin
81cp -f ${1%/*}/i386/bdmesg ${1}/Core/Root/usr/sbin
82local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )
83echo "[BUILD] i386 "
84buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
85
86# build Chameleon package
87echo "================= Chameleon ================="
88outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Chameleon\">"
89choices[$((choicescount++))]="<choice\n\tid=\"Chameleon\"\n\ttitle=\"Chameleon_title\"\n\tdescription=\"Chameleon_description\"\n>\n</choice>\n"
90
91# build standard package
92mkdir -p ${1}/Standard/Root
93mkdir -p ${1}/Standard/Scripts/Tools
94cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts
95# ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile
96echo "[BUILD] Standard "
97buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EFI']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
98# End build standard package
99
100# build efi package
101mkdir -p ${1}/EFI/Root
102mkdir -p ${1}/EFI/Scripts/Tools
103cp -f ${pkgroot}/Scripts/EFI/* ${1}/EFI/Scripts
104# ditto --arch i386 `which SetFile` ${1}/EFI/Scripts/Tools/SetFile
105echo "[BUILD] EFI "
106buildpackage "${1}/EFI" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['noboot'])\"" >/dev/null 2>&1
107# End build efi package
108
109# build reset choice package
110mkdir -p ${1}/noboot/Root
111echo "[BUILD] Reset choice "
112buildpackage "${1}/noboot" "/tmpcham" "" "start_visible=\"true\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) &amp;&amp; exclusive(choices['EFI'])\"" >/dev/null 2>&1
113# End build reset choice package
114
115# build Modules package
116 echo "================= Modules ================="
117 ###############################
118 # AMDGraphicsEnabler.dylib #
119 # ATiGraphicsEnabler.dylib #
120 # IntelGraphicsEnabler.dylib #
121 # klibc.dylib #
122 # NVIDIAGraphicsEnabler.dylib #
123 # Resolution.dylib #
124 # uClibcxx.dylib #
125 ###############################
126 if [ "$(ls -A "${1%/*}/i386/modules")" ]; then
127 outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Module\">"
128 choices[$((choicescount++))]="<choice\n\tid=\"Module\"\n\ttitle=\"Module_title\"\n\tdescription=\"Module_description\"\n>\n</choice>\n"
129 ((xmlindent++))
130 packagesidentity="org.chameleon.module"
131 modules=($( find "${pkgroot}/Scripts/Modules" -type d -depth 1 -not -name '.svn' ))
132 for (( i = 0 ; i < ${#modules[@]} ; i++ ))
133 do
134 mkdir -p "${1}/${modules[$i]##*/}/Root"
135 mkdir -p "${1}/${modules[$i]##*/}/Scripts"
136 ditto --noextattr --noqtn "${modules[$i]}/postinstall" "${1}/${modules[$i]##*/}/Scripts/postinstall"
137 echo "[BUILD] ${modules[$i]##*/} "
138 buildpackage "${1}/${modules[$i]##*/}" "/" "" "start_selected=\"false\"" >/dev/null 2>&1
139 rm -R -f "${1}/${i##*/}"
140 done
141 ((xmlindent--))
142 outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
143 else
144 echo " -= no modules to include =-"
145 fi
146# End build Modules packages
147
148((xmlindent--))
149outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"
150# End build Chameleon package
151
152# build post install package
153echo "================= Post ================="
154mkdir -p ${1}/Post/Root
155mkdir -p ${1}/Post/Scripts
156cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts
157echo "[BUILD] Post "
158buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\"" >/dev/null 2>&1
159outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"
160
161# build meta package
162
163makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"
164
165# clean up
166
167rm -R -f "${1}"
168
169}
170
171fixperms ()
172{
173# $1 path
174find "${1}" -type f -exec chmod 644 {} \;
175find "${1}" -type d -exec chmod 755 {} \;
176chown -R 0:0 "${1}"
177}
178
179buildpackage ()
180{
181# $1 Path to package to build containing Root and or Scripts
182# $2 Install Location
183# $3 Size
184# $4 Options
185
186if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then
187
188local packagename="${1##*/}"
189local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )
190find "${1}" -name '.DS_Store' -delete
191local filecount=$( find "${1}/Root" | wc -l )
192if [ "${3}" ]; then
193local installedsize="${3}"
194else
195local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )
196fi
197local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "
198
199#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "
200
201header+="identifier=\"${identifier}\" "
202header+="version=\"${version}\" "
203
204[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "
205
206header+="auth=\"root\">\n"
207header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"
208rm -R -f "${1}/Temp"
209
210[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"
211[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"
212
213if [ -d "${1}/Scripts" ]; then
214header+="\t<scripts>\n"
215for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )
216do
217header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"
218done
219header+="\t</scripts>\n"
220chown -R 0:0 "${1}/Scripts"
221pushd "${1}/Scripts" >/dev/null
222find . -print | cpio -o -z -H cpio > "../Temp/Scripts"
223popd >/dev/null
224fi
225
226header+="</pkg-info>"
227echo -e "${header}" > "${1}/Temp/PackageInfo"
228pushd "${1}/Root" >/dev/null
229find . -print | cpio -o -z -H cpio > "../Temp/Payload"
230popd >/dev/null
231pushd "${1}/Temp" >/dev/null
232
233xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .
234
235popd >/dev/null
236
237outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"
238
239if [ "${4}" ]; then
240local choiceoptions="${indent[$xmlindent]}${4}\n"
241fi
242choices[$((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"
243
244rm -R -f "${1}"
245fi
246}
247
248makedistribution ()
249{
250rm -f "${1%/*}/${packagename// /}"*.pkg
251
252find "${1}" -type f -name '*.pkg' -depth 1 | while read component
253do
254mkdir -p "${1}/${packagename}/${component##*/}"
255pushd "${1}/${packagename}/${component##*/}" >/dev/null
256xar -x -f "${1%}/${component##*/}"
257popd >/dev/null
258done
259
260ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"
261ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"
262
263find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null
264
265for (( i=0; i < ${#outline[*]} ; i++));
266do
267echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"
268done
269
270for (( i=0; i < ${#choices[*]} ; i++));
271do
272echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"
273done
274
275echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"
276
277perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f`
278perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f`
279
280# Adding Developer and credits
281perl -i -p -e "s/%DEVELOP%/${develop}/g" `find "${1}/${packagename}/Resources" -type f`
282perl -i -p -e "s/%CREDITS%/${credits}/g" `find "${1}/${packagename}/Resources" -type f`
283#
284
285stage=${stage/RC/Release Candidate }
286stage=${stage/FINAL/2.0 Final}
287perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f`
288
289find "${1}/${packagename}" -name '.DS_Store' -delete
290pushd "${1}/${packagename}" >/dev/null
291xar -c -f "${1%/*}/$packagename.pkg" --compression none .
292popd >/dev/null
293
294# Here is the place for assign a Icon to the pkg
295ditto -xk "${pkgroot}/Icons/pkg.zip" "${pkgroot}/Icons/"
296DeRez -only icns "${pkgroot}/Icons/Icons/pkg.icns" > tempicns.rsrc
297Rez -append tempicns.rsrc -o "${1%/*}/$packagename.pkg"
298SetFile -a C "${1%/*}/$packagename.pkg"
299rm -f tempicns.rsrc
300rm -rf "${pkgroot}/Icons/Icons"
301# End
302
303}
304
305main "${1}" "${2}" "${3}" "${4}" "${5}"
306
307

Archive Download this file

Revision: 334