LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File hplip.spec of Package hplip (Project home:uninstall:Printing)

#
# spec file for package hplip
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
#
# 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 http://bugs.opensuse.org/
#


Name:           hplip
Version:        3.15.2
Release:        0
Summary:        HP's Printing, Scanning, and Faxing Software
License:        BSD-3-Clause and GPL-2.0+ and MIT
Group:          Hardware/Printing
Url:            http://hplipopensource.com
# Source0...Source9 is for sources from HP:
# URL for Source0: http://prdownloads.sourceforge.net/hplip/hplip-3.14.10.tar.gz
# URL to verify Source0: http://prdownloads.sourceforge.net/hplip/hplip-3.14.10.tar.gz.asc
# How to verify Source0 see: http://hplipopensource.com/node/327
# For example: /usr/bin/gpg --keyserver pgp.mit.edu --recv-keys 0xA59047B9
#              /usr/bin/gpg --verify hplip-3.14.10.tar.gz.asc hplip-3.14.10.tar.gz
# must result: Good signature from "HPLIP (HP Linux Imaging and Printing) <hplip@hp.com>"
Source0:        http://prdownloads.sourceforge.net/hplip/hplip-%{version}.tar.gz
Source1:        http://prdownloads.sourceforge.net/hplip/hplip-%{version}.tar.gz.asc
Source2:        hplip.keyring
# Patch0...Patch9 is for patches from HP:
# Patch10...Patch99 is for Suse patches for the sources from HP:
# Patch10 fix-uninitialized-variables.diff is obsolete since version 3.13.9 because it is fixed in the source.
# Patch11 fix_gcc44_glib.diff is obsolete since version 3.9.6b because it is fixed in the source.
# Patch12 hplip-3.9.8-CVE-2010-4267.patch fixeed a remote buffer overflow in hpmud/pml.c which
# is no longer needed because it is fixed in the upstream sources in HPLIP version 3.13.7
# Source100... is for special SUSE sources:
# Source100 is obsolete as upstream provides .desktop files now
# It is found automatically in $RPM_SOURCE_DIR by 'suse_update_desktop_file -i hplip':
# Source100:      hplip.desktop
# Source101 hp-toolbox.wrapper was a wrapper for hp-toolbox which is no longer needed
# see https://bugzilla.novell.com/show_bug.cgi?id=755820
# Source102 is a small man page for /usr/bin/hpijs:
Source102:      hpijs.1.gz
# Source103 was the init script for hpssd which is obsolete since version 2.8.4.
# Source104 was a script which outputs a global HAL fdi file which is obsolete
# since openSUSE 11.2 where HAL is no longer used to manage ACLs,
# see https://bugzilla.novell.com/show_bug.cgi?id=542473#c13
# Source105 hplip.SuSEfirewall2 provides support
# to open UDP ports 5353(mdns) and 427(svrloc) for mDNS support
# according to the init-suse-firewall in the tar ball
# (compare also Novell/Suse Bugzilla bnc#498429)
# hplip.SuSEfirewall2 is no longer provided
# see https://bugzilla.novell.com/show_bug.cgi?id=757354#c10
# Source106 hp-systray.wrapper was a wrapper for hp-systray which is no longer needed
# see https://bugzilla.novell.com/show_bug.cgi?id=649280
# Patch100... is for special Suse patches:
# Patch101 change-udev-rules.diff changes the udev rules file 56-hpmud.rules
Patch101:       change-udev-rules.diff
# Patch102 was disable-chgrp_lp.diff that deactivated the "chgrp lp" in Makefile.am
# because during build this results "Operation not permitted" which
# is no longer needed because there is no longer that "chgrp" stuff in HPLIP version 3.13.10.
# Patch103 was no-hplip_cron.diff that deactivated the "cron" stuff in Makefile.am which
# is no longer needed because there is no longer any "cron" stuff in HPLIP version 3.13.6
# Patch104 do_not_open_mdns_port.diff deactivates the open_mdns_port functionality
# in distros.dat for SUSE distros to avoid security issues when ports in the firewall
# get opened. see https://bugs.launchpad.net/bugs/426161
Patch104:       do_not_open_mdns_port.diff
# Patch105 was deactivate-add_group-function.diff that deactivated
# the add_group function that would add the groups ('lp') to user which
# would cause security issues see https://bugs.launchpad.net/bugs/1197416
# which is no longer needed because there is no longer that "chgrp" stuff in HPLIP version 3.13.10.
# Patch106 disable_hp-upgrade.patch disables hp-upgrade/upgrade.py for security reasons,
# see https://bugzilla.novell.com/show_bug.cgi?id=853405
# To upgrade HPLIP an openSUSE software package manager like YaST or zypper should be used.
Patch106:       disable_hp-upgrade.patch
# PATCH-FIX-SUSE: use proper udev rulesdir which is in usr not in /etc
Patch107:       hplip-udev-rules-in-usr.patch
# HPLIP's Python module cupsext.so has a build-time dependancy on the CUPS version:
# It needs symbols (like ippFirstAttribute, ippNextAttribute, ippSetOperation etc)
# that are defined only in libcups.so version > 1.5. For backward compatibility
# cupsext.c has a macro (CUPS_VERSION_1_6) which defines those undefined function names
# if CUPS version is <= 1.5. To check the CUPS version the CUPS_VERSION_MAJOR, CUPS_VERSION_MINOR
# macros from cups/cups.h are used which means it depends on the CUPS version during build-time
# whether or not cupsext will work with CUPS <= 1.5 at run-time.
# See https://bugs.launchpad.net/hplip/+bug/1423220
# and https://bugzilla.opensuse.org/show_bug.cgi?id=918387
# Therefore it BuildRequires the CUPS version as provided in the openSUSE/SLE versions.
# Up to openSUSE 13.2 and SLE11 CUPS < 1.6 is provided (from CUPS 1.3.9 for SLE11 up to CUPS 1.5.4 for openSUSE 13.2).
# For SLE12 by default CUPS 1.7.5 is provided and alternatively CUPS 1.5.4 is provided in the "legacy" module.
# After openSUSE 13.2 (i.e. for current openSUSE Factory) CUPS 2.0 is provided.
# Up to openSUSE 13.2 and SLE12 it BuildRequires CUPS < 1.6 to ensure it even works on SLE12 with CUPS 1.5.4.
# When it was built with CUPS > 1.5 it must also require CUPS > 1.5 during run-time.
# In contrast when it was built with CUPS < 1.6 there must not be a run-time requirement
# for a CUPS version to ensure it works on SLE12 both with CUPS 1.7.5 and CUPS 1.5.4.
# For suse_version values see https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto
%if 0%{?suse_version} > 1320
# For openSUSE after 13.2 (i.e. for current openSUSE Factory) CUPS > 1.5 is provided and required:
BuildRequires:  cups > 1.5
BuildRequires:  cups-devel > 1.5
Requires:       cups > 1.5
%endif
%if 0%{?suse_version} == 1315
# For SLE12 build it with traditional CUPS 1.5.4 to ensure it works on SLE12 both with CUPS 1.7.5 and CUPS 1.5.4.
# Only in the Printing project for SLE12 use cups154 and cups154-devel (from the cups154-SLE12 source package):
BuildRequires:  cups154
BuildRequires:  cups154-devel
Requires:       cups
%endif
%if 0%{?suse_version} == 1320 || 0%{?suse_version} < 1315
# For openSUSE 13.2 and for openSUSE 13.1 and older openSUSE and SLE11 versions CUPS < 1.6 is provided:
BuildRequires:  cups < 1.6
BuildRequires:  cups-devel < 1.6
Requires:       cups
%endif
BuildRequires:  dbus-1-devel
BuildRequires:  fdupes
BuildRequires:  hicolor-icon-theme
BuildRequires:  libdrm-devel
BuildRequires:  libgphoto2-devel
BuildRequires:  libjpeg-devel
BuildRequires:  libqt4-devel
BuildRequires:  libtool
BuildRequires:  libusb-1_0-devel
BuildRequires:  net-snmp-devel
BuildRequires:  pkgconfig
# All printer driver packages should have "BuildRequires: python-cups"
# because python-cups installs special rpm macros that adds Provides tags
# for the printer drivers supported by the package,
# see https://bugzilla.novell.com/show_bug.cgi?id=735865
BuildRequires:  python-cups
BuildRequires:  python-devel
BuildRequires:  python-openssl
BuildRequires:  python-qt4
BuildRequires:  python-xml
BuildRequires:  readline-devel
%if 0%{?suse_version} > 1130
BuildRequires:  sane-backends-devel
%else
BuildRequires:  sane-backends
%endif
# For udev macros
%if 0%{?suse_version} > 1130
BuildRequires:  systemd-rpm-macros
%else
# For older suse_version (in particular for SLE11) define needed udev macros manually:
%{!?_udevrulesdir: %global _udevrulesdir /usr/lib/udev/rules.d }
%endif
%if 0%{?suse_version} == 1110
# For SLE11 redefine _libexecdir because on SLE11 _libexecdir is "/usr/lib64":
%global _libexecdir /usr/lib
%endif
BuildRequires:  update-desktop-files
# Require the exact matching version-release of the hpijs sub-package to make sure
# to have the exact matching version of libhpip and libhpmud installed.
# The exact matching version-release of the sub-package is available on the same
# repository where the main-package is (compare the "Recommends: hplip" entry below).
Requires:       %{name}-hpijs = %{version}-%{release}
# Require the exact matching version-release of the sane sub-package to make sure
# to have the exact matching version of libsane-hpaio installed:
Requires:       %{name}-sane = %{version}-%{release}
# Since version 2.8.4 all interprocess communication uses dbus.
# Therefore python-dbus version 0.80 or greater is required (which pulls in dbus base stuff).
# The dbus stuff in HPLIP requires the Python module gobject
# but there is no automated RPM requirement for python-gobject2,
# see https://answers.launchpad.net/hplip/+question/30741
Requires:       dbus-1-python >= 0.80
# Because foomatic-rip-hplip has CVE-2011-2697 (bnc#698451)
# plus a leftover in CVE-2004-0801 (bnc#59233)
# foomatic-rip-hplip is no longer installed and foomatic-rip
# from foomatic-filters or cups-filters-foomatic-rip is used instead.
# The RPM requirement for foomatic-filters should actually be
# in the hplip-hpijs sub-package but this would bloat a minimalist system
# (see the comment for the hplip-hpijs sub-package below).
# Therefore the hplip main package which is intended
# to get "all the HPLIP stuff" installed has the RPM requirement:
Requires:       foomatic-filters
# foomatic-filters and cups-filters-foomatic-rip
# do not require Ghostscript because depending on the PPD
# (e.g. some PPDs for PostScript printers in OpenPrintingPPDs-postscript)
# foomatic-rip can also be used without Ghostscript but for the drivers
# HPIJS and HPCUPS Ghostscript is needed.
# The RPM requirement for ghostscript should actually be in the
# hplip-hpijs sub-package but this would bloat a minimalist system
# (see the comment for the hplip-hpijs sub-package below).
# Therefore the hplip main package which is intended
# to get "all the HPLIP stuff" installed has the RPM requirement:
Requires:       ghostscript
Requires:       python-gobject2
# Since version 3.9.2 by default only Qt4 is used:
Requires:       python-qt4
# Require special Python stuff (which pulls in Python base stuff).
# At least since openSUSE 11.1 and SLE11 pyxml is no longer required
# (pyxml was required in particular for openSUSE 10.3 and SLE10,
#  see https://answers.launchpad.net/hplip/+question/25696)
# but meanwhile python-xml alone is sufficient for "import xml.parsers.expat"
# see https://bugzilla.novell.com/show_bug.cgi?id=656779#c3
Requires:       python-xml
Requires(post): %{_bindir}/find
Requires(post): /bin/grep
Requires(post): /bin/sed
Requires(post): coreutils
# Either the hplip17 packages or the hplip packages can be installed,
# see https://bugzilla.novell.com/show_bug.cgi?id=251830#c20
# for the full story why there is this unversioned Obsoletes:
Obsoletes:      hplip17
# Obsolete the hplip3 copy that was introduced for older SLED11-GA HP preloads:
Provides:       hplip3 = 3.9.5
Obsoletes:      hplip3 < 3.9.5
# Install into this non-root directory (required when norootforbuild is used):
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
# BuildRequires foomatic-filters (also provided by cups-filters-foomatic-rip)
# to avoid /usr/lib/rpm/brp-symlink ERROR:
#   link target doesn't exist (neither in build root nor in installed system):
#   /usr/lib/cups/filter/foomatic-rip-hplip -> /usr/bin/foomatic-rip (for foomatic-filters) or
#   /usr/lib/cups/filter/foomatic-rip-hplip -> /usr/lib/cups/filter/foomatic-rip (for cups-filters-foomatic-rip)
# From openSUSE 13.2 on explicitly "BuildRequires cups-filters-foomatic-rip"
# to avoid that foomatic-filters is used for build in the "Printing" development project
# (in "Printing" foomatic-filters exists intentionally also for openSUSE_13.2 and openSUSE_Factory)
# which would not match what is used for build in openSUSE:13.2 or openSUSE:Factory
# (in openSUSE:13.2 or openSUSE:Factory foomatic-filters is intentionally dropped).
# Using the matching package for build results that the backward compatibility link
# /usr/lib/cups/filter/foomatic-rip-hplip (see the install section below)
# points to a foomatic-rip executable that is used by default on the runtime system.
%if 0%{?suse_version} > 1310
BuildRequires:  cups-filters-foomatic-rip
%else
BuildRequires:  foomatic-filters
%endif

