Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Add canon lasor printer driver. (CAPT Printer Driver for Linux) #65069

Closed
wants to merge 18 commits into from

Conversation

wizzup
Copy link
Contributor

@wizzup wizzup commented Jul 19, 2019

Work in progress, need some help.

Motivation for this change

To fix #27323

Things done

The binaries are build from source successfully (thanks to @layus and @vcunat for helping me)

Things undone
  • I don't know how to install systemd service file
  • I don't know how to install ppd files to cups
  • There are some cups steps to install the printer not included (eg. start the service) that should be done for NixOS's configuration.nix

Note: I have merge the whole history from my repo, that's why the change is big. Have no idea to do it the other way to preserve contributions records form @layus

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • [ x] NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@symphorien
Copy link
Member

To install the systemd service provided by a derivation:

systemd.packages = [ pkgs.the_derivation ];

To install the ppds:

services.printing.drivers = [ pkgs.the_derivation ];

About the $out/var/captmon directory: it should be created by the nixos module, not the derivation. For example, if it is possible to rename /var/captmon to /var/lib/captmon, then you can simply add this to the systemd unit:

StateDirectory=captmon
Group=lp

Otherwise you would have to use systemd-tmpfiles:

systemd.tmpfiles.rules = [  "d /var/captmon 0770 root lp -" ]

@layus
Copy link
Member

layus commented Aug 13, 2019

Do you need some help to finish this one ? It looks like a big packaging effort :-)

@wizzup
Copy link
Contributor Author

wizzup commented Aug 13, 2019

@layus I still have no idea what to do next

Instruction for building the source can be found on Arch AUR (that is what I have done)

I have no idea on the remaining step for Nix/NixOS.

@layus
Copy link
Member

layus commented Aug 19, 2019

Hi @wizzup,

I took some time to make the extra steps. This driver is a pure mess with 32bit and 64bit binaries in the same packages, and requires to find its stuff in fixed locations.

My best attempt at the moment is available in https://github.com/layus/nixpkgs/tree/canon-merge, and can be easily tested as per the instructions in
layus@13df341

Could you test it and debug/give feedback ? I own no such printer.

@wizzup
Copy link
Contributor Author

wizzup commented Aug 20, 2019

Hi @layus,

Thanks for help.

I setup a dedicated netbook to test this, below are my steps

[root@nixos:~]# git -C /nixpkgs/ rev-parse HEAD
13df34121652fb7c16076ec83046cdffbce0c229
  • edit configuration.nix, rebuild and reboot
[root@nixos:~]# cat /etc/nixos/configuration.nix
{ config, pkgs, ... }:

{
  imports =
    [
      ./hardware-configuration.nix
      /nixpkgs/canon-cups-capt-config.nix
    ];

  nix = {
    binaryCaches = [
      "https://cache.nixos.org"
      "https://wizzup.cachix.org"
    ];

    binaryCachePublicKeys = [
      "wizzup.cachix.org-1:FDHBjAYzhSSGmX3ZGIhgl3+uwNFblIOzjPTb0edaVOw="
    ];
  };

  nixpkgs = {
    system = "x86_64-linux";
    config.allowUnfree = true;
  };

  boot.loader.grub.device = "/dev/sda";

  time.timeZone = "Asia/Bangkok";

  environment.systemPackages = with pkgs; [
    git vim wget
  ];

  services = {
    openssh.enable = true;
    printing.enable = true;
  };

  users.users.jane = {
    isNormalUser = true;
    extraGroups = [ "wheel" ];
  };

  system.stateVersion = "19.03";
}

[root@nixos:~]# nixos-rebuild switch
building Nix...
building the system configuration...
updating GRUB 2 menu...
activating the configuration...
setting up /etc...
reloading user units for jane...
setting up tmpfiles
  • check for printer connection and ppd file
[root@nixos:~]# lpinfo -m | grep -i 3050
CNCUPSLBP3050CAPTK.ppd Canon LBP3010/LBP3018/LBP3050 CAPT (UK)

[root@nixos:~]# lpinfo -v
network beh
network https
network http
network ipps
network ipp
network lpd
network socket
direct usb://Canon/LBP3010/LBP3018/LBP3050?serial=0000B193CFSZ
  • try to add the printer but failed (instruction from here)
