iputils: upgraded package to upstream

Upgraded net-misc/iputils to version 20240117.

BUG=b:309390661
TEST=tast run $DUT network.VPNRouting.ikev2*

Change-Id: Ife8e88a6218c338b3f9d25be9d162c13c3fb10c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/overlays/portage-stable/+/5428313
Reviewed-by: Hugo Benichi <hugobenichi@google.com>
Commit-Queue: Jie Jiang <jiejiang@chromium.org>
Tested-by: Jie Jiang <jiejiang@chromium.org>
diff --git a/net-misc/iputils/Manifest b/net-misc/iputils/Manifest
index 1957967..2863ec7 100644
--- a/net-misc/iputils/Manifest
+++ b/net-misc/iputils/Manifest
@@ -1,2 +1,4 @@
-DIST iputils-20171016_pre.tar.gz 195254 SHA256 2f1870633baeb999fe214a8958353f291caf3cedac242862930d41c760bf1748 SHA512 570896fc58d945e08032134701ab6ea02bbf6fff420437bc5f89687cdcce6f3c1c64418a4c5ff54ca3cdc582bae2c95e196b2c8368eba2b163ebf88490aabf99 WHIRLPOOL 76600ed31bfa10535c7aa6e33ab5019db8814c55ca9941a3857300bccb89650cdc8edea9d654103151bc5f54643f5618c9261d7ba5fa5c14e8f6293bca340db7
-DIST iputils-manpages-20171016_pre.tar.xz 29764 SHA256 f23e5bee1d59c5b8cabc47faab5d175de1c5b663379108ec70e75d2a74888883 SHA512 31b4b0b4e46d7c98530577392c636e4397917cbe415762145a119e68e3223bc85b9d5afcfe61ae01584a35f6a1a772adffc52deeedc722c474179fa1d208d8d9 WHIRLPOOL a80cfa73dd326dedff76de06b3939f631ff017e3bd5cbeb0f988eb27ad997c62c2be1dc645f3e415b7081942a0cbf9139729c998c77b47c989ccd61ad272cf6e
+DIST iputils-20211215.tar.gz 524567 BLAKE2B b88ff84be1d4d6a741f8f3514739ceff45ea40c475b5d4c2df8571fe84d4f1af9bc3fdce29e9ff393417671c75204261c8d64dde00473caa314b0aeb1fbf74ce SHA512 191062e51f7c8e8b38e3e4a96845adb77cd69f487d548c7cc578fad544443b4bc0dbe965d8f8e6fbda0a2f5b2fe2829789c05f873190c53d773245959298f6e9
+DIST iputils-20221126.tar.gz 511944 BLAKE2B 97bdc49810ce9e517211323e8e8ffd2f2be505704d67533db0e8f296701048b82c61b39062aab4a8fa148b29175636a657c2dcdd65e3a16b1572d2f392b8ecf0 SHA512 7fdfd76e6f2977039bc0930a1a5451f17319bf17beefc429751d99ffe143a83344d5b4cdbf008627bd70caafeadaf906a8b7c00393fa819e50d6c02b512c367f
+DIST iputils-20240117.tar.xz 445684 BLAKE2B 635943e12010aef8c1291b407bfbe284e0179391fca76197b77037ae1ffc219fa1d8e36abcea5fb7fff10d55ab40eed7c081e5d92b29f0916a4b4dd806945491 SHA512 c45822c5641f194dc07cba919c13a4b7a79d050bb53957a894ebb6ccc1f71bac1f26489e13d18ef1ce235982f5fa1824e677f95037a0f5cce6bcb94be4c2e2de
+DIST iputils-manpages-20211215.tar.xz 17148 BLAKE2B 63a956805b01f57b070b6b4ceb32f6ddf4313c74203cde821fc2f6f16ab8de14861da31163adf496db555f1961592d4fbc2ba7a977ccb18773af3bdb8d3795c0 SHA512 eb8c8508221b06fc13bf196b01b11f3ec87cd77e25d89c088776e39d249e10a3915ebb39942805adee179b352543063ce3dac158d68783c68c23de550ec14eee
diff --git a/net-misc/iputils/files/iputils-20150815-nonroot-floodping.patch b/net-misc/iputils/files/iputils-20150815-nonroot-floodping.patch
deleted file mode 100644
index 50e108b..0000000
--- a/net-misc/iputils/files/iputils-20150815-nonroot-floodping.patch
+++ /dev/null
@@ -1,11 +0,0 @@
---- iputils-s20150815/ping.h
-+++ iputils-s20150815/ping.h
-@@ -61,7 +61,7 @@
- 
- #define	MAXWAIT		10		/* max seconds to wait for response */
- #define MININTERVAL	10		/* Minimal interpacket gap */
--#define MINUSERINTERVAL	200		/* Minimal allowed interval for non-root */
-+#define MINUSERINTERVAL	0		/* Minimal allowed interval for non-root */
- 
- #define SCHINT(a)	(((a) <= MININTERVAL) ? MININTERVAL : (a))
- 
diff --git a/net-misc/iputils/files/iputils-99999999-musl.patch b/net-misc/iputils/files/iputils-99999999-musl.patch
deleted file mode 100644
index 167e7fa..0000000
--- a/net-misc/iputils/files/iputils-99999999-musl.patch
+++ /dev/null
@@ -1,92 +0,0 @@
-From 58ed671d1003caf32f3c35260531e8e1cd7efb80 Mon Sep 17 00:00:00 2001
-From: Aric Belsito <lluixhi@gmail.com>
-Date: Sun, 29 Oct 2017 23:17:03 +0100
-Subject: [PATCH] Fix build on MUSL
-
-Add missing AI_IDN and NI_IDN declarations.
-
-Bug: https://bugs.gentoo.org/503914
----
- arping.c      |  7 +++++++
- ping.h        | 11 +++++++++++
- tracepath.c   |  8 ++++++++
- traceroute6.c |  4 ++++
- 4 files changed, 30 insertions(+)
-
-diff --git a/arping.c b/arping.c
-index 0ac18cd..5d2145e 100644
---- a/arping.c
-+++ b/arping.c
-@@ -45,6 +45,13 @@
- #ifdef USE_IDN
- #include <idna.h>
- #include <locale.h>
-+
-+#ifndef AI_IDN
-+#define AI_IDN 0x0040
-+#endif
-+#ifndef AI_CANONIDN
-+#define AI_CANONIDN 0x0080
-+#endif
- #endif
- 
- #include "SNAPSHOT.h"
-diff --git a/ping.h b/ping.h
-index c5f0321..0391de0 100644
---- a/ping.h
-+++ b/ping.h
-@@ -38,6 +38,17 @@
- #include <locale.h>
- #include <idna.h>
- #include <stringprep.h>
-+
-+#ifndef AI_IDN
-+#define AI_IDN 0x0040
-+#endif
-+#ifndef AI_CANONIDN
-+#define AI_CANONIDN 0x0080
-+#endif
-+#ifndef NI_IDN
-+#define NI_IDN 32
-+#endif
-+
- #define getaddrinfo_flags (AI_CANONNAME | AI_IDN | AI_CANONIDN)
- #define getnameinfo_flags NI_IDN
- #else
-diff --git a/tracepath.c b/tracepath.c
-index b0eb911..c50e3ec 100644
---- a/tracepath.c
-+++ b/tracepath.c
-@@ -30,6 +30,14 @@
- #ifdef USE_IDN
- #include <idna.h>
- #include <locale.h>
-+
-+#ifndef AI_IDN
-+#define AI_IDN 0x0040
-+#endif
-+#ifndef NI_IDN
-+#define NI_IDN 32
-+#endif
-+
- #define getnameinfo_flags	NI_IDN
- #else
- #define getnameinfo_flags	0
-diff --git a/traceroute6.c b/traceroute6.c
-index 7807956..c6d868a 100644
---- a/traceroute6.c
-+++ b/traceroute6.c
-@@ -247,6 +247,10 @@
- #include <idna.h>
- #include <locale.h>
- 
-+#ifndef NI_IDN
-+#define NI_IDN 32
-+#endif
-+
- #define getnameinfo_flags	NI_IDN
- #else
- #define getnameinfo_flags	0
--- 
-2.14.3
-
diff --git a/net-misc/iputils/files/iputils-99999999-tracepath46.patch b/net-misc/iputils/files/iputils-99999999-tracepath46.patch
deleted file mode 100644
index 20d017b..0000000
--- a/net-misc/iputils/files/iputils-99999999-tracepath46.patch
+++ /dev/null
@@ -1,30 +0,0 @@
-From 2c4d0838dda90515d4971881d86e8b969baebe01 Mon Sep 17 00:00:00 2001
-From: Thomas Deutschmann <whissi@gentoo.org>
-Date: Thu, 19 Oct 2017 17:38:20 +0200
-Subject: [PATCH] tracepath: Support calling `tracepath` as `tracepath4` or
- `tracepath6`
-
----
- tracepath.c | 6 ++++++
- 1 file changed, 6 insertions(+)
-
-diff --git a/tracepath.c b/tracepath.c
-index b0eb911..d2a6edf 100644
---- a/tracepath.c
-+++ b/tracepath.c
-@@ -394,6 +394,12 @@ int main(int argc, char **argv)
- 	setlocale(LC_ALL, "");
- #endif
- 
-+	/* Support being called using `tracepath4` or `tracepath6` symlinks */
-+	if (argv[0][strlen(argv[0])-1] == '4')
-+		hints.ai_family = AF_INET;
-+	else if (argv[0][strlen(argv[0])-1] == '6')
-+		hints.ai_family = AF_INET6;
-+
- 	while ((ch = getopt(argc, argv, "46nbh?l:m:p:")) != EOF) {
- 		switch(ch) {
- 		case '4':
--- 
-2.14.3
-
diff --git a/net-misc/iputils/files/rarpd.conf.d b/net-misc/iputils/files/rarpd.conf.d
deleted file mode 100644
index ef7fc48..0000000
--- a/net-misc/iputils/files/rarpd.conf.d
+++ /dev/null
@@ -1,8 +0,0 @@
-# Config file for /etc/init.d/rarpd
-
-# You probably want to select the interface for this to listen on.
-# By default it uses loopback which most likely won't help.
-RARPD_IFACE="lo"
-
-# See the rarpd(8) manpage for more info.
-RARPD_OPTS="-b /tftpboot"
diff --git a/net-misc/iputils/files/rarpd.init.d b/net-misc/iputils/files/rarpd.init.d
deleted file mode 100644
index 27081fc..0000000
--- a/net-misc/iputils/files/rarpd.init.d
+++ /dev/null
@@ -1,19 +0,0 @@
-#!/sbin/openrc-run
-# Copyright 1999-2015 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-pidfile="/var/run/rarpd.pid"
-command="/usr/sbin/rarpd"
-# The -d option keeps it from forking.  This way s-s-d can do the fork and
-# set up the pidfile with the right value below.
-command_args="-d ${RARPD_OPTS} ${RARPD_IFACE}"
-start_stop_daemon_args="--background --make-pidfile"
-
-start_pre() {
-	if [ ! -f /etc/ethers ] ; then
-		eerror "Please create /etc/ethers with the following content:"
-		eerror "[MAC address] [name or IP]"
-		return 1
-	fi
-	return 0
-}
diff --git a/net-misc/iputils/iputils-20171016_pre.ebuild b/net-misc/iputils/iputils-20171016_pre.ebuild
deleted file mode 100644
index d226370..0000000
--- a/net-misc/iputils/iputils-20171016_pre.ebuild
+++ /dev/null
@@ -1,178 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-# For released versions, we precompile the man/html pages and store
-# them in a tarball on our mirrors.  This avoids ugly issues while
-# building stages, and reduces depedencies.
-# To regenerate man/html pages emerge iputils-99999999[doc] with
-# EGIT_COMMIT set to release tag and tar ${S}/doc folder.
-
-EAPI="6"
-
-inherit flag-o-matic toolchain-funcs fcaps
-
-MY_COMMIT="67e7d0daf1f231cc708217e6aec2f8d5ce7aeacf"
-
-PATCHES=(
-	"${FILESDIR}"/${PN}-99999999-tracepath46.patch
-	"${FILESDIR}"/${PN}-99999999-musl.patch
-)
-
-if [[ ${PV} == "99999999" ]] ; then
-	EGIT_REPO_URI="https://github.com/iputils/iputils.git"
-	inherit git-r3
-else
-	SRC_URI="https://github.com/iputils/iputils/archive/${MY_COMMIT}.tar.gz -> ${P}.tar.gz
-		https://dev.gentoo.org/~whissi/dist/iputils/${PN}-manpages-${PV}.tar.xz"
-	KEYWORDS="*"
-fi
-
-DESCRIPTION="Network monitoring tools including ping and ping6"
-HOMEPAGE="https://wiki.linuxfoundation.org/networking/iputils"
-
-LICENSE="BSD GPL-2+ rdisc"
-SLOT="0"
-IUSE="+arping caps clockdiff doc gcrypt idn ipv6 libressl nettle +openssl rarpd rdisc SECURITY_HAZARD ssl static tftpd tracepath traceroute"
-
-LIB_DEPEND="caps? ( sys-libs/libcap[static-libs(+)] )
-	idn? ( net-dns/libidn:=[static-libs(+)] )
-	ipv6? ( ssl? (
-		gcrypt? ( dev-libs/libgcrypt:0=[static-libs(+)] )
-		nettle? ( dev-libs/nettle[static-libs(+)] )
-		openssl? (
-			!libressl? ( dev-libs/openssl:0=[static-libs(+)] )
-			libressl? ( dev-libs/libressl:0=[static-libs(+)] )
-		)
-	) )"
-RDEPEND="arping? ( !net-misc/arping )
-	rarpd? ( !net-misc/rarpd )
-	traceroute? ( !net-analyzer/traceroute )
-	!static? ( ${LIB_DEPEND//\[static-libs(+)]} )"
-DEPEND="${RDEPEND}
-	static? ( ${LIB_DEPEND} )
-	virtual/os-headers
-"
-if [[ ${PV} == "99999999" ]] ; then
-	DEPEND+="app-text/docbook-xml-dtd:4.2
-		app-text/docbook-xml-dtd:4.5
-		app-text/docbook-xsl-stylesheets
-		dev-libs/libxslt:0
-	"
-fi
-
-REQUIRED_USE="ipv6? ( ssl? ( ^^ ( gcrypt nettle openssl ) ) )"
-
-[ "${PV}" = "99999999" ] || S="${WORKDIR}/${PN}-s${PV}"
-
-S="${WORKDIR}/${PN}-${MY_COMMIT}"
-
-src_prepare() {
-	use SECURITY_HAZARD && PATCHES+=( "${FILESDIR}"/${PN}-20150815-nonroot-floodping.patch )
-
-	default
-}
-
-src_configure() {
-	use static && append-ldflags -static
-
-	TARGETS=(
-		ping
-		$(for v in arping clockdiff rarpd rdisc tftpd tracepath ; do usev ${v} ; done)
-	)
-	if use ipv6 ; then
-		TARGETS+=(
-			$(usex traceroute 'traceroute6' '')
-		)
-	fi
-
-	myconf=(
-		USE_CRYPTO=no
-		USE_GCRYPT=no
-		USE_NETTLE=no
-	)
-
-	if use ipv6 && use ssl ; then
-		myconf=(
-			USE_CRYPTO=$(usex openssl)
-			USE_GCRYPT=$(usex gcrypt)
-			USE_NETTLE=$(usex nettle)
-		)
-	fi
-}
-
-src_compile() {
-	tc-export CC
-	emake \
-		USE_CAP=$(usex caps) \
-		USE_IDN=$(usex idn) \
-		IPV4_DEFAULT=$(usex ipv6 'no' 'yes') \
-		TARGETS="${TARGETS[*]}" \
-		${myconf[@]}
-
-	if [[ ${PV} == "99999999" ]] ; then
-		emake man
-
-		use doc && emake html
-	fi
-}
-
-src_install() {
-	into /
-	dobin ping
-	dosym ping /bin/ping4
-	if use ipv6 ; then
-		dosym ping /bin/ping6
-		dosym ping.8 /usr/share/man/man8/ping6.8
-	fi
-	doman doc/ping.8
-
-	if use arping ; then
-		dobin arping
-		doman doc/arping.8
-	fi
-
-	into /usr
-
-	if use tracepath ; then
-		dosbin tracepath
-		doman doc/tracepath.8
-		dosym tracepath /usr/sbin/tracepath4
-	fi
-
-	local u
-	for u in clockdiff rarpd rdisc tftpd ; do
-		if use ${u} ; then
-			case ${u} in
-			clockdiff) dobin ${u};;
-			*) dosbin ${u};;
-			esac
-			doman doc/${u}.8
-		fi
-	done
-
-	if use tracepath && use ipv6 ; then
-		dosym tracepath /usr/sbin/tracepath6
-		dosym tracepath.8 /usr/share/man/man8/tracepath6.8
-	fi
-
-	if use traceroute && use ipv6 ; then
-		dosbin traceroute6
-		doman doc/traceroute6.8
-	fi
-
-	if use rarpd ; then
-		newinitd "${FILESDIR}"/rarpd.init.d rarpd
-		newconfd "${FILESDIR}"/rarpd.conf.d rarpd
-	fi
-
-	dodoc INSTALL.md
-
-	use doc && dodoc doc/*.html
-}
-
-pkg_postinst() {
-	fcaps cap_net_raw \
-		bin/ping \
-		$(usex arping 'bin/arping' '') \
-		$(usex clockdiff 'usr/bin/clockdiff' '')
-}
diff --git a/net-misc/iputils/iputils-20240117.ebuild b/net-misc/iputils/iputils-20240117.ebuild
new file mode 100644
index 0000000..9077891
--- /dev/null
+++ b/net-misc/iputils/iputils-20240117.ebuild
@@ -0,0 +1,131 @@
+# Copyright 1999-2024 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+PLOCALES="de fr ja pt_BR tr uk zh_CN"
+
+inherit fcaps meson plocale systemd toolchain-funcs
+
+if [[ ${PV} == *9999 ]] ; then
+	EGIT_REPO_URI="https://github.com/iputils/iputils.git"
+	inherit git-r3
+else
+	SRC_URI="https://github.com/iputils/iputils/releases/download/${PV}/${P}.tar.xz"
+	KEYWORDS="*"
+fi
+
+DESCRIPTION="Network monitoring tools including ping and ping6"
+HOMEPAGE="https://wiki.linuxfoundation.org/networking/iputils"
+
+# We install ping unconditionally so BSD is listed by itself
+# See LICENSE on each release, it summaries per-component
+LICENSE="
+	BSD
+	arping? ( GPL-2+ )
+	clockdiff? ( BSD )
+	tracepath? ( GPL-2+ )
+"
+SLOT="0"
+IUSE="+arping caps clockdiff doc idn nls test tracepath"
+RESTRICT="!test? ( test )"
+
+RDEPEND="
+	caps? ( sys-libs/libcap )
+	idn? ( net-dns/libidn2:= )
+	nls? ( virtual/libintl )
+"
+DEPEND="
+	${RDEPEND}
+	virtual/os-headers
+"
+BDEPEND="
+	app-text/docbook-xml-dtd:4.2
+	app-text/docbook-xml-dtd:4.5
+	app-text/docbook-xsl-ns-stylesheets
+	app-text/docbook-xsl-stylesheets
+	dev-libs/libxslt
+	virtual/pkgconfig
+	test? ( sys-apps/iproute2 )
+	nls? ( sys-devel/gettext )
+"
+
+src_prepare() {
+	default
+
+	plocale_get_locales > po/LINGUAS || die
+}
+
+src_configure() {
+	local emesonargs=(
+		-DUSE_CAP=$(usex caps true false)
+		-DUSE_IDN=$(usex idn true false)
+		-DBUILD_ARPING=$(usex arping true false)
+		-DBUILD_CLOCKDIFF=$(usex clockdiff true false)
+		-DBUILD_PING=true
+		-DBUILD_TRACEPATH=$(usex tracepath true false)
+		-DNO_SETCAP_OR_SUID=true
+		-Dsystemdunitdir=$(systemd_get_systemunitdir)
+		-DUSE_GETTEXT=$(usex nls true false)
+		$(meson_use !test SKIP_TESTS)
+		-DBUILD_HTML_MANS=$(usex doc true false)
+		-DBUILD_MANS=true
+	)
+
+	meson_src_configure
+}
+
+src_compile() {
+	tc-export CC
+
+	meson_src_compile
+}
+
+src_test() {
+	if [[ ${EUID} != 0 ]] ; then
+		einfo "Tests require root privileges. Skipping ..."
+		return
+	fi
+
+	meson_src_test
+}
+
+src_install() {
+	meson_src_install
+
+	FILECAPS=( cap_net_raw usr/bin/ping )
+	use arping && FILECAPS+=( usr/bin/arping )
+	use clockdiff && FILECAPS+=( usr/bin/clockdiff )
+
+	dosym ping /usr/bin/ping4
+	dosym ping /usr/bin/ping6
+
+	if use tracepath ; then
+		dosym tracepath /usr/bin/tracepath4
+		dosym tracepath /usr/bin/tracepath6
+		dosym tracepath.8 /usr/share/man/man8/tracepath4.8
+		dosym tracepath.8 /usr/share/man/man8/tracepath6.8
+	fi
+
+	if use doc ; then
+		mv "${ED}"/usr/share/${PN} "${ED}"/usr/share/doc/${PF}/html || die
+	fi
+}
+
+pkg_preinst() {
+	local version_with_tftpd="<${CATEGORY}/${PN}-20211215"
+	if has_version "${version_with_tftpd}[traceroute6]" || has_version "${version_with_tftpd}[tftpd]" ; then
+		HAD_TFTPD_VERSION=1
+	fi
+}
+
+pkg_postinst() {
+	fcaps_pkg_postinst
+
+	if [[ ${HAD_TFTPD_VERSION} -eq 1 ]] ; then
+		ewarn "This upstream version (>= 20211215) drops two tools:"
+		ewarn "1. tftpd (alternatives: net-ftp/tftp-hpa, net-dns/dnsmasq)"
+		ewarn "2. traceroute6 (alternatives: net-analyzer/mtr, net-analyzer/traceroute)"
+		ewarn "Please install one of the listed alternatives if needed!"
+	fi
+}