PDA

View Full Version : Building Canon's 3.80-1 driver for F20 (and probably F21)



al_chem
15th December 2014, 02:19 PM
Edit: I noticed that the driver failed to build in mock and I managed to track the issue down to a missing gettext dependency. Given that the forum still has problems with the attachments, I have uploaded updated files to github (https://github.com/alxpl/cnijfilter).


When it comes to printing/scanning under linux, Canon has come a long way in the past decade, constantly getting better. However, some things are still left to be desired.

Recently, a friend purchased a PIXMA iP7250 and I found out that the rpms from Canon could not be installed in Fedora 20, because of unsatisfiable dependencies. In the past, our users who needed to use their Canon printers with the latest version of Fedora ended up doing one (or more) of the following:

Abandoning printing in Fedora (or even abandoning Fedora altogether).
Installing an older, unsupported version of Fedora.
Purchasing the turboprint driver. Good driver, great support, but nobody goes out to buy a printer that costs 50-150$, expecting to foot another 40$ for it to work in their preferred OS.
Installing packages to satisfy the missing dependencies from older versions of Fedora, or even other rpm-based distributions, then extracting the contents of Canon's rpms, placing them in their intended locations and manually linking libraries. Besides being ugly, unsafe and "unsanitary", it meant that if you ever needed to update or uninstall the driver, you would have to keep track of quite a large number of files in quite a large number of folders across the system (not always respecting FHS or Fedora's own guidelines).
Building compatibility packages for deprecated libraries. Probably the best solution so far, with the downside being that it could lead to system conflicts and problems with future builds of other packages.

Fortunately, Canon provides a source tarball, which even includes a (somewhat problematic) spec file, so you can build your own, fully fedora-compliant, removable and updatable rpms.
This guide covers version 3.80-1 of Canon's driver which supports the following series: MP230, MG2200, E510, MG3200, MG4200, iP7200, MG5400 and MG6300. If your device is covered by an earlier or later driver, I expect you could patch it in a similar fashion, checking what fails when building the packages and when you finally manage to build the rpms, validating them with rpmlint. Keep in mind that not everything reported by rpmlint is a no-go.

Disclaimer: I have built and tested packages in F20, for both i686 and x86_64 architectures. I expect the same procedure to work in F21 and F19, but it has not been tested; I will be making some builds on F21 in the near future and if I find an issue that needs to be addressed, I will update this post. Most of the changes in the patch file, particularly those concerning ipp and libpng, came from various, online sources and I adapted them to this version of the driver. The fact that this works for me does not mean that it will also work for you. Consider yourself warned. Also, due to Canon's license, I can not provide a source rpm, which would speed things up a bit; you'll have to get the source tarball from Canon.

Edit: Everything works as expected in F21.
Edit: Tested and working in F22 as well.


Prerequisites:

You need to have autoconf, automake, gcc-c++ and rpmbuild installed. All other dependencies will be pulled in automatically.

If you 've never built something with rpmbuild before, you will have to create a minimal folder structure in your home folder:

mkdir -p ~/rpmbuild/SOURCES && mkdir ~/rpmbuild/SPECS

(Edit: If you intend to build more packages in the future, you can install rpmdevtools and then run rpmdev-setuptree which will set up the rpmbuild folder structure for you)


Download cnijfilter-source-3.80-1.tar.gz from Canon (md5sum: b6b92717930021d24bd750d4197bdf3b) and place it in the SOURCES subfolder.

Donwload the attached patch (cnijfilter-3.80-1.f20.patch) into the SOURCES subfolder.

Download the attached spec file (cnijfilter-common.spec) into the SPECS subfolder.


Building/Installing:

Install the dependencies (as root):

yum-builddep rpmbuild/SPECS/cnijfilter-common.spec
or alternatively, with dnf:

dnf builddep rpmbuild/SPECS/cnijfilter-common.spec

Build the rpms from the specfile (as your regular user):

rpmbuild -bb rpmbuild/SPECS/cnijfilter-common.spec --define="MODEL [Model Name]" --define="MODEL_NUM [Model ID]" --with build_common_package
For version 3.80-1, the valid name - ID pairs are these:


