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.3
Release:        10%{?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)

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

%package selinux
Summary:          SElinux file contexts for ViewVC
Group:            Development/Tools
Requires:         %{name} = %{version}-%{release}
Requires(post):   policycoreutils
Requires(postun): policycoreutils

%description selinux
SELinux file contexts for ViewVC

%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 \
           viewvc.org/.cvsignore

# 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

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

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

%post selinux
# Set SELinux file context in the policy
/usr/sbin/semanage fcontext -a -t httpd_sys_script_rw_t '%{_localstatedir}/spool/viewvc(/.*)?' 2>/dev/null || :
# Actually change the context
/sbin/restorecon -R %{_localstatedir}/spool/viewvc || :

%postun selinux
# SELinux support
if [ $1 -eq 0 ]; then  # final removal
  /usr/sbin/semanage fcontext -d -t httpd_sys_script_rw_t '%{_localstatedir}/spool/viewvc(/.*)?' 2>/dev/null || :
fi

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

%files selinux

%changelog
* 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