%define bcfversion 3.8

Name:           biber
Version:        2.20
Release:        1
Summary:        Command-line bibliographic manager, BibTeX replacement
License:        (GPL+ or Artistic 2.0) and Artistic 2.0
URL:            http://biblatex-biber.sourceforge.net/
Source0:        https://github.com/plk/biber/archive/%{name}-%{version}.tar.gz
BuildArch:      noarch
BuildRequires:  coreutils
BuildRequires:  perl-interpreter
BuildRequires:  perl-generators
BuildRequires:  perl(Config)
BuildRequires:  perl(Module::Build)
BuildRequires:  perl(strict)
BuildRequires:  perl(utf8)
BuildRequires:  perl(warnings)
BuildRequires:  perl(:VERSION) >= 5.24
BuildRequires:  perl(autovivification)
BuildRequires:  perl(Business::ISBN)
BuildRequires:  perl(Business::ISMN)
BuildRequires:  perl(Business::ISSN)
BuildRequires:  perl(Carp)
BuildRequires:  perl(Class::Accessor)
BuildRequires:  perl(constant)
BuildRequires:  perl(Cwd)
BuildRequires:  perl(Data::Compare)
BuildRequires:  perl(Data::Dump)
BuildRequires:  perl(Data::Uniqid)
BuildRequires:  perl(DateTime)
BuildRequires:  perl(DateTime::Calendar::Julian)
BuildRequires:  perl(DateTime::Format::Builder)
BuildRequires:  perl(DateTime::TimeZone)
BuildRequires:  perl(Digest::MD5)
BuildRequires:  perl(Encode)
BuildRequires:  perl(Encode::Alias)
BuildRequires:  perl-Encode-EUCJPASCII
BuildRequires:  perl(Encode::HanExtra)
BuildRequires:  perl(Encode::JIS2K)
BuildRequires:  perl(Exporter)
BuildRequires:  perl(File::Copy)
BuildRequires:  perl(File::Find)
BuildRequires:  perl(File::Slurper)
BuildRequires:  perl(File::Spec)
BuildRequires:  perl(File::Temp)
BuildRequires:  perl(IO::File)
BuildRequires:  perl(IO::String)
BuildRequires:  perl(IPC::Cmd)
BuildRequires:  perl(IPC::Run3)
BuildRequires:  perl(Lingua::Translit) >= 0.28
BuildRequires:  perl(List::AllUtils)
BuildRequires:  perl(List::MoreUtils)
BuildRequires:  perl(List::MoreUtils::XS)
BuildRequires:  perl(List::Util)
BuildRequires:  perl(locale)
BuildRequires:  perl(Log::Log4perl)
BuildRequires:  perl(Log::Log4perl::Appender::File)
BuildRequires:  perl(Log::Log4perl::Appender::Screen)
BuildRequires:  perl(Log::Log4perl::Layout::PatternLayout)
BuildRequires:  perl(Log::Log4perl::Layout::SimpleLayout)
BuildRequires:  perl(LWP::Protocol::https)
BuildRequires:  perl(LWP::UserAgent)
BuildRequires:  perl(MIME::Charset)
BuildRequires:  perl(parent)
BuildRequires:  perl(Parse::RecDescent)
BuildRequires:  perl(POSIX)
BuildRequires:  perl(Regexp::Common)
BuildRequires:  perl(Scalar::Util)
BuildRequires:  perl(sigtrap)
BuildRequires:  perl(Sort::Key)
BuildRequires:  perl(Storable)
BuildRequires:  perl(Text::Balanced)
BuildRequires:  perl(Text::BibTeX) >= 0.88
BuildRequires:  perl(Text::BibTeX::Name)
BuildRequires:  perl(Text::BibTeX::NameFormat)
BuildRequires:  perl(Text::CSV)
BuildRequires:  perl(Text::CSV_XS)
BuildRequires:  perl(Text::Roman)
BuildRequires:  perl(Text::Wrap)
BuildRequires:  perl(Unicode::Collate::Locale) >= 1.29
BuildRequires:  perl(Unicode::GCString)
BuildRequires:  perl(Unicode::Normalize) >= 1.26
BuildRequires:  perl(Unicode::UCD)
BuildRequires:  perl(URI)
BuildRequires:  perl(vars)
BuildRequires:  perl(XML::LibXML)
BuildRequires:  perl(XML::LibXML::Simple)
BuildRequires:  perl(XML::LibXSLT)
BuildRequires:  perl(XML::Writer)
BuildRequires:  perl(Capture::Tiny)
BuildRequires:  perl(File::Which)
BuildRequires:  perl(open)
BuildRequires:  perl(Test::Differences)
BuildRequires:  perl(Test::More)
Requires:       perl(:MODULE_COMPAT_%(eval "`perl -V:version`"; echo $version))
Requires:       perl(autovivification)
Requires:       perl(Business::ISBN)
Requires:       perl(Business::ISMN)
Requires:       perl(Business::ISSN)
Requires:       perl(Lingua::Translit) >= 0.28
Requires:       perl(LWP::UserAgent)
Requires:       perl(LWP::Protocol::https)
Requires:       perl(Text::BibTeX) >= 0.88
Requires:       perl(Unicode::Collate::Locale) >= 1.29
Requires:       perl(XML::LibXSLT)
Provides:       bcfversion = %{bcfversion}
Provides:       perl(Biber) = %{version}

