Blob Blame History Raw
# More convenient than %%fedora/%%rhel/%%centos.
#global osname  %(cat /etc/redhat-release | sed -e 's/ release.*//')
# Sed is not safe? Awk is here.
%global osname  %(cat /etc/redhat-release | awk '{sub(/ release.*/,""); print}')

# yum still works, however I'd like to shake it off the memory.
%if (0%{?fedora} && 0%{?fedora} >= 21) || (0%{?rhel} && 0%{?rhel} >= 8)
%global pkgmgr  dnf
%bcond_without  py3
%else
%global pkgmgr  yum
%bcond_with     py3
%endif

Name:           krop
Version:        0.4.9
Release:        2%{?dist}
Summary:        Tool to crop PDF files with an eye towards eReaders

License:        GPLv3+
URL:            http://arminstraub.com/software/krop
Source0:        http://arminstraub.com/downloads/%{name}/%{name}-%{version}.tar.gz

BuildArch:      noarch
BuildRequires:  desktop-file-utils
BuildRequires:  libappstream-glib

%if %with py3
BuildRequires:  python3-devel
BuildRequires:  python3-setuptools

Requires:       python3-PyPDF2
Requires:       python3-qt5
Requires:       python3-poppler-qt5
%else
BuildRequires:  python2-devel
BuildRequires:  python-setuptools

Requires:       python-PyPDF2
Requires:       PyQt4
Requires:       python-poppler-qt4
%endif

%description
Krop is a simple graphical tool to crop the pages of PDF files. A unique feature
of krop is its ability to automatically split pages into subpages to fit the
limited screen size of devices such as eReaders. This is particularly useful, if
your eReader does not support convenient scrolling.

%prep
%setup -q
# In terms of OS available on Koji. "of" is needed since Ubuntu appears as font.
find . -type f -name '*.py' -exec sed -i -e 's/of ubuntu/of %{osname}/Ig' \
-e 's|apt-get|%{pkgmgr}|g' -e 's|python-pypdf|pyPdf|g' '{}' +
# remove shebang
sed -i '1d' %{name}/%{name}.py

%build
%if %with py3
%py3_build
%else
%py2_build
%endif

%install
%if %with py3
%py3_install
%else
%py2_install
%endif
desktop-file-install --dir=%{buildroot}%{_datadir}/applications %{name}.desktop
DESTDIR="%{buildroot}" appstream-util install %{name}.appdata.xml

%check
%if %with py3
%{__python3} setup.py check
%else
%{__python2} setup.py check
%endif
appstream-util validate-relax --nonet %{buildroot}%{_datadir}/appdata/*.appdata.xml


%post
update-desktop-database &> /dev/null || :

%postun
update-desktop-database &> /dev/null || :


%files
%license LICENSE
%doc ChangeLog README
%{_bindir}/%{name}
%{_datadir}/appdata/%{name}.appdata.xml
%{_datadir}/applications/%{name}.desktop
%if %with py3
%{python3_sitelib}/%{name}*.egg-info
%{python3_sitelib}/%{name}/
%else
%{python2_sitelib}/%{name}*.egg-info
%{python2_sitelib}/%{name}/
%endif


%changelog
* Fri Mar 25 2016 Raphael Groner <projects.rg@smart.ms> - 0.4.9-2
- port to PyPDF2, Python3, Qt5

* Fri Mar 25 2016 Fedora Release Monitoring <release-monitoring@fedoraproject.org> - 0.4.9-1
- Update to 0.4.9 (#1276890)

* Thu Feb 04 2016 Fedora Release Engineering <releng@fedoraproject.org> - 0.4.8-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild

* Thu Jul 16 2015 Christopher Meng <rpm@cicku.me> - 0.4.8-1
- Update to 0.4.8

* Wed Jun 17 2015 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4.7-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild

* Tue Feb 17 2015 Christopher Meng <rpm@cicku.me> - 0.4.7-1
- Update to 0.4.7

* Sun Jun 08 2014 Fedora Release Engineering <rel-eng@lists.fedoraproject.org> - 0.4.6-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild

* Sat May 24 2014 Richard Hughes <richard@hughsie.com> - 0.4.6-1
- Update to 0.4.6

* Sat Mar 01 2014 Christopher Meng <rpm@cicku.me> - 0.4.5-1
- Update to 0.4.5

* Sun Aug 25 2013 Christopher Meng <rpm@cicku.me> - 0.4.4-1
- Update to 0.4.4

* Wed Aug 14 2013 Christopher Meng <rpm@cicku.me> - 0.4.3-1
- Update to 0.4.3
- Correct desktop MIME update script.

* Wed Jul 31 2013 Christopher Meng <rpm@cicku.me> - 0.4.1-1
- Update to 0.4.1

* Sat Nov 12 2011 Christopher Meng <rpm@cicku.me> - 0.3.0-1
- Initial Package.