##// END OF EJS Templates
buildrpm: introduce --withpython for building rpms that includes Python 2.7
Mads Kiilerich -
r22436:96d95b75 default
parent child Browse files
Show More
@@ -14,6 +14,10 b' while [ "$1" ]; do'
14 14 shift
15 15 BUILD=
16 16 ;;
17 --withpython | --with-python)
18 shift
19 PYTHONVER=2.7.8
20 ;;
17 21 * )
18 22 echo "Invalid parameter $1!" 1>&2
19 23 exit 1
@@ -23,7 +27,7 b' done'
23 27
24 28 cd "`dirname $0`/.."
25 29
26 specfile=contrib/mercurial.spec
30 specfile=$PWD/contrib/mercurial.spec
27 31 if [ ! -f $specfile ]; then
28 32 echo "Cannot find $specfile!" 1>&2
29 33 exit 1
@@ -56,8 +60,28 b' else'
56 60 version=`echo $hgversion | sed -e 's/+.*//'`
57 61 release='0'
58 62 fi
63 if [ "$PYTHONVER" ]; then
64 release=$release+$PYTHONVER
65 RPMPYTHONVER=$PYTHONVER
66 else
67 RPMPYTHONVER=%{nil}
68 fi
59 69
60 70 $HG archive -t tgz $rpmdir/SOURCES/mercurial-$version-$release.tar.gz
71 if [ "$PYTHONVER" ]; then
72 (
73 cd build
74 PYTHON_SRCFILE=Python-$PYTHONVER.tgz
75 [ -f $PYTHON_SRCFILE ] || curl -Lo $PYTHON_SRCFILE http://www.python.org/ftp/python/$PYTHONVER/$PYTHON_SRCFILE
76 ln -f $PYTHON_SRCFILE $rpmdir/SOURCES/$PYTHON_SRCFILE
77
78 DOCUTILSVER=`sed -ne "s/^%global docutilsname docutils-//p" $specfile`
79 DOCUTILS_SRCFILE=docutils-$DOCUTILSVER.tar.gz
80 [ -f $DOCUTILS_SRCFILE ] || curl -Lo $DOCUTILS_SRCFILE http://downloads.sourceforge.net/project/docutils/docutils/$DOCUTILSVER/$DOCUTILS_SRCFILE
81 ln -f $DOCUTILS_SRCFILE $rpmdir/SOURCES/$DOCUTILS_SRCFILE
82 )
83 fi
84
61 85 rpmspec=$rpmdir/SPECS/mercurial.spec
62 86
63 87 sed -e "s,^Version:.*,Version: $version," \
@@ -109,6 +133,10 b' for l in sys.stdin.readlines():'
109 133
110 134 fi
111 135
136 sed -i \
137 -e "s/^%define withpython.*$/%define withpython $RPMPYTHONVER/" \
138 $rpmspec
139
112 140 if [ "$BUILD" ]; then
113 141 rpmbuild --define "_topdir $rpmdir" -ba $rpmspec --clean
114 142 if [ $? = 0 ]; then
@@ -1,6 +1,23 b''
1 1 %global emacs_lispdir %{_datadir}/emacs/site-lisp
2
3 %define withpython %{nil}
4
5 %if "%{?withpython}"
6
7 %global pythonver %{withpython}
8 %global pythonname Python-%{withpython}
9 %global docutilsname docutils-0.11
10 %global pythonhg python-hg
11 %global hgpyprefix /usr/%{pythonhg}
12 # byte compilation will fail on some some Python /test/ files
13 %global _python_bytecompile_errors_terminate_build 0
14
15 %else
16
2 17 %global pythonver %(python -c 'import sys;print ".".join(map(str, sys.version_info[:2]))')
3 18
19 %endif
20
4 21 Summary: A fast, lightweight Source Control Management system
5 22 Name: mercurial
6 23 Version: snapshot
@@ -9,11 +26,19 b' License: GPLv2+'
9 26 Group: Development/Tools
10 27 URL: http://mercurial.selenic.com/
11 28 Source0: %{name}-%{version}-%{release}.tar.gz
29 %if "%{?withpython}"
30 Source1: %{pythonname}.tgz
31 Source2: %{docutilsname}.tar.gz
32 %endif
12 33 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
13 34
14 BuildRequires: python >= 2.4, python-devel, make, gcc, python-docutils >= 0.5, gettext
15 Provides: hg = %{version}-%{release}
35 BuildRequires: make, gcc, gettext
36 %if "%{?withpython}"
37 BuildRequires: readline-devel, openssl-devel, ncurses-devel, zlib-devel, bzip2-devel
38 %else
39 BuildRequires: python >= 2.4, python-devel, python-docutils >= 0.5
16 40 Requires: python >= 2.4
41 %endif
17 42 # The hgk extension uses the wish tcl interpreter, but we don't enforce it
18 43 #Requires: tk
19 44
@@ -22,15 +47,69 b' Mercurial is a fast, lightweight source '
22 47 for efficient handling of very large distributed projects.
23 48
24 49 %prep
50
51 %if "%{?withpython}"
52 %setup -q -n mercurial-%{version}-%{release} -a1 -a2
53 # despite the comments in cgi.py, we do this to prevent rpmdeps from picking /usr/local/bin/python up
54 sed -i '1c#! /usr/bin/env python' %{pythonname}/Lib/cgi.py
55 %else
25 56 %setup -q -n mercurial-%{version}-%{release}
57 %endif
26 58
27 59 %build
60
61 %if "%{?withpython}"
62
63 PYPATH=$PWD/%{pythonname}
64 cd $PYPATH
65 ./configure --prefix=%{hgpyprefix}
66 make all %{?_smp_mflags}
67 cd -
68
69 cd %{docutilsname}
70 LD_LIBRARY_PATH=$PYPATH $PYPATH/python setup.py build
71 cd -
72
73 # verify Python environment
74 LD_LIBRARY_PATH=$PYPATH PYTHONPATH=$PWD/%{docutilsname} $PYPATH/python -c 'import sys, zlib, bz2, ssl, curses, readline'
75
76 # set environment for make
77 export PATH=$PYPATH:$PATH
78 export LD_LIBRARY_PATH=$PYPATH
79 export CFLAGS="-L $PYPATH"
80 export PYTHONPATH=$PWD/%{docutilsname}
81
82 %endif
83
28 84 make all
29 85
30 86 %install
31 87 rm -rf $RPM_BUILD_ROOT
88
89 %if "%{?withpython}"
90
91 PYPATH=$PWD/%{pythonname}
92 cd $PYPATH
93 make install DESTDIR=$RPM_BUILD_ROOT
94 # these .a are not necessary and they are readonly and strip fails - kill them!
95 rm -f %{buildroot}%{hgpyprefix}/lib/{,python2.*/config}/libpython2.*.a
96 cd -
97
98 cd %{docutilsname}
99 LD_LIBRARY_PATH=$PYPATH $PYPATH/python setup.py install --root="$RPM_BUILD_ROOT"
100 cd -
101
102 PATH=$PYPATH:$PATH LD_LIBRARY_PATH=$PYPATH make install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{hgpyprefix} MANDIR=%{_mandir}
103 mkdir -p $RPM_BUILD_ROOT%{_bindir}
104 ( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/hg . )
105 ( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/python2.? %{pythonhg} )
106
107 %else
108
32 109 make install DESTDIR=$RPM_BUILD_ROOT PREFIX=%{_prefix} MANDIR=%{_mandir}
33 110
111 %endif
112
34 113 install -m 755 contrib/hgk $RPM_BUILD_ROOT%{_bindir}/
35 114 install -m 755 contrib/hg-ssh $RPM_BUILD_ROOT%{_bindir}/
36 115
@@ -71,8 +150,13 b' rm -rf $RPM_BUILD_ROOT'
71 150 %dir %{_sysconfdir}/mercurial
72 151 %dir %{_sysconfdir}/mercurial/hgrc.d
73 152 %config(noreplace) %{_sysconfdir}/mercurial/hgrc.d/mergetools.rc
153 %if "%{?withpython}"
154 %{_bindir}/%{pythonhg}
155 %{hgpyprefix}
156 %else
74 157 %if "%{?pythonver}" != "2.4"
75 158 %{_libdir}/python%{pythonver}/site-packages/%{name}-*-py%{pythonver}.egg-info
76 159 %endif
77 160 %{_libdir}/python%{pythonver}/site-packages/%{name}
78 161 %{_libdir}/python%{pythonver}/site-packages/hgext
162 %endif
General Comments 0
You need to be logged in to leave comments. Login now