# Remove these dependencies
%global __requires_exclude %{?__requires_exclude:%{__requires_exclude}|}^perl\\((Text::BibTeX|Unicode::Collate::Locale)\\)$
%global __provides_exclude %{?__provides_exclude:%{__provides_exclude}|}^perl\\(Biber\\)$

%description
Biber is a command-line tool for dealing with bibliographic databases.
Biber offers a large superset of legacy BibTeX (texlive-bibtex)
functionality.  It is often used with the popular BibLaTeX package
(texlive-biblatex), where it is required for some features.


%package tests
Summary:        Tests for %{name}
Requires:       %{name} = %{?epoch:%{epoch}:}%{version}-%{release}
Requires:       coreutils
Requires:       perl-Test-Harness

%description tests
Tests from %{name}. Execute them
with "%{_libexecdir}/%{name}/test".

%prep
%autosetup -p1 -n biber-%{version}
# t/remote-files.t need internet to work
for F in \
    t/remote-files.t \
    t/full-*.t \
; do
    rm "$F";
    perl -i -ne 'print $_ unless m{\A\Q'"$F"'\E\b}' MANIFEST
done

for F in t/*.t; do
    perl -i -MConfig -ple 'print $Config{startperl} if $. == 1 && !s{\A#!\s*perl}{$Config{startperl}}' "$F"
    chmod +x "$F"
done

%build
perl Build.PL installdirs=vendor
./Build

%install
./Build install destdir=%{buildroot} create_packlist=0
%{_fixperms} %{buildroot}/*
# Install tests
mkdir -p %{buildroot}%{_libexecdir}/%{name}
cp -a t %{buildroot}%{_libexecdir}/%{name}
mkdir -p %{buildroot}%{_libexecdir}/%{name}/data/schemata
ln -s "$(realpath --relative-to \
        %{buildroot}%{_libexecdir}/%{name}/data \
        %{buildroot}%{perl_vendorlib}/Biber/biber-tool.conf)" \
    %{buildroot}%{_libexecdir}/%{name}/data
for F in {bcf,config}.{rnc,rng}; do
    # Relative symlinks break the tests
    ln -s %{perl_vendorlib}/Biber/"$F" \
        %{buildroot}%{_libexecdir}/%{name}/data/schemata
done
cat > %{buildroot}%{_libexecdir}/%{name}/test << 'EOF'
#!/usr/bin/bash
set -e
DIR=$(mktemp -d)
cp -a %{_libexecdir}/%{name}/* "$DIR"
pushd "$DIR"
unset BIBER_DEV_TESTS ISBN_RANGE_MESSAGE PAR_TEMP PERL_LWP_SSL_CA_FILE
prove -I . -j "$(getconf _NPROCESSORS_ONLN)"
popd
rm -r "$DIR"
EOF
chmod +x %{buildroot}%{_libexecdir}/%{name}/test

%check
unset BIBER_DEV_TESTS ISBN_RANGE_MESSAGE PAR_TEMP PERL_LWP_SSL_CA_FILE
export HARNESS_OPTIONS=j$(perl -e 'if ($ARGV[0] =~ /.*-j([0-9][0-9]*).*/) {print $1} else {print 1}' -- '%{?_smp_mflags}')
./Build test

%files
%doc README.md Changes TODO.org
%{_bindir}/%{name}
%{_mandir}/man3/*
%{_mandir}/man1/*
%{perl_vendorlib}/Biber*

%files tests
%{_libexecdir}/%{name}

%changelog
* Fri Oct 11 2024 dfh <dufuhang@kylinos.cn> - 2.20-1
- upgrade to version 2.20

* Wed Oct 26 2022 misaka00251 <liuxin@iscas.ac.cn> - 2.18-1
- Init package
