Showing posts with label lpadmin. Show all posts
Showing posts with label lpadmin. Show all posts

Friday, December 16, 2022

colord - freedesktop.org severe device conflict (printer)

solution

NB: This takes the TN-630 toner cartridge.The TN-660 will work. If the entire drum is replaced, it's the DR-630.

Before describing the problem, here's a process for installing this (04f9:0092) Brother printer. This method is faster than the 3 days I spent understanding how colord had undermined the old reliable install method from a previous post. It's still an hour or two but compare that with salvaging configurations from older setups and losing days.

  1. physically connect the printer and lsusb to verify detection.
  2. pacman to install colord and cups. At the Brother site, download the RPM and xarchive to extract the PPD (and filter, if you want to go old skool).
  3. if it won't archive the RPM, then be sure to install its software # pacman -S cpio.
  4. new: $ yay -S brother-hll2315dw. This saves having to harvest, install and do permissions in several directories on executable scripts and data files. This is a 2 day time-saving driver.
  5. can rename (or not rename) the PPD to anything "BrotherA.ppd" for example. Open it up and change the default size to 'letter' from 'A4' and/or any other such changes. Save, and put it into /usr/share/model/. Next, do either 6 or 7.
  6. (CLI, more fun, less reliable)
    # lpadmin -p BrotherA -E -v [insert the USB URI from lpinfo -v] -m BrotherA.ppd
    The USB URI gained from lpinfo -v may be lengthy and will include a serial number.
  7. (GUI, more reliable) Go into CUPS, http://localhost:631/, and "add printer"
  8. inside the admin page, select "have PPD" and go to it in /usr/share/model to install the PPD from step 4 above.
  9. still in the admin page, "maintenance" has the menu to set the device as the default printer.
  10. # systemctl restart cups.service

the reason this conflict is a 3 day kludge

The solution is above, but here is the days-long struggle. We used to just install the printer with the CLI in about 10 minutes.

freedesktop: systemd and now colord

Freedesktop.org developed systemd of course. It's fairly comprehensive and complex, compared with the old Init.d flexibility of simple config files. Recently freedesktop began taking control of session color options too, and by device. Questionable. But in a horrible design decision, their colord daemon was given control not just of colors, but the DBus, apparently to make device queries/directives for color options. In practice, this means simple software conflicts about colors can lead to Dbus failures. Enter CUPS, attempting to set printer color profiles. Disaster.

CUPS circularity

It's a vicious circle. CUPS needs to write a PERL printer profile which contains (among many other settings) color settings. Meanwhile colord retains absolute control of color by controlling the DBus connection. When CUPS detects that colord has already created a device profile, it aborts its entire profile creation attempt, the one with all the settings for the printer. The result of no CUPS profile/filter is a half-installed printer. The printer doesn't print, and the error message "filter error" appears in the CUPS dashboard.

These errors can also be found in the error_log. If we attempt to install a printer, when colord is operating, we'll see the following:

$ cat /var/log/cups/error_log
W [16/Dec/2022:01:50:02 -0800] CreateProfile failed: org.freedesktop.ColorManager.AlreadyExists:profile id \'BrotherA-Gray..\' already exists

...and we can observe the details of the conflicting profile which colord had already installed...

$ colormgr get-devices
Object Path: /org/freedesktop/ColorManager/devices/cups_BrotherA
Owner: root
...
Colorspace: gray
Device ID: cups-BrotherA

colord's phony paths

It's hard to work with colord because it creates phony paths. The path above, /org/freedesktop/ColorManager/[etc], does not exist. No file is there. This is a "path" only in the sense of it being a line in an XML file or an ICC file. Colord knows how to evalute the line, but there's no file.

As for the XML files which contain the phony paths, these are apprently...

/usr/share/dbus-1/interfaces

... and two homes for the ICC files defining colors, for colord and ghostscript...

/usr/share/color/icc/colord
/usr/share/ghostscript/iccprofiles

order of operations circularity

