gnu: deutex: Update to 5.2.1.
[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 Tobias Geerinckx-Rice <me@tobias.gr>
5 ;;; Copyright © 2018, 2019 Ludovic Courtès <ludo@gnu.org>
6 ;;;
7 ;;; This file is part of GNU Guix.
8 ;;;
9 ;;; GNU Guix is free software; you can redistribute it and/or modify it
10 ;;; under the terms of the GNU General Public License as published by
11 ;;; the Free Software Foundation; either version 3 of the License, or (at
12 ;;; your option) any later version.
13 ;;;
14 ;;; GNU Guix is distributed in the hope that it will be useful, but
15 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
16 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ;;; GNU General Public License for more details.
18 ;;;
19 ;;; You should have received a copy of the GNU General Public License
20 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
21
22 (define-module (gnu packages lsof)
23 #:use-module ((guix licenses) #:prefix license:)
24 #:use-module (guix packages)
25 #:use-module (guix download)
26 #:use-module (guix build-system gnu)
27 #:use-module (gnu packages perl))
28
29 (define-public lsof
30 (package
31 (name "lsof")
32 (version "4.91")
33 (source
34 (origin
35 (method url-fetch)
36 (uri
37 (apply append
38 (map
39 (lambda (mirror-uri)
40 (let ((tarball (string-append name "_" version ".tar.bz2")))
41 (list
42 (string-append mirror-uri "/" tarball)
43 ;; Upon every new release, the previous one is moved here:
44 (string-append mirror-uri "/OLD/" tarball))))
45 (list
46 "ftp://lsof.itap.purdue.edu/pub/tools/unix/lsof/"
47
48 ;; Add mirrors because the canonical FTP server at purdue.edu
49 ;; bails out when it cannot do a reverse DNS lookup, as noted
50 ;; at <http://people.freebsd.org/~abe/>.
51 "ftp://ftp.fu-berlin.de/pub/unix/tools/lsof/"
52 (string-append "http://www.mirrorservice.org/sites/"
53 "lsof.itap.purdue.edu/pub/tools/unix/lsof")
54 (string-append "ftp://ftp.mirrorservice.org/sites/"
55 "lsof.itap.purdue.edu/pub/tools/unix/lsof")))))
56 (sha256
57 (base32 "18sh4hbl9jw2szkf0gvgan8g13f3g4c6s2q9h3zq5gsza9m99nn9"))))
58 (build-system gnu-build-system)
59 (native-inputs `(("perl" ,perl)))
60 (arguments
61 `(#:phases
62 (modify-phases %standard-phases
63 (replace 'unpack
64 (lambda* (#:key source #:allow-other-keys)
65 (let ((unpack (assoc-ref %standard-phases 'unpack)))
66 (unpack #:source source)
67 (unpack #:source (car (find-files "." "\\.tar$"))))))
68 (replace 'configure
69 (lambda _
70 (setenv "LSOF_CC" "gcc")
71 (setenv "LSOF_MAKE" "make")
72
73 ;; By default, the makefile captures the output of 'uname -a'.
74 ;; Provide a fixed output instead to make builds reproducible.
75 (setenv "LSOF_SYSINFO"
76 (string-append "GNU/" (utsname:sysname (uname))
77 " (GNU Guix)"))
78
79 (invoke "./Configure" "linux")
80 #t))
81 (add-after 'configure 'patch-timestamps
82 (lambda _
83 (substitute* "Makefile"
84 (("`date`") "`date --date=@1`"))
85 #t))
86 (add-before 'check 'disable-failing-tests
87 (lambda _
88 ;; In libc 2.28, the 'major' and 'minor' macros are provided by
89 ;; <sys/sysmacros.h> only so include it.
90 (substitute* "tests/LTlib.c"
91 (("#ifndef lint")
92 "#include <sys/sysmacros.h>\n\n#ifndef lint"))
93
94 (substitute* "tests/Makefile"
95 ;; Fails with ‘ERROR!!! client gethostbyaddr() failure’.
96 (("(STDTST=.*) LTsock" _ prefix) prefix)
97 ;; Fails without access to a remote NFS server.
98 (("(OPTTST=.*) LTnfs" _ prefix) prefix))
99 #t))
100 (replace 'check
101 (lambda _
102 (with-directory-excursion "tests"
103 ;; Tests refuse to run on ‘unvalidated’ platforms.
104 (make-file-writable "TestDB")
105 (invoke "./Add2TestDB")
106
107 ;; The ‘standard’ tests suggest running ‘optional’ ones as well.
108 (invoke "make" "standard" "optional")
109 #t)))
110 (replace 'install
111 (lambda* (#:key outputs #:allow-other-keys)
112 (let ((out (assoc-ref outputs "out")))
113 (install-file "lsof" (string-append out "/bin"))
114 (install-file "lsof.8" (string-append out "/share/man/man8")))
115 #t)))))
116 (synopsis "Display information about open files")
117 (description
118 "Lsof stands for LiSt Open Files, and it does just that.
119 It lists information about files that are open by the processes running
120 on the system.")
121 (license (license:fsf-free
122 "file://00FAQ"
123 "License inspired by zlib, see point 1.9 of 00FAQ in the distribution."))
124 (home-page "http://people.freebsd.org/~abe/")))