[root@nixos:~]# lpadmin -p LBP3050 -m CNCUPSLBP3050CAPTK.ppd -v ccp://localhost:59687 -E
lpadmin: Bad device-uri scheme "ccp".

ccp:// protocol should handle by ccpd service, so I check the ccpd status but found no clue

[root@nixos:~]# systemctl status ccpd
● ccpd.service - Canon CAPT daemon
   Loaded: loaded (/nix/store/q43gygs4wj6ix3s108jmjwa2kjlhz796-canon-capt-driverpack/lib/systemd/system/ccpd.service; linked; vendor preset: enabled)
   Active: inactive (dead)

[root@nixos:~]# systemctl start ccpd

[root@nixos:~]# systemctl status ccpd
● ccpd.service - Canon CAPT daemon
   Loaded: loaded (/nix/store/q43gygs4wj6ix3s108jmjwa2kjlhz796-canon-capt-driverpack/lib/systemd/system/ccpd.service; linked; vendor preset: enabled)
   Active: active (running) since Tue 2019-08-20 13:28:40 +07; 29s ago
  Process: 833 ExecStart=/nix/store/q43gygs4wj6ix3s108jmjwa2kjlhz796-canon-capt-driverpack/bin/ccpd (code=exited, status=0/SUCCESS)
 Main PID: 843 (ccpd)
    Tasks: 1 (limit: 2337)
   Memory: 32.2M
   CGroup: /system.slice/ccpd.service
           └─843 /bin/ccpd /nix/store/b1hwbh1342m1719x8i2a7l98rfzdcxkk-cndrvcups-capt-2.71/bin/ccpd

Aug 20 13:28:38 nixos systemd[1]: Starting Canon CAPT daemon...
Aug 20 13:28:40 nixos systemd[1]: Started Canon CAPT daemon.

[root@nixos:~]# lpadmin -p LBP3050 -m CNCUPSLBP3050CAPTK.ppd -v ccp://localhost:59687 -E
lpadmin: Bad device-uri scheme "ccp".

Also status of cups

[root@nixos:~]# systemctl status cups
● cups.service - CUPS Scheduler
   Loaded: loaded (/nix/store/k71f88mpa9ydwkvl2rjkqagrrib6cfz2-cups-2.2.10/lib/systemd/system/cups.service; enabled; vendor preset: enabled)
  Drop-In: /nix/store/dz2zg2qf8fcdp6rnraj114785v3ksqll-system-units/cups.service.d
           └─overrides.conf
   Active: active (running) since Tue 2019-08-20 13:22:36 +07; 4min 30s ago
     Docs: man:cupsd(8)
  Process: 737 ExecStartPre=/nix/store/l4a36406qjizqkxlk8zsjdihm2024hb7-unit-script-cups-pre-start (code=exited, status=0/SUCCESS)
 Main PID: 759 (cupsd)
    Tasks: 1 (limit: 2337)
   Memory: 8.8M
   CGroup: /system.slice/cups.service
           └─759 /nix/store/k71f88mpa9ydwkvl2rjkqagrrib6cfz2-cups-2.2.10/sbin/cupsd -l

Aug 20 13:22:37 nixos cupsd[759]: Using policy "default" as the default.
Aug 20 13:22:37 nixos cupsd[759]: Full reload is required.
Aug 20 13:22:37 nixos cupsd[759]: Loaded MIME database from "/nix/store/sif9c34kgc419rs9chy0gxj88a9klv1h-cups-progs/share/cups/mime" and "/etc/cups": 78 types>
Aug 20 13:22:37 nixos cupsd[759]: Loading job cache file "/var/cache/cups/job.cache"...
Aug 20 13:22:37 nixos cupsd[759]: Full reload complete.
Aug 20 13:22:37 nixos cupsd[759]: Cleaning out old files in "/var/cache/cups".
Aug 20 13:22:37 nixos cupsd[759]: Listening to [v1.::1]:631 on fd 6...
Aug 20 13:22:37 nixos cupsd[759]: Listening to 127.0.0.1:631 on fd 7...
Aug 20 13:22:37 nixos cupsd[759]: Listening to /var/run/cups/cups.sock on fd 8...
Aug 20 13:22:37 nixos cupsd[759]: Resuming new connection processing...