When we install the printer, colord moves more quickly than CUPS. Colord detects the printer on the dbus and creates a device color profile faster than CUPS can write a CUPS filter. So, CUPS detects an already-made ICC colord color file, logs this color conflict as an error, and exits its entire filter creation. Accordingly we cannot fix the necessary filter later from some other CUPS process: it was never created and thus cannot be modified.

It seems we must either 1) remove colord, 2) configure colord not to create a profile for the printer, 3) modify CUPS to not to create its own color profile or to accept colord's profile, 4) modify the PPD (if possible) not to seek to create a color profile, or possibly to accept colord's profile, 5) place a filter in opt from a duplicate working setup. It might also require some combination. This is a kludge.

As a short preliminary to the 4th option, the simple act of commenting out a PPD's color settings doesn't stop the conflict.

1. remove colord

So let's pull colord, install the printer, then reinstall colord after CUPS has written a filter. It seems that we can do this: CUPS claims to only use colord ICC profiles "optionally".

# pacman -Rsn colord
checking dependencies...
:: cups optionally requires colord: for ICC color profile support

Packages (2) libgusb-0.4.2-1 colord-1.4.6-1

Total Removed Size: 8.49 MiB

:: Do you want to remove these packages? [Y/n]

...meaning CUPS should be able to install the printer without colord installed. Let's delete the error log, reinstall the printer and check for new errors...

# rm /var/log/cups/error_log
# lpadmin -p BrotherA -E -v usb:/dev/bus/usb/lp0 -m brother_HLL2315.ppd
lpadmin: Printer drivers are deprecated and will stop working in a future version of CUPS.
$ cat /var/log/cups/error_log
cat: /var/log/cups/error_log: No such file or directory

No errors -- seems we're home free. Nope

colord/dbus integration overreach

The printer installed without errors, but attempts to print failed.

FindDeviceById failed: org.freedesktop.DBus.Error.ServiceUnknown:The name org.freedesktop.ColorManager was not provided by any .service files

Yes, CUPS apparently relied on color management from colord as "optional", however reliance on DBus is in no way optional for any application. And, since colord manages both colors and DBus connections to devices, if we take out color management, our printer loses DBus access. The printer cannot then communicate, eg print. A person with a similar problem seems to confirm this. Colord must apparently remain.

2. configure colord

I could find no colord configuration file. Using colormgr, we can delete a colord device profile. But... that's not the problem. The problem is when the color profile (ICC) is created -- which is conflicting with the printer installation. Again, the only time CUPS creates a print filter in /opt/ is its initial read of the PPD file.

3. configure CUPS

The /etc/cups folder has several configuration files.

  • /etc/cups/printers.conf: don't edit when CUPS is running.
  • /etc/cupsd.conf: I know this file is read during systemctl restart cups.service. I've changed log levels from Warn to Debug before and seen its effects inside /var/log/cups/error_log. It also has permissions. It does not look effective for device install conflicts.

4. modify the PPD

I could find no way to modify the PPD that solved the conflict and created a device. It *is* worthwile to go into the PPD and switch the defaults to "Letter" from "A4" if a person is in the US. Saves having to worry about updates to the device file later on which may disrupt other settings.

5. duplicate a filter

During install, the PPD wants to write a PERL filter to the directory specified in the wrapper shebang. This is the filter that is not written and which causes the print failure.

$ ls /opt/brother/Printers/HLL2315DW/cupswrapper
total 76
drwxr-xr-x 2 0 0 4096 May 24 2020 .
drwxr-xr-x 5 0 0 4096 May 24 2020 ..
-rw-r--r-- 1 0 0 18351 Apr 18 2020 Copying
-rw-r--r-- 1 0 0 15010 Apr 18 2020 brother-HLL2315DW-cups-en.ppd
-rwxr-xr-x 1 0 0 24436 Apr 18 2020 brother_lpdwrapper_HLL2315DW
-rwxr--r-- 1 0 0 7650 Apr 18 2020 paperconfigml1

