%global packname showtextdb
%global packver  3.0
%global rlibdir  %{_datadir}/R/library

# No network for OBS.
%bcond_with network

Name:             R-%{packname}
Version:          3.0
Release:          1
Summary:          Font Files for the 'showtext' Package

License:          ASL 2.0
URL:              https://CRAN.R-project.org/package=%{packname}
Source0:          https://cran.r-project.org/src/contrib/%{packname}_%{packver}.tar.gz
Patch0001:        0001-Load-existing-font-file.patch

BuildArch:        noarch
Requires:         wqy-microhei-fonts
BuildRequires:    R-devel
BuildRequires:    tex(latex)
BuildRequires:    wqy-microhei-fonts
BuildRequires:    R-sysfonts >= 0.7
BuildRequires:    R-utils
BuildRequires:    R-curl

%description
Providing font files that can be used by the 'showtext' package.


%prep
%setup -q -c -n %{packname}

pushd %{packname}
rm inst/AUTHORS inst/COPYRIGHTS
%patch0001 -p1
popd


%build


%install
mkdir -p %{buildroot}%{rlibdir}
%{_bindir}/R CMD INSTALL -l %{buildroot}%{rlibdir} %{packname}
test -d %{packname}/src && (cd %{packname}/src; rm -f *.o *.so)
rm -f %{buildroot}%{rlibdir}/R.css

pushd %{buildroot}%{rlibdir}/%{packname}
rm fonts/*
ln -s /usr/share/fonts/wqy-microhei/wqy-microhei.ttc fonts/wqy-microhei.ttc
popd


%check
%if %{with network}
%{_bindir}/R CMD check %{packname}
%else
%{_bindir}/R CMD check %{packname} --no-examples
%endif


%files
%dir %{rlibdir}/%{packname}
%doc %{rlibdir}/%{packname}/html
%{rlibdir}/%{packname}/DESCRIPTION
%doc %{rlibdir}/%{packname}/NEWS.Rd
%{rlibdir}/%{packname}/INDEX
%{rlibdir}/%{packname}/NAMESPACE
%{rlibdir}/%{packname}/Meta
%{rlibdir}/%{packname}/R
%{rlibdir}/%{packname}/help
%{rlibdir}/%{packname}/fonts


%changelog
* Fri Jun 24 2022 misaka00251 <misaka00251@misakanet.cn> - 3.0-1
- Init package (Thanks to fedora team)