%description
The Hewlett-Packard Linux Imaging and Printing project (HPLIP) provides
a unified single and multifunction connectivity solution for HP
printers and scanners (in particular, HP all-in-one devices).

HPLIP provides unified connectivity for printing, scanning, sending
faxes, photo card access, and device management and is designed to work
with CUPS.

It includes the Ghostscript printer driver HPIJS for HP printers and a
special "hp" CUPS back-end that provides bidirectional communication
with the device (required for HP printer device management).

It also includes the SANE scanner driver "hpaio" for HP all-in-one
devices. Basic PC send fax functionality is supported on a number of
devices.

The special "hpfax" CUPS back-end is required to send faxes. Direct
uploading (i.e. without print and scan) of received faxes from the
device to the PC is not supported.

The "hp-toolbox" program is provided for device management.

The "hp-sendfax" program must be used to send faxes.

The "hp-setup" program can be used to set up HP all-in-one devices.

The HPLIP project is open source software and uses GPL-compatible
licenses. For more information, see:

http://hplipopensource.com

%{_docdir}/hplip/index.html

%package hpijs
Summary:        Only plain printing with HPLIP printer drivers
Group:          Hardware/Printing
# On a minimalist system only hplip-hpijs may be installed
# or on a minimalist package repository (e.g. on the openSUSE CDs)
# only hplip-hpijs may be available (even when a usual system is installed).
# When only hplip-hpijs is there, it should tell the dependency resolver
# that for usual functionality, hplip should be installed too (if possible).
# Unfortunately the installer ignores suggested packages silently
# but on the other hand I cannot use "Recommends hplip" here
# because the installer installs recommended packages silently
# which would bloat a minimal selection (when hplip is available to be installed)
# because the minimal selection contains hplip-hpijs which recommends hplip
# so that the installer installs hplip and all what this requires silently
# see https://bugzilla.novell.com/show_bug.cgi?id=546893
# Require only the matching version of the hplip main-package
# (compare the "Requires: hplip-hpijs" entry above) but do not depend
# on the exact matching release because the exact matching release
# may be not available to be installed (e.g. when hplip-hpijs-1.2.3-4.5 is
# installed from the openSUSE CDs but on our official online repository
# only hplip-1.2.3-6.7 is available which should usually also work):
Suggests:       %{name} = %{version}
# Since Nov 14 2007 ghostscript-library does no longer require /usr/bin/hpijs
# but only "Suggests hplip-hpijs" (see Novell/Suse Bugzilla bnc#341564).
# Have the matching "reverse suggests" = "Enhances" here
# to document the ghostscript <-> hplip-hpijs relationship:
Enhances:       ghostscript
# hpijs-standalone was a stand-alone minimalist package
# which is no longer provided since a long time.
# hplip-hpijs and hpijs-standalone both contain /usr/bin/hpijs
# so that both packages have a RPM conflict which should
# be solved by a silent replacement of the old hpijs-standalone.
# This Obsoletes is intentionally unversioned because
# hplip-hpijs should replace any version of hpijs-standalone.
Obsoletes:      hpijs-standalone
# Either the hplip17 packages or the hplip packages can be installed,
# see https://bugzilla.novell.com/show_bug.cgi?id=251830#c20
# for the full story why there is this unversioned Obsoletes:
Obsoletes:      hplip17-hpijs
# Obsolete the hplip3 copy that was introduced for older SLED11-GA HP preloads:
Provides:       hplip3-hpijs = 3.9.5
Obsoletes:      hplip3-hpijs < 3.9.5
# PackMan provides HPLIP in the packages hplip and hplip-hpcups.
# HPLIP does not work if the openSUSE packages hplip and hplip-hpijs
# are installed together with a leftover PackMan package hplip-hpcups
# see https://bugzilla.novell.com/show_bug.cgi?id=515005#c17
# This Obsoletes is intentionally unversioned because
# the openSUSE package hplip-hpijs must replace
# any version of PackMan's hplip-hpcups package.
Obsoletes:      hplip-hpcups

