gnu: Simplify package inputs.
[jackhill/guix/guix.git] / gnu / packages / lsof.scm
1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2013 Andreas Enge <andreas@enge.fr>
3 ;;; Copyright © 2017 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2018, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2018, 2019 Ludovic Courtès <ludo@gnu.org>
6 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.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 lsof)
24 #:use-module ((guix licenses) #:prefix license:)
25 #:use-module (guix packages)
26 #:use-module (guix git-download)
27 #:use-module (guix build-system gnu)
28 #:use-module (guix utils)
29 #:use-module (gnu packages)
30 #:use-module (gnu packages groff)
31 #:use-module (gnu packages perl))
32
33 (define-public lsof
34 (package
35 (name "lsof")
36 (version "4.94.0")
37 (source
38 (origin
39 (method git-fetch)
40 (uri (git-reference
41 (url "https://github.com/lsof-org/lsof")
42 (commit version)))
43 (file-name (git-file-name name version))
44 (sha256
45 (base32 "0yxv2jg6rnzys49lyrz9yjb4knamah4xvlqj596y6ix3vm4k3chp"))
46 (patches (search-patches "lsof-fatal-test-failures.patch"))))
47 (build-system gnu-build-system)
48 (native-inputs
49 (list groff ; for soelim
50 perl))
51 (arguments
52 `(#:phases
53 (modify-phases %standard-phases
54 (replace 'configure
55 (lambda _
56 (setenv "LSOF_CC" ,(cc-for-target))
57 (setenv "LSOF_MAKE" "make")
58
59 ;; By default, the makefile captures the output of 'uname -a'.
60 ;; Provide a fixed output instead to make builds reproducible.
61 (setenv "LSOF_SYSINFO"
62 (string-append "GNU/" (utsname:sysname (uname))
63 " (GNU Guix)"))
64
65 (invoke "./Configure" "linux")))
66 (add-after 'configure 'patch-timestamps
67 (lambda _
68 (substitute* "Makefile"
69 (("`date`") "`date --date=@1`"))))
70 (add-after 'build 'build-man-page
71 (lambda _
72 (with-output-to-file "lsof.8"
73 (lambda _ (invoke "soelim" "Lsof.8")))))
74 (add-before 'check 'disable-failing-tests
75 (lambda _
76 (substitute* "tests/Makefile"
77 ;; Fails with ‘ERROR!!! client gethostbyaddr() failure’.
78 (("(STDTST=.*) LTsock" _ prefix) prefix)
79 ;; LTnfs fails without access to a remote NFS server, and LTlock
80 ;; fails when run on a Btrfs file system (see:
81 ;; https://github.com/lsof-org/lsof/issues/152).
82 (("OPTTST=[[:space:]]*LTbigf LTdnlc LTlock LTnfs")
83 "OPTTST = LTbigf LTdnlc"))))
84 (replace 'check
85 (lambda* (#:key tests? #:allow-other-keys)
86 (when tests?
87 (with-directory-excursion "tests"
88 ;; Tests refuse to run on ‘unvalidated’ platforms.
89 (make-file-writable "TestDB")
90 (invoke "./Add2TestDB")
91
92 ;; The ‘standard’ tests suggest running ‘optional’ ones as well.
93 (invoke "make" "standard" "optional")))))
94 (replace 'install
95 (lambda* (#:key outputs #:allow-other-keys)
96 (let ((out (assoc-ref outputs "out")))
97 (install-file "lsof" (string-append out "/bin"))
98 (install-file "lsof.8" (string-append out "/share/man/man8"))))))))
99 (synopsis "Display information about open files")
100 (description
101 "Lsof stands for LiSt Open Files, and it does just that.
102 It lists information about files that are open by the processes running
103 on the system.")
104 (license (license:fsf-free
105 "file://00FAQ"
106 "License inspired by zlib, see point 1.9 of 00FAQ in the distribution."))
107 (home-page "https://people.freebsd.org/~abe/")))