# 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

# This module usually ships with version numbers having two digits after the decimal point
%global cpan_version 1.994
%global rpm_version 1.99.4

Summary:	Test file attributes through Test::Builder
Name:		perl-Test-File
Version:	%{rpm_version}
Release:	1.%{__distinit}%{__distvers}
License:	Artistic-2.0
URL:		https://metacpan.org/release/Test-File
Source0:	https://cpan.metacpan.org/modules/by-module/Test/Test-File-%{cpan_version}.tar.gz
BuildArch:	noarch
# Module Build
BuildRequires:	coreutils
BuildRequires:	findutils
BuildRequires:	make
BuildRequires:	perl-generators
BuildRequires:	perl-interpreter
BuildRequires:	perl(ExtUtils::MakeMaker) >= 6.64
BuildRequires:	perl(ExtUtils::Manifest) >= 1.21
# Module Runtime
BuildRequires:	perl(Carp)
BuildRequires:	perl(Exporter)
BuildRequires:	perl(File::Spec)
BuildRequires:	perl(strict)
BuildRequires:	perl(Test::Builder)
BuildRequires:	perl(warnings)
BuildRequires:	perl(XSLoader)
# Test Suite
BuildRequires:	perl(Config)
BuildRequires:	perl(Cwd)
BuildRequires:	perl(File::Spec::Functions)
BuildRequires:	perl(Test::Builder) >= 1.001006
BuildRequires:	perl(Test::Builder::Tester)
BuildRequires:	perl(Test::More) >= 1
BuildRequires:	perl(utf8)
# Optional Tests
BuildRequires:	perl(Test::Pod) >= 1.00
BuildRequires:	perl(Test::Pod::Coverage) >= 1.00
# Dependencies
%if 0%{?fedora} < 38 && 0%{?rhel} < 10
Requires:	perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
%endif

%description
This module provides a collection of test utilities for file attributes.

Some file attributes depend on the owner of the process testing the file
in the same way the file test operators do.

