Article: HP Printing using the hplip Package in openSUSE

HP-TOOLBOX is used to Work With Already Installed HP Printers:

http://paste.opensuse.org/view/download/25443500**

Introduction to the hplip Package:**

If you own an HP printer(s), you are lucky in my opinion. While not all HP printers are gems, most all of them will work like a champ using the Package hplip, installed by default in openSUSE. And you will most likely later be able to find an ink or laser cartridge for it when you need it. It is very true printer manufacturers sell printers cheep which often come with very little ink in the box and that cartridges are priced high where they make all of their money. This article is not going to correct how the printer manufacturers make their money. However, If you are looking to buy a printer that works with Linux and openSUSE, HP has got to be on your short list.

The Package hplip, now at version 3.12.11 in openSUSE 12.3, includes the following application files (and much more in documentation):

/usr/bin/hp-align
/usr/bin/hp-check
/usr/bin/hp-check-plugin
/usr/bin/hp-clean
/usr/bin/hp-colorcal
/usr/bin/hp-config_usb_printer
/usr/bin/hp-devicesettings
/usr/bin/hp-diagnose_plugin
/usr/bin/hp-diagnose_queues
/usr/bin/hp-fab
/usr/bin/hp-faxsetup
/usr/bin/hp-firmware
/usr/bin/hp-info
/usr/bin/hp-levels
/usr/bin/hp-linefeedcal
/usr/bin/hp-logcapture
/usr/bin/hp-makecopies
/usr/bin/hp-makeuri
/usr/bin/hp-mkuri
/usr/bin/hp-pkservice
/usr/bin/hp-plugin
/usr/bin/hp-pqdiag
/usr/bin/hp-print
/usr/bin/hp-printsettings
/usr/bin/hp-probe
/usr/bin/hp-query
/usr/bin/hp-scan
/usr/bin/hp-sendfax
/usr/bin/hp-setup
/usr/bin/hp-systray
/usr/bin/hp-systray.wrapper
/usr/bin/hp-testpage
/usr/bin/hp-timedate
/usr/bin/hp-toolbox
/usr/bin/hp-uninstall
/usr/bin/hp-unload
/usr/bin/hp-upgrade
/usr/bin/hp-wificonfig

Most of these application files are actually run for you from the HP-TOOLBOX application once your printer has been installed.

**SETUP and INSTALL a New Printer:
**

  1. Now if you have an HP printer, you must use the hp-setup program to install it. Further, you must install the application as root to get it to work. Two quick commands for this to work are:
For KDE: Alt-F2 and **kdesu /usr/bin/hp-setup**

OR

For Gnome: Alt-F2 and **gnomesu /usr/bin/hp-setup**
  1. If you would like to have an HP-SETUP icon on your desktop and in your Applications menu, copy the following line, paste it into terminal and press enter:
rm ~/bin/hp-icon ; wget -nc  http://paste.opensuse.org/view/download/9430700 -O ~/bin/hp-icon ; chmod  +x ~/bin/hp-icon ; hp-icon 

You should then end up with this in your desktop folder you can run which will request the root user password and should work on all desktops that come with openSUSE:

Let me say up front that in general, hp applications should NOT BE RUN AS ROOT! Root authoroty will be requested when required. For some reason, this does not work out properly for the hp-setup program which is why we need a special exception here for us to use.

  1. You may wish to install all required applications to allow the hplip application set to work. This is not done by default. If you intend on installing the very latest version of hplip, you MUST perform the following command function. Open up a terminal session and copy the following commands, paste it into a terminal session and press enter on each:
su -c "zypper refresh"

AND

su -c "zypper --non-interactive --no-gpg-checks in  --auto-agree-with-licenses cups cups-client cupsddk cups-devel  dbus-1-devel python-gobject2 gcc-c++ ghostscript-library openssl  libjpeg-devel net-snmp-devel glibc libtool libgphoto2-devel  libusb-1_0-devel libusb-1_0-0 make wget python-imaging python-qt4  dbus-1-python-devel dbus-1-python python-devel python-xml  libpython2_7-1_0 python-notify python xsane sane-backends-devel  sane-backends"

Enter the root user password if requested to allow the listed applications to be installed. You may wish to log out and back into openSUSE for some the installed applications to take effect.
**
IN ALL CASES** you will want to add yourself to the sys and lp user groups and you will want to open two ports in the openSUSE Firewall:

  1. Add yourself to the sys and lp user groups. Enter command in terminal. You must log out and back in for this to work:
su -c "/usr/sbin/usermod -a -G sys,lp $USER"
  1. Open up the Firewall ports using the following bash script, save as the file $HOME/bin/hp-firewall:
#! /bin/bash

conffile="/etc/sysconfig/SuSEfirewall2"

