less.scm 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. ;;; GNU Guix --- Functional package management for GNU
  2. ;;; Copyright © 2012 Nikita Karetnikov <nikita@karetnikov.org>
  3. ;;; Copyright © 2019–2021 Tobias Geerinckx-Rice <me@tobias.gr>
  4. ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  5. ;;; Copyright © 2020, 2021 Michael Rohleder <mike@rohleder.de>
  6. ;;; Copyright © 2022 Hartmut Goebel <h.goebel@crazy-compilers.com>
  7. ;;;
  8. ;;; This file is part of GNU Guix.
  9. ;;;
  10. ;;; GNU Guix is free software; you can redistribute it and/or modify it
  11. ;;; under the terms of the GNU General Public License as published by
  12. ;;; the Free Software Foundation; either version 3 of the License, or (at
  13. ;;; your option) any later version.
  14. ;;;
  15. ;;; GNU Guix is distributed in the hope that it will be useful, but
  16. ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
  17. ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. ;;; GNU General Public License for more details.
  19. ;;;
  20. ;;; You should have received a copy of the GNU General Public License
  21. ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
  22. (define-module (gnu packages less)
  23. #:use-module (guix gexp)
  24. #:use-module (guix licenses)
  25. #:use-module (gnu packages)
  26. #:use-module (gnu packages ncurses)
  27. #:use-module (gnu packages perl)
  28. #:use-module (gnu packages perl-compression)
  29. #:use-module (gnu packages file)
  30. #:use-module (guix packages)
  31. #:use-module (guix download)
  32. #:use-module (guix git-download)
  33. #:use-module (guix build-system gnu))
  34. (define-public less
  35. (package
  36. (name "less")
  37. (version "590")
  38. (source
  39. (origin
  40. (method url-fetch)
  41. (uri (list (string-append "mirror://gnu/less/less-"
  42. version ".tar.gz")
  43. (string-append "http://www.greenwoodsoftware.com/less/less-"
  44. version ".tar.gz")))
  45. (patches (search-patches "less-hurd-path-max.patch"))
  46. (sha256
  47. (base32 "044fl3izmsi8n1vqzsqdp65q0qyyn5kmsg4sk7id0mxzx15zbbba"))))
  48. (build-system gnu-build-system)
  49. (inputs (list ncurses))
  50. (home-page "https://www.gnu.org/software/less/")
  51. (synopsis "Paginator for terminals")
  52. (description
  53. "GNU less is a pager, a program that allows you to view large amounts
  54. of text in page-sized chunks. Unlike traditional pagers, it allows both
  55. backwards and forwards movement through the document. It also does not have
  56. to read the entire input file before starting, so it starts faster than most
  57. text editors.")
  58. (license gpl3+))) ; some files are under GPLv2+
  59. (define-public lesspipe
  60. (package
  61. (name "lesspipe")
  62. (version "2.04")
  63. (source (origin
  64. (method git-fetch)
  65. (uri (git-reference
  66. (url "https://github.com/wofr06/lesspipe")
  67. (commit (string-append "v" version))))
  68. (file-name (git-file-name name version))
  69. (sha256
  70. (base32
  71. "1mwmwkmiyrpib18mli4wrh9n0i12cnf08ssrj6a0s6bgjcfxcjr2"))))
  72. (build-system gnu-build-system)
  73. (arguments
  74. (list
  75. #:tests? #f ; no tests
  76. #:phases
  77. #~(modify-phases %standard-phases
  78. (replace 'configure
  79. (lambda* (#:key outputs #:allow-other-keys)
  80. ;; configure is a perl script which the standard configure phase
  81. ;; fails to execute
  82. (invoke "./configure"
  83. (string-append "--prefix=" (assoc-ref outputs "out")))))
  84. (add-before 'install 'fix-makefile
  85. (lambda _
  86. (substitute* "Makefile"
  87. (("\\$\\(DESTDIR\\)/etc") "$(DESTDIR)$(PREFIX)/etc"))))
  88. (add-before 'install 'patch-command-paths
  89. ;; Depending on the content of the file to be displayed and some
  90. ;; settings, lesspipe trees to use a large variety of external
  91. ;; commands, e.g. rpm, dpkg, vimcolor. We only link the
  92. ;; essential ones to avoid this package to pull in all these
  93. ;; dependencies which might never ever we used.
  94. (lambda* (#:key inputs #:allow-other-keys)
  95. (let ((file (search-input-file inputs "/bin/file"))
  96. (tput (search-input-file inputs "/bin/tput")))
  97. (substitute* "sxw2txt"
  98. (("^use warnings;" line)
  99. (string-append
  100. line "\nuse lib '" #$(this-package-input "perl-archive-zip")
  101. "/lib/perl5/site_perl';")))
  102. (substitute* "lesscomplete"
  103. (("file -") (string-append file " -")))
  104. (substitute* "lesspipe.sh"
  105. (("tput colors")
  106. (string-append tput " colors"))
  107. (("file -")
  108. (string-append file " -")))))))))
  109. (inputs
  110. (list file
  111. ncurses ;; for tput
  112. perl-archive-zip))
  113. (native-inputs (list perl))
  114. (home-page "https://github.com/wofr06/lesspipe")
  115. (synopsis "Input filter for less")
  116. (description "To browse files, the excellent viewer @code{less} can be
  117. used. By setting the environment variable @code{LESSOPEN}, less can be
  118. enhanced by external filters to become more powerful. The input filter for
  119. less described here is called @code{lesspipe.sh}. It is able to process a
  120. wide variety of file formats. It enables users to inspect archives and
  121. display their contents without having to unpack them before. The filter is
  122. easily extensible for new formats.")
  123. (license gpl2+)))