%prep
%setup -q -n Test-File-%{cpan_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

%files
%license LICENSE
%doc Changes README.pod SECURITY.md
%{perl_vendorlib}/Test/
%{_mandir}/man3/Test::File.3*

%changelog
* Fri Jan  3 2025 Paul Howarth <paul@city-fan.org> - 1.99.4-1
- Update to 1.994
  - Refresh distro and move to BRIANDFOY
- Package new file SECURITY.md

* Tue Aug  8 2023 Paul Howarth <paul@city-fan.org> - 1.99.3-4
- Fix FTBFS in Rawhide due to %%rpmversion macro becoming an rpm built-in
  (rhbz#2229872)

* Wed Jul 19 2023 Paul Howarth <paul@city-fan.org> - 1.99.3-2
- Drop MODULE_COMPAT dependency from Fedora 38 onwards

* Mon Jan  2 2023 Paul Howarth <paul@city-fan.org> - 1.99.3-1
- Update to 1.993
  - Try harder to check for symlinks on Windows by stealing some code from
    Win32:: (GH#36)
- Use SPDX-format license tag

* Wed Feb 16 2022 Paul Howarth <paul@city-fan.org> - 1.99.2-1
- Update to 1.992
  - Fix race condition in tests for mtime (GH#29)

* Fri Jan 21 2022 Paul Howarth <paul@city-fan.org> - 1.99.1-1
- Update to 1.991
  - Enforce text files in some functions, as warned in GH#18
  - Change up some diag messages:
    - Lowercase first letter
    - Not ! at end
    - Use "file" instead of "filename"
    If you were matching on those, you may need to update your patterns

* Fri Mar  5 2021 Paul Howarth <paul@city-fan.org> - 1.44.8-1
- Update to 1.448
  - Try handling all-numeric user and group names (GH#26)

* Thu Feb 25 2021 Paul Howarth <paul@city-fan.org> - 1.44.7-1
- Update to 1.447
  - Trying harder to get the tests to pass on Cygwin

* Sun Feb 21 2021 Paul Howarth <paul@city-fan.org> - 1.44.6-1
- Update to 1.446
  - Better Cygwin detection

* Tue Feb 16 2021 Paul Howarth <paul@city-fan.org> - 1.44.5-1
- Update to 1.445
  - Get the tests to pass under Cygwin (GH#17)

* Wed Jan  6 2021 Paul Howarth <paul@city-fan.org> - 1.44.4-1
- Update to 1.444
  - Change the file_writeable_ok tests to file_writable_ok, which is the
    correct spelling; the old names work but now warn to use the new name
  - Some updates to refresh the tests
  - Start mirroring Test2::Tools::File so we support the same names
  - Deprecated directories in tests appropriate for only plain files; it's a
    diag() message now but will be a test failure later
  - Merge some test additions from Desmond Daignault (GH#20)
  - Remove Travis, add GitHub actions
  - Add file_is_symlink_not_ok
- License changed to Artistic 2.0
- Drop workaround for building with ExtUtils::MakeMaker < 6.64
- Use %%license unconditionally

* Fri Jun  7 2019 Paul Howarth <paul@city-fan.org> - 1.44.3-8
- Perl 5.30 rebuild

* Tue Apr 10 2018 Paul Howarth <paul@city-fan.org> - 1.44.3-4
- BR: perl-generators unconditionally
- BR: perl-interpreter rather than perl

* Mon Apr 17 2017 Paul Howarth <paul@city-fan.org> - 1.44.3-1
- Update to 1.443
  - Found another relative path require issue:
    http://blogs.perl.org/users/ryan_voots/2017/04/trials-and-troubles-with-changing-inc.html
  - This is another attempt at avoiding failures from the v5.26 removal of . from @INC
- Drop support for EOL distributions prior to F-13
  - Drop BuildRoot: and Group: tags
  - Drop explicit buildroot cleaning in %%install section
  - Drop explicit %%clean section
  - Drop workaround for building with Test::More < 1.001006

* Fri Sep 23 2016 Paul Howarth <paul@city-fan.org> - 1.44.2-1
- Update to 1.442
  - Fix for missing . in @INC; this relates to CVE-2016-1238
    (https://github.com/briandfoy/test-file/issues/14)
- Split rpm and upstream versioning

* Tue Aug  2 2016 Paul Howarth <paul@city-fan.org> - 1.44-3
- BR: perl-generators where available
- Avoid installing README.pod with old ExtUtils::MakeMaker versions
- Simplify find command using -delete

* Mon Jul  6 2015 Paul Howarth <paul@city-fan.org> - 1.44-1
- Update to 1.44
  - check file_mode_has tests for Windows
  - Fix file_has_* tests to work on Windows (GH#13)

* Tue Jun 23 2015 Paul Howarth <paul@city-fan.org> - 1.43-1
- Update to 1.43
  - Fix problem with META* specifying requirements (CPAN RT#105210)
  - Don't install README.pod
- Avoid the Test::Prereq test, which erroneously moans about Test::utf8
- Avoid installation of bogus Test::README manpage with old EU::MM versions

* Wed Sep 24 2014 Paul Howarth <paul@city-fan.org> - 1.41-1
- Update to 1.41
  - Uncomment accidentally commented symlink_target_is_absolute_ok
  - Add mtime test functions (GH#8)
  - Allow tests to run in parallel (CPAN RT#89908, CPAN RT#91862)
  - Fix up tests for UTF-8 checks
- This release by BDFOY → update source URL
- Stop trying to patch in support for building with old Test::Builder versions
  and bundle a sufficiently up to date version instead (just for testing)
- Classify buildreqs by usage

* Mon Sep  1 2014 Paul Howarth <paul@city-fan.org> - 1.36-3
- Drop %%defattr, redundant since rpm 4.4
- Use %%license where possible

* Thu Jan  2 2014 Paul Howarth <paul@city-fan.org> - 1.36-1
- Update to 1.36
  - Fix bad line counts on latest dev version of Perl (CPAN RT#89849)
- Update patches for building with old Test::Builder versions

* Thu Oct 10 2013 Paul Howarth <paul@city-fan.org> - 1.35-1
- Update to 1.35
  - Don't distribute MYMETA.* (CPAN RT#89175)
  - Add dir_exists_ok and dir_contains_ok
  - Add file_contains_* functions
- Update patches for building with old Test::Builder versions
- Update patches for building with old Test::More versions
- Add new patch for building with ExtUtils::MakeMaker < 6.48

* Tue Jul 24 2012 Paul Howarth <paul@city-fan.org> - 1.34-3
- BR: perl(ExtUtils::MakeMaker) and perl(Test::More)
- BR: at least version 1.21 of perl(Test::Manifest)
- BR: at least version 1.00 of perl(Test::Pod)
- No need to explicitly require perl(Exporter)

* Mon Jul  2 2012 Paul Howarth <paul@city-fan.org> - 1.34-2
- Perl 5.16 rebuild

* Sun Jun  3 2012 Paul Howarth <paul@city-fan.org> - 1.34-1
- Update to 1.34
  - Fixed problem in links.t (CPAN RT#76853)
- Don't need to remove empty directories from buildroot
- Drop support for old distributions prior to FC-3:
  - Don't need to define %%{perl_vendorlib}
  - Use DESTDIR rather than PERL_INSTALL_ROOT

* Mon Feb 20 2012 Paul Howarth <paul@city-fan.org> - 1.33-1
- Update to 1.33
  - Fixed problem in MANIFEST file (CPAN RT#37676)

* Sat Feb 18 2012 Paul Howarth <paul@city-fan.org> - 1.32-1
- Update to 1.32
  - Fixed qr//mx patterns to work with older Perls (CPAN RT#74365)
  - Fixed incorrect spelling of "privileges" in SKIP blocks (CPAN RT#74483)
  - Skip testing of symlinks on Windows (CPAN RT#57682)
  - Fixed automatically generated test name for owner_isnt (CPAN RT#37676)
- Drop upstreamed patch for CPAN RT#74365
- Add buildreqs for Perl core modules that might be dual-lived
- Update patches for building with old Test::Builder versions

* Wed Jan 25 2012 Paul Howarth <paul@city-fan.org> - 1.31-1
- Update to 1.31
  - Added some SKIP blocks to avoid test failures when running as root
- Remove guard code preventing package build as root, now that it works

* Mon Jan 23 2012 Paul Howarth <paul@city-fan.org> - 1.30-1
- Update to 1.30
  - Added dir_exists_ok and dir_contains_ok
  - Added file_contains_like and file_contains_unlike
  - Fixed a few grammatical errors in POD
- This release by BAREFOOT -> update source URL
- Add patch to support building with Test::More < 0.88
- Drop buildreq perl(Test::Prereq) since t/prereq.t isn't in the test_manifest
- Add patch to work around Perl RT#3038 on old perls with broken qr//m
  (CPAN RT#74365)

* Thu Jul  7 2011 Paul Howarth <paul@city-fan.org> - 1.29-5
- Rebuild for perl 5.14.1 in Rawhide
- Nobody else likes macros for commands
- Fix dist tag for CentOS 6 and Scientific Linux

* Thu Jun 24 2010 Paul Howarth <paul@city-fan.org> - 1.29-4
- Rebuild for perl 5.12.1 in Rawhide

* Thu May 13 2010 Paul Howarth <paul@city-fan.org> - 1.29-3
- Fix dist tag for RHEL-6 Beta

* Fri Mar  5 2010 Paul Howarth <paul@city-fan.org> - 1.29-2
- Manually add dependency on perl(Exporter), from "use base qw(Exporter)"
- Dist tag for Rawhide no longer needs special-casing
- Use %%{_fixperms} macro instead of our own %%{__chmod} incantation

* Wed Jun 10 2009 Paul Howarth <paul@city-fan.org> - 1.29-1
- Update to 1.29 (manpage filename fixed)
- Update patches for old Test::Builder versions

* Mon Jun  1 2009 Paul Howarth <paul@city-fan.org> - 1.28-1
- Update to 1.28 (upstream makes manpages again)
- Update manpage patch to fix manpage filename (RT #46327)

* Fri May 22 2009 Paul Howarth <paul@city-fan.org> - 1.27-1
- Update to 1.27 (test updates)

* Sun May 17 2009 Paul Howarth <paul@city-fan.org> - 1.26-1
- Update to 1.26 (upstream doesn't make man pages)
- Update to SLES-compatible dist tag macros
- Apply patch to reinstate manpage as we want it anyway
- Update patches for old Test::Builder versions

* Wed Jun 11 2008 Paul Howarth <paul@city-fan.org> - 1.25-1
- Update to 1.25
- Drop 1.24_02 patch, no longer needed
- Update patches for old Test::Builder versions
- Add buildreq perl(Test::Manifest)

* Sun May 25 2008 Paul Howarth <paul@city-fan.org> - 1.24-1
- Update to 1.24
- Patch to include fixes to test suite in 1.24_02
- Move Test::Builder patches to later patch numbers so that upstream patches
  can be applied first
- Update patches for old Test::Builder versions

* Thu Apr 24 2008 Paul Howarth <paul@city-fan.org> - 1.23-1
- Update to 1.23
- Update patches for old Test::Builder versions

* Thu Nov  1 2007 Paul Howarth <paul@city-fan.org> - 1.22-1
- Update to 1.22

* Wed Oct 31 2007 Paul Howarth <paul@city-fan.org> - 1.21-1
- Update to 1.21
- Fix perl-Test-File-1.17-TB31.patch (group_isnt test failure exposed by
  mock upgrade)

* Mon Oct 29 2007 Paul Howarth <paul@city-fan.org> - 1.19-1
- Update to 1.19
- Fix dist tag for Fedora 7 onwards
- Clarify license as GPL version 1 or later, or Artistic (i.e. same as perl)

* Wed Jan 10 2007 Paul Howarth <paul@city-fan.org> - 1.18-1
- Update to 1.18
- Include LICENSE file
- Add buildreq perl(Test::Pod::Coverage)

* Mon Nov 27 2006 Paul Howarth <paul@city-fan.org> - 1.17-1
- Update to 1.17
- Fix argument order for find with -depth
- Fix up patches for old Test::Builder versions

* Fri Sep  1 2006 Paul Howarth <paul@city-fan.org> - 1.16-2
- Fix distribution tags for development releases

* Mon Jul 10 2006 Paul Howarth <paul@city-fan.org> - 1.16-1
- Update to 1.16

* Thu May 18 2006 Paul Howarth <paul@city-fan.org> - 1.15-1
- Update to 1.15

* Wed Mar 22 2006 Paul Howarth <paul@city-fan.org> - 1.14-2
- Conditionally apply patch only where needed

* Thu Mar  9 2006 Paul Howarth <paul@city-fan.org> - 1.14-1
- Update to 1.14
- Fix build on CentOS
- Update test patch

* Tue Jan  3 2006 Paul Howarth <paul@city-fan.org> - 1.13-1
- Update to 1.13
- Add BuildConflict for recent Test::Simple versions that don't need %%patch0
- Edit Makefile.PL to remove updated Test::Builder requirement

* Sat Dec 31 2005 Paul Howarth <paul@city-fan.org> - 1.12-1
- Update to 1.12
- Simplify distribution-detection
- Clarify spec by removing __perl_version and __perl_package macros
- Unconditionally remove buildroot in %%clean and %%install
- Don't use macros in build-time command paths, hardcode them instead
- Add patch to fix CPAN rt#16782

* Tue Oct  4 2005 Paul Howarth <paul@city-fan.org> - 1.11-1
- Update to 1.11
- Remove redundant find of empty .bs files and optimization flags
- Fix directory ownership
- Use search.cpan.org URLs
- Add BR's perl(Test::Pod) & perl(Test::Prereq) for improved test cover

* Fri Jun 24 2005 Paul Howarth <paul@city-fan.org> - 1.10-1
- Update to 1.10
- Rewrite spec file in (mainly) Fedora Extras style
- Include full URL for source
- Fix URL
- Use MODULE_COMPAT dependency style and remove explicit perl dependency
- Remove MANIFEST from %%doc
- Remove all manual dependencies apart from perl(Test::Builder::Tester)

* Fri Apr  1 2005 Paul Howarth <paul@city-fan.org> - 1.09-1
- Update to 1.09

* Wed Feb  9 2005 Paul Howarth <paul@city-fan.org> - 1.08-1
- Update to 1.08

* Wed Oct 27 2004 Paul Howarth <paul@city-fan.org> - 1.06-1
- Update to 1.06
- Tidy up spec file

* Tue May 11 2004 Paul Howarth <paul@city-fan.org> - 0.05-1
- Initial build