%description hpijs
HPIJS is HPLIP's Ghostscript printer driver for HP printers.
HPCUPS is HPLIP's native CUPS printer driver for HP printers.

This sub-package includes only what is needed for plain printing
with the printer drivers in HPLIP for standard HP printers.

It does neither provide device status information,
nor support for scanning, nor support for faxing,
nor support for memory card (mass storage) access,
nor support for non-standard devices e.g. no support
for devices which require an additional plugin from HP.

This sub-package includes in particular:

The hpijs binary and the libraries libhpip and libhpmud
which are needed to run it.

The HPCUPS driver (%{_prefix}/lib[64]/cups/filter/hpcups).

The CUPS backend "hp".

All HPLIP PPD files (also for HP PostScript printers).

For the full-featured HPLIP printing and scanning solution,
the main-package package hplip must be installed.

For full documentation and license see the main-package hplip.

%package sane
Summary:        Only plain scanning with HPLIP scan drivers
Group:          Hardware/Scanner
# Require the exact matching version-release of the hpijs sub-package to make sure
# to have the exact matching version of libhpip and libhpmud installed.
# A wrong library version may let libsane-hpaio crash (e.g. segfault)
# which lets the whole scanning stack frontend<->libsane-dll<->libsane-backend crash
# also for any other backend when the hpaio backend is enabled (e.g. "scanimage -L"):
Requires:       %{name}-hpijs = %{version}-%{release}
# See comment in hpijs sub-package for same Suggests:
Suggests:       %{name} = %{version}
Enhances:       sane-backends
# Automatically install this package if hpijs sub-package and sane-backends are
# both installed:
Supplements:    packageand(%{name}-hpijs:sane-backends)

