Unverified Commit 4e6ae964 authored by Sandro Jäckel's avatar Sandro Jäckel Committed by GitHub
Browse files

Merge pull request #254409 from anund/fix_less_pipe_dependency

lesspipe: validate and add script dependencies
parents 931ee755 2e267112
Loading
Loading
Loading
Loading
+78 −4
Original line number Diff line number Diff line
{ lib, stdenv, fetchFromGitHub, makeWrapper, perl, procps, file, gnused, bash, binutils }:
{ lib
, stdenv
, fetchFromGitHub
, makeWrapper
, perl
, procps
, bash

# shell referenced dependencies
, resholve
, binutils-unwrapped
, file
, gnugrep
, coreutils
, gnused
, gnutar
, iconv
, ncurses
}:

stdenv.mkDerivation rec {
  pname = "lesspipe";
@@ -28,9 +46,65 @@ stdenv.mkDerivation rec {
  installFlags = [ "DESTDIR=$(out)" ];

  postInstall = ''
    for f in lesspipe.sh lesscomplete; do
      wrapProgram "$out/bin/$f" --prefix-each PATH : "${lib.makeBinPath [ binutils file gnused procps ]}"
    done
    # resholve doesn't see strings in an array definition
    substituteInPlace $out/bin/lesspipe.sh --replace 'nodash strings' "nodash ${binutils-unwrapped}/bin/strings"

    ${resholve.phraseSolution "lesspipe.sh" {
      scripts = [ "bin/lesspipe.sh" ];
      interpreter = "${bash}/bin/bash";
      inputs = [
        coreutils
        file
        gnugrep
        gnused
        gnutar
        iconv
        procps
        ncurses
      ];
      keep = [ "$prog" "$c1" "$c2" "$c3" "$c4" "$c5" "$cmd" "$colorizer" "$HOME" ];
      fake = {
        # script guards usage behind has_cmd test function, it's safe to leave these external and optional
        external = [
          "cpio" "isoinfo" "cabextract" "bsdtar" "rpm2cpio" "bsdtar" "unzip" "ar" "unrar" "rar" "7zr" "7za" "isoinfo"
          "gzip" "bzip2" "lzip" "lzma" "xz" "brotli" "compress" "zstd" "lz4"
          "archive_color" "bat" "batcat" "pygmentize" "source-highlight" "vimcolor" "code2color"

          "w3m" "lynx" "elinks" "html2text" "dtc" "pdftotext" "pdftohtml" "pdfinfo" "ps2ascii" "procyon" "ccze"
          "mdcat" "pandoc" "docx2txt" "libreoffice" "pptx2md" "mdcat" "xlscat" "odt2txt" "wvText" "antiword" "catdoc"
          "broken_catppt" "sxw2txt" "groff" "mandoc" "unrtf" "dvi2tty" "pod2text" "perldoc" "h5dump" "ncdump" "matdump"
          "djvutxt" "openssl" "gpg" "plistutil" "plutil" "id3v2" "csvlook" "jq" "zlib-flate" "lessfilter"
        ] ++ lib.optional stdenv.isDarwin [
          # resholve only identifies this on darwin
          # call site is gaurded by || so it's safe to leave dynamic
          "locale"
        ];
        builtin = [ "setopt" ];
      };
      execer = [
        "cannot:${iconv}/bin/iconv"
      ];
    }}
    ${resholve.phraseSolution "lesscomplete" {
      scripts = [ "bin/lesscomplete" ];
      interpreter = "${bash}/bin/bash";
      inputs = [
        coreutils
        file
        gnugrep
        gnused
        gnutar
      ];
      keep = [ "$prog" "$c1" "$c2" "$c3" "$c4" "$c5" "$cmd" ];
      fake = {
        # script guards usage behind has_cmd test function, it's safe to leave these external and optional
        external = [
          "cpio" "isoinfo" "cabextract" "bsdtar" "rpm2cpio" "bsdtar" "unzip" "ar" "unrar" "rar" "7zr" "7za" "isoinfo"
          "gzip" "bzip2" "lzip" "lzma" "xz" "brotli" "compress" "zstd" "lz4"
        ];
        builtin = [ "setopt" ];
      };
    }}
  '';

  meta = with lib; {