From 1323930b7b263568ace78caf346189272fffb08e Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Sat, 13 Jul 2019 09:31:46 +0200 Subject: [PATCH 1/5] hplip: add meta.downloadPage --- pkgs/misc/drivers/hplip/3.16.11.nix | 1 + pkgs/misc/drivers/hplip/3.18.5.nix | 1 + pkgs/misc/drivers/hplip/default.nix | 1 + 3 files changed, 3 insertions(+) diff --git a/pkgs/misc/drivers/hplip/3.16.11.nix b/pkgs/misc/drivers/hplip/3.16.11.nix index 8f5004693ea..5e275a1f2b3 100644 --- a/pkgs/misc/drivers/hplip/3.16.11.nix +++ b/pkgs/misc/drivers/hplip/3.16.11.nix @@ -184,6 +184,7 @@ pythonPackages.buildPythonApplication { meta = with stdenv.lib; { description = "Print, scan and fax HP drivers for Linux"; homepage = http://hplipopensource.com/; + downloadPage = https://sourceforge.net/projects/hplip/files/hplip/; license = if withPlugin then licenses.unfree else with licenses; [ mit bsd2 gpl2Plus ]; diff --git a/pkgs/misc/drivers/hplip/3.18.5.nix b/pkgs/misc/drivers/hplip/3.18.5.nix index 2be65e40c45..9c9694edbd4 100644 --- a/pkgs/misc/drivers/hplip/3.18.5.nix +++ b/pkgs/misc/drivers/hplip/3.18.5.nix @@ -216,6 +216,7 @@ pythonPackages.buildPythonApplication { meta = with stdenv.lib; { description = "Print, scan and fax HP drivers for Linux"; homepage = https://developers.hp.com/hp-linux-imaging-and-printing; + downloadPage = https://sourceforge.net/projects/hplip/files/hplip/; license = if withPlugin then licenses.unfree else with licenses; [ mit bsd2 gpl2Plus ]; diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix index ea955428809..2e2b4548e15 100644 --- a/pkgs/misc/drivers/hplip/default.nix +++ b/pkgs/misc/drivers/hplip/default.nix @@ -216,6 +216,7 @@ pythonPackages.buildPythonApplication { meta = with stdenv.lib; { description = "Print, scan and fax HP drivers for Linux"; homepage = https://developers.hp.com/hp-linux-imaging-and-printing; + downloadPage = https://sourceforge.net/projects/hplip/files/hplip/; license = if withPlugin then licenses.unfree else with licenses; [ mit bsd2 gpl2Plus ]; From 15aacfb45077d572fd3999ab00a6fe630af2cae7 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Sun, 30 Jun 2019 15:13:33 +0200 Subject: [PATCH 2/5] hplip: 3.19.1 -> 3.19.6 Release notes: https://developers.hp.com/hp-linux-imaging-and-printing/release_notes --- pkgs/misc/drivers/hplip/default.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix index 2e2b4548e15..1726e8ea421 100644 --- a/pkgs/misc/drivers/hplip/default.nix +++ b/pkgs/misc/drivers/hplip/default.nix @@ -12,16 +12,16 @@ let name = "hplip-${version}"; - version = "3.19.1"; + version = "3.19.6"; src = fetchurl { url = "mirror://sourceforge/hplip/${name}.tar.gz"; - sha256 = "1kl1q4753xx1w76dhp92wgrhn5k1yx1ib35pyi0vi3mw0njbhrzm"; + sha256 = "0vfnc6pg7wzs68qn5mlk3cyl969d8n55bydgydq2wzfikvpfvnpw"; }; plugin = fetchurl { url = "https://www.openprinting.org/download/printdriver/auxfiles/HP/plugins/${name}-plugin.run"; - sha256 = "1fwjypy1ycyi7rr1vk1yxhbdhx51n7fxhvjb36mzw8qz71dif2i3"; + sha256 = "1b5gys04kh41gg7r7rzlpdbc2f4jirl2ik22cd935mm85k7abfwq"; }; hplipState = substituteAll { From 60311e09576528982582bf9cf1eb86c109a72387 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Sun, 30 Jun 2019 15:15:28 +0200 Subject: [PATCH 3/5] hplip: patch imageProcessor segfault in `hpcups` (#58949) Beginning with version 3.18.7, `hpcups` fails with > DEBUG: imageProcessorStartPage failed and segfaults (tested with HP LaserJet 1000 printer). Upstream bug reports: * https://bugs.launchpad.net/hplip/+bug/1788706 * https://bugs.launchpad.net/hplip/+bug/1787289 There is a patch available in one of the reports: https://bugs.launchpad.net/hplip/+bug/1787289/+attachment/5176026/+files/hplip.patch It applies to 3.18.7, but not to later versions. This commit adds a slight adaption of the patch that applies to versions 3.18.9 -- 3.19.6. The patch fixes https://github.com/NixOS/nixpkgs/issues/58949 . Note that the patch is merely a workaround: It simply removes all calls into the ImageProcessor library from `HPCupsFilter.cpp`. --- pkgs/misc/drivers/hplip/default.nix | 7 +++ pkgs/misc/drivers/hplip/image-processor.patch | 62 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 pkgs/misc/drivers/hplip/image-processor.patch diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix index 1726e8ea421..eced20902c6 100644 --- a/pkgs/misc/drivers/hplip/default.nix +++ b/pkgs/misc/drivers/hplip/default.nix @@ -82,6 +82,13 @@ pythonPackages.buildPythonApplication { makeWrapperArgs = [ "--prefix" "PATH" ":" "${nettools}/bin" ]; + patches = [ + # remove ImageProcessor usage, it causes segfaults, see + # https://bugs.launchpad.net/hplip/+bug/1788706 + # https://bugs.launchpad.net/hplip/+bug/1787289 + ./image-processor.patch + ]; + prePatch = '' # HPLIP hardcodes absolute paths everywhere. Nuke from orbit. find . -type f -exec sed -i \ diff --git a/pkgs/misc/drivers/hplip/image-processor.patch b/pkgs/misc/drivers/hplip/image-processor.patch new file mode 100644 index 00000000000..ef1040ba08b --- /dev/null +++ b/pkgs/misc/drivers/hplip/image-processor.patch @@ -0,0 +1,62 @@ +diff --git i/prnt/hpcups/HPCupsFilter.cpp w/prnt/hpcups/HPCupsFilter.cpp +index 5b282d8..153ee3a 100644 +--- i/prnt/hpcups/HPCupsFilter.cpp ++++ w/prnt/hpcups/HPCupsFilter.cpp +@@ -31,7 +31,6 @@ + \*****************************************************************************/ + + #include "HPCupsFilter.h" +-#include "ImageProcessor.h" + + #include + #include +@@ -637,16 +636,10 @@ int HPCupsFilter::processRasterData(cups_raster_t *cups_raster) + + + sprintf(hpPreProcessedRasterFile, "%s/hp_%s_cups_SwapedPagesXXXXXX",CUPS_TMP_DIR, m_JA.user_name); +- image_processor_t* imageProcessor = imageProcessorCreate(); + + while (cupsRasterReadHeader2(cups_raster, &cups_header)) + { + +- IMAGE_PROCESSOR_ERROR result = imageProcessorStartPage(imageProcessor, &cups_header); +- if (result != IPE_SUCCESS){ +- dbglog("DEBUG: imageProcessorStartPage failed result = %d\n", result); +- } +- + current_page_number++; + + if (current_page_number == 1) { +@@ -745,11 +738,6 @@ int HPCupsFilter::processRasterData(cups_raster_t *cups_raster) + color_raster = rgbRaster; + black_raster = kRaster; + +- result = imageProcessorProcessLine(imageProcessor, m_pPrinterBuffer, cups_header.cupsBytesPerLine); +- if (result != IPE_SUCCESS){ +- dbglog("DEBUG: imageProcessorProcessLine failed result = %d\n", result); +- } +- + + if ((y == 0) && !is_ljmono) { + //For ljmono, make sure that first line is not a blankRaster line.Otherwise printer +@@ -780,11 +768,6 @@ int HPCupsFilter::processRasterData(cups_raster_t *cups_raster) + } + } // for() loop end + +- result = imageProcessorEndPage(imageProcessor); +- if (result != IPE_SUCCESS){ +- dbglog("DEBUG: imageProcessorEndPage failed result = %d\n", result); +- } +- + + m_Job.NewPage(); + if (err != NO_ERROR) { +@@ -800,8 +783,6 @@ int HPCupsFilter::processRasterData(cups_raster_t *cups_raster) + rgbRaster = NULL; + } + +- imageProcessorDestroy(imageProcessor); +- + unlink(hpPreProcessedRasterFile); + return ret_status; + } From 5aafd1d0dba2800e14421b3f93721e8b2d1cd0f7 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Sat, 13 Jul 2019 09:25:56 +0200 Subject: [PATCH 4/5] hplip: udev rule: drop `nohup` instead of patching it hplip's udev rule uses `nohup` to attempt to detach its printer configuration script from the udev process. However, this attempt is futile as udev tracks its child processes with cgroups: https://unix.stackexchange.com/a/243648 The hardcoded path to `nohup` was patched to use Nix' `nohup`. This commit alters the patch script so that it simply drops the call to `nohup`. --- pkgs/misc/drivers/hplip/3.16.11.nix | 2 +- pkgs/misc/drivers/hplip/3.18.5.nix | 2 +- pkgs/misc/drivers/hplip/default.nix | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/misc/drivers/hplip/3.16.11.nix b/pkgs/misc/drivers/hplip/3.16.11.nix index 5e275a1f2b3..4e9b4cbf0ae 100644 --- a/pkgs/misc/drivers/hplip/3.16.11.nix +++ b/pkgs/misc/drivers/hplip/3.16.11.nix @@ -176,7 +176,7 @@ pythonPackages.buildPythonApplication { # Needs a lot of patching but might save someone a bit of confusion: substituteInPlace $out/etc/udev/rules.d/56-hpmud.rules \ --replace {,${bash}}/bin/sh \ - --replace {/usr,${coreutils}}/bin/nohup \ + --replace /usr/bin/nohup "" \ --replace {,${utillinux}/bin/}logger \ --replace {/usr,$out}/bin ''; diff --git a/pkgs/misc/drivers/hplip/3.18.5.nix b/pkgs/misc/drivers/hplip/3.18.5.nix index 9c9694edbd4..7da6b2db930 100644 --- a/pkgs/misc/drivers/hplip/3.18.5.nix +++ b/pkgs/misc/drivers/hplip/3.18.5.nix @@ -208,7 +208,7 @@ pythonPackages.buildPythonApplication { # Needs a lot of patching but might save someone a bit of confusion: substituteInPlace $out/etc/udev/rules.d/56-hpmud.rules \ --replace {,${bash}}/bin/sh \ - --replace {/usr,${coreutils}}/bin/nohup \ + --replace /usr/bin/nohup "" \ --replace {,${utillinux}/bin/}logger \ --replace {/usr,$out}/bin ''; diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix index eced20902c6..6c02fa52124 100644 --- a/pkgs/misc/drivers/hplip/default.nix +++ b/pkgs/misc/drivers/hplip/default.nix @@ -215,7 +215,7 @@ pythonPackages.buildPythonApplication { # Needs a lot of patching but might save someone a bit of confusion: substituteInPlace $out/etc/udev/rules.d/56-hpmud.rules \ --replace {,${bash}}/bin/sh \ - --replace {/usr,${coreutils}}/bin/nohup \ + --replace /usr/bin/nohup "" \ --replace {,${utillinux}/bin/}logger \ --replace {/usr,$out}/bin ''; From 2daea2c81f1690fb12070abe67f5ab6b1d582159 Mon Sep 17 00:00:00 2001 From: Yarny0 <41838844+Yarny0@users.noreply.github.com> Date: Sun, 30 Jun 2019 15:29:17 +0200 Subject: [PATCH 5/5] hplip: retain udev rules in WithPlugin version Beginning with commit 8ffd6af27e6dfae0a3b4d77db03409f62c5b8d98, the build recipe for `hplipWithPlugin` explicitely drops a udev rule file that is delivered with the sources. In `hplip` (without plugin), the rule file is retained. The udev rules takes care of uploading firmware to certain printers (and maybe of other things), e.g. to HP LaserJet 1000. This commit reinstates the rule file and expands the fixup script so that the rules are also patched in the WithPlugin version. --- pkgs/misc/drivers/hplip/3.16.11.nix | 8 +++----- pkgs/misc/drivers/hplip/3.18.5.nix | 8 +++----- pkgs/misc/drivers/hplip/default.nix | 8 +++----- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/pkgs/misc/drivers/hplip/3.16.11.nix b/pkgs/misc/drivers/hplip/3.16.11.nix index 4e9b4cbf0ae..ebea49d9540 100644 --- a/pkgs/misc/drivers/hplip/3.16.11.nix +++ b/pkgs/misc/drivers/hplip/3.16.11.nix @@ -142,8 +142,6 @@ pythonPackages.buildPythonApplication { mkdir -p $out/etc/sane.d/dll.d mv $out/etc/sane.d/dll.conf $out/etc/sane.d/dll.d/hpaio.conf - - rm $out/etc/udev/rules.d/56-hpmud.rules ''; # The installed executables are just symlinks into $out/share/hplip, @@ -171,9 +169,9 @@ pythonPackages.buildPythonApplication { postFixup = '' substituteInPlace $out/etc/hp/hplip.conf --replace /usr $out - '' + stdenv.lib.optionalString (!withPlugin) '' - # A udev rule to notify users that they need the binary plugin. - # Needs a lot of patching but might save someone a bit of confusion: + # Patch udev rules: + # with plugin, they upload firmware to printers, + # without plugin, they complain about the missing plugin. substituteInPlace $out/etc/udev/rules.d/56-hpmud.rules \ --replace {,${bash}}/bin/sh \ --replace /usr/bin/nohup "" \ diff --git a/pkgs/misc/drivers/hplip/3.18.5.nix b/pkgs/misc/drivers/hplip/3.18.5.nix index 7da6b2db930..68220392fd0 100644 --- a/pkgs/misc/drivers/hplip/3.18.5.nix +++ b/pkgs/misc/drivers/hplip/3.18.5.nix @@ -174,8 +174,6 @@ pythonPackages.buildPythonApplication { mkdir -p $out/var/lib/hp cp ${hplipState} $out/var/lib/hp/hplip.state - - rm $out/etc/udev/rules.d/56-hpmud.rules ''; # The installed executables are just symlinks into $out/share/hplip, @@ -203,9 +201,9 @@ pythonPackages.buildPythonApplication { postFixup = '' substituteInPlace $out/etc/hp/hplip.conf --replace /usr $out - '' + stdenv.lib.optionalString (!withPlugin) '' - # A udev rule to notify users that they need the binary plugin. - # Needs a lot of patching but might save someone a bit of confusion: + # Patch udev rules: + # with plugin, they upload firmware to printers, + # without plugin, they complain about the missing plugin. substituteInPlace $out/etc/udev/rules.d/56-hpmud.rules \ --replace {,${bash}}/bin/sh \ --replace /usr/bin/nohup "" \ diff --git a/pkgs/misc/drivers/hplip/default.nix b/pkgs/misc/drivers/hplip/default.nix index 6c02fa52124..851aa9f3f88 100644 --- a/pkgs/misc/drivers/hplip/default.nix +++ b/pkgs/misc/drivers/hplip/default.nix @@ -181,8 +181,6 @@ pythonPackages.buildPythonApplication { mkdir -p $out/var/lib/hp cp ${hplipState} $out/var/lib/hp/hplip.state - - rm $out/etc/udev/rules.d/56-hpmud.rules ''; # The installed executables are just symlinks into $out/share/hplip, @@ -210,9 +208,9 @@ pythonPackages.buildPythonApplication { postFixup = '' substituteInPlace $out/etc/hp/hplip.conf --replace /usr $out - '' + stdenv.lib.optionalString (!withPlugin) '' - # A udev rule to notify users that they need the binary plugin. - # Needs a lot of patching but might save someone a bit of confusion: + # Patch udev rules: + # with plugin, they upload firmware to printers, + # without plugin, they complain about the missing plugin. substituteInPlace $out/etc/udev/rules.d/56-hpmud.rules \ --replace {,${bash}}/bin/sh \ --replace /usr/bin/nohup "" \