%description sane
This sub-package includes only what is needed for plain scanning
with the scan drivers in HPLIP for standard HP all-in-one printers.

%package devel
Summary:        Development files for hplip
Group:          Development/Languages/C and C++
# Require the exact matching version-release of the hpijs sub-package to make sure
# to have the exact matching version of libhpip and libhpmud installed:
Requires:       %{name}-hpijs = %{version}-%{release}
# Require the exact matching version-release of the sane sub-package to make sure
# to have the exact matching version of libsane-hpaio installed:
Requires:       %{name}-sane = %{version}-%{release}

%description devel
This sub-package is only required by developers.

%prep
# Be quiet when unpacking:
%setup -q
# Patch101 change-udev-rules.diff changes the udev rules file 56-hpmud.rules
%patch101 -b .change-udev-rules.orig
# Patch104 do_not_open_mdns_port.diff deactivates the open_mdns_port functionality
# in distros.dat for SUSE distros to avoid security issues when ports in the firewall
# get opened. see https://bugs.launchpad.net/bugs/426161
%patch104 -b .do_not_open_mdns_port.orig
# Patch106 disable_hp-upgrade.patch disables hp-upgrade/upgrade.py for security reasons,
# see https://bugzilla.novell.com/show_bug.cgi?id=853405
# To upgrade HPLIP an openSUSE software package manager like YaST or zypper should be used.
%patch106 -b .disable_hp-upgrade.orig
%patch107 -p1 -b .udev_rules_dir.orig