grep ^FW_SERVICES_ACCEPT_EXT $conffile | grep -q "0/0,udp,,5353"
if  $? -ne 0 ]; then
    sed -i 's/^FW_SERVICES_ACCEPT_EXT="\(.*\)"/FW_SERVICES_ACCEPT_EXT="0\/0,udp,,5353 \1"/' $conffile
fi

grep ^FW_SERVICES_ACCEPT_EXT $conffile | grep -q "0/0,udp,,427"
if  $? -ne 0 ]; then
    sed -i 's/^FW_SERVICES_ACCEPT_EXT="\(.*\)"/FW_SERVICES_ACCEPT_EXT="0\/0,udp,,427 \1"/' $conffile
fi

systemctl stop SuSEfirewall2.service
systemctl start SuSEfirewall2.service

exit 0

The script must be marked executable to work. In terminal you use this command:

chmod +x $HOME/bin/hp-firewall

Then open up terminal and run the command to apply the firewall modifications. You would only need to run this one time:

sudo hp-firewall

CHECK and REPAIR your hplip Installation:

You may wish to check your installation to make sure it is setup correctly. Open up terminal and run the following command:

/usr/bin/hp-check -t

If any problems are found, use the following command to fix them:

/usr/bin/hp-doctor

For information on how to use the hplip allplications, an HTML file is installed by default. Open up your default web browser and paste in the following command:

file:///usr/share/doc/packages/hplip/index.html

You can also pop up the CUPS printing control from your Web Browser with the following URL:

http://localhost:631

INSTALL the Latest Version of hplip:

For anyone who wants to install or compile any C or C++ source files, you should take the following steps first:

Open YaST / Software / Software Management - Select the View Button on the top left and pick Patterns. Now, you will see several Patterns listed and you want to select:

   Development 

[X] Base Development
[X] Linux Kernel Development
[X] C/C++ Development

Then Press the Accept button on the bottom right and allow these applications to install.

If you then feel you need to install the very latest version of the hplip application, here is what you do, all examples here assume version 3.13.7 for the names to work out right. In general, if you stick with the default hplip application version installed by openSUSE, you will avoid some problems I mention below:

  1. Get the latest Version of the Application (3.13.7): Download HP Linux Imaging and Printing from SourceForge.net, (Download to $HOME/Downloads)

  2. Open Up Terminal and change to the Downloads folder:

cd $HOME/Downloads
  1. Uncompress the Tarball:
tar xvfz hplip-3.13.7.tar.gz
  1. Change to the newly create folder:
cd hplip-3.13.7
  1. Configure the Source Files
./configure --with-hpppddir=/usr/share/cups/model/HP --prefix=/usr  --enable-qt4 --disable-libusb01_build --enable-doc-build  --disable-cups-ppd-install --disable-foomatic-drv-install  --disable-foomatic-ppd-install --disable-hpijs-install  --disable-udev_sysfs_rules --disable-policykit --enable-cups-drv-install  --enable-hpcups-install --enable-network-build --enable-dbus-build  --enable-scan-build --enable-fax-build
  1. Run Make on the files:
make
  1. Install as root
su -c "make install"

When you compile and install your own copy of hplip outside of using YaST and you do not use an RPM installation file, YaST does not know it has been installed. You can check to see if you have the latest application by starting the HP-TOOLBOX and then using the File / About command to see your present running version. You might need to log out and back into openSUSE after such an update from YaST to see that this has happened to you:

To prevent an update from YaST to hplip, do the following:

YaST / Enter Root User Password / Software / Software Management / enter and search for hplip / right click on each file and select Protected and the use the Accept button on the bottom right:

If you have already replaced the file from an update, but you have not removed the compile folder for the new copy of hplip, you need only change to the folder again and run the install from terminal:

cd $HOME/Downloads
cd hplip-3.13.7
make

As always if you have corrections or Additions, please let me know what they are.

Thank You,

In step #5 you have small typo mixing ‘-’ and ‘_’ between filename and the command to run.

I am running openSuse 12.2 x64 with hplip 3.12.4-3.1.2.
I have managed to run most of this except the firewall code. The output is:
“Failed to issue method call: Unit SuSEfirewall2.service failed to load: No such file or directory. See system logs and ‘systemctl status SuSEfirewall2.service’ for details.”

systemctl status SuSEfirewall2.service

SuSEfirewall2.service
Loaded: error (Reason: No such file or directory)
Active: inactive (dead)

That said, in YaST firewall, under custom rules I see the 2 correct udp ports so I guess it is done. BUT, I have a firewall on my router and openSuse is NAT behind that router so I have not paid attention to the firewall settings. YaST shows it active on startup. Those rules for my printer, which is connected via ethernet and using lpd & cups, are external rules. Shouldn’t they be internal rules? If so do I manually have to input them or is there an easy way to merely change them to internal?

Sorry for the lengthy comment, not sure all this verbage belongs here.
jon

Can you post a fixed version? It seemed to work for me, but its copied from the HP Web Site and then has a small modification I added at the end.

Thank You,