[Printer Model Name] [Printer Model ID]
mp230 401
mg2200 402
e510 403
mg3200 404
mg4200 405
ip7200 406
mg5400 407
mg6300 408

When rpmbuild is done, you will get two rpms plus a debuginfo one (don't mind that) in rpmbuild/RPMS/{arch} folder: cnijfilter-common-3.80-1.{dist}.{arch}.rpm and cnijfilter-{printer model}-3.80-1.{dist}.{arch}.rpm. Install them both in that order (ideally via yum or dnf) and you're good to go.


Network printer:
If you have connected your printer over a network you can set it up from within your desktop environment's tools or you can use the cnijnetprn utility provided by Canon:

Running

cnijnetprn --search auto
will scan your network for the printer. After a while, you'll see something like this:

networkcnijnet:/00-1A-2B-3C-4D-5E "Canon iP7200 series" "Canon-iP7200-series_00-1A-2B-3C-44-5F"
The first part, networkcnijnet:/00-1A-2B-3C-4D-5E is the device uri. You can use that when you set up your printer in your DE's printer configuration tool, or you can simply run as root (adjust accordingly for your device):


lpadmin -p canonip7200 -m canonip7200.ppd -v cnijnet:/00-1A-2B-3C-44-5F -E

Note: Don't just guess the name of the ppd file, look in /usr/share/cups/model/.

Note 2: In MATE, the printer administration tool shows ink cartridge levels, whereas GNOME's does not. In any case, there are a couple of utilities bundled with the driver cngpijmnt and cngpijmon{printer_name}. The first one provides access to the printer maintenance functions (e.g. cleaning, deep cleaning, nozzle check, print head alignment etc.), while the other serves as a printer monitor, querying and displaying printer status and ink cartridge levels. I don't know if cngpijmnt takes any arguments, cngpijmon accepts the printer queue name as one (this is for an iP7200 set up with a printer queue named IP7200NET):

cngpijmonip7200 IP7200NET
You might learn a little bit more by visiting the links in this presentation (https://www.linuxfoundation.org/images/6/65/MontrealSummit-2007-Canon_Printer_Drivers_for_Linux_070926-2.pdf).


A perfectionist's request: If you can figure out a way to a) fix the remaining errors/warnings that rpmlint spits out, without contacting upstream and/or b) make the warnings during the build phase disappear, please let me know!

Skull One
16th December 2014, 11:50 AM
Good job!
Building compatibility packages for the old libraries is probably simpler for users, since these packages can freely be redistributed (and maybe put in the repository?); but rebuilding the drivers is useful to fix bugs for instance.

Hum....
You just forgot to attach the patch & spec files...

al_chem
16th December 2014, 12:03 PM
Thank you for noticing the missing attachments, they must have disappeared between previews.

I had discussed the issue of compatibility libraries with some of the devs, and the general consensus is that unless something is badly needed, we won't ship deprecated libraries; upstream should catch up instead.

omalley10
24th February 2015, 09:10 PM
Thanks for the guide! Strangely, I cannot download the attachements. (I get redirected to a 1 by 1 gif image.)

al_chem
24th February 2015, 09:29 PM
Maybe there's a bug somewhere in the forum code, I don't know. You can get both files from github (https://github.com/alxpl/cnijfilter).

omalley10
24th February 2015, 09:51 PM
Amazing, it worked like a charm. Thanks a lot!

Did you figure out how to make the scanner work too?

al_chem
24th February 2015, 10:24 PM
No, sorry. My device is just a printer. There might be a specific binary for scanning among the utilities that get compiled in the driver though, check the names of the executables in your rpms and see if any of them have something to do with scanning.

DBelton
25th February 2015, 12:11 AM
There is an issue with forum attachments right now. Can't upload new attachments and previously uploaded ones aren't accessible.

We are working on resolving this issue, but unknown as to how long it is going to be.


Edit:

Thanks, al chem, for posting another link to get the files :)