| 1 |
%global emacs_lispdir %{_datadir}/emacs/site-lisp |
| 2 |
|
| 3 |
%define withpython %{nil} |
| 4 |
|
| 5 |
%global pythonexe python3 |
| 6 |
|
| 7 |
%if "%{?withpython}" |
| 8 |
%global pythonver %{withpython} |
| 9 |
%global pythonname Python-%{withpython} |
| 10 |
%global pythonhg python-hg |
| 11 |
%global hgpyprefix /opt/%{pythonhg} |
| 12 |
# byte compilation will fail on some some Python /test/ files |
| 13 |
%global _python_bytecompile_errors_terminate_build 0 |
| 14 |
|
| 15 |
%else |
| 16 |
%global pythonver %(%{pythonexe} -c 'import sys;print(".".join(map(str, sys.version_info[:2])))') |
| 17 |
|
| 18 |
%endif |
| 19 |
|
| 20 |
Summary: A fast, lightweight Source Control Management system |
| 21 |
Name: mercurial |
| 22 |
Version: snapshot |
| 23 |
Release: 0 |
| 24 |
License: GPLv2+ |
| 25 |
Prefix: / |
| 26 |
Group: Development/Tools |
| 27 |
URL: https://mercurial-scm.org/ |
| 28 |
Source0: %{name}-%{version}-%{release}.tar.gz |
| 29 |
%if "%{?withpython}" |
| 30 |
Source1: %{pythonname}.tgz |
| 31 |
%endif |
| 32 |
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root |
| 33 |
|
| 34 |
BuildRequires: make, gcc, gettext |
| 35 |
%if "%{?withpython}" |
| 36 |
BuildRequires: readline-devel, openssl-devel, ncurses-devel, zlib-devel, bzip2-devel |
| 37 |
%else |
| 38 |
BuildRequires: %{pythonexe} >= %{pythonver}, %{pythonexe}-devel, python3-docutils |
| 39 |
Requires: %{pythonexe} >= %{pythonver} |
| 40 |
%endif |
| 41 |
# The hgk extension uses the wish tcl interpreter, but we don't enforce it |
| 42 |
#Requires: tk |
| 43 |
|
| 44 |
%description |
| 45 |
Mercurial is a fast, lightweight source control management system designed |
| 46 |
for efficient handling of very large distributed projects. |
| 47 |
|
| 48 |
%prep |
| 49 |
|
| 50 |
%if "%{?withpython}" |
| 51 |
%setup -q -n mercurial-%{version}-%{release} -a1 |
| 52 |
%else |
| 53 |
%setup -q -n mercurial-%{version}-%{release} |
| 54 |
%endif |
| 55 |
|
| 56 |
%build |
| 57 |
|
| 58 |
export HGPYTHON3=1 |
| 59 |
|
| 60 |
%if "%{?withpython}" |
| 61 |
|
| 62 |
PYPATH=$PWD/%{pythonname} |
| 63 |
PYTHON_FULLPATH=$PYPATH/python3 |
| 64 |
cd $PYPATH |
| 65 |
./configure --prefix=%{hgpyprefix} --with-ensurepip=install --enable-optimizations --with-lto |
| 66 |
make all %{?_smp_mflags} |
| 67 |
# add a symlink and only refer to python3 from here on |
| 68 |
ln -s python python3 |
| 69 |
# remove python reference |
| 70 |
sed -i 's|#!/usr/bin/env python|#!/usr/bin/env python3|' Lib/encodings/rot_13.py |
| 71 |
$PYTHON_FULLPATH -m ensurepip --default-pip |
| 72 |
$PYTHON_FULLPATH -m pip install setuptools setuptools-scm docutils |
| 73 |
cd - |
| 74 |
|
| 75 |
# verify Python environment |
| 76 |
LD_LIBRARY_PATH=$PYPATH $PYTHON_FULLPATH -c 'import sys, zlib, bz2, ssl, curses, readline' |
| 77 |
LD_LIBRARY_PATH=$PYPATH $PYTHON_FULLPATH -c "import ssl; print(ssl.HAS_TLSv1_2)" |
| 78 |
LD_LIBRARY_PATH=$PYPATH $PYTHON_FULLPATH -c "import docutils" |
| 79 |
|
| 80 |
# set environment for make |
| 81 |
export PATH=$PYPATH:$PATH |
| 82 |
export LD_LIBRARY_PATH=$PYPATH |
| 83 |
export CFLAGS="-L $PYPATH" |
| 84 |
%else |
| 85 |
PYTHON_FULLPATH=$(which python3) |
| 86 |
$PYTHON_FULLPATH -m pip install pip setuptools setuptools-scm packaging --upgrade |
| 87 |
%endif |
| 88 |
|
| 89 |
make -C contrib/chg |
| 90 |
|
| 91 |
sed -i -e '1s|#!/usr/bin/env python3$|#!/usr/bin/env %{pythonexe}|' contrib/hg-ssh |
| 92 |
|
| 93 |
%install |
| 94 |
rm -rf $RPM_BUILD_ROOT |
| 95 |
|
| 96 |
export HGPYTHON3=1 |
| 97 |
|
| 98 |
%if "%{?withpython}" |
| 99 |
|
| 100 |
PYPATH=$PWD/%{pythonname} |
| 101 |
PYTHON_FULLPATH=$PYPATH/python3 |
| 102 |
cd $PYPATH |
| 103 |
make install DESTDIR=$RPM_BUILD_ROOT |
| 104 |
# these .a are not necessary and they are readonly and strip fails - kill them! |
| 105 |
rm -f %{buildroot}%{hgpyprefix}/lib/{,python2.*/config}/libpython2.*.a |
| 106 |
cd - |
| 107 |
|
| 108 |
PATH=$PYPATH:$PATH LD_LIBRARY_PATH=$PYPATH make install PYTHON=$PYTHON_FULLPATH DESTDIR=$RPM_BUILD_ROOT PIP_PREFIX=$RPM_BUILD_ROOT/%{hgpyprefix} PREFIX=%{hgpyprefix} MANDIR=%{_mandir} PURE="--rust" |
| 109 |
mkdir -p $RPM_BUILD_ROOT%{_bindir} |
| 110 |
( cd $RPM_BUILD_ROOT%{_bindir}/ && ln -s ../..%{hgpyprefix}/bin/hg . ) |
| 111 |
pathfix.py -n -i %{hgpyprefix}/bin/python3 $(readlink -f $RPM_BUILD_ROOT%{_bindir}/hg) |
| 112 |
|
| 113 |
%else |
| 114 |
PYTHON_FULLPATH=$(which python3) |
| 115 |
make install PYTHON=$PYTHON_FULLPATH DESTDIR=$RPM_BUILD_ROOT PREFIX=$RPM_BUILD_ROOT/%{_prefix} MANDIR=%{_mandir} PURE="--rust" |
| 116 |
|
| 117 |
%endif |
| 118 |
|
| 119 |
install -m 755 contrib/chg/chg $RPM_BUILD_ROOT%{_bindir}/ |
| 120 |
install -m 755 contrib/hgk $RPM_BUILD_ROOT%{_bindir}/ |
| 121 |
install -m 755 contrib/hg-ssh $RPM_BUILD_ROOT%{_bindir}/ |
| 122 |
|
| 123 |
mkdir -p $RPM_BUILD_ROOT%{emacs_lispdir} |
| 124 |
install -m 644 contrib/mercurial.el $RPM_BUILD_ROOT%{emacs_lispdir}/ |
| 125 |
install -m 644 contrib/mq.el $RPM_BUILD_ROOT%{emacs_lispdir}/ |
| 126 |
|
| 127 |
mkdir -p $RPM_BUILD_ROOT/%{_sysconfdir}/mercurial/hgrc.d |
| 128 |
|
| 129 |
%clean |
| 130 |
rm -rf $RPM_BUILD_ROOT |
| 131 |
|
| 132 |
%files |
| 133 |
%defattr(-,root,root,-) |
| 134 |
%doc CONTRIBUTORS COPYING doc/README doc/hg*.txt doc/hg*.html *.cgi contrib/*.fcgi contrib/*.wsgi |
| 135 |
%doc %attr(644,root,root) %{_mandir}/man?/hg* |
| 136 |
%doc %attr(644,root,root) contrib/*.svg |
| 137 |
%dir %{_datadir}/emacs/site-lisp/ |
| 138 |
%{_datadir}/emacs/site-lisp/mercurial.el |
| 139 |
%{_datadir}/emacs/site-lisp/mq.el |
| 140 |
%{_bindir}/hg |
| 141 |
%{_bindir}/chg |
| 142 |
%{_bindir}/hgk |
| 143 |
%{_bindir}/hg-ssh |
| 144 |
%dir %{_sysconfdir}/mercurial |
| 145 |
%dir %{_sysconfdir}/mercurial/hgrc.d |
| 146 |
%if "%{?withpython}" |
| 147 |
%{hgpyprefix} |
| 148 |
%else |
| 149 |
%{_libdir}/python%{pythonver}/site-packages/mercurial-*.dist-info/ |
| 150 |
%{_libdir}/python%{pythonver}/site-packages/%{name} |
| 151 |
%{_libdir}/python%{pythonver}/site-packages/hgext |
| 152 |
%{_libdir}/python%{pythonver}/site-packages/hgext3rd |
| 153 |
%{_libdir}/python%{pythonver}/site-packages/hgdemandimport |
| 154 |
/usr/share/bash-completion/completions/hg |
| 155 |
/usr/share/zsh/site-functions/_hg |
| 156 |
%endif |