I wipe the Arch linux installation on this test netbook during NixOS installation procress (silly me) and I can't compare any command outputs.

beside ccp:// protocol problem there also missing ccpdadmin command

@layus
Copy link
Member

layus commented Aug 20, 2019

beside ccp:// protocol problem there also missing ccpdadmin command

ccpdadmin is present, but not in the system path. To add it to the system path, you can add in canon-cups-capt-config.nix (from memory, expect typos).

    environment.systemPackages = [ canon-cups-capt ];

or you can extract the full path to ccpd from systemctl cat ccpd and replace ccpd by ccpdadmin in that path.

@layus
Copy link
Member

layus commented Aug 20, 2019

@wizzup It seems that I was a bit overengineering this as I added a FHS user env that may not be needed.

I have written a new canon-cups-capt-config-no-fhs.nix config that works here.
I was at least able to add the printer with padmin -p LBP3050 -m CNCUPSLBP3050CAPTK.ppd -v ccp://localhost:59687 -E and use it to print. Obviously, it fails with

$ sudo journalctl --unit=cups.service
...
aoû 20 11:14:41 klatch cupsd[6843]: pstocapt3 write error,9.
aoû 20 11:14:41 klatch cupsd[6843]: ccp send_data error, exit
...

but this is a good start.

The file also includes environment.systemPackages = [ canon-cups-capt ]; so you should get ccpdadmin and captstatusui in your command line.

Can you paste here the output of ccpdadmin and test captstatusui -P LBP3050 ?

@layus
Copy link
Member

layus commented Aug 20, 2019

You can also ping me on irc/riot if you want quick interactions

@wizzup
Copy link
Contributor Author

wizzup commented Aug 22, 2019

Sorry for late reply,

Thanks to canon-cups-capt-config-no-fhs.nix, ccpdadmin is now available but I don't have /dev/usb/lp0

[root@nixos:~]# ccpdadmin 

Usage: 
  ccpdadmin [-p Printer-name -o Printer-dev-path]
  ccpdadmin [-x Remove-Printer-name]


 CUPS_ConfigPath = /etc/cups/
 LOG Path        = None
 UI Port         = 59787

 Entry Num  : Spooler	: Backend	: FIFO path		: Device Path 	: Status 
 ----------------------------------------------------------------------------

Adding udev rules (source) doesn't seem to fix it.

  services = {
    openssh.enable = true;
    printing.enable = true;
    
    udev.extraRules = ''
      BUS="usb", KERNEL="lp[0-9]*",   NAME="usb/%k", GROUP="lp"
    '';
  };

[root@nixos:~]# lsusb
Bus 001 Device 003: ID 5986:0182 Acer, Inc
Bus 001 Device 002: ID 04a9:26da Canon, Inc. LBP3010B printer
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

[root@nixos:~]# find /dev/ | grep -i usb
/dev/v4l/by-path/pci-0000:00:1d.7-usb-0:4:1.0-video-index0
/dev/v4l/by-path/pci-0000:00:1d.7-usb-0:4:1.0-video-index1
/dev/v4l/by-id/usb-Bison_HP_Webcam-50-video-index0
/dev/v4l/by-id/usb-Bison_HP_Webcam-50-video-index1
/dev/input/by-id/usb-Bison_HP_Webcam-50-event-if00
/dev/input/by-path/pci-0000:00:1d.7-usb-0:4:1.0-event
/dev/bus/usb
/dev/bus/usb/005
/dev/bus/usb/005/001
/dev/bus/usb/004
/dev/bus/usb/004/001
/dev/bus/usb/003
/dev/bus/usb/003/001
/dev/bus/usb/002
/dev/bus/usb/002/001
/dev/bus/usb/001
/dev/bus/usb/001/003
/dev/bus/usb/001/002
/dev/bus/usb/001/001

[root@nixos:~]# find /proc/ | grep -i usb
/proc/irq/16/ehci_hcd:usb1
/proc/irq/16/uhci_hcd:usb2
/proc/irq/17/uhci_hcd:usb3
/proc/irq/18/uhci_hcd:usb4
/proc/irq/19/uhci_hcd:usb5