%build
# If AUTOMAKE='automake --foreign' is not set, autoreconf (in fact automake)
# complains about missing files like NEWS, README, AUTHORS, ChangeLog
# in each directory where a Makefile.am exists:
AUTOMAKE='automake --foreign' autoreconf -fvi
# Set our preferred architecture-specific flags for the compiler and linker:
export CFLAGS="%{optflags}"
export CXXFLAGS="%{optflags} -fno-strict-aliasing"
# Static "hpijs" PPD files via enable-foomatic-ppd-install
# require foomatic-rip-hplip via their cupsFilter entries
# so that enable-foomatic-rip-hplip-install is also needed.
# Since version 3.9.6 the default printer driver install changed from hpijs to hpcups.
# According to http://hplipopensource.com/hplip-web/release_notes.html
# all drv installs require CUPSDDK 1.2.3 or higher.
# Otherwise a static PPD install must be performed.
# Furthermore dynamic PPDs will be deprecated in the future in CUPS,
# see http://www.cups.org/str.php?L3772
# For hpcups static PPD install one needs:
# --enable-hpcups-install enable hpcups install (default=yes)
# --disable-cups-drv-install enable cups dynamic ppd install (default=yes)
# --enable-cups-ppd-install enable cups static ppd install (default=no)
# For both hpcups and hpijs install with static PPDs one needs additionally:
# --enable-hpijs-install enable hpijs install (default=no)
# --disable-foomatic-drv-install enable foomatic dynamic ppd install (default=no), uses drvdir and hpppddir
# --enable-foomatic-ppd-install enable foomatic static ppd install (default=no), uses hpppddir
# --enable-foomatic-rip-hplip-install enable foomatic-rip-hplip install (default=no), uses cupsfilterdir
# Because foomatic-rip-hplip has CVE-2011-2697 (bnc#698451) plus a leftover in CVE-2004-0801 (bnc#59233)
# which are fixed up to openSUSE 11.4 with patches, after openSUSE 11.4 (i.e. since openSUSE 12.1)
# foomatic-rip-hplip is no longer installed and foomatic-rip from
# foomatic-filters or cups-filters-foomatic-rip is used instead so that
# --disable-foomatic-rip-hplip-install is explicitly set and as a consequence the "cupsFilter" entries
# in the static PPDs are changed in the install section to use foomatic-rip.
# Since HPLIP 3.13.10 --with-htmldir is new but it does not inhertit its value from --with-docdir
# so that --with-htmldir must be explicitly set.
%configure \
            --disable-qt3 \
            --enable-qt4 \
            --disable-policykit \
            --enable-doc-build \
            --enable-network-build \
            --enable-pp-build \
            --enable-scan-build \
            --enable-gui-build \
            --enable-fax-build \
            --enable-dbus-build \
            --enable-hpcups-install \
            --disable-cups-drv-install \
            --enable-cups-ppd-install \
            --enable-hpijs-install \
            --disable-foomatic-drv-install \
            --enable-foomatic-ppd-install \
            --disable-foomatic-rip-hplip-install \
            --with-hpppddir=%{_datadir}/cups/model/manufacturer-PPDs/%{name} \
            --with-cupsbackenddir=%{_libexecdir}/cups/backend \
            --with-cupsfilterdir=%{_libexecdir}/cups/filter \
            --with-drvdir=%{_libexecdir}/cups/driver \
            --with-mimedir=%{_sysconfdir}/cups \
            --with-docdir=%{_defaultdocdir}/%{name} \
            --with-htmldir==%{_defaultdocdir}/%{name}
make %{?_smp_mflags}

%install
make DESTDIR=%{buildroot} install %{?_smp_mflags}
# Make and install Python compiled bytecode files
# (.pyc compiled python and .pyo optimized compiled python)
# because normal users do not have write permissions
# to the install location /usr/share/hplip/ so that
# for normal users Python would recompile the sources every time
# which results longer program startup time and waste of CPU for compiling,
# see https://en.opensuse.org/openSUSE:Packaging_Python#Byte_Compiled_Files
# and http://lists.opensuse.org/opensuse-packaging/2014-10/msg00028.html
# Make and install .pyc files:
%py_compile %{buildroot}%{_datadir}/hplip
# Make and install .pyo files:
%py_compile -O %{buildroot}%{_datadir}/hplip
# Hardlink .pyc and .pyo when they have same content.
# Do not run "fdupes buildroot/_datadir/hplip" because
# fdupes will link any files with same content there
# which can have unexpected side-effects, compare
# https://bugzilla.opensuse.org/show_bug.cgi?id=784670
for pyc in $( find %{buildroot}%{_datadir}/hplip -name '*.pyc' )
do pyo="${pyc%.pyc}.pyo"
   if test -f $pyo && cmp -s $pyc $pyo
   then echo hardlinking $pyc and $pyo because both have same content
        ln -f $pyc $pyo
   fi
