gnu: Add texlive-generic-xstring.
[jackhill/guix/guix.git] / gnu / packages / less.scm
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 ;;;
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
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
36 (define-public less
37 (package
38 (name "less")
39 (version "590")
40 (source
41 (origin
42 (method url-fetch)
43 (uri (list (string-append "mirror://gnu/less/less-"
44 version ".tar.gz")
45 (string-append "http://www.greenwoodsoftware.com/less/less-"
46 version ".tar.gz")))
47 (patches (search-patches "less-hurd-path-max.patch"))
48 (sha256
49 (base32 "044fl3izmsi8n1vqzsqdp65q0qyyn5kmsg4sk7id0mxzx15zbbba"))))
50 (build-system gnu-build-system)
51 (inputs (list ncurses))
52 (home-page "https://www.gnu.org/software/less/")
53 (synopsis "Paginator for terminals")
54 (description
55 "GNU less is a pager, a program that allows you to view large amounts
56 of text in page-sized chunks. Unlike traditional pagers, it allows both
57 backwards and forwards movement through the document. It also does not have
58 to read the entire input file before starting, so it starts faster than most
59 text editors.")
60 (license gpl3+))) ; some files are under GPLv2+
61
62 (define-public lesspipe
63 (package
64 (name "lesspipe")
65 (version "2.06")
66 (source (origin
67 (method git-fetch)
68 (uri (git-reference
69 (url "https://github.com/wofr06/lesspipe")
70 (commit (string-append "v" version))))
71 (file-name (git-file-name name version))
72 (sha256
73 (base32
74 "0f67f45dznhnw99r4zxrzf1xvspzj2rpg2z8b905ixmzpnv86772"))))
75 (build-system gnu-build-system)
76 (arguments
77 (list
78 #:tests? #f ; no tests
79 #:phases
80 #~(modify-phases %standard-phases
81 (replace 'configure
82 (lambda* (#:key outputs #:allow-other-keys)
83 ;; configure is a perl script which the standard configure phase
84 ;; fails to execute
85 (invoke "./configure"
86 (string-append "--prefix=" (assoc-ref outputs "out")))))
87 (add-before 'install 'fix-makefile
88 (lambda _
89 (substitute* "Makefile"
90 (("\\$\\(DESTDIR\\)/etc") "$(DESTDIR)$(PREFIX)/etc"))))
91 (add-before 'install 'patch-command-paths
92 ;; Depending on the content of the file to be displayed and some
93 ;; settings, lesspipe tries to use a large variety of external
94 ;; commands, e.g. rpm, dpkg, vimcolor. We only link the
95 ;; essential ones to avoid this package to pull in all these
96 ;; dependencies which might never ever be used.
97 (lambda* (#:key inputs #:allow-other-keys)
98 (let ((file (search-input-file inputs "/bin/file"))
99 (tput (search-input-file inputs "/bin/tput")))
100 (substitute* "sxw2txt"
101 (("^use warnings;" line)
102 (string-append
103 line "\nuse lib '" #$(this-package-input "perl-archive-zip")
104 "/lib/perl5/site_perl';")))
105 (substitute* "lesscomplete"
106 (("file -") (string-append file " -")))
107 (substitute* "lesspipe.sh"
108 (("tput colors")
109 (string-append tput " colors"))
110 (("file -")
111 (string-append file " -")))))))))
112 (inputs
113 (list file
114 ncurses ;; for tput
115 perl-archive-zip))
116 (native-inputs (list perl))
117 (home-page "https://github.com/wofr06/lesspipe")
118 (synopsis "Input filter for less")
119 (description "To browse files, the excellent viewer @code{less} can be
120 used. By setting the environment variable @code{LESSOPEN}, less can be
121 enhanced by external filters to become more powerful. The input filter for
122 less described here is called @code{lesspipe.sh}. It is able to process a
123 wide variety of file formats. It enables users to inspect archives and
124 display their contents without having to unpack them before. The filter is
125 easily extensible for new formats.")
126 (license gpl2+)))