From 02429c1f7d500aceec0d1ff4424556ac53079e4e Mon Sep 17 00:00:00 2001
From: "Frank Ch. Eigler" <fche@redhat.com>
Date: Fri, 19 Nov 2021 15:19:38 -0500
Subject: [PATCH] Resolves: rhbz2025054

---
 .gitignore     |  1 +
 sources        |  2 +-
 systemtap.spec | 83 ++++++++++++++++++++++++++++++++------------------
 3 files changed, 56 insertions(+), 30 deletions(-)

diff --git a/.gitignore b/.gitignore
index 30043b7..be2f65f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -59,3 +59,4 @@
 /systemtap-4.5-0.202101291559git9e1a0f5703ad.tar.gz
 /systemtap-4.5-0.202102101544git8d5e0abc542c.tar.gz
 /systemtap-4.5.tar.gz
+/systemtap-4.6.tar.gz
diff --git a/sources b/sources
index 9e90fe5..b4b4a67 100644
--- a/sources
+++ b/sources
@@ -1 +1 @@
-SHA512 (systemtap-4.5.tar.gz) = 8136779a9f5cb0fbaae565eab1ab6fa307f1024dfc2c6c3845acfadff0eecc684ba89aa5d442c7b90c2c73edaab41ca07bae2bad8361f80fe8e9928b40466cd3
+SHA512 (systemtap-4.6.tar.gz) = 835b45597e9de0ea17857b47d542c87d155cb5c772f8595f41845a25ff06b862cb9c4b635292c3a6c66cb5255a07eee3af7cb7861110a4a05f545a4b35f11402
diff --git a/systemtap.spec b/systemtap.spec
index 7147aef..a60756d 100644
--- a/systemtap.spec
+++ b/systemtap.spec
@@ -4,14 +4,13 @@
 %{!?with_htmldocs: %global with_htmldocs 0}
 %{!?with_monitor: %global with_monitor 1}
 # crash is not available
-%ifarch ppc ppc64 %{sparc} %{mips}
+%ifarch ppc ppc64 %{sparc} %{mips} %{riscv}
 %{!?with_crash: %global with_crash 0}
 %else
 %{!?with_crash: %global with_crash 1}
 %endif
 %{!?with_rpm: %global with_rpm 1}
 %{!?elfutils_version: %global elfutils_version 0.179}
-%{!?pie_supported: %global pie_supported 1}
 %{!?with_boost: %global with_boost 0}
 %ifarch %{ix86} x86_64 ppc ppc64 ppc64le aarch64
 %{!?with_dyninst: %global with_dyninst 0%{?fedora} >= 18 || 0%{?rhel} >= 7}
@@ -39,6 +38,7 @@
 %{!?with_python3_probes: %global with_python3_probes (0%{?fedora} >= 23 || 0%{?rhel} > 7)}
 %{!?with_httpd: %global with_httpd 0}
 %{!?with_specific_python: %global with_specific_python 0%{?fedora} >= 31}
+%{!?with_sysusers: %global with_sysusers 0%{?fedora} >= 32 || 0%{?rhel} >= 9}
 
 # Virt is supported on these arches, even on el7, but it's not in core EL7
 %if 0%{?rhel} <= 7
@@ -89,8 +89,8 @@
 %define __brp_mangle_shebangs_exclude_from .stp$
 
 Name: systemtap
-Version: 4.5
-Release: 7%{?release_override}%{?dist}
+Version: 4.6
+Release: 1%{?release_override}%{?dist}
 # for version, see also configure.ac
 
 
@@ -126,12 +126,6 @@ License: GPLv2+
 URL: http://sourceware.org/systemtap/
 Source: ftp://sourceware.org/pub/systemtap/releases/systemtap-%{version}.tar.gz
 
-Patch1: rhbz1972803.patch
-Patch2: rhbz1972828.patch
-Patch3: rhbz1972805.patch
-Patch4: rhbz1982908.patch
-Patch5: rhbz1985124.patch
-
 # Build*
 BuildRequires: make
 BuildRequires: gcc-c++
@@ -180,6 +174,7 @@ BuildRequires: xmlto /usr/share/xmlto/format/fo/pdf
 %endif
 %endif
 %if %{with_emacsvim}
