Blob Blame History Raw
%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}

# EL4 & EL5 do not have cvsgraph or enscript.. yet
%if 0%{?rhel}
%define with_cvsgraph_enscript 0
%else
%define with_cvsgraph_enscript 1
%endif

# EL4 has a subversion that does not meet the minimum reqs for subversion
%if 0%{?rhel} && "%rhel" < "5"
%define with_subversion 0
%else
%define with_subversion 1
%endif


Name:           viewvc
Version:        1.0.7
Release:        1%{?dist}
Summary:        Browser interface for CVS and SVN version control repositories

Group:          Development/Tools
License:        BSD
URL:            http://www.viewvc.org/
Source0:        http://www.viewvc.org/%{name}-%{version}.tar.gz
Source1:        viewvc.conf
Patch0:         viewvc-temp-location.patch
BuildRoot:      %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)

Obsoletes:      %{name}-selinux < 1.0.3-13
Conflicts:      selinux-policy < 2.5.10-2

BuildArch:      noarch
BuildRequires:  python-devel >= 2.0
Requires:       mod_python, rcs, diffutils
%if 0%{with_subversion}
Requires:       subversion >= 1.2
%endif
%if 0%{with_cvsgraph_enscript}
Requires:       enscript, cvsgraph
%endif

%description
ViewVC is a browser interface for CVS and Subversion version control
repositories. It generates templatized HTML to present navigable directory,
revision, and change log listings. It can display specific versions of files
as well as diffs between those versions. Basically, ViewVC provides the bulk
of the report-like functionality you expect out of your version control tool,
but much more prettily than the average textual command-line program output.

%if 0%{!?with_subversion}
This version only supports CVS repositories.
%endif

%prep
%setup -q
%patch0 -p0 -b .temp-location

%build

%install
%{__rm} -rf %{buildroot}
%{__python} viewvc-install --destdir="%{buildroot}" --prefix="%{python_sitelib}/viewvc"

# Remove unneeded files
%{__rm} -f %{buildroot}%{python_sitelib}/viewvc/bin/mod_python/.htaccess

# Move non-python to /usr/share
%{__mkdir} -p %{buildroot}%{_datadir}/viewvc
%{__mv} %{buildroot}%{python_sitelib}/viewvc/templates %{buildroot}%{_datadir}/viewvc

# Fix python files shebang and CONF_PATHNAME
%{__perl} -pi \
  -e 's|/usr/local/bin/python|%{_bindir}/python|g;' \
  -e 's|\s*/usr/bin/env python|%{_bindir}/python|g;' \
  -e 's|CONF_PATHNAME =.*|CONF_PATHNAME = r"%{_sysconfdir}/viewvc/viewvc.conf"|g;' \
  $(find %{buildroot}%{python_sitelib}/viewvc/ -type f)

# Set mode 755 on executable scripts
%{__grep} -rl '^#!' %{buildroot}%{python_sitelib}/viewvc | xargs %{__chmod} 0755

# Fix paths in configuration
%{__perl} -pi \
  -e 's|templates/|%{_datadir}/viewvc/templates/|g;' \
  -e 's|^template_dir = .*|template_dir = %{_datadir}/viewvc/templates|g;' \
  -e 's|^#docroot = .*|docroot = /viewvc-static|;' \
  -e 's|^cvsgraph_conf = .*|cvsgraph_conf = %{_sysconfdir}/viewvc/cvsgraph.conf|;' \
  %{buildroot}%{python_sitelib}/viewvc/viewvc.conf

%if 0%{with_cvsgraph_enscript}
%{__perl} -pi \
  -e 's|^use_cvsgraph = .*|use_cvsgraph = 1|;' \
  -e 's|^use_enscript = .*|use_enscript = 1|;' \
  %{buildroot}%{python_sitelib}/viewvc/viewvc.conf
%endif