We can see that the PPD copied itself over and that an executable (755) PERL script (brother_lpdwrapper_HLL2315DW) was written. "Copying" is a license but should also be copied. I put the entire HLL2315DW directory - as is - on a USB key and copied it to the non-printing system. I saved to my installation directory.

HL-L2315DW old-skool steps

Somewhere between my old post and the newest way at the top.

  • install colord, cups, do all the download and xarchive of the PPD and filter from the Brother site, described in this post, repeated here in brief
  • can rename (or not rename) the PPD to anything "BrotherA.ppd" for example, but the filter (must) keep its full given name. Its only content will be the shebang and the /opt location.
  • Attempt to install the printer normally.
    # lpadmin -p BrotherA -E -v usb:/dev/bus/usb/lp0 -m brother2315.ppd
    But now the problem is the URI. This has become extremely finnicky with colord running the dbus. So instead of usb:/dev/[etc] above, use lpinfo -v to get a better USB descriptor. Copy and paste it into the command.
  • install and unpack the entire HLL2315DW directory described above and set 755 permissions on appropriate files in the subdirectories lpd, inf, and cupswraper, as well as chown them to "0" (root). This is time consuming so for Arch users, the AUR package will handle this step

Saturday, April 18, 2020

[solved] Brother HL-L2315DW USB install ( 04f9:0092)

2022 update: due to evolving colord conflicts with CUPS color-setting, it's best to follow the instructions in my most recent post on this install. There's plenty of relevant older info below, but it probably depends on one's time and inclination whether to move onto the other post or start below.


Typical printing links and commands:

  • http://localhost:631 CUPS admin page
  • # lpadmin -x Brother remove a printer by its installed name, eg. "Brother"
  • $ lpinfo -v get info on all connected printers
  • # lpstat -o list all print jobs
  • # cancel -a cancel all print jobs
  • # systemctl [enable/disable/start/stop/restart] cups.service
  • /var/log/cups/error_log CUPS error logs

The printers are priced $90 clearance (c. 2020) or sometimes $70 refurbished. Refurbished with 2-year warranty is best. Eg, "refurbished" from Wal-Mart ($70), with an Allstate 2 year plan ($6), costs less than a new model ($90) yet with deeper protections, such as free shipping for repairs.

Links: Openprinting.org database :: Brother L2315DW downloads page


solution

Go to the Brother L2315DW downloads page and select Linux -> RPM's. Note in the screenshot below that, even though they have three available downloads, both the PPD and LPD are contained in the single 0.2MB PPD download circled in red. The file is hll2315dwcupswrapper-3.2.1-1.i386.rpm.

Use xarchiver to open the RPM and extract its single folder, "opt" Inside opt, I continued drilling down into its subdirectories. I located both necessary files in /opt/brother/Printers/HLL2315DW/cupswrapper/. The CUPS PPD is named brother-HLL2315DW-cups-en.ppd, feel free to rename to [whatever].ppd. As for the LPD, it must retain its name, and you might want to save it (its a Perl script), but you could also just create the file, since its contents are just a single line (see further down).

owner and permission

Ownership will automatically become root b/c these can't be copied into their directories as user -- when you 'su'-up to copy them, they'll move over as owned by root. I have a working system with 755 on the filter but the instructions say it should 751.

  • CUPS (PPD) 755 $ chmod 755 file
  • LPD text file 751 $ chmod 751 file

locations

  • CUPS (PPD) /usr/share/cups/model/foo.ppd
  • LPD file /usr/lib/cups/filter/brother_lpdwrapper_HLL2315DW

LPD file

The ONLY way I could get to print was to use default options, which meant creating a custom brother_lpdwrapper_HLL2315DW file. Duplex printing -- an option physically available on the printer -- might be possible from some printer setting, but it cannot be accomplished in the CUPS software without errors that prevent printing altogether. Let the printer report its defaults to CUPS for successful printing. The file which makes CUPS adopt printer defaults is a single shebang line, with no line breaks (it is multiple line below due to column width word-wrapping). Don't forget permissions must be 751.
#! /opt/brother/Printers/HLL2315DW/cupswrapper/brother_lpdwrapper_HLL2315DW