+# for _emacs_sitelispdir macros etc.
 BuildRequires: emacs
 %endif
 %if %{with_java}
@@ -202,6 +197,9 @@ BuildRequires: python2-setuptools
 BuildRequires: python-setuptools
 %endif
 %endif
+%if %{with_python3}
+BuildRequires: python3
+%endif
 %if %{with_python3_probes}
 BuildRequires: python3-devel
 BuildRequires: python3-setuptools
@@ -214,6 +212,10 @@ BuildRequires: /usr/bin/pathfix.py
 BuildRequires: libmicrohttpd-devel
 BuildRequires: libuuid-devel
 %endif
+%if %{with_sysusers}
+BuildRequires:  systemd-rpm-macros
+%endif
+
 
 # Install requirements
 Requires: systemtap-client = %{version}-%{release}
@@ -490,7 +492,7 @@ This package includes support files needed to run systemtap scripts
 that probe python 3 processes.
 %endif
 
-%if %{with_python3}
+%if %{with_python3_probes}
 %package exporter
 Summary: Systemtap-prometheus interoperation mechanism
 License: GPLv2+
@@ -508,7 +510,8 @@ to remote requesters on demand.
 Summary: Systemtap Cross-VM Instrumentation - host
 License: GPLv2+
 URL: http://sourceware.org/systemtap/
-Requires: libvirt >= 1.0.2
+# only require libvirt-libs really
+#Requires: libvirt >= 1.0.2
 Requires: libxml2
 
 %description runtime-virthost
@@ -542,11 +545,6 @@ systemtap-runtime-virthost machine to execute systemtap scripts.
 
 %prep
 %setup -q
-%patch1 -p1
-%patch2 -p1
-%patch3 -p1
-%patch4 -p1
-%patch5 -p1
 
 %build
 
@@ -595,14 +593,6 @@ systemtap-runtime-virthost machine to execute systemtap scripts.
 %global docs_config --enable-docs=prebuilt
 %endif
 
-# Enable pie as configure defaults to disabling it
-%if %{pie_supported}
-%global pie_config --enable-pie
-%else
-%global pie_config --disable-pie
-%endif
-
-
 %if %{with_java}
 %global java_config --with-java=%{_jvmdir}/java
 %else
@@ -652,8 +642,8 @@ systemtap-runtime-virthost machine to execute systemtap scripts.
 # We don't ship compileworthy python code, just oddball samples
 %global py_auto_byte_compile 0
 
-%configure %{dyninst_config} %{sqlite_config} %{crash_config} %{docs_config} %{pie_config} %{rpm_config} %{java_config} %{virt_config} %{dracut_config} %{python3_config} %{python2_probes_config} %{python3_probes_config} %{httpd_config} %{bpf_config} %{debuginfod_config} --disable-silent-rules --with-extra-version="rpm %{version}-%{release}"
-make %{?_smp_mflags}
+%configure %{dyninst_config} %{sqlite_config} %{crash_config} %{docs_config} %{rpm_config} %{java_config} %{virt_config} %{dracut_config} %{python3_config} %{python2_probes_config} %{python3_probes_config} %{httpd_config} %{bpf_config} %{debuginfod_config} --disable-silent-rules --with-extra-version="rpm %{version}-%{release}"
+make %{?_smp_mflags} V=1
 
 
 %install
@@ -665,6 +655,13 @@ for dir in $(ls -1d $RPM_BUILD_ROOT%{_mandir}/{??,??_??}) ; do
     echo "%%lang($lang) $dir/man*/*" >> %{name}.lang
 done
 
+%if %{with_sysusers}
+install -p -D -m 0644 systemtap-runtime.sysusers %{buildroot}%{_sysusersdir}/systemtap-runtime.conf
+install -p -D -m 0644 systemtap-server.sysusers %{buildroot}%{_sysusersdir}/systemtap-server.conf
+install -p -D -m 0644 systemtap-testsuite.sysusers %{buildroot}%{_sysusersdir}/systemtap-testsuite.conf
+%endif
+
+
 ln -s %{_datadir}/systemtap/examples
 
 # Fix paths in the example scripts.