@wizzup
Copy link
Contributor Author

wizzup commented Aug 25, 2019

Hi, I have some update report

  • Both cups and ccpd services are running
  • Printer can be add via ccp protocol (the usb device number keep changing on every boot so I wrote script for that)

I think the main road block is

pstocapt3 write error,9.

I didn't capture the picture of cupstatusui GUI, below are what it show

Message: Printer Error
Check the DevicePath of /etc/ccpd.conf

I have collect the test scripts and outputs on this gist

One more question: Do you have any idea how to set the LogLevel to debug?

Aug 25 16:30:47 nixos cupsd[828]: Hint: Try setting the LogLevel to "debug" to find out more.

@layus
Copy link
Member

layus commented Sep 5, 2019

@wizzup Are you ready for another round ? I have updated my branch, and I am now using an FHS (as expected) to work around programs looking in /bin/ and /usr/bin directly.

You should remove /etc/ccpd.conf and /etc/cups/ppd/<printer-name>.ppd, and reinstall the printer in cups with lpadmin and in ccpd with ccpdadmin after your nixos-rebuild switch

Everything works for me, except for some connection issues. The cups filters pipeline works with all the ghostcript opvp binary sh*t stuf, and ccpd seems to be able to listen on the local network, and on /dev/lp0.

Once everything is set up, it should be working just like that.

In case of issues, I am very interested in the output of

  • sudo journalctl --unit=cups.service -xe
  • sudo journalctl --unit=ccpd.service -xe
  • sudo netstat -lptu

other interesting traces can be obtained by running ccpd by hand. You ust first stop the ccpd service, then ensure that all the sub-processes are dead (ps axu | grep ccpd and kill -9 manually). ccpd in FHS seems pretty resistant to kills.

  • sudo strace -ff -s1000 ccpd

PS: You should really setup an udev rule, your script will come in the way sooner or later. There has been reports of users that had to plug the printer before starting ccpd for example. See #65069 (comment)

@layus
Copy link
Member

layus commented Sep 6, 2019

Oh, I just found the culprit for the "'Can't connect to CCPD" cups status error. You need to define 59687 (the port configured in lpadmin) in ccpd.conf

<Ports>
# Status Monitor API socket port
#  Default PORT  59787
UI_Port  59787
PDATA_Port  59687
</Ports>

It is in the sample ccpd.conf, but not in the one written by ccpdadmin on its first invocation.

@layus
Copy link
Member

layus commented Sep 6, 2019

