From cd4c8d63f5698d86960086c3d0e3c94c08efd285 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Wed, 7 Jul 2021 20:52:43 +0200 Subject: [PATCH] foomatic-db-engine: init at unstable-2022-05-03 `foomatic-db-engine` contains several perl scripts to parse and process XML files from the Foomatic database packages. It can be used to extract ppd files, which will be accomplished in a follow-up commit. The package also contains scripts to handle print queues and jobs. It can -- optionally -- talk to the local cups server, to network printers and to SMB print servers. The build recipe contains switches to enable these features; however, they are not needed when generating ppd files. There is a daily snapshot of a source archive available at https://www.openprinting.org/download/foomatic/ . However, these files rotate daily and cannot be used as a stable download source. So we rely on OpenPrinting's Github repository instead and pinpoint a fresh commit. --- .../drivers/foomatic-db-engine/default.nix | 94 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 96 insertions(+) create mode 100644 pkgs/misc/cups/drivers/foomatic-db-engine/default.nix diff --git a/pkgs/misc/cups/drivers/foomatic-db-engine/default.nix b/pkgs/misc/cups/drivers/foomatic-db-engine/default.nix new file mode 100644 index 00000000000..b5e107ebf37 --- /dev/null +++ b/pkgs/misc/cups/drivers/foomatic-db-engine/default.nix @@ -0,0 +1,94 @@ +{ lib +, perlPackages +, fetchFromGitHub +, withCupsAccess ? false # needed to access local cups server +, cups +, cups-filters +, curl +, withSocketAccess ? false # needed to access network printers +, netcat-gnu +, withSMBAccess ? false # needed to access SMB-connected printers +, samba +, autoconf +, automake +, file +, makeWrapper +}: + +perlPackages.buildPerlPackage { + pname = "foomatic-db-engine"; + version = "unstable-2022-05-03"; + + src = fetchFromGitHub { + # there is also a daily snapshot at the `downloadPage`, + # but it gets deleted quickly and would provoke 404 errors + owner = "OpenPrinting"; + repo = "foomatic-db-engine"; + rev = "2e6f14b54748fa121a4d2e3d480010e10b070c5a"; + hash = "sha256-m7FQTxWmawbtm24h8UqznGKXgX41JhOtyyFMRwEhm5k="; + }; + + outputs = [ "out" ]; + + propagatedBuildInputs = [ + perlPackages.Clone + perlPackages.DBI + perlPackages.XMLLibXML + ]; + + buildInputs = + # provide some "cups-*" commands to `foomatic-{configure,printjob}` + # so that they can manage a local cups server (add queues, add jobs...) + lib.optionals withCupsAccess [ cups cups-filters curl ] + # the commands `foomatic-{configure,getpjloptions}` need + # netcat if they are used to query or alter a network + # printer via AppSocket/HP JetDirect protocol + ++ lib.optional withSocketAccess netcat-gnu + # `foomatic-configure` can be used to access printers that are + # shared via the SMB protocol, but it needs the `smbclient` binary + ++ lib.optional withSMBAccess samba + ; + + nativeBuildInputs = [ autoconf automake file makeWrapper ]; + + # sed-substitute indirection is more robust against + # characters in paths that might need escaping + prePatch = '' + sed -Ei 's|^(S?BINSEARCHPATH=).+$|\1"@PATH@"|g' configure.ac + substituteInPlace configure.ac --subst-var PATH + touch Makefile.PL # `buildPerlPackage` fails unless this exists + ''; + + preConfigure = '' + ./make_configure + ''; + + configureFlags = [ + "--sysconfdir=${placeholder "out"}/etc" + "LIBDIR=${placeholder "out"}/share/foomatic" + "PERLPREFIX=${placeholder "out"}" + ]; + + postFixup = '' + for bin in "${placeholder "out"}/bin"/*; do + test '!' -L "$bin" || continue # skip symlink + wrapProgram "$bin" --set PERL5LIB "$PERL5LIB" + done + ''; + + doCheck = false; # no tests, would fail + + meta = { + description = "OpenPrinting printer support database engine"; + downloadPage = "https://www.openprinting.org/download/foomatic/"; + homepage = "https://openprinting.github.io/projects/02-foomatic/"; + license = lib.licenses.gpl2Only; + maintainers = [ lib.maintainers.yarny ]; + longDescription = '' + Foomatic's database engine generates PPD files + from the data in Foomatic's XML database. + It also contains scripts to directly + generate print queues and handle jobs. + ''; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 5b1faf8d586..088bea97441 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -36319,6 +36319,8 @@ with pkgs; epson-workforce-635-nx625-series = callPackage ../misc/drivers/epson-workforce-635-nx625-series { }; + foomatic-db-engine = callPackage ../misc/cups/drivers/foomatic-db-engine {}; + gutenprint = callPackage ../misc/drivers/gutenprint { }; gutenprintBin = callPackage ../misc/drivers/gutenprint/bin.nix { };