done
# HPLIP's "make install" installs -rw-r--r-- usr/share/hplip/fax/pstotiff
# and usr/lib/cups/filter/pstotiff -> usr/share/hplip/fax/pstotiff
# so that when the CUPS filter usr/lib/cups/filter/pstotiff is called,
# it cannot execute usr/share/hplip/fax/pstotiff which is fixed hereby
# (see https://bugs.launchpad.net/hplip/+bug/1064247 and bnc#783810):
chmod a+x %{buildroot}%{_datadir}/hplip/fax/pstotiff
# The /var/lib/hp directory is created everywhere except on openSUSE 12.2 and later versions
# (perhaps an autoconf issue) so that it is created here as simple and fail-safe workaround
# see https://bugs.launchpad.net/bugs/1018303 and bnc#780413
# using fixed "/var/log/hp" because this is hardcoded in the HPLIP sources
# regarding owner and permissions see the "files hpijs" section below
# and Patch102 no-chgrp_lp_hplip_Logdir.diff:
test -d %{buildroot}%{_localstatedir}/lib/hp || install -d %{buildroot}%{_localstatedir}/lib/hp
# Create a /var/log/hp/tmp/ directory that is needed by hp-sendfax
# as a workaround until HPLIP upstream implemented it correctly
# see https://bugzilla.novell.com/show_bug.cgi?id=800312
# and https://bugs.launchpad.net/bugs/1016507
install -d %{buildroot}%{_localstatedir}/log/hp/tmp
# Remove the installed /etc/sane.d/dll.conf
# because this is provided by the sane-backends package:
rm %{buildroot}%{_sysconfdir}/sane.d/dll.conf
# Remove the installed HAL fdi file because HAL is no longer used (HAL is deprecated):
rm %{buildroot}%{_datadir}/hal/fdi/preprobe/10osvendor/20-hplip-devices.fdi
# Remove the installed hplip-printer@.service file for systemd
# because it would run hp-config_usb_printer - a tool to automatically
# set up HP USB printers and if needed automatically download and install
# non-free proprietary plugin software from HP which should not happen
# and it can cause whatever kind of strange behaviour
# see for example https://bugs.launchpad.net/bugs/1197416
# while in contrast manual printer setup via hp-setup usually "just works"
# and it is clear for the user what goes on and in case of failure what went wrong.
rm %{buildroot}%{_libexecdir}/systemd/system/hplip-printer@.service
# Begin "General tests and adjustments for all PPDs" (see manufacturer-PPDs.spec):
pushd %{buildroot}%{_datadir}/cups/model/manufacturer-PPDs/%{name}
# Do not pollute the build log file with zillions of meaningless messages:
set +x
gunzip *.ppd.gz
# Make some general tests and adjustments for all PPDs:
echo "Making some general tests and adjustments for all PPDs:"
# Add a line-feed to the end of all PPDs to fix those PPDs where it is missing.
# See Novell/Suse Bugzilla bug #309832: Unix/Linux text files must end with a line-feed.
# Otherwise reading the last line results EOF and then some programs may ignore the last line.
echo "Adding a line-feed to the end of all PPDs to fix those PPDs where it is missing..."
for p in *.ppd
do echo -en '\n' >>$p
done
# Because foomatic-rip-hplip has CVE-2011-2697 (bnc#698451) plus a leftover in CVE-2004-0801 (bnc#59233)
# foomatic-rip-hplip is no longer installed and foomatic-rip from foomatic-filters or cups-filters-foomatic-rip
# is used instead so that the "cupsFilter" entries in the static PPDs must be changed accordingly:
echo "Replacing insecure foomatic-rip-hplip with foomatic-rip everywhere in in the PPDs..."
for p in *.ppd
do sed -i -e 's/foomatic-rip-hplip/foomatic-rip/' $p
done
# Final test by cupstestppd:
# To save disk space gzip the files (gzipped PPDs can also be used by CUPS).
# Future goal: Only have files which don't FAIL for cupstestppd.
# Ignore FAILs because of errors in UIConstraints and/or NonUIConstraints
# which are detected since cupstestppd in CUPS > 1.2.7 (i.e. in openSUSE 10.3).
# See Novell/Suse Bugzilla bug #309822: When this bug is fixed, cupstestppd would
# no longer result zero exit code.
# In the long run the PPDs should be fixed but as far as we know there have been
# no problems because of such UIConstraints errors so that it should be o.k.
# let those PPDs pass even if they are not strictly compliant.
# Ignore FAILs because of missing cupsFilter programs because
# in the package build environment the usual HPLIP filters
# like "hpcups" and "hpcupsfax" are
# installed at an unusual place (in the BuildRoot directory).
# For now keep all PPDs even if cupstestppd FAILs.
# Reason:
# With each CUPS version upgrade cupstestppd finds more and more errors
# so that more and more PPDs would be no longer included in the RPM
# which have been included before which results a regression.
# As far as we know there have been no problems at all because of
# not strictly compliant PPDs in HPLIP so that it is much better
# to provide all HPLIP PPDs so that the matching printers can be used
# than to be rigorous regarding enforcing compliance to the PPD specification:
echo "Final testing by cupstestppd..."
for p in *.ppd
do grep -E -v '^\*UIConstraints:|^\*NonUIConstraints:|^\*cupsFilter:' $p | cupstestppd - || true
   gzip $p
