File k2pdfopt.spec of Package k2pdfopt
# SPDX-License-Identifier: GPL-3.0-or-later
# OBS spec for openSUSE Tumbleweed
Name: k2pdfopt
Version: 2.55
Release: 0
Summary: Optimize PDF/DJVU for mobile e-readers and smartphones
License: GPL-3.0-or-later
URL: http://www.willus.com/k2pdfopt
# Upstream source (fetched by _service:download_files)
Source0: http://www.willus.com/k2pdfopt/src/%{name}_v%{version}_src.zip
# Debian patch series (fetched by _service:download_files)
Patch1: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0001-CMakeLists.txt-add-missing-install-command.patch
Patch2: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0002-CMakeLists.txt-do-not-detect-ghostscript-at-compile-.patch
Patch3: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0003-CMakeLists.txt-use-system-mupdf.patch
Patch4: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0004-CMakeLists.txt-use-system-gocr.patch
Patch5: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0005-CMakeLists.txt-use-system-gsl.patch
Patch6: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0006-k2pdfopt.h-dst_ocr_visibility_flags-workaround.patch
Patch7: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0007-k2pdfoptlib-k2ocr.c-conditionally-enable-tesseract-r.patch
Patch8: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0008-willuslib-CMakeLists.txt-typo.patch
Patch9: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0009-willuslib-CMakeLists.txt-conditionally-add-source-fi.patch
Patch10: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0010-willuslib-use-system-leptonica.patch
Patch11: https://salsa.debian.org/yangfl-guest/k2pdfopt/-/raw/dbc5c01db8d3fdf4aefda7a80ff40e4dd48f0486/debian/patches/0011-willuslib-use-system-djvu.patch
# Local files (committed to OBS)
Patch12: jasper_header_path.patch
Patch13: disable_tesseract.patch
Patch14: fix_jasper_lib.patch
Source1: mupdf.pc
# Build requirements
BuildRequires: cmake
BuildRequires: gcc-c++
BuildRequires: make
BuildRequires: unzip
BuildRequires: pkgconfig
BuildRequires: libdjvulibre-devel
BuildRequires: mujs-devel
BuildRequires: mupdf-devel-static
BuildRequires: zlib-devel
BuildRequires: libpng16-devel
# Optional features as in the AUR recipe (safe to drop if undesired)
BuildRequires: libjasper-devel
BuildRequires: leptonica-devel
BuildRequires: gocr
BuildRequires: gsl-devel
# Runtime hints similar to PKGBUILD's optdepends
Recommends: ghostscript
Recommends: jasper
Recommends: gsl
Recommends: leptonica
%description
k2pdfopt optimizes PDF and DjVu files for small screens (e-ink readers,
smartphones). It can reflow text, crop margins, and rasterize pages to
improve legibility.
%prep
# Unpack and apply patches in numeric order
%autosetup -p1 -n %{name}_v%{version}
# Drop the pkg-config shim in the source root (used if distro lacks a mupdf.pc)
cp -v "%{SOURCE1}" ./mupdf.pc
%build
export PKG_CONFIG_PATH=..
%cmake
%cmake_build
%install
%cmake_install
%files
%{_bindir}/k2pdfopt