File hplip.spec of Package hplip.import4987

# spec file for package hplip
# Copyright (c) 2011 SUSE LINUX Products 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

# norootforbuild

Name:           hplip
BuildRequires:  cups cups-devel dbus-1-devel fdupes libdrm-devel libgphoto2-devel libjpeg-devel libqt4-devel libusb-devel net-snmp-devel pkgconfig python-devel python-openssl python-qt4 python-xml readline-devel update-desktop-files
%if 0%{?suse_version} > 1130
BuildRequires:  sane-backends-devel
BuildRequires:  sane-backends
Summary:        HP's Printing, Scanning, and Faxing Software
# HPLIP has reached 1.0 status. With this release a date encoded revision number is used:
# x.y.m : x = major release number, y = year (eg: 6 = 2006), m = month (eg: 6a = second release in June)
# Official releases have a 3 digit number and release candidates have a 4 digit number: x.y.m.rc
Version:        3.11.5
Release:        1.<RELEASE5>
Group:          Hardware/Printing
License:        BSD3c(or similar) ; GPLv2+ ; MIT License (or similar)
# Source0...Source9 is for sources from HP:
# URL for Source0:
# URL to verify Source0:
# How to verify Source0 see:
# For example: /usr/bin/gpg --keyserver --recv-keys 0xA59047B9
#              /usr/bin/gpg --verify hplip-3.11.5.tar.gz.asc hplip-3.11.5.tar.gz
# must result: Good signature from "HPLIP (HP Linux Imaging and Printing) <>"
Source0:        %{name}-%{version}.tar.bz2
# Patch0...Patch9 is for patches from HP:
# Patch10...Patch99 is for Suse patches for the sources from HP:
# Patch10 fixes "... is used uninitialized ..." warnings:
Patch10:        fix-uninitialized-variables.diff
# 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 fixes a remote buffer overflow in hpmud/pml.c:
Patch12:        hplip-3.9.8-CVE-2010-4267.patch
# Patch13 foomatic-rip-hplip-3.11.5.CVE-2004-0801.CVE-2011-2697.patch
# fixes a leftover (strip out dangerous \x01 chars in arguments)
# which is related to CVE-2004-0801 (bnc#59233) and mainly
# it fixes CVE-2011-2697 which is a remote code execution
# as user lp issue (bnc#698451):
Patch13:        foomatic-rip-hplip-3.11.5.CVE-2004-0801.CVE-2011-2697.patch
# Source100... is for special Suse sources:
# Source100 is the primary source for the suse_update_desktop_file stuff.
# It is found automatically in $RPM_SOURCE_DIR by 'suse_update_desktop_file -i hplip':
Source100:      %{name}.desktop
# Source101 is a wrapper for hp-toolbox which shows meaningful error messages even under X.
# hp-toolbox.wrapper is called via hplip.desktop:
Source101:      hp-toolbox.wrapper
# 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
# 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):
Source105:      hplip.SuSEfirewall2
# Source106 is a wrapper for hp-systray which tests via "lpstat"
# whether or not a 'hp:/...' print queue exists and exits otherwise,
# see
# hp-systray.wrapper is called via /etc/xdg/autostart/hplip-systray.desktop
# which is changed accordingly in the install section.
Source106:      hp-systray.wrapper
# Patch100... is for special Suse patches:
# Patch101 changes the udev rules files 55-hpmud.rules and 56-hpmud_support.rules:
Patch101:       change-udev-rules.diff
# Install into this non-root directory (required when norootforbuild is used):
BuildRoot:      %{_tmppath}/%{name}-%{version}-build
PreReq:         coreutils, /bin/grep, /bin/sed, /usr/bin/find
# 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).
# 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}
# 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
# but meanwhile python-xml alone is sufficient for "import xml.parsers.expat"
# see
Requires:       python-xml
# Since version 3.9.2 by default only Qt4 is used:
Requires:       python-qt4
# 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
Requires:       dbus-1-python >= 0.80, python-gobject2
# Either the hplip17 packages or the hplip packages can be installed,
# see
# for the full story why there is this unversioned Obsoletes:
Obsoletes:      hplip17
# Skip testing devel dependencies required by libtool .la files by the following comment:
# skip-check-libtool-deps

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

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:


%package hpijs
License:        BSD3c(or similar) ; GPLv2+ ; MIT License (or similar)
Summary:        Only plain printing with HPLIP printer drivers
Group:          Hardware/Printing
# 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_any <-> hplip-hpijs relationship:
Enhances:       ghostscript_any
# 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
# 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:       hplip = %{version}
# 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
# for the full story why there is this unversioned Obsoletes:
Obsoletes:      hplip17-hpijs
# 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
# 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 HPIJS CUPS filter foomatic-rip-hplip.

The HPCUPS driver (/usr/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.

# Be quiet when unpacking:
%setup -q
# Patch10 fix-uninitialized-variables.diff
# fixes "... is used uninitialized ..." warnings:
# Patch12 hplip-3.9.8-CVE-2010-4267.patch
# fixes a remote buffer overflow in hpmud/pml.c:
# Patch13 foomatic-rip-hplip-3.11.5.CVE-2004-0801.CVE-2011-2697.patch
# fixes a leftover (strip out dangerous \x01 chars in arguments)
# which is related to CVE-2004-0801 (bnc#59233) and mainly
# it fixes CVE-2011-2697 which is a remote code execution
# as user lp issue (bnc#698451):
# Patch101 change-udev-rules.diff
# changes the udev rules files 55-hpmud.rules and 56-hpmud_support.rules:

# 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 exists:
AUTOMAKE='automake --foreign' autoreconf --force --install
# Set our preferred architecture-specific flags for the compiler and linker:
export CXXFLAGS="$RPM_OPT_FLAGS -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
# all drv installs require CUPSDDK 1.2.3 or higher.
# Otherwise a static PPD install must be performed.
# 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
./configure --prefix=/usr \
            --libdir=%_libdir \
            --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 \
            --enable-foomatic-rip-hplip-install \
            --with-hpppddir=%{_datadir}/cups/model/manufacturer-PPDs/%{name} \
            --with-cupsbackenddir=/usr/lib/cups/backend \
            --with-cupsfilterdir=/usr/lib/cups/filter \
            --with-drvdir=/usr/lib/cups/driver \
            --with-mimedir=%{_sysconfdir}/cups \

make install DESTDIR=%{buildroot}
# 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
# 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
# Correct or remove non-working PPDs:
# Several HP PPDs contain "600x600x2dpi" which is not allowed
# according to the Adobe PPD specification section 5.9
# and which can be simply replaced by "600x1200dpi"
# because "600x1200dpi" is not used elsewhere in the PPD.
# Some PPDs contain a "*cupsFilter: ... hppostprocessing" line
# which cannot work because there is no "hppostprocessing" filter.
# Some PPDs contain "1284DeviceId" which must be "1284DeviceID".
# Some PPDs contain "* PageRegion" which must be "*PageRegion".
# Some HPIJS PPDs contain a too long ShortNickName (longer than 31 chars)
# therefore from all ShortNickName entries " Foomatic/hpijs" is simply removed
# but they still exists in the NickName entries which are shown to the user
# when the user selects a PPD to set up a print queue:
echo "Correcting or removing non-working PPDs..."
for p in *.ppd
do perl -pi -e 's/600x600x2dpi/600x1200dpi/;' $p
   grep -q '^\*cupsFilter:.*hppostprocessing' $p && rm -v $p
   perl -pi -e 's/1284DeviceId/1284DeviceID/;' $p
   perl -pi -e 's/\* PageRegion/*PageRegion/;' $p
   sed -i -e '/^\*ShortNickName:/s/ Foomatic\/hpijs//;' $p
# Change default media size to A4 if this is an available choice in the PPD and then
# set DefaultPageSize, DefaultPageRegion, DefaultImageableArea, DefaultPaperDimension to A4:
echo "Changing default media size to A4 if this is an available choice in the PPD..."
for p in *.ppd
do for i in PageSize PageRegion ImageableArea PaperDimension
   do if grep -q "^\*$i[[:space:]]*A4[:/]" $p
      then grep -q "^\*Default$i:[[:space:]]*A4\$" $p || perl -pi -e "s/^\*Default$i:.*/\*Default$i: A4/" $p
# 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 "foomatic-rip-hplip", "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
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":
# Begin "Desktop menue entry stuff":
# Install the wrapper for hp-toolbox:
install -m 755 %{SOURCE101} %{buildroot}%{_bindir}/hp-toolbox.wrapper
# Install /usr/share/hplip/data/images/64x64/hp_logo.png as desktop icon file
# because it is used in the and sources:
install -d %{buildroot}%{_datadir}/pixmaps
install -m 644 %{buildroot}%{_datadir}/%{name}/data/images/64x64/hp_logo.png %{buildroot}%{_datadir}/pixmaps/HPmenu.png
# Set up and install the desktop menue entry stuff using "Categories=System;Monitor;"
# and remove HP's hplip.desktop and hplip-systray.desktop files before because we use Source100:
# (additionally there is/was a typo in HP's install because of the trailing blank at 'applications ')
rm %{buildroot}%{_datadir}/applications/%{name}*.desktop
%suse_update_desktop_file -i %{name} Settings HardwareSettings Printing
# 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}/etc/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/
# Source105 hplip.SuSEfirewall2 provides support
# to open UDP ports 5353(mdns) and 427(svrloc) for mDNS support:
install -d %{buildroot}/etc/sysconfig/SuSEfirewall2.d/services/
install -m 644 %{SOURCE105} %{buildroot}/etc/sysconfig/SuSEfirewall2.d/services/hplip
# Begin "Desktop autostart notification tray stuff":
# Install the wrapper for hp-systray:
install -m 755 %{SOURCE106} %{buildroot}%{_bindir}/hp-systray.wrapper
# Change /etc/xdg/autostart/hplip-systray.desktop to call hp-systray.wrapper:
sed -i -e '/^Exec=hp-systray$/s/hp-systray/hp-systray.wrapper/;' %{buildroot}/etc/xdg/autostart/hplip-systray.desktop
# End of "Desktop autostart notification tray stuff".
# Find duplicate files:
%fdupes -s %{buildroot}

exit 0

%triggerin -- 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 /etc/sane.d/dll.conf ]
then if ! grep -q 'hpaio' /etc/sane.d/dll.conf
     then echo -e '# The hpaio backend is provided by the hplip package:\n#hpaio' >>/etc/sane.d/dll.conf