done
echo "Moving PPDs that use the hpps filter to %{_datadir}/cups/model/manufacturer-PPDs/hplip-hpps..."
# PPDs for various printers that use the hpps filter
# must be moved to the hplip main-package because
# the /usr/lib/cups/filter/hpps Python script imports
# various HPLIP modules from the hplip main-package
# so that the hpps filter belongs to the hplip main-package
# (see https://bugzilla.novell.com/show_bug.cgi?id=876690).
# Accordingly the PPDs that use the hpps filter must be moved
# to the hplip main-package which is implemented by moving them
# to a new directory /usr/share/cups/model/manufacturer-PPDs/hplip-hpps
# that is listed in the files list of the hplip main-package:
install -d %{buildroot}%{_datadir}/cups/model/manufacturer-PPDs/%{name}-hpps
for p in *.ppd.gz
do zgrep -q '^\*cupsFilter:.*hpps' $p && mv $p ../%{name}-hpps
done
echo "Moving PPDs that require a proprietary plugin from HP to %{_datadir}/cups/model/manufacturer-PPDs/hplip-plugin..."
# PPDs for various printers that require a proprietary plugin from HP
# must be moved to the hplip main-package because
# the proprietary plugin from HP must be downloaded and installed
# by using HP's "hp-plugin" tool from the hplip main-package
# (HP's "hp-setup" tool calls "hp-plugin" when needed).
# Accordingly PPDs that require a proprietary plugin from HP must be moved
# to the hplip main-package which is implemented by moving them
# to a new directory /usr/share/cups/model/manufacturer-PPDs/hplip-plugin
# that is listed in the files list of the hplip main-package
# (see https://bugzilla.novell.com/show_bug.cgi?id=876690):
install -d %{buildroot}%{_datadir}/cups/model/manufacturer-PPDs/%{name}-plugin
for p in *.ppd.gz
do zgrep -q '^\*NickName:.*requires proprietary plugin' $p && mv $p ../%{name}-plugin
done
echo "End of general tests and adjustments for all PPDs."
# Switch back to the usual build log messages:
set -x
# End of "General tests and adjustments for all PPDs":
popd
# Because foomatic-rip-hplip has CVE-2011-2697 (bnc#698451)
# plus a leftover in CVE-2004-0801 (bnc#59233)
# foomatic-rip-hplip is no longer installed and foomatic-rip
# from foomatic-filters or cups-filters-foomatic-rip must be used instead.
# To be backward compatible with PPDs in /etc/cups/ppd/ for existing print queues
# a compatibility link /usr/lib/cups/filter/foomatic-rip-hplip is installed
# which points to the actual foomatic-rip executable.
# In foomatic-filters foomatic-rip is installed as /usr/bin/foomatic-rip but
# in cups-filters-foomatic-rip it is installed as /usr/lib/cups/filter/foomatic-rip:
if test -e %{_libexecdir}/cups/filter/foomatic-rip
then ln -s foomatic-rip %{buildroot}%{_libexecdir}/cups/filter/foomatic-rip-hplip
else if test -e %{_bindir}/foomatic-rip
     then ln -s ../../../bin/foomatic-rip %{buildroot}%{_libexecdir}/cups/filter/foomatic-rip-hplip
     fi
fi
# Replace the invalid Desktop categories
%suse_update_desktop_file -r %{buildroot}%{_datadir}/applications/hplip.desktop System HardwareSettings
# Let suse_update_desktop_file add X-SuSE-translate key to /etc/xdg/autostart/hplip-systray.desktop
# so that we can update its translations with translation-only packages.
%suse_update_desktop_file %{buildroot}%{_sysconfdir}/xdg/autostart/hplip-systray.desktop
# End of "Desktop menue entry stuff".
# Install the man page for /usr/bin/hpijs:
install -d %{buildroot}%{_mandir}/man1
install -m 644 %{SOURCE102} %{buildroot}%{_mandir}/man1/
# Run fdupes:
# The RPM macro fdupes runs /usr/bin/fdupes that links files with identical content.
# Never run fdupes carelessly over the whole buildroot directory
# because in older openSUSE and SLE11 versions fdupes
# links files with different owner, group, or permissions
# see https://bugzilla.novell.com/show_bug.cgi?id=784670
# and even in current openSUSE versions fdupes links across sub-package boundaries,
# compare https://bugzilla.novell.com/show_bug.cgi?id=784869
# so that fdupes can only run for specific directories where linking files is safe:
%fdupes -s %{buildroot}%{_datadir}/hplip/data/images

%post -p /bin/bash
%if 0%{?suse_version} > 1130
%udev_rules_update
%endif
%if 0%{?suse_version} >= 1140
%desktop_database_post
%endif
%if 0%{?suse_version} > 1130
%icon_theme_cache_post
%else
gtk-update-icon-cache %{_datadir}/icons/hicolor || true
%endif
/sbin/ldconfig
exit 0

%triggerin -p /bin/bash -- sane-backends
# As hplip can be used for plain printers it cannot "PreReq sane-backends".
# Therefore if sane-backends is installed it may be installed or updated after hplip.
# In this case trigger to add the SANE backend "hpaio" to /etc/sane.d/dll.conf if it is not there.
# To be safe there is a test that /etc/sane.d/dll.conf is writable.
if [ -w %{_sysconfdir}/sane.d/dll.conf ]
then if ! grep -q 'hpaio' %{_sysconfdir}/sane.d/dll.conf
     then echo -e '# The hpaio backend is provided by the hplip package:\n#hpaio' >>%{_sysconfdir}/sane.d/dll.conf
     fi
fi
exit 0

%postun -p /bin/bash
%if 0%{?suse_version} >= 1140
%desktop_database_postun
%endif
%if 0%{?suse_version} > 1130
%icon_theme_cache_postun
%else
gtk-update-icon-cache %{_datadir}/icons/hicolor || true
%endif
/sbin/ldconfig
# If the package was removed (but not if it was updated)
# then remove the hpaio lines in /etc/sane.d/dll.conf.
# Don't remove them when the hplip package was automatically
# replaced by the hplip17 package (via RPM obsoletes) or vice versa.
# Because postun of the old package runs last (after triggerin -- sane-backends)
# it is done via a special "ls" test if any libsane-hpaio.so exists
# (e.g. there could be only 32-bit installed on 64-bit hardware).
# If the "ls" test does not fail, some kind of HPLIP is installed.
# The package sane-backends may not be installed (see triggerin)
# and therefore the test that /etc/sane.d/dll.conf is writable.
# The "exit 0" is necessary, otherwise the postun script
# would exit with non-zero exit-code if the package was not removed.
if [ "$1" = "0" ]
then if ! ls %{_prefix}/lib*/sane/libsane-hpaio.so* &>/dev/null
     then [ -w %{_sysconfdir}/sane.d/dll.conf ] && sed -i -e '/hpaio/d' %{_sysconfdir}/sane.d/dll.conf
     fi
