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