]>
Commit | Line | Data |
---|---|---|
1 | #!/bin/bash | |
2 | #---------------------------------------------------------------------- | |
3 | # Build an RPM containing both wxGTK and wxPython | |
4 | ||
5 | ##set -o xtrace | |
6 | ||
7 | spectemplate=distrib/wxPythonFull.spec.in | |
8 | ||
9 | if [ ! -d wxPython -o ! -e ${spectemplate} ]; then | |
10 | echo "Please run this script from the root wxPython directory." | |
11 | exit 1 | |
12 | fi | |
13 | ||
14 | ||
15 | #---------------------------------------------------------------------- | |
16 | # Initialization | |
17 | ||
18 | version=`python -c "import setup;print setup.VERSION"` | |
19 | wxpdir=`pwd` | |
20 | wxdir=${wxpdir}/.. | |
21 | distdir=${wxpdir}/dist | |
22 | builddir=${wxpdir}/_build_rpm | |
23 | rpmtop=${builddir}/rpmtop | |
24 | cvsroot=:pserver:anoncvs@cvs.wxwindows.org:/pack/cvsroots/wxwindows | |
25 | pythonbin=/usr/bin/python | |
26 | port=GTK | |
27 | lcport=gtk | |
28 | unicode=0 | |
29 | tarname=wxPython-src | |
30 | srpmonly=0 | |
31 | skipclean=0 | |
32 | ||
33 | #---------------------------------------------------------------------- | |
34 | # Check parameters | |
35 | ||
36 | function usage { | |
37 | echo "Usage: $0 py_version [command flags...]" | |
38 | echo " py_version which python version to use." | |
39 | echo "" | |
40 | echo "command flags:" | |
41 | echo " skipcopy Don't copy the files for the tarball from the workspace" | |
42 | echo " skiptar Don't build the tarball" | |
43 | echo " skiprpm Don't build the RPM" | |
44 | echo " skipclean Don't do the cleanup at the end" | |
45 | echo " speconly Do nothing but write the RPM spec file" | |
46 | echo " srpm Only make the SRPM" | |
47 | } | |
48 | ||
49 | if [ $# -lt 1 ]; then | |
50 | usage | |
51 | exit 1 | |
52 | fi | |
53 | ||
54 | pyver=$1 | |
55 | shift | |
56 | ||
57 | ver2=`echo ${version} | cut -c 1,2,3` | |
58 | tarver=${tarname}-${version} | |
59 | ||
60 | python=${pythonbin}${pyver} | |
61 | if [ ! -e ${python} ]; then | |
62 | echo "${python} not found!" | |
63 | exit 1 | |
64 | fi | |
65 | ||
66 | ||
67 | function makespec { | |
68 | echo "*** Writing ${distdir}/wxPython.spec" | |
69 | cat ${spectemplate} \ | |
70 | | sed s:@PYTHON@:${python}:g \ | |
71 | | sed s:@PYVER@:${pyver}:g \ | |
72 | | sed s:@TARNAME@:${tarname}:g \ | |
73 | | sed s:@VERSION@:${version}:g \ | |
74 | | sed s:@VER2@:${ver2}:g \ | |
75 | > ${distdir}/wxPython.spec | |
76 | } | |
77 | ||
78 | ||
79 | ||
80 | for flag in $*; do | |
81 | case ${flag} in | |
82 | skipcopy) skipcopy=1 ;; | |
83 | skipclean) skipclean=1 ;; | |
84 | skiptar) skiptar=1; skipcopy=1 ;; | |
85 | skiprpm) skiprpm=1 ;; | |
86 | speconly) makespec; exit 0 ;; | |
87 | srpm) srpmonly=1; ;; | |
88 | ||
89 | *) echo "Unknown flag \"${flag}\"" | |
90 | usage | |
91 | exit 1 | |
92 | esac | |
93 | done | |
94 | ||
95 | ||
96 | #---------------------------------------------------------------------- | |
97 | # Setup build dirs | |
98 | ||
99 | echo "*** Setting up" | |
100 | ||
101 | if [ ! -d ${builddir} ]; then | |
102 | mkdir -p ${builddir} | |
103 | fi | |
104 | ||
105 | if [ ! -d ${distdir} ]; then | |
106 | mkdir -p ${distdir} | |
107 | fi | |
108 | ||
109 | for dir in SOURCES SPECS BUILD RPMS SRPMS; do | |
110 | if [ ! -d ${rpmtop}/${dir} ]; then | |
111 | mkdir -p ${rpmtop}/${dir} | |
112 | fi | |
113 | done | |
114 | ||
115 | ||
116 | #---------------------------------------------------------------------- | |
117 | # Copy the sources from my CVS workspace | |
118 | ||
119 | function cleanup { | |
120 | RMFILES=`find . -name "$1"` | |
121 | if [ "$RMFILES" != "" ]; then | |
122 | rm -rf $RMFILES | |
123 | fi | |
124 | } | |
125 | ||
126 | ||
127 | if [ -z "${skipcopy}" ]; then | |
128 | echo "*** Copying CVS tree" | |
129 | pushd ${builddir} > /dev/null | |
130 | if [ -e ${tarver} ]; then | |
131 | rm -rf ${tarver} | |
132 | fi | |
133 | mkdir -p ${tarver} | |
134 | ||
135 | # copy root dir contents | |
136 | cp -pf --link ${wxdir}/* ${tarver} > /dev/null 2>&1 | |
137 | ||
138 | # copy all top dirs except CVS, demos, samples, and wxPython | |
139 | for d in art build contrib debian docs include lib locale patches samples src utils; do | |
140 | if [ -e ${wxdir}/$d ]; then | |
141 | cp -Rpf --link ${wxdir}/$d ${tarver} #> /dev/null 2>&1 | |
142 | fi | |
143 | done | |
144 | mkdir ${tarver}/distrib | |
145 | cp -Rpf --link ${wxdir}/distrib/scripts ${tarver}/distrib | |
146 | ||
147 | ||
148 | # now do the same thing for wxPython, but use the DIRLIST to select dirs to copy | |
149 | for dir in `grep -v '#' ${wxdir}/wxPython/distrib/DIRLIST`; do | |
150 | mkdir ${tarver}/${dir} | |
151 | ##echo "cp -pf --link ${wxdir}/${dir}/* ${tarver}/${dir}" | |
152 | cp -pf --link ${wxdir}/${dir}/* ${tarver}/${dir} > /dev/null 2>&1 | |
153 | done | |
154 | ||
155 | # using DIRLIST as above will normally skip any files starting | |
156 | # with a dot, but there are a few .files that we do want to | |
157 | # copy... | |
158 | for dir in wxPython/distrib/msw; do | |
159 | cp -pf --link ${wxdir}/${dir}/.[a-zA-Z]* ${tarver}/${dir} > /dev/null 2>&1 | |
160 | done | |
161 | ||
162 | echo "*** Removing uneeded stuff from copy of CVS tree" | |
163 | pushd ${tarver} > /dev/null | |
164 | cleanup .cvsignore | |
165 | cleanup CVS | |
166 | cleanup CVSROOT | |
167 | rm BuildCVS.txt | |
168 | rm -f ChangeLog | |
169 | rm *.spec | |
170 | rm -rf distrib/msw/tmake | |
171 | #rm -rf docs/html | |
172 | #rm -rf docs/latex | |
173 | #rm -rf contrib/docs | |
174 | #rm -rf contrib/samples | |
175 | rm locale/*.mo | |
176 | cleanup ".#*" | |
177 | cleanup "#*#" | |
178 | cleanup "*~" | |
179 | cleanup "*.orig" | |
180 | cleanup "*.rej" | |
181 | cleanup "*.pyc" | |
182 | cleanup core | |
183 | cleanup "core.[0-9]*" | |
184 | rm -f wxPython/samples/embedded/embedded | |
185 | rm -f wxPython/samples/embedded/embedded.o | |
186 | ||
187 | # ports that are not supported yet | |
188 | #cleanup cocoa # wxMac needs some cocoa headers | |
189 | cleanup mgl | |
190 | cleanup motif | |
191 | cleanup os2 | |
192 | cleanup x11 | |
193 | cleanup univ | |
194 | cleanup wine | |
195 | ||
196 | rm -f wxPython/wx/* > /dev/null 2>&1 | |
197 | ||
198 | popd > /dev/null | |
199 | popd > /dev/null | |
200 | fi | |
201 | ||
202 | ||
203 | #---------------------------------------------------------------------- | |
204 | # Make the spec file and copy to ${builddir}/${tarver} so it will be | |
205 | # in the tar file when it's built | |
206 | ||
207 | # TODO? Output all combinations of spec files to put in the tar file?? | |
208 | ||
209 | makespec | |
210 | cp ${distdir}/wxPython.spec ${builddir}/${tarver}/wxPython.spec | |
211 | ||
212 | ||
213 | #---------------------------------------------------------------------- | |
214 | # Build the tar file | |
215 | ||
216 | if [ -z "${skiptar}" ]; then | |
217 | echo "*** Creating language catalogs..." | |
218 | pushd ${builddir}/${tarver}/locale > /dev/null | |
219 | make allmo | |
220 | popd > /dev/null | |
221 | ||
222 | echo "*** Creating tarball..." | |
223 | cp distrib/README.1st.txt ${builddir}/${tarver} | |
224 | pushd ${builddir} > /dev/null | |
225 | tar cvf ${distdir}/${tarver}.tar ${tarver} > /dev/null | |
226 | ||
227 | echo "*** Compressing..." | |
228 | if [ -e ${distdir}/${tarver}.tar.bz2 ]; then | |
229 | rm ${distdir}/${tarver}.tar.bz2 | |
230 | fi | |
231 | bzip2 --best ${distdir}/${tarver}.tar | |
232 | popd > /dev/null | |
233 | fi | |
234 | ||
235 | ||
236 | #---------------------------------------------------------------------- | |
237 | # build the RPM | |
238 | ||
239 | if [ -z "${skiprpm}" ]; then | |
240 | echo "*** Building RPMs..." | |
241 | cp ${distdir}/${tarver}.tar.bz2 ${rpmtop}/SOURCES | |
242 | ||
243 | if [ "${srpmonly}" = "1" ]; then | |
244 | rpmbuild -bs \ | |
245 | --define "_topdir ${rpmtop}" \ | |
246 | --define "_tmppath ${builddir}" \ | |
247 | --define "release 1" \ | |
248 | ${distdir}/wxPython.spec | |
249 | if [ "$?" != "0" ]; then | |
250 | echo "*** RPM failure, exiting." | |
251 | exit 1 | |
252 | fi | |
253 | ||
254 | else | |
255 | rpmbuild -ba \ | |
256 | --define "_topdir ${rpmtop}" \ | |
257 | --define "_tmppath ${builddir}" \ | |
258 | --define "port gtk" --define "unicode 0" \ | |
259 | --define "pyver ${pyver}" \ | |
260 | ${distdir}/wxPython.spec | |
261 | if [ "$?" != "0" ]; then | |
262 | echo "*** RPM failure, exiting." | |
263 | exit 1 | |
264 | fi | |
265 | ||
266 | rpmbuild -ba \ | |
267 | --define "_topdir ${rpmtop}" \ | |
268 | --define "_tmppath ${builddir}" \ | |
269 | --define "port gtk2" --define "unicode 1" \ | |
270 | --define "pyver ${pyver}" \ | |
271 | ${distdir}/wxPython.spec | |
272 | if [ "$?" != "0" ]; then | |
273 | echo "*** RPM failure, exiting." | |
274 | exit 1 | |
275 | fi | |
276 | fi | |
277 | ||
278 | echo "*** Moving RPMs to ${distdir}" | |
279 | mv -f `find ${rpmtop} -name "wxPython*.rpm"` ${distdir} | |
280 | fi | |
281 | ||
282 | #---------------------------------------------------------------------- | |
283 | # Cleanup | |
284 | ||
285 | if [ "${skipclean}" = "0" ]; then | |
286 | echo "*** Cleaning up" | |
287 | rm -rf ${rpmtop} | |
288 | rm -rf ${builddir} | |
289 | fi | |
290 | ||
291 | ||
292 |