fi
exit 0

%post hpijs -p /bin/bash
/sbin/ldconfig
exit 0

%postun hpijs -p /bin/bash
/sbin/ldconfig
exit 0

%files
%defattr(-, root, root)
%config %{_sysconfdir}/xdg/autostart/hplip-systray.desktop
%if 0%{?suse_version} == 1110
%dir /usr/lib/udev
%dir /usr/lib/udev/rules.d
%endif
%config %{_udevrulesdir}/56-hpmud.rules
%{_bindir}/hp-align
%{_bindir}/hp-check
%{_bindir}/hp-clean
%{_bindir}/hp-colorcal
%{_bindir}/hp-config_usb_printer
%{_bindir}/hp-devicesettings
%{_bindir}/hp-diagnose_plugin
%{_bindir}/hp-diagnose_queues
%{_bindir}/hp-doctor
%{_bindir}/hp-fab
%{_bindir}/hp-faxsetup
%{_bindir}/hp-firmware
%{_bindir}/hp-info
%{_bindir}/hp-levels
%{_bindir}/hp-linefeedcal
%{_bindir}/hp-logcapture
%{_bindir}/hp-makecopies
%{_bindir}/hp-makeuri
%{_bindir}/hp-pkservice
%{_bindir}/hp-plugin
%{_bindir}/hp-pqdiag
%{_bindir}/hp-print
%{_bindir}/hp-printsettings
%{_bindir}/hp-probe
%{_bindir}/hp-query
%{_bindir}/hp-scan
%{_bindir}/hp-sendfax
%{_bindir}/hp-setup
%{_bindir}/hp-systray
%{_bindir}/hp-testpage
%{_bindir}/hp-timedate
%{_bindir}/hp-toolbox
%{_bindir}/hp-uninstall
%{_bindir}/hp-unload
%{_bindir}/hp-upgrade
%{_bindir}/hp-wificonfig
%{_libdir}/python%{py_ver}/site-packages/cupsext.*
%{_libdir}/python%{py_ver}/site-packages/hpmudext.*
%{_libdir}/python%{py_ver}/site-packages/pcardext.*
%{_libdir}/python%{py_ver}/site-packages/scanext.*
%dir %{_libexecdir}/cups
%dir %{_libexecdir}/cups/backend
%{_libexecdir}/cups/backend/hpfax
%dir %{_libexecdir}/cups/filter
%{_libexecdir}/cups/filter/hpps
%dir %{_datadir}/cups
%dir %{_datadir}/cups/model
%dir %{_datadir}/cups/model/manufacturer-PPDs
%{_datadir}/cups/model/manufacturer-PPDs/%{name}-hpps/
%{_datadir}/cups/model/manufacturer-PPDs/%{name}-plugin/
%doc %{_defaultdocdir}/%{name}/
%{_datadir}/applications/%{name}.desktop
%{_datadir}/hplip/
%exclude %{_datadir}/hplip/data/models/models.dat

%files hpijs
%defattr(-, root, root)
%config %{_sysconfdir}/hp/
%config %{_sysconfdir}/cups/pstotiff.convs
%config %{_sysconfdir}/cups/pstotiff.types
%{_bindir}/hpijs
%doc %{_mandir}/man1/hpijs.1.gz
%{_libdir}/libhpip.so.*
%{_libdir}/libhpmud.so.*
%dir %{_libexecdir}/cups
%dir %{_libexecdir}/cups/backend
%{_libexecdir}/cups/backend/hp
%dir %{_libexecdir}/cups/filter
%{_libexecdir}/cups/filter/foomatic-rip-hplip
%{_libexecdir}/cups/filter/hpcups
%{_libexecdir}/cups/filter/hpcupsfax
%{_libexecdir}/cups/filter/pstotiff
%dir %{_datadir}/cups
%dir %{_datadir}/cups/model
%dir %{_datadir}/cups/model/manufacturer-PPDs
%{_datadir}/cups/model/manufacturer-PPDs/%{name}/
%{_datadir}/%{name}/data/models/models.dat
# Use fixed "/var/log/hp" because this is hardcoded in the HPLIP sources.
# Regarding attr(0775,root,lp) see the comment for /var/log/hp/tmp below:
%dir %attr(0775,root,lp) %{_localstatedir}/log/hp
# Regarding attr(0775,root,lp) for /var/log/hp/tmp
# see https://bugzilla.novell.com/show_bug.cgi?id=800312#c0
# i.e. it is reasonable secure and hp-sendfax works with it:
%dir %attr(0775,root,lp) %{_localstatedir}/log/hp/tmp
# Use fixed "/var/lib/hp" because this is hardcoded in the HPLIP sources:
%dir %{_localstatedir}/lib/hp

%files sane
%defattr(-, root, root)
%dir %{_libdir}/sane
%{_libdir}/sane/libsane-hpaio.so.*

%files devel
%defattr(-, root, root)
%{_libdir}/libhpip.so
%{_libdir}/libhpmud.so
%{_libdir}/*.la
%{_libdir}/sane/libsane-hpaio.so
%{_libdir}/sane/*.la

%changelog