1{ stdenv, lib, fetchurl, ncurses, perl, help2man
2, apparmorRulesFromClosure
3}:
4
5stdenv.mkDerivation rec {
6 pname = "inetutils";
7 version = "2.2";
8
9 src = fetchurl {
10 url = "mirror://gnu/${pname}/${pname}-${version}.tar.xz";
11 sha256 = "sha256-1Uf2kXLfc6/vaRoPeIYoD9eBrOoo3vT/S0shIIaonYA";
12 };
13
14 outputs = ["out" "apparmor"];
15
16 patches = [
17 # https://git.congatec.com/yocto/meta-openembedded/commit/3402bfac6b595c622e4590a8ff5eaaa854e2a2a3
18 ./inetutils-1_9-PATH_PROCNET_DEV.patch
19 ];
20
21 nativeBuildInputs = [ help2man perl /* for `whois' */ ];
22 buildInputs = [ ncurses /* for `talk' */ ];
23
24 # Don't use help2man if cross-compiling
25 # https://lists.gnu.org/archive/html/bug-sed/2017-01/msg00001.html
26 # https://git.congatec.com/yocto/meta-openembedded/blob/3402bfac6b595c622e4590a8ff5eaaa854e2a2a3/meta-networking/recipes-connectivity/inetutils/inetutils_1.9.1.bb#L44
27 preConfigure = let
28 isCross = stdenv.hostPlatform != stdenv.buildPlatform;
29 in lib.optionalString isCross ''
30 export HELP2MAN=true
31 '';
32
33 configureFlags = [ "--with-ncurses-include-dir=${ncurses.dev}/include" ]
34 ++ lib.optionals stdenv.hostPlatform.isMusl [ # Musl doesn't define rcmd
35 "--disable-rcp"
36 "--disable-rsh"
37 "--disable-rlogin"
38 "--disable-rexec"
39 ] ++ lib.optional stdenv.isDarwin "--disable-servers";
40
41 # Test fails with "UNIX socket name too long", probably because our
42 # $TMPDIR is too long.
43 doCheck = false;
44
45 installFlags = [ "SUIDMODE=" ];
46
47 postInstall = ''
48 mkdir $apparmor
49 cat >$apparmor/bin.ping <<EOF
50 $out/bin/ping {
51 include <abstractions/base>
52 include <abstractions/consoles>
53 include <abstractions/nameservice>
54 include "${apparmorRulesFromClosure { name = "ping"; } [stdenv.cc.libc]}"
55 include <local/bin.ping>
56 capability net_raw,
57 network inet raw,
58 network inet6 raw,
59 mr $out/bin/ping,
60 }
61 EOF
62 '';
63
64 meta = with lib; {
65 description = "Collection of common network programs";
66
67 longDescription =
68 '' The GNU network utilities suite provides the
69 following tools: ftp(d), hostname, ifconfig, inetd, logger, ping, rcp,
70 rexec(d), rlogin(d), rsh(d), syslogd, talk(d), telnet(d), tftp(d),
71 traceroute, uucpd, and whois.
72 '';
73
74 homepage = "https://www.gnu.org/software/inetutils/";
75 license = licenses.gpl3Plus;
76
77 maintainers = with maintainers; [ matthewbauer ];
78 platforms = platforms.unix;
79 };
80}