Name:             liberation-fonts
Summary:          Liberation Fonts
Version:          2.00.3
Release:          2
Epoch:            1
# The license of the Liberation Fonts is a EULA that contains GPLv2 and two
# exceptions:
# The first exception is the standard FSF font exception.
# The second exception is an anti-lockdown clause somewhat like the one in
# GPLv3. This license is Free, but GPLv2 and GPLv3 incompatible.
License:          Liberation
URL:              https://github.com/liberationfonts/%{name}
Source0:          https://github.com/liberationfonts/%{name}/files/2012633/%{name}-%{version}.tar.gz
Source1:          %{name}-mono.conf
Source2:          %{name}-sans.conf
Source3:          %{name}-serif.conf
Source4:          liberation.metainfo.xml
Source5:          liberation-mono.metainfo.xml
Source6:          liberation-sans.metainfo.xml
Source7:          liberation-serif.metainfo.xml
BuildArch:        noarch
BuildRequires:    fontpackages-devel >= 1.13, xorg-x11-font-utils libappstream-glib fontforge python3 python3-fonttools
Requires:         fontpackages-filesystem >= 1.13
Obsoletes:        liberation-narrow-fonts < 1:2.0.0
Provides:         liberation-narrow-fonts = %{epoch}:%{version}-%{release}
Obsoletes:        liberation-fonts-common liberation-sans-fonts liberation-serif-fonts liberation-mono-fonts
Provides:         liberation-fonts-common liberation-sans-fonts liberation-serif-fonts liberation-mono-fonts

%description
The Liberation Fonts are intended to be replacements for the three most
commonly used fonts on Microsoft systems: Times New Roman, Arial, and Courier New.

%prep
%autosetup -n %{name}-%{version} -p1

%build
%make_build
mv liberation-fonts-ttf-%{version}/* .

%install
install -m 0755 -d %{buildroot}%{_fontdir}
install -m 0644 -p *.ttf %{buildroot}%{_fontdir}
install -m 0755 -d %{buildroot}%{_sysconfdir}/X11/fontpath.d
ln -s %{_fontdir} %{buildroot}%{_sysconfdir}/X11/fontpath.d/%{name}
install -m 0755 -d %{buildroot}%{_fontconfig_templatedir} %{buildroot}%{_fontconfig_confdir}
install -m 0644 -p %{SOURCE1} %{buildroot}%{_fontconfig_templatedir}/59-liberation-mono.conf
install -m 0644 -p %{SOURCE2} %{buildroot}%{_fontconfig_templatedir}/59-liberation-sans.conf
install -m 0644 -p %{SOURCE3} %{buildroot}%{_fontconfig_templatedir}/59-liberation-serif.conf
install -Dm 0644 -p %{SOURCE4} %{buildroot}%{_datadir}/appdata/liberation.metainfo.xml
install -Dm 0644 -p %{SOURCE5} %{buildroot}%{_datadir}/appdata/liberation-mono.metainfo.xml
install -Dm 0644 -p %{SOURCE6} %{buildroot}%{_datadir}/appdata/liberation-sans.metainfo.xml
install -Dm 0644 -p %{SOURCE7} %{buildroot}%{_datadir}/appdata/liberation-serif.metainfo.xml

for fconf in 59-liberation-mono.conf 59-liberation-sans.conf 59-liberation-serif.conf; do
  ln -s %{_fontconfig_templatedir}/$fconf %{buildroot}%{_fontconfig_confdir}/$fconf
done

mkfontscale %{buildroot}%{_fontdir}
mkfontdir %{buildroot}%{_fontdir}

%check
appstream-util validate-relax --nonet %{buildroot}%{_datadir}/appdata/liberation*.metainfo.xml

%_font_pkg -f *-liberation-*.conf Liberation*.ttf
%{_datadir}/appdata/*.metainfo.xml
%doc AUTHORS ChangeLog README TODO
%license  LICENSE
%dir %{_fontdir}
%verify(not md5 size mtime) %{_fontdir}/fonts.dir
%verify(not md5 size mtime) %{_fontdir}/fonts.scale
%{_sysconfdir}/X11/fontpath.d/%{name}

%changelog
* Tue Dec 3 2019 chenzhenyu <chenzhenyu13@huawei.com> - 2.00.3-2
- Package init