@@ -788,24 +785,37 @@ pathfix.py -pni "%{__python3} %{py3_shbang_opts}" %{buildroot}%{python3_sitearch
 %endif
 
 %pre runtime
+%if %{with_sysusers}
+%sysusers_create_compat $RPM_BUILD_ROOT/systemtap-runtime.sysusers
+%else
 getent group stapusr >/dev/null || groupadd -f -g 156 -r stapusr
 getent group stapsys >/dev/null || groupadd -f -g 157 -r stapsys
 getent group stapdev >/dev/null || groupadd -f -g 158 -r stapdev
+%endif
 exit 0
 
 %pre server
+%if %{with_sysusers}
+%sysusers_create_compat $RPM_BUILD_ROOT/systemtap-server.sysusers
+%else
 getent group stap-server >/dev/null || groupadd -f -g 155 -r stap-server
 getent passwd stap-server >/dev/null || \
   useradd -c "Systemtap Compile Server" -u 155 -g stap-server -d %{_localstatedir}/lib/stap-server -r -s /sbin/nologin stap-server 2>/dev/null || \
   useradd -c "Systemtap Compile Server" -g stap-server -d %{_localstatedir}/lib/stap-server -r -s /sbin/nologin stap-server
+%endif
+exit 0
 
 %pre testsuite
+%if %{with_sysusers}
+%sysusers_create_compat $RPM_BUILD_ROOT/systemtap-testsuite.sysusers
+%else
 getent passwd stapusr >/dev/null || \
     useradd -c "Systemtap 'stapusr' User" -g stapusr -r -s /sbin/nologin stapusr
 getent passwd stapsys >/dev/null || \
     useradd -c "Systemtap 'stapsys' User" -g stapsys -G stapusr -r -s /sbin/nologin stapsys
 getent passwd stapdev >/dev/null || \
     useradd -c "Systemtap 'stapdev' User" -g stapdev -G stapusr -r -s /sbin/nologin stapdev
+%endif
 exit 0
 
 %post server
@@ -962,7 +972,7 @@ if [ "$1" -ge "1" ]; then
 fi
 exit 0
 
-%if %{with_python3}
+%if %{with_python3_probes}
 %if %{with_systemd}
 %preun exporter
 if [ $1 = 0 ] ; then
@@ -1027,6 +1037,9 @@ exit 0
 %doc README README.unprivileged AUTHORS NEWS 
 %{!?_licensedir:%global license %%doc}
 %license COPYING
+%if %{with_sysusers}
+%{_sysusersdir}/systemtap-server.conf
+%endif
 
 
 %files devel -f systemtap.lang
@@ -1096,6 +1109,9 @@ exit 0
 %doc README README.security AUTHORS NEWS 
 %{!?_licensedir:%global license %%doc}
 %license COPYING
+%if %{with_sysusers}
+%{_sysusersdir}/systemtap-runtime.conf
+%endif
 
 
 %files client -f systemtap.lang
@@ -1162,6 +1178,9 @@ exit 0
 %files testsuite
 %dir %{_datadir}/systemtap
 %{_datadir}/systemtap/testsuite
+%if %{with_sysusers}
+%{_sysusersdir}/systemtap-testsuite.conf
+%endif
 
 
 %if %{with_java}
@@ -1203,7 +1222,7 @@ exit 0
 %endif
 %endif
 
-%if %{with_python3}
+%if %{with_python3_probes}
 %files exporter
 %{_sysconfdir}/stap-exporter
 %{_sysconfdir}/sysconfig/stap-exporter
@@ -1221,6 +1240,12 @@ exit 0
 
 # PRERELEASE
 %changelog
+* Fri Nov 19 2021 Frank Ch. Eigler <fche@redhat.com> - 4.6-1
+- Upstream release.
+
+* Thu Sep 09 2021 Frank Ch. Eigler <fche@redhat.com> - 4.5-8
+- rhbz1985124: Kernel 5.14 compatibility omnibus cont'd.
+
 * Thu Aug 12 2021 Frank Ch. Eigler <fche@redhat.com> - 4.5-7
 - rhbz1985124: Kernel 5.14 compatibility omnibus.