File mercurial.spec of Package mercurial
#
# spec file for package mercurial
#
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via http://bugs.opensuse.org/
#
# norootforbuild
%{!?python_sitelib: %global python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")}
%{!?python_sitearch: %global python_sitearch %(%{__python} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1))")}
%if 0%{?suse_version} >= 1100 && !0%{?sles_version}
%define with_doc 1
%endif
%if 0%{?suse_version} >= 1110
%define with_lang 1
%endif
Name: mercurial
BuildRequires: gcc python-devel python-xml
%if 0%{?with_doc}
BuildRequires: asciidoc docutils sgml-skel xmlto
%endif
BuildRequires: perl
%if 0%{?suse_version} > 1020
BuildRequires: fdupes
%endif
Summary: Scalable Distributed SCM
Version: 1.7.5
Release: 1
License: GPLv2+
Group: Development/Tools/Version Control
BuildRoot: %{_tmppath}/%{name}-%{version}-build
Url: http://www.selenic.com/mercurial/
# http://mercurial.selenic.com/release/mercurial-%{version}.tar.gz
%if 0%{?suse_version} > 1110 || 0%{?fedora} || 0%{?mdkversion} > 200910 || 0%{?rhel_version} >= 600
Source: %{name}-%{version}.tar.xz
BuildRequires: xz
%else
Source: %{name}-%{version}.tar.bz2
%endif
Source1: cacerts.rc
Source99: rpmlintrc
Patch: mercurial-hgk-path-fix.diff
Patch1: mercurial-sle10-inotify-fixes.diff
Patch2: mercurial-docutils-compat.diff
# hgext/hgcia needs python-xml
Requires: python-xml
# require rcs for 3-way "merge" command.
Requires: rcs
%if 0%{?suse_version} >= 1130
Requires: ca-certificates
%endif
%if 0%{?with_lang}
Recommends: %{name}-lang
%endif
%py_requires
%description
Mercurial is a fast, lightweight source control management system
designed for efficient handling of very large distributed projects.
%lang_package
%prep
%setup -q
# %setup -n %{name}-%{version}-mq
# set version number manually (for snapshot only)
# sed -e s"/^version = ''$/version = '"%{version}"'/" setup.py > foo.py
# mv foo.py setup.py
%patch
%patch1 -p1
# mercurial uses new docutils options not available on 11.1 and older
# this makes it possible to "build"
%if 0%{?suse_version} <= 1110
%patch2 -p0
%endif
%build
%__make \
build \
%if 0%{?with_doc}
doc \
%endif
PREFIX="%{_prefix}"
%install
%__python setup.py install --prefix=%{_prefix} --root="$RPM_BUILD_ROOT" \
--record-rpm=files.lst
%if 0%{?with_doc}
%__make -C doc DESTDIR="%{buildroot}" PREFIX="%{_prefix}" install
%else
pushd doc
for f in hg.1 hgrc.5 hgignore.5 ; do
%__gzip $f && f=$f.gz
ff="${f##*/}"
n="${ff%.gz}"
n="${n##*.}"
%__install -D -m0644 "$f" "%{buildroot}%{_mandir}/man$n/$ff"
done
popd
%endif
# install stuff in contrib
install -c -m 0755 contrib/hgk $RPM_BUILD_ROOT%{_bindir}
install -c -m 0755 contrib/convert-repo $RPM_BUILD_ROOT%{_bindir}
install -c -m 0755 contrib/shrink-revlog.py $RPM_BUILD_ROOT%{_bindir}
%__python -c 'import compileall; compileall.compile_dir("%{buildroot}%{python_sitearch}/",ddir="%{python_sitearch}/",force=True)'
mkdir -p $RPM_BUILD_ROOT/etc/bash_completion.d
install -c -m 0644 contrib/bash_completion $RPM_BUILD_ROOT/etc/bash_completion.d/mercurial.sh
mkdir -p $RPM_BUILD_ROOT%{_datadir}/zsh/site-functions
install -c -m 0644 contrib/zsh_completion $RPM_BUILD_ROOT%{_datadir}/zsh/site-functions/_mercurial
mkdir -p $RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp
install -c -m 0644 contrib/*.el $RPM_BUILD_ROOT%{_datadir}/emacs/site-lisp
mkdir -p $RPM_BUILD_ROOT%{_datadir}/xemacs/site-lisp
install -c -m 0644 contrib/*.el $RPM_BUILD_ROOT%{_datadir}/xemacs/site-lisp
mkdir -p $RPM_BUILD_ROOT/etc/mercurial/hgrc.d
install -c -m 0644 contrib/mergetools.hgrc $RPM_BUILD_ROOT%{_sysconfdir}/mercurial/hgrc.d/mergetools.rc
%if 0%{?suse_version} >= 1130
install -c -m 0644 %{SOURCE1} $RPM_BUILD_ROOT%{_sysconfdir}/mercurial/hgrc.d/cacerts.rc
%endif
%if 0%{?suse_version} > 1020
%fdupes -s "%{buildroot}%{_datadir}"
%fdupes -s "%{buildroot}%{_libdir}"
%endif
chmod 644 $RPM_BUILD_DIR/%{name}-%{version}/hgweb.cgi
if [ "%{python_sitelib}" != "%{python_sitearch}" ]; then
%__install -d "%{buildroot}%{python_sitelib}/mercurial"
%__mv "%{buildroot}%{python_sitearch}/mercurial/locale" \
"%{buildroot}%{python_sitelib}/mercurial/locale"
fi
%__perl -n -i -e 'print unless m,/mercurial/locale(/?|/.+)$,' files.lst
LANGFILES="$PWD/%{name}.lang"
>"$LANGFILES"
pushd "%{buildroot}%{python_sitelib}/mercurial/locale"
/bin/ls -1 | while read lang; do
echo "%lang($lang) %{python_sitelib}/mercurial/locale/$lang" >>"$LANGFILES"
done
popd #%python_sitelib/mercurial/locale
%if ! 0%{?with_lang}
%__mv files.lst files.lst.orig
cat files.lst.orig "%{name}.lang" > files.lst
%__rm files.lst.orig
%endif
%clean
%{?buildroot:%__rm -rf "%{buildroot}"}
%files -f files.lst
%defattr(-, root, root)
%doc README CONTRIBUTORS COPYING hgweb.cgi
%doc contrib/sample.hgrc
%{_bindir}/*
/etc/bash_completion.d/*
%{_datadir}/zsh/
%dir /etc/mercurial
%dir /etc/mercurial/hgrc.d
%config /etc/mercurial/hgrc.d/*
%{_datadir}/emacs
%{_datadir}/xemacs
%{_mandir}/man1/hg.1%{ext_man}
%{_mandir}/man5/hgignore.5%{ext_man}
%{_mandir}/man5/hgrc.5%{ext_man}
%if 0%{?with_lang}
%files lang -f %{name}.lang
%defattr(-, root, root)
%endif
%dir %{python_sitelib}/mercurial
%dir %{python_sitelib}/mercurial/locale
%changelog