{nixos/tests/}/cups-pdf: use getExe and substituteInPlace

With `lib.getExe`, we also use "magick" instead of "convert`,
and thereby avoid the ImageMagick warning message:

> WARNING: The convert command is deprecated in IMv7, use "magick" instead of "convert" or "magick convert"

The replacement string for the
`cp` command is shortened.
This is a bit risky since an update might inadvertently
introduce a similar string that is then also replaced.
However, the leading double-quote and
trailing space seem safe enough to me.
This commit is contained in:
Yarny0 2025-03-05 18:57:57 +01:00
parent f4f89032a1
commit 74838606a0
2 changed files with 3 additions and 2 deletions

View file

@ -37,7 +37,7 @@
machine.wait_until_succeeds(f"su - alice -c 'pdfinfo /var/spool/cups-pdf-{name}/users/alice/*.pdf'")
machine.succeed(f"cp /var/spool/cups-pdf-{name}/users/alice/*.pdf /tmp/{name}.pdf")
machine.copy_from_vm(f"/tmp/{name}.pdf", "")
run(f"${hostPkgs.imagemagickBig}/bin/convert -density 300 $out/{name}.pdf $out/{name}.jpeg", shell=True, check=True)
run(f"${lib.getExe hostPkgs.imagemagickBig} -density 300 $out/{name}.pdf $out/{name}.jpeg", shell=True, check=True)
assert text.encode() in run(f"${lib.getExe hostPkgs.tesseract} $out/{name}.jpeg stdout", shell=True, check=True, capture_output=True).stdout
'';

View file

@ -21,7 +21,8 @@ stdenv.mkDerivation {
buildInputs = [ cups ];
postPatch = ''
sed -r 's|(gscall, size, ")cp |\1${coreutils}/bin/cp |' cups-pdf.c -i
substituteInPlace cups-pdf.c \
--replace-fail '"cp ' '"${lib.getExe' coreutils "cp"} '
'';
# gcc command line is taken from original cups-pdf's README file