[Nix-dev] canon printer drivers (cnijfilter)

Nawal Husnoo nawal at husnoo.com
Thu Jun 22 08:55:20 CEST 2017


Sample code from my attempts might help:

mkdir -p $out/
cp -r $src/* $out/


chmod 777 -R $out/*


patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
    --set-rpath $libPath:$out/lib \
    $out/bin/cnijnpr

ln -sv $out/lib/libcnbpcmcm356.so.8.0.1 $out/lib/libcnbpcmcm356.so

LIBTIFF=$(pkg-config --libs-only-L libtiff-4 | sed -e
's/-L//g')/libtiff.so.5
ln -s $LIBTIFF $out/lib/libtiff.so.4

ldd $out/lib/cups/filter/pstocanonij


The latter looks inside the binary and tries to link it (dynamically) - it
should show what's still missing. The tiff business just makes tiff
available to the canon driver.


The rpath bit in the patchelf command is probably what you're looking for
initially.

hth

Nawal









On 22 Jun 2017 03:24, "Matt McHenry" <matt at mchenryfamily.org> wrote:

> Okay, patchelf seemed promising.  I just pushed
> https://github.com/jerith666/nixpkgs/commit/237a52ca24026f2e
> 4d8a5543eb7aa98f610f642c to add it to my expression.  However, it doesn't
> seem to have helped.  :-(
>
> Looking at the source code, the "Error: CNCL_SetParam" is coming from
> ./cnijfilter/src/bjfilter.c line 661.  The CNCL_SetParam() function is not
> defined in any of the provided source code, though -- rather, it looks like
> it's in ./328/libs_bin/libcnbpcnclapi328.so.3.3.0.
>
> I have a gdb trace laying around from last time I worked on this, and it
> has this stack trace:
>
> Catchpoint 1 (call to syscall open), 0xf7fd8da9 in __kernel_vsyscall ()
> eax is -38
> (gdb) where
> #0  0xf7fd8da9 in __kernel_vsyscall ()
> #1  0xf7d65f23 in __open_nocancel () from /nix/store/bgmm5m6q04fl5myf831
> c73l1xmbl38xw-glibc-2.24/lib/libc.so.6
> #2  0xf7cf9fd6 in __GI__IO_file_open () from /nix/store/bgmm5m6q04fl5myf831
> c73l1xmbl38xw-glibc-2.24/lib/libc.so.6
> #3  0xf7cfa1d1 in __GI__IO_file_fopen () from
> /nix/store/bgmm5m6q04fl5myf831c73l1xmbl38xw-glibc-2.24/lib/libc.so.6
> #4  0xf7cedd31 in __fopen_internal () from /nix/store/bgmm5m6q04fl5myf831
> c73l1xmbl38xw-glibc-2.24/lib/libc.so.6
> #5  0xf7cedd9e in fopen@@GLIBC_2.1 () from /nix/store/bgmm5m6q04fl5myf831
> c73l1xmbl38xw-glibc-2.24/lib/libc.so.6
> #6  0xf7fd1b08 in BJVSOpenFile () from /nix/store/9ci3apl3d8spw0zdp20
> 2cwr325n8hz28-cnijfilter-2.80/lib/libcnbpcmcm328.so
> #7  0xf7fcafa3 in CommandComp2Ext_Open () from
> /nix/store/9ci3apl3d8spw0zdp202cwr325n8hz28-cnijfilter-2.80/
> lib/libcnbpcmcm328.so
> #8  0xf7fce059 in CommandComp2 () from /nix/store/9ci3apl3d8spw0zdp20
> 2cwr325n8hz28-cnijfilter-2.80/lib/libcnbpcmcm328.so
> #9  0xf7e60d4d in CNCL_SetParam () from /nix/store/9ci3apl3d8spw0zdp20
> 2cwr325n8hz28-cnijfilter-2.80/lib/libcnbpcnclapi328.so
> #10 0x0804b3c8 in main ()
>
> I think this means that it's trying to open some file and failing.  My
> *guess* is that it's trying to open one of these files, but doesn't have
> the proper nix store path:
>
> $ file /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/
> lib/bjlib/*
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cifip3500.conf:
> ASCII text
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cifip4500.conf:
> ASCII text
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cifmp140.conf:
> ASCII text
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cifmp210.conf:
> ASCII text
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cifmp520.conf:
> ASCII text
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cifmp610.conf:
> ASCII text
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnb_3150.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnb_3160.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnb_3190.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnb_3260.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnb_3270.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnb_3280.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnbpname315.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnbpname316.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnbpname319.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnbpname326.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnbpname327.tbl:
> TrueType font data
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib/cnbpname328.tbl:
> TrueType font data
>
> that's what my https://github.com/jerith666/
> <https://github.com/jerith666/nixpkgs/commit/446b9230fbde3c71e8a285180614c32cdb2cf051>
> nixpkgs/commit/
> <https://github.com/jerith666/nixpkgs/commit/446b9230fbde3c71e8a285180614c32cdb2cf051>
> 446b9230fbde3c71e8a285180614c32cdb2cf051
> <https://github.com/jerith666/nixpkgs/commit/446b9230fbde3c71e8a285180614c32cdb2cf051>
> "try using shorter libpath via /var/lib/cups" was trying to remedy, to let
> these libs be found via:
>
> $ ls -l /var/lib/cups/path/lib/bjlib
> lrwxrwxrwx 1 root root 69 Dec 31  1969 /var/lib/cups/path/lib/bjlib ->
> /nix/store/g1gdd81qh6dskjalg6icg56yw74rb03b-cnijfilter-2.80/lib/bjlib
>
> But, that doesn't seem to have worked ... or, I'm still barking up the
> wrong tree.
>
> Anyway, that's what I've got for tonight ... maybe more tomorrow ... I
> think the next step is to try to fire up gdb again and see *what* file it's
> trying to open down inside that call to CNCL_SetParam().
>
>
> On Wed, Jun 21, 2017 at 7:47 AM, Matt McHenry <matt at mchenryfamily.org>
> wrote:
>
>> The error doesn't show up in the cups log -- the only thing it says is
>> "Error: CNCL_SetParam" -- but to cups, the process it spawned seems to have
>> succeeded.  See attached log.
>>
>> As I recall, the problem is that one of the executables that gets built
>> then tries to load one of binary libraries included in the tarball from
>> canon, and can't find it.  I'll have to go refresh my memory some more, but
>> won't have time until this evening.
>>
>> I have not tried patchelf -- that may be a good lead.
>>
>> I don't think a FHS env will work, because as you say, the cups service
>> can't be run in there.
>>
>> On Wed, Jun 21, 2017 at 2:36 AM, Nawal Husnoo <nawal at husnoo.com> wrote:
>>
>>> Thanks for that Matt!
>>>
>>> I wonder if the versioning thing is a windows-related behaviour.
>>>
>>> Could you say a few words about the link errors you had? Have you used
>>> patchelf?
>>>
>>> >* patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" \
>>> *>*     --set-rpath $libPath:$out/lib \
>>> *>*     $out/bin/cngpijmonmp250*
>>>
>>> Another option I could live with is if we could create a buildFHSUserEnv
>>> - I tried it with the binary canon drivers, but it turned out it's cups
>>> that needs to be inside for the pesky things to be found, but then systemd
>>> wouldn't let me restart cups.service inside a user env...
>>>
>>> Cheers,
>>>
>>> Nawal.
>>>
>>>
>>>
>>> On 21 June 2017 at 01:49, Matt McHenry <matt at mchenryfamily.org> wrote:
>>>
>>>> Hi Nawal,
>>>>
>>>> I see you've been trying to get canon's linux drivers working on nixos
>>>> [1][2][3].  I've also tried my hand at this.  I think I've made more
>>>> progress than you, but was never able to get it working, and eventually
>>>> resigned myself to just printing with the gutenprint driver.  I'd be
>>>> interested in continuing to hack at it as time permits, though.
>>>>
>>>> I got to the point of cups executing what I think is the correct chain
>>>> of filters, all built from the source that my nix expression pulls from the
>>>> Canon Japan website.  However, at least one of the filters is unable to
>>>> load at least one dynamically linked library, so it fails.  I don't know
>>>> much about shared libraries on linux in general or NixOS in particular, so
>>>> I was mostly just thrashing around a lot.
>>>>
>>>> I've pushed what I have to the cnijfilter branch in my nixpkgs clone
>>>> [4].  To try it, just add pkgs.cnijfilter to services.printing.drivers in
>>>> configuration.nix.  (I also tried adding cnijfilter to
>>>> environment.systemPackages, that didn't seem to help.)
>>>>
>>>> I've gleaned a lot from the other distros builds [5][6][7].  In
>>>> particular, the cnijfilter-common library does not follow a normal
>>>> versioning pattern -- each version supports a certain set of printers.  So
>>>> you don't want the latest, you want whatever matches up with your printer.
>>>> (My printer is an MX-700, which uses the mp520 driver.  So I've been
>>>> working on version 2.80 of cnijfilter-common.)  But my hope is that the
>>>> overall structure of the build would be very portable between versions.
>>>>
>>>> It looks like you've worked from the debian packages -- perhaps looking
>>>> in more detail at how they are built will give us some more clues?
>>>>
>>>> I'm not sure whether it makes more sense to open an issue to document
>>>> this work, or keep discussing on the mailing list.
>>>>
>>>> [1] https://mailman.science.uu.nl/pipermail/nix-dev/2017-June/02
>>>> 3942.html
>>>> [2] https://mailman.science.uu.nl/pipermail/nix-dev/2017-June/02
>>>> 3943.html
>>>> [3] https://mailman.science.uu.nl/pipermail/nix-dev/2017-June/02
>>>> 3946.html
>>>>
>>>> [4] https://github.com/jerith666/nixpkgs/tree/cnijfilter
>>>>
>>>> [5] https://bugs.gentoo.org/show_bug.cgi?id=130645
>>>> [6] https://aur.archlinux.org/packages/cnijfilter-mp620/?comments=all
>>>> [7] https://github.com/spremi/cnijfilter-source-3.80
>>>>
>>>
>>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mailman.science.uu.nl/pipermail/nix-dev/attachments/20170622/18b40cae/attachment.html>


More information about the nix-dev mailing list