{
    udev.extraRules = ''
        SUBSYSTEMS=="usb", ATTRS{idVendor}=="04a9", ATTRS{idProduct}=="26da", ATTRS{serial}=="<your serial>", SYMLINK+="usb/lbp3010", GROUP="lp"
    '';

and you can get your serial number with

udevadm info -a -n /dev/usb/lp0 | grep '{serial}'

@wizzup
Copy link
Contributor Author

wizzup commented Sep 7, 2019

I try the updated code, it is not working yet

The captstatusui now read

Message: Communication Error
Check the following:
- Is printer turned on?
- Is the cable properly connected?
[jane@nixos:~/test]$ lsusb | grep LBP
Bus 001 Device 006: ID 04a9:26da Canon, Inc. LBP3010B printer

[jane@nixos:~/test]$ ls -l /dev/usb/lbp3050 
lrwxrwxrwx 1 root root 18 Sep  7 18:00 /dev/usb/lbp3050 -> ../bus/usb/001/006

Update logs collection is on the same previous gist
https://gist.github.com/wizzup/ae200415454789279da25812777d366a

Please let me know if I did anything wrong or not including any information.
Also, If you can't clone the gist, I can setup a repo for logging and test scripts.

@layus
Copy link
Member

layus commented Sep 7, 2019

It looks very promising. ccpd is running and listening on the right ports, you have the /dev/usb/lbp3050 symlink and the message from captstatusui is one that I have never seen and seems more advanced than what I got.

One issue I have with your script is that it goes quite fast, and you may be missing failures at some stages. For example, the journalctl information that you obtained is heavily truncated. It stops right after starting the filters

Sep 07 17:53:50 nixos cupsd[3061]: LBP3050 root 25 [07/Sep/2019:17:53:50 +0700] total 0 - localhost setup-printer.sh - -
Sep 07 17:53:50 nixos cupsd[3061]: Adding start banner page "none".
Sep 07 17:53:50 nixos cupsd[3061]: Queued on "LBP3050" by "root".
Sep 07 17:53:50 nixos cupsd[3061]: REQUEST localhost - - "POST /printers/LBP3050 HTTP/1.1" 200 334 Create-Job successful-ok
Sep 07 17:53:50 nixos cupsd[3061]: File of type application/x-shell queued by "root".
Sep 07 17:53:50 nixos cupsd[3061]: Adding end banner page "none".
Sep 07 17:53:50 nixos cupsd[3061]: Started filter /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/filter/texttopdf (PID 3113)
Sep 07 17:53:50 nixos cupsd[3061]: Started filter /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/filter/pdftopdf (PID 3114)
Sep 07 17:53:50 nixos cupsd[3061]: Started filter /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/filter/pdftops (PID 3115)
Sep 07 17:53:50 nixos cupsd[3061]: Started filter /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/filter/pstocapt3 (PID 3116)
Sep 07 17:53:50 nixos cupsd[3061]: Started backend /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/backend/ccp (PID 3117)

Looking at the previous cups session (also included in the logs) I can see

Sep 07 17:43:18 nixos cupsd[2738]: Started filter /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/filter/texttopdf (PID 2767)
Sep 07 17:43:18 nixos cupsd[2738]: Started filter /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/filter/pdftopdf (PID 2768)
Sep 07 17:43:18 nixos cupsd[2738]: Started filter /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/filter/pdftops (PID 2769)
Sep 07 17:43:18 nixos cupsd[2738]: Started filter /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/filter/pstocapt3 (PID 2770)
Sep 07 17:43:18 nixos cupsd[2738]: Started backend /nix/store/hvp542pjmhz1zsx7cys5kjl4l1yb9dcw-cups-progs/lib/cups/backend/ccp (PID 2771)
Sep 07 17:43:18 nixos cupsd[2738]: REQUEST localhost - - "POST /printers/LBP3050 HTTP/1.1" 200 570 Send-Document successful-ok
Sep 07 17:43:49 nixos cupsd[2738]: Saving job.cache...
Sep 07 17:44:20 nixos cupsd[2738]: Can\'t connect to CCPD: Connection refused
Sep 07 17:44:20 nixos cupsd[2738]: send_data error, no ccpd connection, exit
Sep 07 17:44:20 nixos cupsd[2738]: ccp send_data error, exit
Sep 07 17:44:20 nixos cupsd[2738]: Hint: Try setting the LogLevel to "debug" to find out more.
Sep 07 17:44:20 nixos cupsd[2738]: LBP3050 root 25 [07/Sep/2019:17:44:20 +0700] total 0 - localhost setup-printer.sh - -
Sep 07 17:44:20 nixos cupsd[2738]: Backend returned status 1 (failed)
Sep 07 17:44:20 nixos cupsd[2738]: Printer stopped due to backend errors; please consult the syslog file for details.

which means that all the filters started, but the backend (ccp) failed, being incapable of connecting to ccpd.

This issue should be solved now (it works for me here), so I guess you either have an old ccpd running (these processes are incredibly hard to kill) or you did not allow enough time for ccpd to start.

killing ccpd

To kill it, use ps

$ ps axu | grep ccpd
layus    7492  0.0  0.0 129016  2412 pts/0    S+   21:44   0:00 grep --color=auto ccpd
root     22520  0.0  0.0  88092  3568 ?        Rs   sep06   1:38 ccpd
root     22521  0.0  0.0      0     0 ?        Z    sep06   0:18 [ccpd] <defunct>

and then force kill anything related to ccpd with sudo kill -9

$ sudo kill -9 22520 22521

You should really kill manually all old ccpd before making a new attempt.

testing ccpd connection

To test that the server is reachable, you can use telnet:

echo "" | telnet 127.0.01 59787
Trying 127.0.0.1...
Connected to 127.0.01.
Escape character is '^]'.
Connection closed by foreign host.

telnet is quite explicit on failure:

echo "" | telnet 127.0.01 98765
Trying 127.0.0.1...
telnet: Unable to connect to remote host: Connection refused

testing cups filters + backend manually

You can debug printing issues manually by running the cups filters in a custom script

cups_path=/etc/cups/path/lib/cups
export PATH=$cups_path/filter:$cups_path/backend:$PATH
# here the name is the queue name. Check that this file exists
export PPD=/etc/cups/ppd/LBP3050.ppd
export FINAL_CONTENT_TYPE=application/vnd.cups-postscript

texttopdf 1 me '' 1 '' <./setup-printer.sh >texttopdf-out.pdf
pdftopdf  1 me '' 1 '' <texttopdf-out.pdf  >pdftopdf-out.pdf
pdftops   1 me '' 1 '' <pdftopdf-out.pdf   >pdftops-out.ps
pstocapt3 1 me '' 1 '' <pdftops-out.ps     >pstocapt3-out.capt
ccp       1 me '' 1 '' <pstocapt3-out.capt

You should see the same error message by running this script as the one printed in cups logs.

you can inspect the *-out.{pdf,ps} files to see that everything went well. pstocapt3-out.capt should be a binary blob. You should not recognize any text in there. In particular I had ghostscript debug output in there, and that was plain wrong.

You need not be root to run this.

Other worries/issues.

I am a bit surprised that the owner of /dev/usb/lbp3050 is set to root:root but this is just a world readable symlink. What are the permissions and owners of /dev/bus/usb/001/006 ?

The correct order seems to be

  1. Start printer
  2. Plug in printer
  3. Start ccpd
  4. try to print

Calling ccpdadmin may require a ccpd restart to take the new configuration. Try not calling ccpdadmin when the setup is correct.

If you are willing to give even more help, you can run ccp manually, with strace, like this: sudo strace -ff -s 1000 ccpd |& tee ccpd.log and then run the last two printing steps (pstocapt3 & ccp) with strace too. With strace, you need |& to pipe the output because it prints everything to stderr, but we want to get stderr and stdout in sync in the logs.

@wizzup
Copy link
Contributor Author

wizzup commented Sep 8, 2019

OK, let assume the problem is around ccpd not cups

I create mtest.sh and run with

sudo ./mtest.sh |& tee mtest.out

Please let me know if this help or not.
https://gist.github.com/wizzup/ae200415454789279da25812777d366a

'';

buildPhase = ''
make
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make should be called by default already, you should be able to remove this.

libtool
pkgconfig

cndrvcups-common
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some build tools here should go to nativeBuildInputs:

Suggested change
cndrvcups-common
nativeBuildInputs = [ autoconf automake libtool pkgconfig ];

@layus
Copy link
Member

layus commented Sep 8, 2019

@Mic92 Thanks for your review. This is really a work in progress, and not ready at all for merge or review.

@wizzup could you add a [WIP] tag in front of the issue title ?

@layus
Copy link
Member

layus commented Sep 8, 2019

@wizzup Sorry, this erro comes from the manual call of ccp. You need "PRINTER" defined in the env:

set -xe

nix_path=/etc/cups/path/lib/cups
export PATH=$nix_path/filter:$nix_path/backend:$PATH
export PPD=/etc/cups/ppd/LBP3050.ppd
export FINAL_CONTENT_TYPE=application/vnd.cups-postscript
export PRINTER=LBP3050

ccp 1 me '' 1 '' <pstocapt3-out.capt
exit 0

In strace, ccp should exit with a normal value after having copied (read and written) it's data to ccpd socket. Then you will have to trace ccpd to find the real culprit for the issue you previously described.

For ewample, when piping "lol" in ccp, I get a trace like this, meaning it works correctly.

[pid 17494] brk(NULL)                   = 0xf9f000
[pid 17494] brk(0xfc0000)               = 0xfc0000
[pid 17494] openat(AT_FDCWD, "/dev/urandom", O_RDONLY) = 3
[pid 17494] read(3, "3\223JN\304_v\21", 8) = 8
[pid 17494] close(3)                    = 0
[pid 17494] getrandom("\x35", 1, GRND_NONBLOCK) = 1
[pid 17494] stat("/etc/gnutls/default-priorities", 0x7ffd1779a1e0) = -1 ENOENT (No such file or directory)
[pid 17494] rt_sigaction(SIGTERM, {sa_handler=0x401450, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f69599e6c50}, NULL, 8) = 0
[pid 17494] rt_sigaction(SIGPIPE, {sa_handler=0x401450, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7f69599e6c50}, NULL, 8) = 0
    this part looks like the one you got before your failure

[pid 17494] read(0, "lol\n", 4088)      = 4
    you see that my dummy input is actually read

[pid 17494] stat("/etc/resolv.conf", {st_mode=S_IFREG|0644, st_size=287, ...}) = 0
[pid 17494] openat(AT_FDCWD, "/etc/host.conf", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid 17494] futex(0x7f6959b65a04, FUTEX_WAKE_PRIVATE, 2147483647) = 0
[pid 17494] openat(AT_FDCWD, "/etc/resolv.conf", O_RDONLY|O_CLOEXEC) = 3
[pid 17494] fstat(3, {st_mode=S_IFREG|0644, st_size=287, ...}) = 0
[pid 17494] read(3, "# Generated by resolvconf [more resolv.cong data] \n", 4096) = 287
[pid 17494] read(3, "", 4096)           = 0
[pid 17494] close(3)                    = 0
[pid 17494] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
[pid 17494] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = 0
[pid 17494] sendto(3, "\2\0\0\0\r\0\0\0\6\0\0\0hosts\0", 18, MSG_NOSIGNAL, NULL, 0) = 18
[pid 17494] poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 5000) = 1 ([{fd=3, revents=POLLIN|POLLHUP}])
[pid 17494] recvmsg(3, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="hosts\0", iov_len=6}, {iov_base="\310O\3\0\0\0\0\0", iov_len=8}], msg_iovlen=2, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[4]}], msg_controllen=20, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 14
[pid 17494] mmap(NULL, 217032, PROT_READ, MAP_SHARED, 4, 0) = 0x7f6958ed9000
[pid 17494] close(4)                    = 0
[pid 17494] close(3)                    = 0
[pid 17494] socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
[pid 17494] connect(3, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110) = 0
[pid 17494] sendto(3, "\2\0\0\0\4\0\0\0\n\0\0\0localhost\0", 22, MSG_NOSIGNAL, NULL, 0) = 22
[pid 17494] poll([{fd=3, events=POLLIN|POLLERR|POLLHUP}], 1, 5000) = 1 ([{fd=3, revents=POLLIN|POLLHUP}])
[pid 17494] read(3, "\2\0\0\0\1\0\0\0\n\0\0\0\0\0\0\0\2\0\0\0\4\0\0\0\2\0\0\0\0\0\0\0", 32) = 32
[pid 17494] readv(3, [{iov_base="localhost\0", iov_len=10}, {iov_base="\177\0\0\1\177\0\0\1", iov_len=8}], 2) = 18
[pid 17494] close(3)                    = 0
[pid 17494] socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 3
[pid 17494] connect(3, {sa_family=AF_INET, sin_port=htons(59687), sin_addr=inet_addr("127.0.0.1")}, 16) = 0
    Here the connection to ccpd is started

