##
##  svnweb.spec -- OpenPKG RPM Package Specification
##  Copyright (c) 2000-2025 OpenPKG Project <http://openpkg.org/>
##
##  Permission to use, copy, modify, and distribute this software for
##  any purpose with or without fee is hereby granted, provided that
##  the above copyright notice and this permission notice appear in all
##  copies.
##
##  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
##  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
##  MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
##  IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
##  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
##  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
##  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
##  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
##  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
##  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
##  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
##  SUCH DAMAGE.
##

#   package information
Name:         svnweb
Summary:      Subversion Repository Viewer
URL:          http://search.cpan.org/~nikc/SVN-Web/
Vendor:       Chia-liang Kao, Nik Clayton et al.
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        EVAL
Group:        SCM
License:      Artistic/GPL
Version:      0.53
Release:      20100725

#   list of sources
Source0:      http://www.cpan.org/authors/id/N/NI/NIKC/SVN-Web-%{version}.tar.gz
Source1:      svnweb-apache.conf
Source2:      svnweb.yaml
Patch0:       svnweb.patch

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, perl-openpkg
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  perl, perl-parse, perl-text, perl-mail, perl-locale, perl-time, perl-util, perl-ds, perl-www, perl-template
PreReq:       perl, perl-parse, perl-text, perl-mail, perl-locale, perl-time, perl-util, perl-ds, perl-www, perl-template
BuildPreReq:  yaml, yaml::with_perl = yes
PreReq:       yaml, yaml::with_perl = yes
BuildPreReq:  subversion, subversion-perl
PreReq:       subversion, subversion-perl
PreReq:       apache, apache-perl, apache-apreq, apache-apreq::with_perl = yes

%description
    SVN::Web provides a full-featured and theme-able Web interface to
    local or remote Subversion (SVN) repositories.

%track
    prog svnweb = {
        version   = %{version}
        url       = http://search.cpan.org/~nikc/SVN-Web/
        regex     = SVN-Web-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -n SVN-Web-%{version}
    chmod a+rw Build.PL
    %patch -p0

%build

%install
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/etc/svnweb \
        $RPM_BUILD_ROOT%{l_prefix}/etc/apache/apache.d
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE svnweb.yaml} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/svnweb/config.yaml
    %{l_shtool} install -c -m 644 %{l_value -s -a} \
        %{SOURCE svnweb-apache.conf} \
        $RPM_BUILD_ROOT%{l_prefix}/etc/apache/apache.d/svnweb.conf
    %{l_prefix}/bin/perl-openpkg prepare
    %{l_prefix}/bin/perl-openpkg configure \
        -A --norun_apache_tests \
        -A --norun_apache_cgi_tests \
        -A --norun_svnweb-server_tests \
        -A --skip_questions
    %{l_prefix}/bin/perl-openpkg configure build install
    %{l_prefix}/bin/perl-openpkg -F perl-openpkg-files fixate cleanup
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT \
        %{l_files_std} \
        `cat perl-openpkg-files` \
        '%config %{l_prefix}/etc/svnweb/*' \
        '%config %{l_prefix}/etc/apache/apache.d/*'

%files -f files

%clean

%post
    #   after upgrade, restart service
    [ $1 -eq 2 ] || exit 0
    eval `%{l_rc} apache status 2>/dev/null`
    [ ".$apache_active" = .yes ] && %{l_rc} apache restart
    exit 0

