Chameleon Applications

Chameleon Applications Svn Source Tree

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

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

Archive Download this file

Revision: 330