[pid 17494] write(3, "CCP2\7\0\0\0LBP3050", 15) = 15
[pid 17494] read(3, "CCP3\1\0\0\0", 8)  = 8
[pid 17494] write(3, "\1\0\0\0\4\0\0\0lol\n", 12) = 12
[pid 17494] read(3, "CCP3\1\0\0\0", 8)  = 8
[pid 17494] read(0, "", 4088)           = 0
[pid 17494] write(3, "\1\0\0\0\0\0\0\0", 8) = 8
[pid 17494] read(3, "CCP3\1\0\0\0", 8)  = 8
[pid 17494] close(3)                    = 0
[pid 17494] exit_group(0)               = ?
[pid 17494] +++ exited with 0 +++
    And this is a clean exit, with the socket being closed and the return value set to 0.

@wizzup wizzup changed the title Add canon lasor printer driver. (CAPT Printer Driver for Linux) [WIP] Add canon lasor printer driver. (CAPT Printer Driver for Linux) Sep 10, 2019
@lheckemann lheckemann added this to the 20.03 milestone Sep 10, 2019
@wizzup
Copy link
Contributor Author

wizzup commented Sep 13, 2019

I update mtest.sh according to suggestions, There are some progress

  • Both trace are now exit with 0 but there is nothing print out of the printer
