File ponysay.spec of Package ponysay

#
# spec file for package ponysay
#
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.

# Please submit bugfixes or comments via https://bugs.opensuse.org/
#


%bcond_without restricted
Name:           ponysay
Version:        3.0.3
Release:        0
Summary:        Cowsay reimplemention for ponies
License:        GPL-3.0-or-later
URL:            https://github.com/erkin/ponysay
Source:         https://github.com/erkin/%{name}/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
BuildRequires:  fdupes
BuildRequires:  python3
BuildRequires:  texinfo
Requires:       python3
Requires(post): %{install_info_prereq}
Requires(preun): %{install_info_prereq}
Recommends:     %{name}-extra
BuildArch:      noarch

%description
ponysay as an awesome terminal application to display ponies speaking
messages in your terminal.
It has many features; you can use its info manual to explore them.

%if %{with restricted}
%package extra
Summary:        Extra ponies for ponysay
License:        NonFree
Requires:       %{name} = %{version}

%description extra
ponysay as an awesome terminal application to display ponies speaking
messages in your terminal.
It has many features; you can use its info manual to explore them.

This package contains extra ponies for ponysay.
%endif

%prep
%setup -q
touch pony-files.list extra-pony-files.list
find *ponies/ -name '*.pony' | while read pony; do
    if [ "$(sed -e "/^FREE: /!d;s/^.* \([^ ]\+\)$/\1/" "$pony")" = "yes" ]; then
        echo "%{_datadir}/%{name}/$pony" >> pony-files.list
    else
        echo "%{_datadir}/%{name}/$pony" >> extra-pony-files.list
    fi
done

%build
python3 setup.py build \
%if %{with restricted}
  --freedom=partial
%else
  --freedom=strict
%endif

%install
python3 setup.py install \
  --dest-dir=%{buildroot} \
  --prefix=%{_prefix}    \
%if %{with restricted}
  --freedom=partial      \
%else
  --freedom=strict       \
%endif
  --everything           \
  --without-man-compression \
  --with-pdf=%{_docdir}/%{name}/
rm -r %{buildroot}%{_datadir}/licenses/
%if 0%{?suse_version} <= 1500
rm %{buildroot}%{_infodir}/dir
%endif
%fdupes %{buildroot}%{_datadir}/%{name}/

%post
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info%{?ext_info}
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}-tool.info%{?ext_info}
%install_info --info-dir=%{_infodir} %{_infodir}/ponythink.info%{?ext_info}

%postun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info%{?ext_info}
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}-tool.info%{?ext_info}
%install_info_delete --info-dir=%{_infodir} %{_infodir}/ponythink.info%{?ext_info}

%files -f pony-files.list
%license COPYING CREDITS LICENSE
%doc CHANGELOG CONTRIBUTING README.md
%doc %{_docdir}/%{name}/
%{_bindir}/pony*
%dir %{_datadir}/%{name}/
%{_datadir}/%{name}/balloons/
%{_datadir}/%{name}/quotes/
%{_datadir}/%{name}/ucs
%dir %{_datadir}/%{name}/*ponies/
%{_datadir}/%{name}/*ponies/metadata
%{_infodir}/*%{?ext_info}
%dir %{_mandir}/tr/
%{_mandir}/*/*
%{_datadir}/bash-completion/
%{_datadir}/zsh/
%{_datadir}/fish/

%if %{with restricted}
%files extra -f extra-pony-files.list
%endif

%changelog
openSUSE Build Service is sponsored by