less.scm 5.5 KB

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