PPD file

The PPD part is like years prior.
  • assigned read/execute (5) permissions that have worked with prior PPD's... $ chmod 755 printer.ppd
  • copied it to the Arch PPD directory... # cp printer.ppd /usr/share/cups/model/printer.ppd
  • verify the USB-attached printer is detected $lsusb
  • verify CUPS is running... # systemctl
  • install the printer # lpadmin -p Brother -E -v usb:/dev/usb/lp0 -m printer.ppd
  • alternatively, if having problems, you can use the bus ID's in lsusb and be more specific about the PPD locations as well (all one line):
    lpadmin -p Brother -E -v usb:/dev/bus/usb/lp0 -m printer.ppd
  • check it in CUPS http://localhost:631, and verify or assign it default printer
  • still in CUPS, verify the printer is awaiting print jobs and not paused
  • print a test page
  • copy the PPD to one's installation USB key so they needn't download it again for an OS/CUPS re-install

wifi install

Not worth it for a home-use stand-alone printer. It's too flaky. Eg, the next power outage, the WiFi router assigns the printer with a new DHCP address and one has to install the printer again.

somewhat common filter problem

There's a fail where the filter does not print over to the /opt directory.

$ ls/opt/brother/Printers': No such file or directory

The error log looks like this:

cat /var/log/cups/error_log W [14/Dec/2022:22:24:51 -0800] CreateProfile failed: org.freedesktop.ColorManager.AlreadyExists:profile id \'Brother-Gray..\' already exists

What has happened? The printer driver PPD attempted to create a settings file in /opt/brother/Printers/[model], but part of the PPD attempt included setting printer colors. The desktop ColorManager (ICC files) settings from free desktop (files are in /usr/share/dbus-1/interfaces) conflict with the PPD color. Due to the conflict, CUPS aborts creation of the printer configuration file in /opt and then fails to print based on lack of that filter.

These color manager related failures are based on colord ICC profiles for each device and are complex.

colormgr is the command line device for changing colord ICC files.

additional

There's been changes in CUPS, such as requiring the LPR translation file, and PPD's may disappear entirely at some point.
  • cannot select Duplex and have it print. If I could, I'd want "DuplexNoTumble". Duplex with tumble inverts the top and bottom of the front/back of a page like for clipboard use. However, the printer only works in single page mode.
  • after installation, it's efficient to set it as the default printer in case one has an application that sends to an LPR default, not to a printer name (eg. geeqie).
  • Some failures require a CUPS restart...
    # systemctl restart cups.service

Saturday, March 23, 2013

cups - hp office jet pro 8500a - 12 hours of fail in Lubuntu

Links: open printing.org   scroll down for tarball link   uninstall hplip   hp-setup options
Note this may also play HEAVILY into encountered problems with Ubuntu/Lubuntu printer addition: gnome keyring fiasco
So a year and a half ago, I added this printer in Minislack/Zenwalk. In 2013, I'm into Lubuntu, mostly for an updated set of libraries for the time being. I know Lubuntu (so far) uses usblp for usb printers so it should go OK. One thing, I'm expecting to compile my core applications as I've already noticed from Ubuntu/Lubuntu versions of avconv and ffmpeg, that they seem to be watered down. I suppose they have to be for such a popular distribution, so I keep my expectations for this distro to having a recent set of libraries for compiling. Back to our printer story... scroll down to Pt 3 for installation.

