# 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

Name:		perl-Data-Section-Simple
Version:	0.07
Release:	27.%{__distinit}%{__distvers}
Summary:	Read data from __DATA__
License:	GPL-1.0-or-later OR Artistic-1.0-Perl
URL:		https://metacpan.org/release/Data-Section-Simple
Source0:	https://cpan.metacpan.org/modules/by-module/Data/Data-Section-Simple-%{version}.tar.gz
BuildArch:	noarch
# Build
BuildRequires:	coreutils
BuildRequires:	findutils
BuildRequires:	make
BuildRequires:	perl-generators
BuildRequires:	perl-interpreter
BuildRequires:	perl(ExtUtils::MakeMaker)
BuildRequires:	perl(warnings)
# Module
BuildRequires:	perl(base)
BuildRequires:	perl(Exporter)
BuildRequires:	perl(strict)
# Test Suite
BuildRequires:	perl(lib)
BuildRequires:	perl(Test::More) >= 0.88
BuildRequires:	perl(Test::Pod) >= 1.41
# Dependencies
%if 0%{?fedora} < 38 && 0%{?rhel} < 10
Requires:	perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
%endif

%description
Data::Section::Simple is a simple module to extract data from the __DATA__
section of the file.

%prep
%setup -q -n Data-Section-Simple-%{version}

%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 RELEASE_TESTING=1

%files
%license LICENSE
%doc Changes README
%{perl_vendorlib}/Data/
%{_mandir}/man3/Data::Section::Simple.3*

%changelog
* Fri Mar 17 2023 Paul Howarth <paul@city-fan.org> - 0.07-27
- Use SPDX-format license tag
- Use %%license unconditionally

* Sat Jun  1 2019 Paul Howarth <paul@city-fan.org> - 0.07-15
- 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.88
  - Drop legacy BuildRoot: and Group: tags

* Mon Aug 15 2016 Paul Howarth <paul@city-fan.org> - 0.07-7
- BR: perl-generators where available
- Simplify find command using -delete

* Thu Aug 28 2014 Paul Howarth <paul@city-fan.org> - 0.07-3
- Use %%license where possible

* Thu Apr 24 2014 Paul Howarth <paul@city-fan.org> - 0.07-1
- Update to 0.07
  - Revert the change in 0.06
- Update patch for building with Test::More < 0.88

* Sat Apr 12 2014 Paul Howarth <paul@city-fan.org> - 0.06-1
- Update to 0.06
  - Fix race condition in a forked environment
    (https://github.com/miyagawa/Data-Section-Simple/pull/4)
- Update patch for building with Test::More < 0.88
- Drop support for old distributions prior to FC-5
  - Drop %%defattr, redundant since rpm 4.4
  - Drop patch for building with ExtUtils::MakeMaker < 6.30

* Tue Jul 16 2013 Paul Howarth <paul@city-fan.org> - 0.05-2
- Perl 5.18 rebuild

* Tue Jun 11 2013 Paul Howarth <paul@city-fan.org> - 0.05-1
- Update to 0.05
  - Use MakeMaker
- Revert to ExtUtils::MakeMaker flow
- Add patch to support building with ExtUtils::MakeMaker < 6.30

* Mon May 20 2013 Paul Howarth <paul@city-fan.org> - 0.04-2
- Use Module::Build::Tiny's new --create_packlist option

* Fri Mar 29 2013 Paul Howarth <paul@city-fan.org> - 0.04-1
- Update to 0.04
  - Do not throw exceptions when there's no template
    (https://github.com/miyagawa/Data-Section-Simple/pull/2)
- URL moved to github
- Source0 moved to MetaCPAN
- Package upstream's new LICENSE file
- Switch to Module::Build::Tiny flow
- Update patch for building with Test::More < 0.88

* Wed Jun 20 2012 Paul Howarth <paul@city-fan.org> - 0.03-3
- BR: perl(base), perl(Cwd), perl(Exporter) and perl(lib)
- Don't need to remove empty directories from the buildroot
- Drop support for old distributions prior to FC-3:
  - Don't need to define %%{perl_vendorlib}
  - Use DESTDIR rather than PERL_INSTALL_ROOT
  - Drop patch supporting building with Perl 5.8.0

* Mon Sep 19 2011 Paul Howarth <paul@city-fan.org> - 0.03-1
- Update to 0.03
  - Noted the use of utf8 pragma
  - Doc typo fixes (Util)

* Wed Aug  3 2011 Paul Howarth <paul@city-fan.org> - 0.02-1
- Initial RPM version