Root/
| |
---|---|
Source at commit 1162 created 13 years 13 days ago. By mozodojo, Added new C-State _CST generation method using SystemIO registers instead of FixedHW. New feature is activating by use "CSTUsingSystemIO" key in org.chameleon.Boot.plist | |
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 | #version=$( grep I386BOOT_CHAMELEONVERSION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )␊ |
12 | version=$( cat version )␊ |
13 | stage=${version##*-}␊ |
14 | revision=$( grep I386BOOT_CHAMELEONREVISION sym/i386/vers.h | awk '{ print $3 }' | tr -d '\"' )␊ |
15 | builddate=$( grep I386BOOT_BUILDDATE sym/i386/vers.h | awk '{ print $3,$4 }' | tr -d '\"' )␊ |
16 | timestamp=$( date -j -f "%Y-%m-%d %H:%M:%S" "${builddate}" "+%s" )␊ |
17 | ␊ |
18 | distributioncount=0␊ |
19 | xmlindent=0␊ |
20 | ␊ |
21 | indent[0]="\t"␊ |
22 | indent[1]="\t\t"␊ |
23 | indent[2]="\t\t\t"␊ |
24 | indent[3]="\t\t\t\t"␊ |
25 | ␊ |
26 | main ()␊ |
27 | {␊ |
28 | ␊ |
29 | # clean up the destination path␊ |
30 | ␊ |
31 | ␉rm -R -f "${1}"␊ |
32 | ␉␊ |
33 | ␉echo "Building $packagename Install Package v${version%%-*} $stage r$revision $builddate"␊ |
34 | ␉␊ |
35 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}<choices-outline>"␊ |
36 | ␊ |
37 | # build core package␊ |
38 | ␊ |
39 | ␉mkdir -p ${1}/Core/Root/usr/sbin␊ |
40 | ␉mkdir -p ${1}/Core/Root/usr/local/bin␊ |
41 | ␉mkdir -p ${1}/Core/Root/usr/standalone/i386␊ |
42 | ␉cp -f ${1%/*}/i386/boot ${1}/Core/Root/usr/standalone/i386␊ |
43 | ␉cp -f ${1%/*}/i386/boot0 ${1}/Core/Root/usr/standalone/i386␊ |
44 | ␉cp -f ${1%/*}/i386/boot1f32 ${1}/Core/Root/usr/standalone/i386␊ |
45 | ␉cp -f ${1%/*}/i386/boot1h ${1}/Core/Root/usr/standalone/i386␊ |
46 | ␉cp -f ${1%/*}/i386/boot1he ${1}/Core/Root/usr/standalone/i386␊ |
47 | ␉cp -f ${1%/*}/i386/boot1hp ${1}/Core/Root/usr/standalone/i386␊ |
48 | ␉cp -f ${1%/*}/i386/cdboot ${1}/Core/Root/usr/standalone/i386␊ |
49 | ␉cp -f ${1%/*}/i386/chain0 ${1}/Core/Root/usr/standalone/i386␊ |
50 | ␉fixperms "${1}/Core/Root/"␊ |
51 | ␉cp -f ${pkgroot}/fdisk ${1}/Core/Root/usr/sbin␊ |
52 | ␉local coresize=$( du -hkc "${1}/Core/Root" | tail -n1 | awk {'print $1'} )␊ |
53 | ␉buildpackage "${1}/Core" "/" "0" "start_visible=\"false\" start_selected=\"true\""␊ |
54 | ␊ |
55 | # build standard package ␊ |
56 | ␊ |
57 | ␉mkdir -p ${1}/Standard/Root␊ |
58 | ␉mkdir -p ${1}/Standard/Scripts/Tools␊ |
59 | ␉cp -f ${pkgroot}/Scripts/Standard/* ${1}/Standard/Scripts␊ |
60 | ␉ditto --arch i386 `which SetFile` ${1}/Standard/Scripts/Tools/SetFile␊ |
61 | ␉buildpackage "${1}/Standard" "/" "${coresize}" "start_enabled=\"true\" start_selected=\"upgrade_allowed()\" selected=\"exclusive(choices['EnhancedHFS']) && exclusive(choices['EnhancedFAT'])\""␊ |
62 | ␊ |
63 | # build efi fat32 package ␊ |
64 | ␊ |
65 | ␉mkdir -p ${1}/EnhancedFAT/Root␊ |
66 | ␉mkdir -p ${1}/EnhancedFAT/Scripts/Tools␊ |
67 | ␉cp -f ${pkgroot}/Scripts/FAT/* ${1}/EnhancedFAT/Scripts␊ |
68 | ␉ditto --arch i386 `which SetFile` ${1}/EnhancedFAT/Scripts/Tools/SetFile␊ |
69 | ␉buildpackage "${1}/EnhancedFAT" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['EnhancedHFS'])\""␊ |
70 | ␊ |
71 | # build efi hfs package ␊ |
72 | ␊ |
73 | ␉mkdir -p ${1}/EnhancedHFS/Root␊ |
74 | ␉mkdir -p ${1}/EnhancedHFS/Scripts/Tools␊ |
75 | ␉cp -f ${pkgroot}/Scripts/HFS/* ${1}/EnhancedHFS/Scripts␊ |
76 | ␉ditto --arch i386 `which SetFile` ${1}/EnhancedHFS/Scripts/Tools/SetFile␊ |
77 | ␉buildpackage "${1}/EnhancedHFS" "/" "${coresize}" "start_visible=\"systemHasGPT()\" start_selected=\"false\" selected=\"exclusive(choices['Standard']) && exclusive(choices['EnhancedFAT'])\""␊ |
78 | ␊ |
79 | # build options packages␊ |
80 | ␊ |
81 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Options\">"␊ |
82 | ␉choices[$((choicescount++))]="<choice\n\tid=\"Options\"\n\ttitle=\"Options_title\"\n\tdescription=\"Options_description\"\n>\n</choice>\n"␊ |
83 | ␉((xmlindent++))␊ |
84 | ␉packagesidentity="org.chameleon"␊ |
85 | ␉options=($( find "${pkgroot}/Scripts/Options" -type d -depth 1 -not -name '.svn' ))␊ |
86 | ␉for (( i = 0 ; i < ${#options[@]} ; i++ )) ␊ |
87 | ␉do␊ |
88 | ␉␉mkdir -p "${1}/${options[$i]##*/}/Root"␊ |
89 | ␉␉mkdir -p "${1}/${options[$i]##*/}/Scripts"␊ |
90 | ␉␉␊ |
91 | ␉␉ditto --noextattr --noqtn "${options[$i]}/postinstall" "${1}/${options[$i]##*/}/Scripts/postinstall"␊ |
92 | ␉␉␊ |
93 | ␉␉buildpackage "${1}/${options[$i]##*/}" "/" "" "start_selected=\"false\""␊ |
94 | ␉done␊ |
95 | ␉((xmlindent--))␊ |
96 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
97 | ␊ |
98 | # build theme packages␊ |
99 | ␊ |
100 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Themes\">"␊ |
101 | ␉choices[$((choicescount++))]="<choice\n\tid=\"Themes\"\n\ttitle=\"Themes_title\"\n\tdescription=\"Themes_description\"\n>\n</choice>\n"␊ |
102 | ␉((xmlindent++))␊ |
103 | ␉packagesidentity="org.chameleon.theme"␊ |
104 | ␉artwork="${1%/*}"␊ |
105 | ␉themes=($( find "${artwork%/*}/artwork/themes" -type d -depth 1 -not -name '.svn' ))␊ |
106 | ␉for (( i = 0 ; i < ${#themes[@]} ; i++ )) ␊ |
107 | ␉do␊ |
108 | ␉␉theme=$( echo ${themes[$i]##*/} | awk 'BEGIN{OFS=FS=""}{$1=toupper($1);print}' )␊ |
109 | ␉␉mkdir -p "${1}/${theme}/Root/"␊ |
110 | ␉␉ditto --noextattr --noqtn "${themes[$i]}" "${1}/${themes[$i]##*/}/Root/${theme}"␊ |
111 | ␉␉find "${1}/${themes[$i]##*/}" -name '.DS_Store' -or -name '.svn' -exec rm -R {} \+␊ |
112 | ␉␉find "${1}/${themes[$i]##*/}" -type f -exec chmod 644 {} \+␊ |
113 | ␊ |
114 | ␉␉buildpackage "${1}/${theme}" "/.Chameleon/Extra/Themes" ""␊ |
115 | ␉␉rm -R -f "${1}/${i##*/}"␊ |
116 | ␉done␊ |
117 | ␊ |
118 | ␉((xmlindent--))␊ |
119 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
120 | ␊ |
121 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Extras\">"␊ |
122 | ␉choices[$((choicescount++))]="<choice\n\tid=\"Extras\"\n\ttitle=\"Extras_title\"\n\tdescription=\"Extras_description\"\n>\n</choice>\n"␊ |
123 | ␊ |
124 | ␉((xmlindent++))␊ |
125 | ␊ |
126 | # build kext packages ␊ |
127 | ␊ |
128 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"Kexts\">"␊ |
129 | ␉choices[$((choicescount++))]="<choice\n\tid=\"Kexts\"\n\ttitle=\"Kexts_title\"\n\tdescription=\"Kexts_description\"\n>\n</choice>\n"␊ |
130 | ␉((xmlindent++))␊ |
131 | ␉packagesidentity="org.chameleon"␊ |
132 | ␉kexts=($( find "${pkgroot}/Kexts" -type d -name '*.kext' -depth 1 ))␊ |
133 | ␉for (( i = 0 ; i < ${#kexts[@]} ; i++ )) ␊ |
134 | ␉do␊ |
135 | ␉␉filename="${kexts[$i]##*/}"␊ |
136 | ␉␉mkdir -p "${1}/${filename%.kext}/Root/"␊ |
137 | ␉␉ditto --noextattr --noqtn --arch i386 "${kexts[$i]}" "${1}/${filename%.kext}/Root/${filename}"␊ |
138 | ␉␉find "${1}/${filename%.kext}" -name '.DS_Store' -or -name '.svn' -exec rm -R -f {} \; 2>/dev/null␊ |
139 | ␉␉fixperms "${1}/${filename%.kext}/Root/"␊ |
140 | ␉␉chown 501:20 "${1}/${filename%.kext}/Root/"␊ |
141 | ␉␉buildpackage "${1}/${filename%.kext}" "/.Chameleon/Extra/Extensions" ""␊ |
142 | ␉␉rm -R -f "${1}/${filename%.kext}"␊ |
143 | ␉done␊ |
144 | ␊ |
145 | ␉((xmlindent--))␊ |
146 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
147 | ␊ |
148 | ␉((xmlindent--))␊ |
149 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t</line>"␊ |
150 | ␊ |
151 | # build post install package ␊ |
152 | ␊ |
153 | ␉mkdir -p ${1}/Post/Root␊ |
154 | ␉mkdir -p ${1}/Post/Scripts␊ |
155 | ␉cp -f ${pkgroot}/Scripts/Post/* ${1}/Post/Scripts␊ |
156 | ␉buildpackage "${1}/Post" "/" "" "start_visible=\"false\" start_selected=\"true\""␊ |
157 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}</choices-outline>"␊ |
158 | ␊ |
159 | # build meta package␊ |
160 | ␊ |
161 | ␉makedistribution "${1}" "${2}" "${3}" "${4}" "${5}"␊ |
162 | ␊ |
163 | # clean up ␊ |
164 | ␊ |
165 | ␉rm -R -f "${1}"␊ |
166 | ␊ |
167 | }␊ |
168 | ␊ |
169 | fixperms ()␊ |
170 | {␊ |
171 | ␉# $1 path␊ |
172 | ␉find "${1}" -type f -exec chmod 644 {} \;␊ |
173 | ␉find "${1}" -type d -exec chmod 755 {} \;␊ |
174 | ␉chown -R 0:0 "${1}"␊ |
175 | }␊ |
176 | ␊ |
177 | buildpackage ()␊ |
178 | {␊ |
179 | # $1 Path to package to build containing Root and or Scripts␊ |
180 | # $2 Install Location␊ |
181 | # $3 Size␊ |
182 | # $4 Options␊ |
183 | ␊ |
184 | if [ -d "${1}/Root" ] && [ "${1}/Scripts" ]; then␊ |
185 | ␊ |
186 | ␉local packagename="${1##*/}"␊ |
187 | ␉local identifier=$( echo ${packagesidentity}.${packagename//_/.} | tr [:upper:] [:lower:] )␊ |
188 | ␉find "${1}" -name '.DS_Store' -delete␊ |
189 | ␉local filecount=$( find "${1}/Root" | wc -l )␊ |
190 | ␉if [ "${3}" ]; then␊ |
191 | ␉␉local installedsize="${3}"␊ |
192 | ␉else␊ |
193 | ␉␉local installedsize=$( du -hkc "${1}/Root" | tail -n1 | awk {'print $1'} )␊ |
194 | ␉fi␊ |
195 | ␉local header="<?xml version=\"1.0\"?>\n<pkg-info format-version=\"2\" "␊ |
196 | ␊ |
197 | ␉#[ "${3}" == "relocatable" ] && header+="relocatable=\"true\" "␉␉␊ |
198 | ␊ |
199 | ␉header+="identifier=\"${identifier}\" "␊ |
200 | ␉header+="version=\"${version}\" "␊ |
201 | ␊ |
202 | ␉[ "${2}" != "relocatable" ] && header+="install-location=\"${2}\" "␊ |
203 | ␊ |
204 | ␉header+="auth=\"root\">\n"␊ |
205 | ␉header+="\t<payload installKBytes=\"${installedsize##* }\" numberOfFiles=\"${filecount##* }\"/>\n"␊ |
206 | ␉rm -R -f "${1}/Temp"␊ |
207 | ␊ |
208 | ␉[ -d "${1}/Temp" ] || mkdir -m 777 "${1}/Temp"␊ |
209 | ␉[ -d "${1}/Root" ] && mkbom "${1}/Root" "${1}/Temp/Bom"␊ |
210 | ␊ |
211 | ␉if [ -d "${1}/Scripts" ]; then ␊ |
212 | ␉␉header+="\t<scripts>\n"␊ |
213 | ␉␉for script in $( find "${1}/Scripts" -type f \( -name 'pre*' -or -name 'post*' \) )␊ |
214 | ␉␉do␊ |
215 | ␉␉␉header+="\t\t<${script##*/} file=\"./${script##*/}\"/>\n"␊ |
216 | ␉␉done␊ |
217 | ␉␉header+="\t</scripts>\n"␊ |
218 | ␉␉chown -R 0:0 "${1}/Scripts"␊ |
219 | ␉␉pushd "${1}/Scripts" >/dev/null␊ |
220 | ␉␉find . -print | cpio -o -z -H cpio > "../Temp/Scripts"␊ |
221 | ␉␉popd >/dev/null␊ |
222 | ␉fi␊ |
223 | ␊ |
224 | ␉header+="</pkg-info>"␊ |
225 | ␉echo -e "${header}" > "${1}/Temp/PackageInfo"␊ |
226 | ␉pushd "${1}/Root" >/dev/null␊ |
227 | ␉find . -print | cpio -o -z -H cpio > "../Temp/Payload"␊ |
228 | ␉popd >/dev/null␊ |
229 | ␉pushd "${1}/Temp" >/dev/null␊ |
230 | ␊ |
231 | ␉xar -c -f "${1%/*}/${packagename// /}.pkg" --compression none .␊ |
232 | ␊ |
233 | ␉popd >/dev/null␊ |
234 | ␊ |
235 | ␉outline[$((outlinecount++))]="${indent[$xmlindent]}\t<line choice=\"${packagename// /}\"/>"␊ |
236 | ␊ |
237 | ␉if [ "${4}" ]; then␊ |
238 | ␉␉local choiceoptions="${indent[$xmlindent]}${4}\n"␉␊ |
239 | ␉fi␊ |
240 | ␉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"␊ |
241 | ␊ |
242 | ␉rm -R -f "${1}"␊ |
243 | fi␊ |
244 | }␊ |
245 | ␊ |
246 | makedistribution ()␊ |
247 | {␊ |
248 | ␉rm -f "${1%/*}/${packagename// /}"*.pkg␊ |
249 | ␊ |
250 | ␉find "${1}" -type f -name '*.pkg' -depth 1 | while read component␊ |
251 | ␉do␊ |
252 | ␉␉mkdir -p "${1}/${packagename}/${component##*/}"␊ |
253 | ␉␉pushd "${1}/${packagename}/${component##*/}" >/dev/null␊ |
254 | ␉␉xar -x -f "${1%}/${component##*/}"␊ |
255 | ␉␉popd >/dev/null␊ |
256 | ␉done␊ |
257 | ␊ |
258 | ␉ditto --noextattr --noqtn "${pkgroot}/Distribution" "${1}/${packagename}/Distribution"␊ |
259 | ␉ditto --noextattr --noqtn "${pkgroot}/Resources" "${1}/${packagename}/Resources"␊ |
260 | ␊ |
261 | ␉find "${1}/${packagename}/Resources" -type d -name '.svn' -exec rm -R -f {} \; 2>/dev/null␊ |
262 | ␊ |
263 | ␉for (( i=0; i < ${#outline[*]} ; i++));␊ |
264 | ␉␉do␊ |
265 | ␉␉␉echo -e "${outline[$i]}" >> "${1}/${packagename}/Distribution"␊ |
266 | ␉␉done␊ |
267 | ␊ |
268 | ␉for (( i=0; i < ${#choices[*]} ; i++));␊ |
269 | ␉␉do␊ |
270 | ␉␉␉echo -e "${choices[$i]}" >> "${1}/${packagename}/Distribution"␊ |
271 | ␉␉done␊ |
272 | ␊ |
273 | ␉echo "</installer-gui-script>" >> "${1}/${packagename}/Distribution"␊ |
274 | ␊ |
275 | ␉perl -i -p -e "s/%CHAMELEONVERSION%/${version%%-*}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
276 | ␉perl -i -p -e "s/%CHAMELEONREVISION%/${revision}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
277 | ␊ |
278 | ␉stage=${stage/RC/Release Candidate }␊ |
279 | ␉stage=${stage/FINAL/2.0 Final}␊ |
280 | ␉perl -i -p -e "s/%CHAMELEONSTAGE%/${stage}/g" `find "${1}/${packagename}/Resources" -type f`␊ |
281 | ␊ |
282 | ␉find "${1}/${packagename}" -name '.DS_Store' -delete␊ |
283 | ␉pushd "${1}/${packagename}" >/dev/null␊ |
284 | ␉xar -c -f "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" --compression none .␊ |
285 | ␉popd >/dev/null␊ |
286 | ␊ |
287 | ␉md5=$( md5 "${1%/*}/${packagename// /}-${version}-r${revision}.pkg" | awk {'print $4'} )␊ |
288 | ␉echo "MD5 (${packagename// /}-${version}-r${revision}.pkg) = ${md5}" > "${1%/*}/${packagename// /}-${version}-r${revision}.pkg.md5"␊ |
289 | }␊ |
290 | ␊ |
291 | main "${1}" "${2}" "${3}" "${4}" "${5}"␊ |
292 | ␊ |
293 |