Commit 74838606 authored by Yarny0's avatar Yarny0
Browse files

{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.
parent f4f89032
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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
  '';

+2 −1
Original line number Diff line number Diff line
@@ -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