# Detect the distribution in use
%global __despace head -n 1 | tr -d '[:space:]' | sed -e 's/[(].*[)]//g'
%global __lower4 cut -c 1-4 | tr '[:upper:]' '[:lower:]'
%global __distfile %([ -f /etc/SuSE-release ] && echo /etc/SuSE-release || echo /etc/redhat-release)
%global __distinit %(sed -e 's/ release .*//' -e 's/\\([A-Za-z]\\)[^ ]*/\\1/g' %{__distfile} | %{__despace} | %{__lower4})
%global __distvers %(sed -e 's/.* release \\([^. ]*\\).*/\\1/' %{__distfile} | %{__despace})
# Identify Alma, CentOS, CentOS Stream and Rocky Linux as rhel
%if "%{__distinit}" == "a" || "%{__distinit}" == "c" || "%{__distinit}" == "cl" || "%{__distinit}" == "cs" || "%{__distinit}" == "rl"
%global __distinit rhel
%endif
# Dist tag for Fedora is still "fc"
%if "%{__distinit}" == "f"
%global __distinit fc
%endif

# We don't really need ExtUtils::MakeMaker ≥ 6.64
%global old_eumm %(perl -MExtUtils::MakeMaker -e 'print (($ExtUtils::MakeMaker::VERSION < 6.64) ? 1 : 0);' 2>/dev/null || echo 0)

Name:		perl-Devel-CheckBin
Version:	0.04
Release:	23.%{__distinit}%{__distvers}
Summary:	Check that a command is available
License:	GPL-1.0-or-later OR Artistic-1.0-Perl
URL:		https://metacpan.org/release/Devel-CheckBin
Source0:	https://cpan.metacpan.org/modules/by-module/Devel/Devel-CheckBin-%{version}.tar.gz
Patch0:		Devel-CheckBin-0.04-old-EU::MM.patch
BuildArch:	noarch
# Module Build
BuildRequires:	coreutils
BuildRequires:	findutils
BuildRequires:	make
BuildRequires:	perl-generators
BuildRequires:	perl-interpreter
# Module Runtime
BuildRequires:	perl(Config)
BuildRequires:	perl(Exporter)
BuildRequires:	perl(ExtUtils::MakeMaker)
BuildRequires:	perl(File::Spec)
BuildRequires:	perl(parent)
BuildRequires:	perl(strict)
BuildRequires:	perl(warnings)
# Test Suite
BuildRequires:	perl(File::Temp)
BuildRequires:	perl(Test::More) >= 0.98
# Runtime
%if 0%{?fedora} < 38 && 0%{?rhel} < 10
Requires:	perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
%endif

%description
Devel::CheckBin is a perl module that checks whether a particular command is
available.

%prep
%setup -q -n Devel-CheckBin-%{version}

# We don't really need ExtUtils::MakeMaker ≥ 6.64
%if %{old_eumm}
%patch0
%endif

%build
perl Makefile.PL INSTALLDIRS=vendor
make %{?_smp_mflags}

%install
make pure_install DESTDIR=%{buildroot}
find %{buildroot} -type f -name .packlist -delete
%{_fixperms} -c %{buildroot}

%check
make test

%files
%license LICENSE
%doc Changes README.md
%{perl_vendorlib}/Devel/
%{_mandir}/man3/Devel::CheckBin.3*

%changelog
* Tue Mar 28 2023 Paul Howarth <paul@city-fan.org> - 0.04-23
- Use SPDX-format license tag
- Use %%license unconditionally

* Fri May 31 2019 Paul Howarth <paul@city-fan.org> - 0.04-11
- Modernize spec
  - Switch upstream from search.cpan.org to metacpan.org
  - BR: perl-generators unconditionally
  - BR: perl-interpreter rather than perl
  - Don't explicitly clean buildroot in %%install section
  - Drop explicit %%clean section
  - Drop support for building with Test::More < 0.98
  - Drop legacy BuildRoot: and Group: tags

* Wed Aug 17 2016 Paul Howarth <paul@city-fan.org> - 0.04-3
- BR: perl-generators where available
- Simplify find command using -delete

* Wed Jul 22 2015 Paul Howarth <paul@city-fan.org> - 0.04-1
- Update to 0.04
  - Use 'find' rather than 'ls' as test command on Win32
  - Fix test to handle paths with spaces
- Add patch to support building with ExtUtils::MakeMaker < 6.64
- Update patch for building with Test::More < 0.96

* Sat Jun 13 2015 Paul Howarth <paul@city-fan.org> - 0.03-2
- Perl 5.22 rebuild

* Thu Apr 30 2015 Paul Howarth <paul@city-fan.org> - 0.03-1
- Update to 0.03
  - Re-packaging with EU::MM

* Fri Aug 15 2014 Paul Howarth <paul@city-fan.org> - 0.02-1
- Initial RPM version