diff --git a/contrib/buildrpm b/contrib/buildrpm index 4c4385eb26bc4638ff0308a8b86f8dea247c852f_Y29udHJpYi9idWlsZHJwbQ==..96d95b75a63beaf62743c7fed32f443edff159c5_Y29udHJpYi9idWlsZHJwbQ== 100755 --- a/contrib/buildrpm +++ b/contrib/buildrpm @@ -14,6 +14,10 @@ shift BUILD= ;; + --withpython | --with-python) + shift + PYTHONVER=2.7.8 + ;; * ) echo "Invalid parameter $1!" 1>&2 exit 1 @@ -23,7 +27,7 @@ cd "`dirname $0`/.." -specfile=contrib/mercurial.spec +specfile=$PWD/contrib/mercurial.spec if [ ! -f $specfile ]; then echo "Cannot find $specfile!" 1>&2 exit 1 @@ -56,5 +60,11 @@ version=`echo $hgversion | sed -e 's/+.*//'` release='0' fi +if [ "$PYTHONVER" ]; then + release=$release+$PYTHONVER + RPMPYTHONVER=$PYTHONVER +else + RPMPYTHONVER=%{nil} +fi $HG archive -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz @@ -59,5 +69,19 @@ $HG archive -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz +if [ "$PYTHONVER" ]; then +( + cd build + PYTHON_SRCFILE=Python-$PYTHONVER.tgz + [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE + ln -f $PYTHON_SRCFILE $rpmdir/SOURCES/$PYTHON_SRCFILE + + DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile` + DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz + [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE + ln -f $DOCUTILS_SRCFILE $rpmdir/SOURCES/$DOCUTILS_SRCFILE +) +fi + rpmspec=$rpmdir/SPECS/mercurial.spec sed -e "s,^Version:.*,Version: $version," \ @@ -109,6 +133,10 @@ fi +sed -i \ + -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \ + $rpmspec + if [ "$BUILD" ]; then rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean if [ $? = 0 ]; then diff --git a/contrib/mercurial.spec b/contrib/mercurial.spec index 4c4385eb26bc4638ff0308a8b86f8dea247c852f_Y29udHJpYi9tZXJjdXJpYWwuc3BlYw==..96d95b75a63beaf62743c7fed32f443edff159c5_Y29udHJpYi9tZXJjdXJpYWwuc3BlYw== 100755 --- a/contrib/mercurial.spec +++ b/contrib/mercurial.spec @@ -1,3 +1,18 @@ %global emacs_lispdir %{_datadir}/emacs/site-lisp + +%define withpython %{nil} + +%if "%{?withpython}" + +%global pythonver %{withpython} +%global pythonname Python-%{withpython} +%global docutilsname docutils-0.11 +%global pythonhg python-hg +%global hgpyprefix /usr/%{pythonhg} +# byte compilation will fail on some some Python /test/ files +%global _python_bytecompile_errors_terminate_build 0 + +%else + %global pythonver %(python -c 'import sys;print ".".join(map(str, sys.version_info[:2]))') @@ -2,5 +17,7 @@ %global pythonver %(python -c 'import sys;print ".".join(map(str, sys.version_info[:2]))') +%endif + Summary: A fast, lightweight Source Control Management system Name: mercurial Version: snapshot @@ -9,5 +26,9 @@ Group: Development/Tools URL: http://mercurial.selenic.com/ Source0: %{name}-%{version}-%{release}.tar.gz +%if "%{?withpython}" +Source1: %{pythonname}.tgz +Source2: %{docutilsname}.tar.gz +%endif BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root @@ -12,5 +33,8 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root -BuildRequires: python >= 2.4, python-devel, make, gcc, python-docutils >= 0.5, gettext -Provides: hg = %{version}-%{release} +BuildRequires: make, gcc, gettext +%if "%{?withpython}" +BuildRequires: readline-devel, openssl-devel, ncurses-devel, zlib-devel, bzip2-devel +%else +BuildRequires: python >= 2.4, python-devel, python-docutils >= 0.5 Requires: python >= 2.4 @@ -16,4 +40,5 @@ Requires: python >= 2.4 +%endif # The hgk extension uses the wish tcl interpreter, but we don't enforce it #Requires: tk @@ -22,4 +47,10 @@ for efficient handling of very large distributed projects. %prep + +%if "%{?withpython}" +%setup -q -n mercurial-%{version}-%{release} -a1 -a2 +# despite the comments in cgi.py, we do this to prevent rpmdeps from picking /usr/local/bin/python up +sed -i '1c#! /usr/bin/env python' %{pythonname}/Lib/cgi.py +%else %setup -q -n mercurial-%{version}-%{release} @@ -25,3 +56,4 @@ %setup -q -n mercurial-%{version}-%{release} +%endif %build @@ -26,6 +58,30 @@ %build + +%if "%{?withpython}" + +PYPATH=$PWD/%{pythonname} +cd $PYPATH +./configure --prefix=%{hgpyprefix} +make all %{?_smp_mflags} +cd - + +cd %{docutilsname} +LD_LIBRARY_PATH=$PYPATH $PYPATH/python setup.py build +cd - + +# verify Python environment +LD_LIBRARY_PATH=$PYPATH PYTHONPATH=$PWD/%{docutilsname} $PYPATH/python -c 'import sys, zlib, bz2, ssl, curses, readline' + +# set environment for make +export PATH=$PYPATH:$PATH +export LD_LIBRARY_PATH=$PYPATH +export CFLAGS="-L $PYPATH" +export PYTHONPATH=$PWD/%{docutilsname} + +%endif + make all %install rm -rf $RPM_BUILD_ROOT @@ -28,6 +84,27 @@ make all %install rm -rf $RPM_BUILD_ROOT + +%if "%{?withpython}" + +PYPATH=$PWD/%{pythonname} +cd $PYPATH +make install DESTDIR=$RPM_BUILD_ROOT +# these .a are not necessary and they are readonly and strip fails - kill them! +rm -f %{buildroot}%{hgpyprefix}/lib/{,python2.*/config}/libpython2.*.a +cd - + +cd %{docutilsname} +LD_LIBRARY_PATH=$PYPATH $PYPATH/python setup.py install --root="$RPM_BUILD_ROOT" +cd - + +PATH=$PYPATH:$PATH LD_LIBRARY_PATH=$PYPATH make install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{hgpyprefix} MANDIR=%{_mandir} +mkdir -p $RPM_BUILD_ROOT%{_bindir} +( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/hg . ) +( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/python2.? %{pythonhg} ) + +%else + make install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} MANDIR=%{_mandir} @@ -32,5 +109,7 @@ make install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} MANDIR=%{_mandir} +%endif + install -m 755 contrib/hgk $RPM_BUILD_ROOT%{_bindir}/ install -m 755 contrib/hg-ssh $RPM_BUILD_ROOT%{_bindir}/ @@ -71,8 +150,12 @@ %dir %{_sysconfdir}/mercurial %dir %{_sysconfdir}/mercurial/hgrc.d %config(noreplace) %{_sysconfdir}/mercurial/hgrc.d/mergetools.rc +%if "%{?withpython}" +%{_bindir}/%{pythonhg} +%{hgpyprefix} +%else %if "%{?pythonver}" != "2.4" %{_libdir}/python%{pythonver}/site-packages/%{name}-*-py%{pythonver}.egg-info %endif %{_libdir}/python%{pythonver}/site-packages/%{name} %{_libdir}/python%{pythonver}/site-packages/hgext @@ -74,5 +157,6 @@ %if "%{?pythonver}" != "2.4" %{_libdir}/python%{pythonver}/site-packages/%{name}-*-py%{pythonver}.egg-info %endif %{_libdir}/python%{pythonver}/site-packages/%{name} %{_libdir}/python%{pythonver}/site-packages/hgext +%endif