exit 0

# If the package was removed and if it was updated
# remove all byte-compiled Python .pyc (and perhaps .pyo) files
# which are created at run-time by Python in /usr/share/hplip/.
# Use a generic method via "find" so that it works in any case
# without the need to maintain a long list of individual files.
# Even if this may accidentally remove "foreign" .pyc/.pyo files
# which do not originate from matching .py files from this package
# (e.g. third-party stuff in /usr/share/hplip/), there is no damage
# because Python could re-create them or work only with .py files.
find /usr/share/hplip/ -name '*.py[co]' -delete
exit 0

# 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 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 /usr/lib*/sane/* &>/dev/null
     then [ -w /etc/sane.d/dll.conf ] && sed -i -e '/hpaio/d' /etc/sane.d/dll.conf
exit 0

%post hpijs
exit 0

%postun hpijs
exit 0

%defattr(-, root, root)
%config %{_sysconfdir}/xdg/autostart/hplip-systray.desktop
%config %{_sysconfdir}/sysconfig/SuSEfirewall2.d/services/hplip
%dir %{_sysconfdir}/udev
%dir %{_sysconfdir}/udev/rules.d
%config %{_sysconfdir}/udev/rules.d/55-hpmud.rules
%config %{_sysconfdir}/udev/rules.d/56-hpmud_support.rules
%dir %{_libdir}/sane
%dir /usr/lib/cups
%dir /usr/lib/cups/backend
%dir /usr/lib/cups/filter
%dir /var/lib/hp
%doc %{_defaultdocdir}/%{name}/
%exclude %{_datadir}/%{name}/data/models/models.dat

%files hpijs
%defattr(-, root, root)
%config %{_sysconfdir}/hp/
%config %{_sysconfdir}/cups/pstotiff.convs
%config %{_sysconfdir}/cups/pstotiff.types
%doc %{_mandir}/man1/hpijs.1.gz
%dir /usr/lib/cups
%dir /usr/lib/cups/backend
%dir /usr/lib/cups/filter
%dir %{_datadir}/cups
%dir %{_datadir}/cups/model
%dir %{_datadir}/cups/model/manufacturer-PPDs

openSUSE Build Service is sponsored by