[jane@nixos:~/test]$ lpq
LBP3050 is ready
no entries

The status monitor (captstatusui) still report printer is not connected as previous one.
2019-09-13-155937_381x354_scrot

What are the different setting from previous one that solve ccpd connection issue here? What should we do next?

Logs are at the same gist, the command I use is the same as previous one

sudo ./mtest.sh |& tee mtest.out

@layus
Copy link
Member

layus commented Sep 13, 2019

The ccp trace is perfect, the ccpd trace is strange.
Do you see at the end of ccp when it reads and writes to the tcp socket of ccpd ? (https://gist.github.com/wizzup/ae200415454789279da25812777d366a#file-ccp-trace-L3370)

There are a lot of [pid 1334] read(3, "CCP3\1\0\0\0", 8) = 8, which means that ccpd must write it on the other end, but it does not appear as writes in your ccpd trace. This means that ccp is speaking with another ccpd running.

To kill ccpd properly, you first need to sudo systemctl stop ccpd, and then you may have to kill the processes like you do in mtest.sh, except that on some occasions I had to kill -9 instead of kill.
If the service is not stopped, it will restart ccpd after the kill. Stopping the service should kill ccpd, but...

Not sure if you run your entire script with sudo, but ccpd needs admin rigts to run properly. You have to sudo strace it. (strace sudo does not work because sudo does not allow being traced)

@stale
Copy link

stale bot commented Aug 3, 2020

Hello, I'm a bot and I thank you in the name of the community for your contributions.

Nixpkgs is a busy repository, and unfortunately sometimes PRs get left behind for too long. Nevertheless, we'd like to help committers reach the PRs that are still important. This PR has had no activity for 180 days, and so I marked it as stale, but you can rest assured it will never be closed by a non-human.

If this is still important to you and you'd like to remove the stale label, we ask that you leave a comment. Your comment can be as simple as "still important to me". But there's a bit more you can do:

If you received an approval by an unprivileged maintainer and you are just waiting for a merge, you can @ mention someone with merge permissions and ask them to help. You might be able to find someone relevant by using Git blame on the relevant files, or via GitHub's web interface. You can see if someone's a member of the nixpkgs-committers team, by hovering with the mouse over their username on the web interface, or by searching them directly on the list.

If your PR wasn't reviewed at all, it might help to find someone who's perhaps a user of the package or module you are changing, or alternatively, ask once more for a review by the maintainer of the package/module this is about. If you don't know any, you can use Git blame on the relevant files, or GitHub's web interface to find someone who touched the relevant files in the past.

If your PR has had reviews and nevertheless got stale, make sure you've responded to all of the reviewer's requests / questions. Usually when PR authors show responsibility and dedication, reviewers (privileged or not) show dedication as well. If you've pushed a change, it's possible the reviewer wasn't notified about your push via email, so you can always officially request them for a review, or just @ mention them and say you've addressed their comments.

Lastly, you can always ask for help at our Discourse Forum, or more specifically, at this thread or at #nixos' IRC channel.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 3, 2020
@ryantm ryantm marked this pull request as draft October 23, 2020 03:06
@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Oct 23, 2020
@FRidh FRidh modified the milestones: 20.09, 21.03 Dec 20, 2020
@stale
Copy link

stale bot commented Jun 18, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 18, 2021
@danyeet
Copy link

danyeet commented Dec 8, 2021

Hey is there work done on this still? I know it's a bit niche but it would be nice if it got done cause probably people still need to use canon printers lol.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Dec 8, 2021
@layus
Copy link
Member

layus commented Dec 8, 2021

Well, as you can see it is quite a complex issue, and I do not possess such a printer. So it is difficult to make progress. I guess this can be safely closed, and anyone can resume the job from here.

@layus layus closed this Dec 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

No support for canon lasor printer. (CAPT Printer Driver for Linux)
8 participants