Pt 1 Groundwork

  • HPLIP has apparently changed to where it must now be compiled to get the .ppd's out of the source? (Edit 2013-03-24 after unpacking the HPLIP source, the .ppd's are available, but in a compressed "gz"format, eg "hp-officejet_pro_8500_a910.ppd". Select and use as needed (chmod 644 the file) without proceeding further with HPLIP compilation. Save both "hpcups" and the "hpijs" versions, since hpcups is new, its rasterization is different, and YMMV. If one proceeds with the HPLIP installation, the gz'ed ppd's are also placed into /usr/share/ppd/HP
  • Before doing so, use Synaptic to install developer versions of libjpeg, libcups, libusb1, and libsane to avoid ./configure fails. My final HPLIP configure line was $ ./configure --prefix=/usr --enable-lite-build --disable-network-build. I only needed scanning and printing, and via a USB connection.

Pt 2 errors

This make proceeded along for a while until exiting with
prnt/hpcups/CommonDefinitions.h:43:25: fatal error: cups/raster.h: No such file or directory
I installed apt-file (# apt-get apt-file find) and sought out the raster.h code. Sure enough, it was located:
$ apt-file search cups/raster.h
libcupsimage2-dev: /usr/include/cups/raster.h
lsb-build-base3: /usr/include/lsb3/cups/raster.h

So accordingly...
# apt-get install libcupsimage2-dev
...and back to the compiling. I have to hand it to whomever came up with the excellent idea of apt-file. The remainder, including # make install, appeared to go normally.

next errors

To check the installation...
$ hp-check -t
The program 'hp-check' is currently not installed. You can install it by typing:
sudo apt-get install hplip
Perhaps some library linking did not go well, $PATH was not updated, or files were installed into a non-standard location for the PATH or CUPS. The latter is what happened during a prior HPLIP install in 2011.
$ ls /usr/bin |grep hp
dvihp
hp-mkuri
php
php5
pitchplay
Not encouraging.
$ which hp-check
$
Not encouraging.
$ find -name hp-check
$
Not encouraging.
# service cups restart
cups stop/waiting
cups start/running, process 11411
$ hp-check -t
The program 'hp-check' is currently not installed. You can install it by typing:
sudo apt-get install hplip
Not encouraging.
# reboot
$ hp-check -t
The program 'hp-check' is currently not installed. You can install it by typing:
sudo apt-get install hplip
Not encouraging.

uninstalling HPLIP

Link: Uninstall instructions. From the installation directory...
# make uninstall
( cd '/usr/share/cups/drv/hp' && rm -f hpcups.drv )
( cd '/etc/cron.daily' && rm -f hplip_cron )
( cd '/usr/share/hal/fdi/preprobe/10osvendor' && rm -f 20-hplip-devices.fdi )
( cd '/usr/share/ppd/HP'...all ppds)
( cd '/etc/udev/rules.d' && rm -f 56-hpmud_support.rules 86-hpmud_plugin.rules 56-hpmud_add_printer.rules 55-hpmud.rules )
( cd '/usr/share/doc/...various docs.)
( cd '/usr/share/doc/hplip-3.13.3/styles' && rm -f css.css )
( cd '/usr/share/doc/hplip-3.13.3/images' && rm -f favicon.ico print.png toolbox_actions.png toolbox_fax.png toolbox_print_control.png toolbox_print_settings.png toolbox_status.png toolbox_supplies.png xsane.png )
( cd '/usr/share/doc/hplip-3.13.3' && rm -f COPYING copyright README_LIBJPG )
( cd '/usr/lib/cups/backend' && rm -f hp )
( cd '/usr/bin' && rm -f hp-mkuri )
( cd '/usr/lib/cups/filter' && rm -f hpcups )
( cd '/usr/lib/cups/filter' && rm -f hpcupsfax )
( cd '/etc/hp' && rm -f hplip.conf )
This is where HPLIP had been installed. I don't believe the HAL issue will be important, but we'll see. Additionally, from the uninstall, we have some idea what libraries were installed and why they might not have been located...
/bin/bash ./libtool --mode=uninstall rm -f usr/lib/libhpmud.la'
libtool: uninstall: rm -f /usr/lib/libhpmud.la /usr/lib/libhpmud.so.0.0.6 /usr/lib/libhpmud.so.0 /usr/lib/libhpmud.so
/bin/bash ./libtool --mode=uninstall rm -f '/usr/lib/libhpip.la'
libtool: uninstall: rm -f /usr/lib/libhpip.la /usr/lib/libhpip.so.0.0.1 /usr/lib/libhpip.so.0 /usr/lib/libhpip.so
/bin/bash ./libtool --mode=uninstall rm -f '/usr/lib/sane/libsane-hpaio.la'
libtool: uninstall: rm -f /usr/lib/sane/libsane-hpaio.la /usr/lib/sane/libsane-hpaio.so.1.0.0 /usr/lib/sane/libsane-hpaio.so.1 /usr/lib/sane/libsane-hpaio.so
( cd '/usr/lib/cups/filter' && rm -f pstotiff )
We'll see if we can get by without these libraries, eg, may not be able to do scanning. Still, simple printing, to start. A decent PPD should be sufficient.

Pt 3 Printer Installation (10 minute)

Note: "udevmonitor" is now "udevadm monitor".
1. Uncompress the ppd wherever you find it as a .ppd.gz from the HPLIP source (no need to compile HPLIP)
2. Copy it to where it can be found and chmod it.
# cp hp-officejet_pro_8500_a910.ppd /usr/share/cups/model/1sttry.ppd
# chmod 644 /usr/share/cups/model/1sttry.ppd
3. Verify you the user are in the groups lp and lpadmin, eg via "$ groups" or "# userconfig"
4. Verify the file /etc/cups/cupsd.conf has the line (or add it and restart CUPS):
FileDevice Yes
5. Run # udevadm monitor
6. Connect printer into USB, write-down dev address eg, usb:/dev/usb/lp0 that appears.
7. Be sure CUPS is running, eg # service cups restart
8. Add the printer to that USB address.
# lpadmin -p hp8500 -E -v usb:/dev/usb/lp0 -m 1sttry.ppd
9. Print, profit
10. If problems occur, see my post from 2011. You might have to uninstall the printer and try a different PPD or a different location for the PPD. The command to cancel current print jobs is # lprm -, the command to remove the printer (eg, named 'hp8500' above): # lpadmin -x hp8500. Also # lpstat -v is your friend.

One additional error

Uninstalling the HPLIP libraries earlier above did come back to bite. Everything installed properly, but when attempting to print, an error: "/usr/lib/cups/filter/hp/cups not available: No such file or directory". I then reinstalled HPLIP but installed PPD manually. Appeared all good, but print jobs gave error that printer was waiting to become available. Looked into /var/log/cups/error.log, and noted the following
The name org.freedesktop.ColorManager was not provided by any .service files
This appears to be a common error. By now, I also saw a lot others pissed off about the various security (non)interactions around loopback security and their distro. For example, this person's SuSE rant.

Incidentally, I noted that, in each case, a gnome keyring error appears, stopping communication with the printer. Apparently, a person has to hack their own laptop(!) for normal use if they use Ubuntu/Lubuntu. The roots of gnome-keyring persist into PAM, of course, and the LDAP abortion in their own system. To avoid contributing to my own productivity loss past the 12 hours already lost here, I eventually installed the HP5800a with "apt-get hplip". At some point, I will return to Slackware but, before doing so, I will attempt to euthanize gnome-keyring, PAM, and whatever other interconnected encryption garbage is in this distro when I have a few days to spare and see if a printer can be attached.

Again, adding a printer is typically a console job of 10 minutes, but I just gave up and let the immense Ubuntu RAM-killing daemon colluge do it for me after 12 lost hours. Google "cups pam" and you'll see why I gave up.

lpadmin

Lpadmin is part of CUPS and doesn't work when CUPS is not running.

GET A LIST OF PENDING PRINT JOBS BY INSTALLED PRINTER NAME
# lpstat

CANCEL ALL PENDING PRINT JOBS
# cancel -a

PRINT A TEST PAGE (eg, the man page for lpadmin)
# man lpadmin | lp -d HP8500