+pyver=$1
+shift
+
+ver2=`echo ${version} | cut -c 1,2,3`
+tarver=${tarname}-${version}
+
+python=${pythonbin}${pyver}
+if [ ! -e ${python} ]; then
+ echo "${python} not found!"
+ exit 1
+fi
+
+
+function makespec {
+ echo "*** Writing ${distdir}/wxPython${port}.spec"
+ cat ${spectemplate} \
+ | sed s:@PYTHON@:${python}:g \
+ | sed s:@PYVER@:${pyver}:g \
+ | sed s:@PORT@:${port}:g \
+ | sed s:@LCPORT@:${lcport}:g \
+ | sed s:@TARNAME@:${tarname}:g \
+ | sed s:@VERSION@:${version}:g \
+ | sed s:@VER2@:${ver2}:g \
+ | sed s:@UNICODE@:${unicode}:g \
+ > ${distdir}/wxPython${port}.spec
+}
+
+
+
+for flag in $*; do
+ case ${flag} in
+ skipcopy) skipcopy=1 ;;
+ skipclean) skipclean=1 ;;
+ skiptar) skiptar=1 ;;
+ skiprpm) skiprpm=1 ;;
+ gtk2) unicode=1; port=GTK2; lcport=gtk2 ;;
+ x11) port=X11; lcport=x11 ;;
+ smp) export SMP=2 ;;
+ speconly) makespec; exit 0 ;;
+ srpm) rpmflag=-bs; ;;
+
+ *) echo "Unknown flag \"${flag}\""
+ usage
+ exit 1
+ esac
+done
+
+
+#----------------------------------------------------------------------
+# Setup build dirs
+
+echo "*** Setting up"
+
+if [ ! -d ${builddir} ]; then
+ mkdir -p ${builddir}
+fi
+
+if [ ! -d ${distdir} ]; then
+ mkdir -p ${distdir}
+fi
+
+for dir in SOURCES SPECS BUILD RPMS SRPMS; do
+ if [ ! -d ${rpmtop}/${dir} ]; then
+ mkdir -p ${rpmtop}/${dir}
+ fi
+done
+
+
+#----------------------------------------------------------------------
+# Copy the sources from my CVS workspace
+
+function cleanup {
+ RMFILES=`find . -name "$1"`
+ if [ "$RMFILES" != "" ]; then
+ rm -rf $RMFILES
+ fi
+}
+
+
+if [ -z "${skipcopy}" ]; then
+ echo "*** Copying CVS tree"
+ pushd ${builddir} > /dev/null
+ if [ -e ${tarver} ]; then
+ rm -rf ${tarver}
+ fi
+ mkdir -p ${tarver}
+
+ # copy root dir contents
+ cp -pf --link ${wxdir}/* ${tarver} > /dev/null 2>&1
+
+ # copy all top dirs except CVS, build, demos, utils, samples, and wxPython
+ for d in art build contrib debian distrib docs include lib locale misc patches src; do
+ if [ -e ${wxdir}/$d ]; then
+ cp -Rpf --link ${wxdir}/$d ${tarver} #> /dev/null 2>&1
+ fi
+ done
+
+ # now do the same thing for wxPython, skipping it's build dirs and such
+ mkdir ${tarver}/wxPython
+ cp -pf --link ${wxdir}/wxPython/* ${tarver}/wxPython > /dev/null 2>&1
+ for d in contrib demo distrib distutils docs include licence samples scripts src SWIG wx wxPython; do
+ cp -Rpf --link ${wxdir}/wxPython/$d ${tarver}/wxPython #> /dev/null 2>&1
+ done
+
+# cp -Rpf --link ${wxdir}/* ${tarver} > /dev/null 2>&1
+# rm -r ${tarver}/bld*
+# rm -r ${tarver}/wxPython/build*
+# rm -r ${tarver}/wxPython/_build_rpm
+
+ echo "*** Removing uneeded stuff from copy of CVS tree"
+ pushd ${tarver} > /dev/null
+ cleanup .cvsignore
+ cleanup CVS
+ cleanup CVSROOT
+ rm BuildCVS.txt
+ rm *.spec
+ rm -rf docs/html
+ rm -rf docs/latex
+ rm -rf contrib/docs
+ rm -rf contrib/samples
+ rm locale/*.mo
+ cleanup ".#*"
+ cleanup "*~"
+ cleanup "*.orig"
+ cleanup "*.rej"
+ cleanup "*.pyc"
+ cleanup core
+ cleanup "core.[0-9]*"
+
+ rm -f wxPython/wx/* > /dev/null 2>&1
+ rm wxPython/demo/.setup.sh
+ rm -r wxPython/docs/xml-raw
+
+ popd > /dev/null
+ popd > /dev/null
+fi
+