sys-process/procps: Uprev to 3.3.17-r1

Bring in a new version from upstream with various fixes. Only changes vs.
upstream is the usual KEYWORDS=* adjustment.

Cherry-pick of https://chromium.git.corp.google.com/chromiumos/overlays/portage-stable/+/67eb9700527d76682268b13e4314ac78a2ef376a

BUG=b/240345414
TEST=Builds and passes tests.
RELEASE_NOTE=none

Change-Id: I5584461bc332cf9fdbe12e2316f60999ac528c40
Reviewed-on: https://cos-review.googlesource.com/c/third_party/overlays/portage-stable/+/37307
Tested-by: Cusky Presubmit Bot <presubmit@cos-infra-prod.iam.gserviceaccount.com>
Reviewed-by: Robert Kolchmeyer <rkolchmeyer@google.com>
diff --git a/sys-process/procps/Manifest b/sys-process/procps/Manifest
index 44d632d..f9a2cf0 100644
--- a/sys-process/procps/Manifest
+++ b/sys-process/procps/Manifest
@@ -1 +1 @@
-DIST procps-ng-3.3.15.tar.xz 904416 SHA256 10bd744ffcb3de2d591d2f6acf1a54a7ba070fdcc432a855931a5057149f0465 SHA512 bc83ccc1941e7be8266588fdfbba17e2424b30163a215873ee6dee96215d66249f5d5e46fec2278d030b42bd7599861c4878360042dacec4c221ce411453747c WHIRLPOOL eefe38e341730c011f222f7f8fca1191ec78749c5740ff4fe520a2d04018f8d367ce82a975e6a08d409727966a550d17b8c450ad6a542f0bd671c125b3551ce8
+DIST procps-ng-3.3.17.tar.xz 1008428 BLAKE2B 43aa1a21d4f0725b1c02457f343cf1fc66bc1771b25c6eaf689c9775c190e90545bfac1729f027abc4d3d13de37ffac4828554b5b25e12bcf6af9540de1695f3 SHA512 59e9a5013430fd9da508c4655d58375dc32e025bb502bb28fb9a92a48e4f2838b3355e92b4648f7384b2050064d17079bf4595d889822ebb5030006bc154a1a7
diff --git a/sys-process/procps/files/procps-3.3.17-musl-fix.patch b/sys-process/procps/files/procps-3.3.17-musl-fix.patch
new file mode 100644
index 0000000..4402354
--- /dev/null
+++ b/sys-process/procps/files/procps-3.3.17-musl-fix.patch
@@ -0,0 +1,78 @@
+Temporary stopgap patch (a different solution was used upstream
+in the next release, should be in the next after 3.3.17 -- we'll need to
+add --disable-w instead).
+
+https://bugs.gentoo.org/794997
+
+From 7bfe2b7c12b33aabca71491360c433d2d3f7bbf4 Mon Sep 17 00:00:00 2001
+From: Alexander Kanavin <alex.kanavin@gmail.com>
+Date: Wed, 24 Feb 2021 21:14:31 +0000
+Subject: [PATCH 1/2] w.c: correct musl builds
+
+No need to redefine UT_ stuff to something that does not exist.
+
+UT_ is already provided in musl but via utmp.h header, so include
+it always.
+
+Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
+---
+ w.c | 9 +--------
+ 1 file changed, 1 insertion(+), 8 deletions(-)
+
+diff --git a/w.c b/w.c
+index 9d07ac9e..d10639b8 100644
+--- a/w.c
++++ b/w.c
+@@ -57,9 +57,8 @@
+ #include <unistd.h>
+ #ifdef HAVE_UTMPX_H
+ #	include <utmpx.h>
+-#else
+-#	include <utmp.h>
+ #endif
++#include <utmp.h>
+ #include <arpa/inet.h>
+ 
+ static int ignoreuser = 0;	/* for '-u' */
+@@ -72,12 +71,6 @@ typedef struct utmpx utmp_t;
+ typedef struct utmp utmp_t;
+ #endif
+ 
+-#if !defined(UT_HOSTSIZE) || defined(__UT_HOSTSIZE)
+-#	define UT_HOSTSIZE __UT_HOSTSIZE
+-#	define UT_LINESIZE __UT_LINESIZE
+-#	define UT_NAMESIZE __UT_NAMESIZE
+-#endif
+-
+ #ifdef W_SHOWFROM
+ # define FROM_STRING "on"
+ #else
+-- 
+GitLab
+
+
+From 145165aba6c659f3f0f3567a323a3e6170408ea6 Mon Sep 17 00:00:00 2001
+From: Alexander Kanavin <alex.kanavin@gmail.com>
+Date: Wed, 24 Feb 2021 21:16:14 +0000
+Subject: [PATCH 2/2] proc/escape.c: add missing include
+
+Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
+---
+ proc/escape.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/proc/escape.c b/proc/escape.c
+index 2e8fb7dd..e1f4612d 100644
+--- a/proc/escape.c
++++ b/proc/escape.c
+@@ -21,6 +21,7 @@
+ #include <sys/types.h>
+ #include <string.h>
+ #include <limits.h>
++#include <langinfo.h>
+ #include "procps.h"
+ #include "escape.h"
+ #include "readproc.h"
+-- 
+GitLab
+
diff --git a/sys-process/procps/procps-3.3.15-r1.ebuild b/sys-process/procps/procps-3.3.15-r1.ebuild
deleted file mode 100644
index 80d2772..0000000
--- a/sys-process/procps/procps-3.3.15-r1.ebuild
+++ /dev/null
@@ -1,80 +0,0 @@
-# Copyright 1999-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-EAPI=6
-
-inherit toolchain-funcs flag-o-matic
-
-DESCRIPTION="standard informational utilities and process-handling tools"
-HOMEPAGE="http://procps-ng.sourceforge.net/ https://gitlab.com/procps-ng/procps"
-SRC_URI="mirror://sourceforge/${PN}-ng/${PN}-ng-${PV}.tar.xz"
-
-LICENSE="GPL-2"
-SLOT="0/6" # libprocps.so
-KEYWORDS="*"
-IUSE="elogind +kill modern-top +ncurses nls selinux static-libs systemd test unicode"
-
-COMMON_DEPEND="
-	elogind? ( sys-auth/elogind )
-	ncurses? ( >=sys-libs/ncurses-5.7-r7:=[unicode?] )
-	selinux? ( sys-libs/libselinux )
-	systemd? ( sys-apps/systemd )
-"
-DEPEND="${COMMON_DEPEND}
-	elogind? ( virtual/pkgconfig )
-	ncurses? ( virtual/pkgconfig )
-	systemd? ( virtual/pkgconfig )
-	test? ( dev-util/dejagnu )"
-RDEPEND="
-	${COMMON_DEPEND}
-	kill? (
-		!sys-apps/coreutils[kill]
-		!sys-apps/util-linux[kill]
-	)
-	!<sys-apps/sysvinit-2.88-r6
-"
-
-S="${WORKDIR}/${PN}-ng-${PV}"
-
-PATCHES=(
-	"${FILESDIR}"/${PN}-3.3.11-sysctl-manpage.patch # 565304
-	"${FILESDIR}"/${PN}-3.3.12-proc-tests.patch # 583036
-
-	# Upstream fixes
-)
-
-src_configure() {
-	# http://www.freelists.org/post/procps/PATCH-enable-transparent-large-file-support
-	append-lfs-flags #471102
-	local myeconfargs=(
-		--docdir='$(datarootdir)'/doc/${PF}
-		$(use_with elogind)
-		$(use_enable kill)
-		$(use_enable modern-top)
-		$(use_with ncurses)
-		$(use_enable nls)
-		$(use_enable selinux libselinux)
-		$(use_enable static-libs static)
-		$(use_with systemd)
-		$(use_enable unicode watch8bit)
-	)
-	econf "${myeconfargs[@]}"
-}
-
-src_test() {
-	emake check </dev/null #461302
-}
-
-src_install() {
-	default
-	#dodoc sysctl.conf
-
-	dodir /bin
-	mv "${ED%/}"/usr/bin/ps "${ED%/}"/bin/ || die
-	if use kill; then
-		mv "${ED%/}"/usr/bin/kill "${ED}"/bin/ || die
-	fi
-
-	gen_usr_ldscript -a procps
-	find "${D}" -name '*.la' -delete || die
-}
diff --git a/sys-process/procps/procps-3.3.17-r1.ebuild b/sys-process/procps/procps-3.3.17-r1.ebuild
new file mode 100644
index 0000000..6fffa5a
--- /dev/null
+++ b/sys-process/procps/procps-3.3.17-r1.ebuild
@@ -0,0 +1,104 @@
+# Copyright 1999-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=7
+
+# See https://bugs.gentoo.org/835813 before bumping to 4.x!
+
+inherit flag-o-matic multilib-minimal toolchain-funcs usr-ldscript
+
+DESCRIPTION="Standard informational utilities and process-handling tools"
+HOMEPAGE="http://procps-ng.sourceforge.net/ https://gitlab.com/procps-ng/procps"
+SRC_URI="mirror://sourceforge/${PN}-ng/${PN}-ng-${PV}.tar.xz"
+
+LICENSE="GPL-2"
+SLOT="0/8" # libprocps.so
+KEYWORDS="*"
+IUSE="elogind +kill modern-top +ncurses nls selinux static-libs systemd test unicode"
+RESTRICT="!test? ( test )"
+
+DEPEND="
+	elogind? ( sys-auth/elogind )
+	ncurses? ( >=sys-libs/ncurses-5.7-r7:=[unicode(+)?] )
+	selinux? ( sys-libs/libselinux[${MULTILIB_USEDEP}] )
+	systemd? ( sys-apps/systemd[${MULTILIB_USEDEP}] )
+"
+BDEPEND="
+	elogind? ( virtual/pkgconfig )
+	ncurses? ( virtual/pkgconfig )
+	systemd? ( virtual/pkgconfig )
+	test? ( dev-util/dejagnu )
+"
+RDEPEND="${DEPEND}
+	kill? (
+		!sys-apps/coreutils[kill]
+		!sys-apps/util-linux[kill]
+	)
+	!<app-i18n/man-pages-l10n-4.2.0-r1
+	!<app-i18n/man-pages-de-2.12-r1
+	!<app-i18n/man-pages-pl-0.7-r1
+"
+
+PATCHES=(
+	"${FILESDIR}"/${PN}-3.3.11-sysctl-manpage.patch # 565304
+	"${FILESDIR}"/${PN}-3.3.12-proc-tests.patch # 583036
+)
+
+src_prepare() {
+	default
+
+	# Please drop this after 3.3.17 and instead use --disable-w on musl.
+	# bug #794997
+	use elibc_musl && eapply "${FILESDIR}"/${PN}-3.3.17-musl-fix.patch
+}
+
+multilib_src_configure() {
+	if tc-is-cross-compiler ; then
+		# This isn't ideal but upstream don't provide a placement
+		# when malloc is missing anyway, leading to errors like:
+		# pslog.c:(.text.startup+0x108): undefined reference to `rpl_malloc'
+		# See https://sourceforge.net/p/psmisc/bugs/71/
+		# (and https://lists.gnu.org/archive/html/autoconf/2011-04/msg00019.html)
+		export ac_cv_func_malloc_0_nonnull=yes \
+			ac_cv_func_realloc_0_nonnull=yes
+	fi
+
+	# http://www.freelists.org/post/procps/PATCH-enable-transparent-large-file-support
+	append-lfs-flags #471102
+	local myeconfargs=(
+		$(multilib_native_use_with elogind) # No elogind multilib support
+		$(multilib_native_use_enable kill)
+		$(multilib_native_use_enable modern-top)
+		$(multilib_native_use_with ncurses)
+		$(use_enable nls)
+		$(use_enable selinux libselinux)
+		$(use_enable static-libs static)
+		$(use_with systemd)
+		$(use_enable unicode watch8bit)
+	)
+	ECONF_SOURCE="${S}" econf "${myeconfargs[@]}"
+}
+
+multilib_src_test() {
+	emake check </dev/null #461302
+}
+
+multilib_src_install() {
+	default
+	dodoc "${S}"/sysctl.conf
+
+	if multilib_is_native_abi ; then
+		dodir /bin
+		mv "${ED}"/usr/bin/ps "${ED}"/bin/ || die
+		if use kill ; then
+			mv "${ED}"/usr/bin/kill "${ED}"/bin/ || die
+		fi
+
+		gen_usr_ldscript -a procps
+	fi
+}
+
+multilib_src_install_all() {
+	einstalldocs
+	find "${ED}" -type f -name '*.la' -delete || die
+}