File xpdf.spec of Package xpdf

#
# spec file for package xpdf
#
# Copyright (c) 2022 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/
#


%define _lang $(zcat %{_sourcedir}/%{name}-[a-z]*.tar.gz | sed -n '/Unix.*share.xpdf./s,.*/,,p')
Name:           xpdf
Version:        4.05
Release:        0
Summary:        PDF viewer
License:        GPL-2.0-only AND GPL-3.0-only AND Apache-2.0
Group:          Productivity/Publishing/PDF
URL:            https://www.xpdfreader.com
Source0:        https://dl.xpdfreader.com/%{name}-%{version}.tar.gz
Source1:        https://dl.xpdfreader.com/%{name}-%{version}.tar.gz.sig
Source2:        https://dl.xpdfreader.com/%{name}-apache-%{version}.tar.gz
Source3:        https://dl.xpdfreader.com/%{name}-apache-%{version}.tar.gz.sig
Source4:        %{name}.keyring
Source5:        https://dl.xpdfreader.com/%{name}-arabic.tar.gz
Source6:        https://dl.xpdfreader.com/%{name}-chinese-simplified.tar.gz
Source7:        https://dl.xpdfreader.com/%{name}-chinese-traditional.tar.gz
Source8:        https://dl.xpdfreader.com/%{name}-cyrillic.tar.gz
Source9:        https://dl.xpdfreader.com/%{name}-greek.tar.gz
Source10:       https://dl.xpdfreader.com/%{name}-hebrew.tar.gz
Source11:       https://dl.xpdfreader.com/%{name}-japanese.tar.gz
Source12:       https://dl.xpdfreader.com/%{name}-korean.tar.gz
Source13:       https://dl.xpdfreader.com/%{name}-latin2.tar.gz
Source14:       https://dl.xpdfreader.com/%{name}-thai.tar.gz
Source15:       https://dl.xpdfreader.com/%{name}-turkish.tar.gz
BuildRequires:  cmake
BuildRequires:  cups-devel
BuildRequires:  gcc-c++
BuildRequires:  hicolor-icon-theme
BuildRequires:  ninja
BuildRequires:  pkgconfig
BuildRequires:  pkgconfig(Qt5Network)
BuildRequires:  pkgconfig(Qt5PrintSupport)
BuildRequires:  pkgconfig(Qt5Svg)
BuildRequires:  pkgconfig(Qt5Widgets)
BuildRequires:  pkgconfig(freetype2)
BuildRequires:  pkgconfig(lcms2)
BuildRequires:  pkgconfig(libjpeg)
BuildRequires:  pkgconfig(libpng)
BuildRequires:  pkgconfig(libtiff-4)
BuildRequires:  pkgconfig(zlib)
BuildRequires:  update-desktop-files
%if 0%{?suse_version} >= 1550 || 0%{?sle_version} >= 150200
BuildRequires:  rsvg-convert
%else
BuildRequires:  rsvg-view
%endif
Requires:       ghostscript-fonts-std
%requires_eq    libQt5Svg5
Recommends:     %{name}-tools = %{version}

%description
Xpdf is a free PDF viewer and toolkit, including a text extractor, image
converter, HTML converter, and more.

%package tools
Summary:        Command line tools
License:        GPL-2.0-only AND GPL-3.0-only
Group:          Productivity/Publishing/PDF
Conflicts:      poppler-tools

%description tools
The open source Xpdf toolkit also includes several command line tools which
perform various functions on PDF files:
  - pdftotext: converts PDF to text
  - pdftops: converts PDF to PostScript
  - pdftoppm: converts PDF pages to netpbm (PPM/PGM/PBM) image files
  - pdftopng: converts PDF pages to PNG image files
  - pdftohtml: converts PDF to HTML
  - pdfinfo: extracts PDF metadata
  - pdfimages: extracts raw images from PDF files
  - pdffonts: lists fonts used in PDF files
  - pdfdetach: extracts attached files from PDF files

%{expand:%( \
for lang in %{_lang}; do \
echo "%%{expand:%%(cat << EOF >&1
%package -n     %{name}-$lang
Summary:        Encoding maps
License:        GPL-2.0-only AND GPL-3.0-only AND BSD-3-Clause
Group:          Productivity/Publishing/PDF
Requires:       %{name} = %{version}
#Suggests:       noto-sans-jp-regular-fonts # japanese
#Suggests:       noto-sans-kr-regular-fonts # korean
#Suggests:       noto-sans-sc-regular-fonts # chinese-simplified
#Suggests:       noto-sans-tc-regular-fonts # chinese-traditional
BuildArch:      noarch

%description -n %{name}-$lang
This package provides encoding maps required to support non-UTF-8
national fonts for various languages: $lang.

%files -n %{name}-$lang
%dir %{_datadir}/%{name}
%{_datadir}/%{name}/$lang
%{_datadir}/%{name}/$lang-%{name}rc
EOF)}"; \
done)}

