##
##  subversion-cvs.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 version
%define       V_subversion  1.6.12
%define       V_cvs2svn     2.3.0
%define       V_svn2cvs     20080504

#   package information
Name:         subversion-cvs
Summary:      Subversion Source Revision Control System (CVS Migration Tools)
URL:          http://subversion.apache.org/
Vendor:       Apache Software Foundation
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        BASE
Group:        SCM
License:      Apache/BSD
Version:      %{V_subversion}
Release:      20100725

#   list of sources
Source0:      http://download.openpkg.org/components/versioned/subversion/cvs2svn-%{V_cvs2svn}.tar.gz
Source1:      http://download.openpkg.org/components/versioned/subversion/svn2cvs.pl-%{V_svn2cvs}

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101
PreReq:       OpenPKG, openpkg >= 20160101
BuildPreReq:  perl
PreReq:       perl, perl-xml
BuildPreReq:  python
PreReq:       python, python::with_dbm = yes
PreReq:       cvs, rcs

%description
    This package provides CVS migration tools for Subversion.

%track
    prog subversion-cvs:cvs2svn = {
        version   = %{V_cvs2svn}
        url       = http://download.openpkg.org/components/versioned/subversion/
        regex     = cvs2svn-(__VER__)\.tar\.gz
    }
    prog subversion-cvs:svn2cvs = {
        version   = %{V_svn2cvs}
        url       = http://download.openpkg.org/components/versioned/subversion/
        regex     = svn2cvs.pl-(__VER__)
    }

%prep
    %setup -q -c
    cp %{SOURCE svn2cvs.pl-%{V_svn2cvs}} svn2cvs.pl

%build

%install
    #   create installation hierarchy
    %{l_shtool} mkdir -f -p -m 755 \
        $RPM_BUILD_ROOT%{l_prefix}/bin \
        $RPM_BUILD_ROOT%{l_prefix}/man/man1

    #   install cvs2svn(1) tool
    ( cd cvs2svn-%{V_cvs2svn}
      %{l_shtool} mkdir -f -p -m 755 \
          $RPM_BUILD_ROOT%{l_prefix}/libexec/subversion/cvs2svn/cvs2svn_rcsparse \
          $RPM_BUILD_ROOT%{l_prefix}/libexec/subversion/cvs2svn/cvs2svn_lib
      ( echo "#!/bin/sh"
        echo "PYTHONPATH=\"%{l_prefix}/libexec/subversion/cvs2svn\""
        echo "export PYTHONPATH"
        echo "%{l_prefix}/bin/python %{l_prefix}/libexec/subversion/cvs2svn/cvs2svn \${1+\"\$@\"}"
      ) >cvs2svn.sh
      %{l_shtool} install -c -m 755 \
          cvs2svn.sh $RPM_BUILD_ROOT%{l_prefix}/bin/cvs2svn
      %{l_shtool} install -c -m 644 \
          cvs2svn.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/
      %{l_shtool} install -c -m 644 \
          cvs2svn $RPM_BUILD_ROOT%{l_prefix}/libexec/subversion/cvs2svn/
      %{l_shtool} install -c -m 644 \
          cvs2svn_rcsparse/*.py \
          $RPM_BUILD_ROOT%{l_prefix}/libexec/subversion/cvs2svn/cvs2svn_rcsparse/
      %{l_shtool} install -c -m 644 \
          cvs2svn_lib/*.py \
          $RPM_BUILD_ROOT%{l_prefix}/libexec/subversion/cvs2svn/cvs2svn_lib/
    ) || exit $?

    #   install svn2cvs(1) tool
    %{l_shtool} install -c -m 755 \
        -e 's;#!/usr/bin/perl;#!%{l_prefix}/bin/perl;' \
        svn2cvs.pl $RPM_BUILD_ROOT%{l_prefix}/bin/svn2cvs
    %{l_prefix}/bin/pod2man svn2cvs.pl >svn2cvs.1
    %{l_shtool} install -c -m 644 \
        svn2cvs.1 $RPM_BUILD_ROOT%{l_prefix}/man/man1/svn2cvs.1

    #   determine installation files
    %{l_rpmtool} files -v -ofiles -r$RPM_BUILD_ROOT %{l_files_std}

%files -f files

%clean

