File epsonscan2.spec of Package epsonscan2

#
# spec file for package epsonscan2
#
# Copyright (c) 2024 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 RELEASE_ -1

Name:           epsonscan2
Version:        6.7.70.0
Release:        0
Summary:        Epson scanner management utility
License:        GPL-3.0-or-later
Group:          Hardware/Scanner
URL:            http://support.epson.net/linux/en/epsonscan2.php
Source:         %{name}-%{version}%{RELEASE_}.src.tar.gz
Source99:       %{name}.rpmlintrc
BuildRequires:  cmake
BuildRequires:  fdupes
BuildRequires:  gcc-c++
BuildRequires:  libboost_filesystem-devel
BuildRequires:  libboost_system-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libpng-devel
BuildRequires:  libtiff-devel
BuildRequires:  libusb-devel
BuildRequires:  rapidjson-devel
BuildRequires:  libharu-devel
BuildRequires:  update-desktop-files
BuildRequires:  zlib-devel
BuildRequires:  cmake(Qt5Core)
BuildRequires:  cmake(Qt5Gui)
BuildRequires:  cmake(Qt5Widgets)

Patch1:         0001-Remove-built-in-deps.patch
Patch2:         0002-Fix-crash.patch
Patch3:         0003-Use-XDG-open-to-open-the-directory.patch
Patch4:         0004-Fix-a-crash-on-an-OOB-container-access.patch
Patch5:         0005-Fix-crash-no-serial-number.patch

Suggests:       avahi-utils
Suggests:       epsonscan2-non-free-plugin

%description
Epson Scan 2 is Linux software for Epson scanners &
multifunction printer.
Epson Scan 2 has own front-end, it allows to set various
scanner settings with graphical user interface
and save the scanned images to the various file type.
It supports USB and network connection for the network
capable scanners.
Scanner can be controlled via not only own front-end but
also command line option.

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

# Fix ORC PATH
sed -i 's|/usr/libexec|%{_libexecdir}|g' src/Controller/Src/Filter/GetOrientation.cpp
sed -i 's|/usr/lib/%{_arch}-linux-gnu|%{_libdir}|g' src/ScanSDK/Src/SDK/SCANSDKsample_C++/EslStub.cpp

%build
find . -name "CMakeCache.txt" | xargs -I {} rm {}
find . -name "cmake_install.cmake" | xargs -I{} rm {}
find . -name "Makefile" | xargs -I{} rm {}
find . -name "CMakeFiles" | xargs -I {}  rm -rf {}

%if 0%{?suse_version} > 1600
%global optflags %{optflags} -Wno-return-type
%endif

%cmake \
    -DCMAKE_INSTALL_PREFIX=%{_prefix} \
    -DEPSON_DESTDIR=%{buildroot} \
    -DEPSON_VERSION=%{version}

%cmake_build

%install
%cmake_install

install -d %{buildroot}/%{_datadir}/applications

printf '%s\n' \
    '[Desktop Entry]' \
    'Categories=Application;Graphics;RasterGraphics;Scanning;GTK;' \
    'Encoding=UTF-8' \
    'Exec=/usr/bin/%{name}' \
    'Name=Epson Scan 2' \
    'GenericName=Epson Scan 2' \
    'Comment=Epson scanner management utility' \
    'Comment[zh_CN]=Epson 扫描仪管理工具' \
    'Keywords=epson;scan;scanner;epson scan;' \
    'Icon=%{_datadir}/pixmaps/%{name}.ico' \
    'Terminal=false' \
    'Type=Application' | \
    install -DTm 644 /dev/stdin %{buildroot}/%{_datadir}/applications/%{name}.desktop

%suse_update_desktop_file %{name}

install -d %{buildroot}%{_sysconfdir}/ld.so.conf.d
printf '%s\n' \
    '%{_libdir}/%{name}' | \
    install -DTm 644 /dev/stdin %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}.conf

install -d %{buildroot}/%{_datadir}
install -d %{buildroot}%{_datadir}/pixmaps
cp %{buildroot}%{_libdir}/%{name}/Resources/Icons/escan2_app.ico %{buildroot}%{_datadir}/pixmaps/%{name}.ico

rm -rf %{buildroot}/%{_datadir}/doc/*

%fdupes -s %{buildroot}

%check

%post -n %{name} -p /sbin/ldconfig
%postun -n %{name} -p /sbin/ldconfig

%files
%license COPYING LICENSE
%doc README AUTHORS NEWS

%dir %{_sysconfdir}/sane.d
%dir %{_sysconfdir}/sane.d/dll.d
%config %{_sysconfdir}/sane.d/dll.d/%{name}
%dir %{_sysconfdir}/ld.so.conf.d
%config %{_sysconfdir}/ld.so.conf.d/%{name}.conf

%{_bindir}/%{name}

%{_datadir}/pixmaps/%{name}.ico

%{_datadir}/applications/%{name}.desktop

%dir %{_libdir}/%{name}
%{_libdir}/%{name}/*
%dir %{_libdir}/sane
%{_libdir}/sane/libsane-epsonscan2.so.1
%{_libdir}/sane/libsane-epsonscan2.so.1.0.0

%{_udevrulesdir}/60-%{name}.rules

%changelog
openSUSE Build Service is sponsored by