##
##  perl-ssh.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.
##

#   versions of individual parts
%define       V_perl               5.22
%define       V_net_ssh2           0.73
%define       V_net_ssh            0.09
%define       V_net_ssh_expect     1.09
%define       V_net_scp            0.08
%define       V_net_scp_expect     0.16
%define       V_net_sftp_foreign   1.93
%define       V_net_openssh        0.83

#   package information
Name:         perl-ssh
Summary:      Perl Modules for use with SSH
URL:          http://www.cpan.org/
Vendor:       Perl Community
Packager:     OpenPKG Project
Distribution: OpenPKG Community
Class:        PLUS
Group:        Perl
License:      GPL/Artistic
Version:      %{V_perl}
Release:      20230125

#   list of sources
Source0:      http://www.cpan.org/authors/id/R/RK/RKITOVER/Net-SSH2-%{V_net_ssh2}.tar.gz
Source1:      http://www.cpan.org/authors/id/I/IV/IVAN/Net-SSH-%{V_net_ssh}.tar.gz
Source2:      http://www.cpan.org/authors/id/B/BN/BNEGRAO/Net-SSH-Expect-%{V_net_ssh_expect}.tar.gz
Source3:      http://www.cpan.org/authors/id/I/IV/IVAN/Net-SCP-%{V_net_scp}.tar.gz
Source4:      http://www.cpan.org/authors/id/R/RY/RYBSKEJ/Net-SCP-Expect-%{V_net_scp_expect}.tar.gz
Source5:      http://www.cpan.org/authors/id/S/SA/SALVA/Net-SFTP-Foreign-%{V_net_sftp_foreign}.tar.gz
Source6:      http://www.cpan.org/authors/id/S/SA/SALVA/Net-OpenSSH-%{V_net_openssh}.tar.gz

#   build information
BuildPreReq:  OpenPKG, openpkg >= 20160101, perl >= %{V_perl}, perl-openpkg >= %{V_perl}
PreReq:       OpenPKG, openpkg >= 20160101, perl >= %{V_perl}
BuildPreReq:  perl-sys, perl-term, libssh2
PreReq:       perl-sys, perl-term, libssh2, openssh

%description
    Various Perl modules for use with Secure Shell (SSH):
    - Net::SSH2 (%{V_net_ssh2})
    - Net::SSH (%{V_net_ssh})
    - Net::SSH::Expect (%{V_net_ssh_expect})
    - Net::SCP (%{V_net_scp})
    - Net::SCP::Expect (%{V_net_scp_expect})
    - Net::SFTP::Foreign (%{V_net_sftp_foreign})
    - Net::OpenSSH (%{V_net_openssh})

%track
    prog perl-ssh:Net-SSH2 = {
        version   = %{V_net_ssh2}
        url       = http://www.cpan.org/authors/id/R/RK/RKITOVER/
        regex     = Net-SSH2-(__VER__)\.tar\.gz
    }
    prog perl-ssh:Net-SSH = {
        version   = %{V_net_ssh}
        url       = http://www.cpan.org/authors/id/I/IV/IVAN/
        regex     = Net-SSH-(__VER__)\.tar\.gz
    }
    prog perl-ssh:Net-SSH-Expect = {
        version   = %{V_net_ssh_expect}
        url       = http://www.cpan.org/authors/id/B/BN/BNEGRAO/
        regex     = Net-SSH-Expect-(__VER__)\.tar\.gz
    }
    prog perl-ssh:Net-SCP = {
        version   = %{V_net_scp}
        url       = http://www.cpan.org/authors/id/I/IV/IVAN/
        regex     = Net-SCP-(__VER__)\.tar\.gz
    }
    prog perl-ssh:Net-SCP-Expect = {
        version   = %{V_net_scp_expect}
        url       = http://www.cpan.org/authors/id/R/RY/RYBSKEJ/
        regex     = Net-SCP-Expect-(__VER__)\.tar\.gz
    }
    prog perl-ssh:Net-SFTP-Foreign = {
        version   = %{V_net_sftp_foreign}
        url       = http://www.cpan.org/authors/id/S/SA/SALVA/
        regex     = Net-SFTP-Foreign-(__VER__)\.tar\.gz
    }
    prog perl-ssh:Net-OpenSSH = {
        version   = %{V_net_openssh}
        url       = http://www.cpan.org/authors/id/S/SA/SALVA/
        regex     = Net-OpenSSH-(__VER__)\.tar\.gz
    }

%prep
    %setup -q -c
    %setup -q -T -D -a 1
    %setup -q -T -D -a 2
    %setup -q -T -D -a 3
    %setup -q -T -D -a 4
    %setup -q -T -D -a 5
    %setup -q -T -D -a 6

%build

%install
    %{l_shtool} subst \
        -e 's:inc = \([^$]\)\(.;\):inc = \1%{l_prefix}/include\2:' \
        -e 's:lib = \([^$]\)\(.;\):lib = \1%{l_prefix}/lib\2:' \
        -e 's:-lssh2:-lssh2 -lcrypto -lz -lm:' \
        Net-SSH2-%{V_net_ssh2}/Makefile.PL
    %{l_prefix}/bin/perl-openpkg prepare
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE0} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE1} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE2} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE3} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE4} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE5} configure build install
    %{l_prefix}/bin/perl-openpkg -d %{SOURCE6} 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`

%files -f files

%clean