# Install config to sysconf directory
%{__install} -Dp -m0644 %{buildroot}%{python_sitelib}/viewvc/viewvc.conf %{buildroot}%{_sysconfdir}/viewvc/viewvc.conf
%{__rm} -f %{buildroot}%{python_sitelib}/viewvc/viewvc.conf
%{__install} -Dp -m0644 %{buildroot}%{python_sitelib}/viewvc/cvsgraph.conf %{buildroot}%{_sysconfdir}/viewvc/cvsgraph.conf
%{__rm} -f %{buildroot}%{python_sitelib}/viewvc/cvsgraph.conf

# Install Apache configuration
%{__sed} -e s,__datadir__,%{_datadir}, \
         -e s,__python_sitelib__,%{python_sitelib}, %{SOURCE1} > viewvc.conf
%{__install} -Dp -m0644 viewvc.conf %{buildroot}/etc/httpd/conf.d/viewvc.conf

# mod_python files mustn't be executable since they don't have shebang
# make rpmlint happy!
%{__chmod} 0644 %{buildroot}%{python_sitelib}/viewvc/bin/mod_python/*.py

# Rename viewvc.py to viewvc-mp.py for mod_python to avoid import cycle errors
%{__mv} %{buildroot}%{python_sitelib}/viewvc/bin/mod_python/viewvc.py \
        %{buildroot}%{python_sitelib}/viewvc/bin/mod_python/viewvc-mp.py

# Kill patch backup file
%{__rm} -f %{buildroot}%{python_sitelib}/viewvc/lib/viewvc.py.temp-location

# Make spool directory for temp files
%{__mkdir} -p %{buildroot}%{_localstatedir}/spool/viewvc

%clean
%{__rm} -rf %{buildroot}

%files
%defattr(-, root, root, -)
%doc CHANGES README INSTALL TODO COMMITTERS LICENSE.html docs
%config(noreplace) %{_sysconfdir}/viewvc
%config(noreplace) %{_sysconfdir}/httpd/conf.d/viewvc.conf
%{python_sitelib}/*
%{_datadir}/*
%attr(0700,apache,apache) %{_localstatedir}/spool/viewvc

%changelog
* Wed Oct 15 2008 Bojan Smojver <bojan@rexursive.com> - 1.0.7-1
- Bump up to 1.0.7

* Fri Sep 19 2008 Bojan Smojver <bojan@rexursive.com> - 1.0.6-1
- Bump up to 1.0.6

* Fri Feb 29 2008 Bojan Smojver <bojan@rexursive.com> - 1.0.5-1
- Bump up to 1.0.5

* Sun Jun  3 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.4-2
- Avoid import cycle errors (temporary fix)

* Tue May 15 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.4-1
- Bump up to 1.0.4

* Wed Mar 28 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-13
- Supply obsoletes/conflicts
  (suggestions by Peter Gordon, Bernard Johnson and Ville Skyttä)

* Thu Mar 22 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-12
- Drop selinux package, required context now in official policy

* Fri Mar 09 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-11
- Bump for tag

* Tue Mar 06 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-10
- Enable enscript only when available

* Tue Mar 06 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-9
- Enable cvsgraph

* Sun Mar 04 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-8
- EPEL support patch by Bernard Johnson

* Sat Mar 03 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-7
- Incorporate suggestions from package review process by Bernard Johnson

* Sat Mar 03 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-6
- Use restorecon instead of chcon

* Fri Mar 02 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-5
- SELinux integration

* Fri Mar 02 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-4
- Incorporate suggestions from package review process by Bernard Johnson

* Fri Mar 02 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-3
- Move non-python files out of %%{python_sitelib}

* Thu Mar 01 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-2
- Incorporate suggestions from package review process by Bernard Johnson

* Thu Mar 01 2007 Bojan Smojver <bojan@rexursive.com> - 1.0.3-1
- Initial release, 1.0.3
- Based on package provided by Dag Wieers