%prep
%setup -q -a2 -a5 -a6 -a7 -a8 -a9 -a10 -a11 -a12 -a13 -a14 -a15
sed -i 's/555555/aaaaaa/g' `find -name "*.svg"`
sed -i "s|/usr/local/etc|%{_sysconfdir}|" `grep -rl '/usr/local/etc'`
sed -i "s|/usr/local/share|%{_datadir}|" `grep -rl '/usr/local/share' | grep -v 'GlobalParams\.cc'`
cp -fv %{name}-apache-%{version}/Stream* %{name}/
sed -i -e 's/^#\(fontFile\)/\1/' \
    -e 's/^#\(textEncoding\)/\1/' \
    -e 's/^#\(enableFreeType\)/\1/' \
    -e 's/^#\(antialias\)/\1/' doc/sample-%{name}rc
echo -e "\n# Support non-UTF-8 national fonts." >> doc/sample-%{name}rc
sed -i 's,\.\.\.\.,share/fonts/truetype,' %{name}-*/add-to-%{name}rc
sed -i 's/^#\(fontFileCC\)/\1/' %{name}-*/add-to-%{name}rc

%build
%define __builder ninja
%cmake \
    -DBUILD_SHARED_LIBS=OFF \
    -DA4_PAPER=ON \
    -DNO_TEXT_SELECT=OFF \
    -DMULTITHREADED=ON \
    -DUSE_EXCEPTIONS=ON \
    -DUSE_FIXEDPOINT=ON \
    -DSPLASH_CMYK=ON \
    -DSPLASH_DEVICEN=ON \
    -DUSE_LCMS=ON \
    -DHIGHLIGHTED_REGIONS=OFF \
    -DSYSTEM_XPDFRC= \
    -DXPDFWIDGET_PRINTING=ON \
    -DEVAL_MODE=ON \
    -DBUILDING_XPDFREADER=ON \
    -DSYSTEM_XPDFRC=%{_sysconfdir}/%{name}rc \
    -DXPDFRC_DATADIR=%{_datadir}/%{name}
%ninja_build

%install
%cmake_install
for i in 16 24 32 48 64; do
    install -dm 0755 %{buildroot}%{_datadir}/icons/hicolor/$i\x$i/apps
    rsvg-convert -a -w $i %{name}-qt/%{name}-icon.svg -o %{buildroot}%{_datadir}/icons/hicolor/$i\x$i/apps/%{name}.png
done
install -Dm 0644 %{name}-qt/%{name}-icon.svg %{buildroot}%{_datadir}/icons/hicolor/scalable/apps/%{name}.svg
%suse_update_desktop_file -c %{name} "XpdfReader" "PDF viewer" %{name} %{name} Office Viewer
sed -i '/Icon=/s/$/\nMimeType=application\/pdf\;/' %{buildroot}%{_datadir}/applications/%{name}.desktop

install -dm 0755 %{buildroot}%{_sysconfdir}
cp doc/sample-%{name}rc %{buildroot}%{_sysconfdir}/%{name}rc

# install encoding maps files and update xpdfrc
for i in %{_lang}; do
    install -dm 0755 %{buildroot}%{_datadir}/%{name}/${i}
    find %{name}-${i}/ -maxdepth 1 -mindepth 1 ! -name README ! -name add-to-%{name}rc -exec cp -a {} \
    %{buildroot}%{_datadir}/%{name}/${i}/ \;
    find %{buildroot}%{_datadir}/%{name}/${i}/ -name 'LICENSE.md' -print -delete
    cat %{name}-${i}/add-to-%{name}rc >> %{buildroot}%{_datadir}/%{name}/${i}-%{name}rc
    echo "include %{_datadir}/%{name}/${i}-%{name}rc" >> %{buildroot}%{_sysconfdir}/%{name}rc
done

%files
%doc ANNOUNCE CHANGES README
%config(noreplace) %{_sysconfdir}/%{name}rc
%{_bindir}/%{name}
%{_datadir}/applications/%{name}.desktop
%{_datadir}/icons/hicolor/*/apps/%{name}.??g
%{_mandir}/man?/%{name}*.?%{?ext_man}
%license COPYING COPYING3 %{name}-apache-%{version}/APACHE-2.0.txt

%files tools
%{_bindir}/pdf*
%{_mandir}/man?/pdf*.?%{?ext_man}

%changelog
openSUSE Build Service is sponsored by