public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Sam James" <sam@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-debug/dtrace/
Date: Thu, 12 Sep 2024 00:10:06 +0000 (UTC)	[thread overview]
Message-ID: <1726099591.0b93226603134a169a41d1ae2213688167bd2b2c.sam@gentoo> (raw)

commit:     0b93226603134a169a41d1ae2213688167bd2b2c
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 12 00:06:23 2024 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Sep 12 00:06:31 2024 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=0b932266

dev-debug/dtrace: rework pkg_postinst

For first installs, we enable the service and start it.

This is unusual, but the behaviour without dtprobed running is
untested/unsupported. It's not a network service, it has no configuration,
reads a single device node, and does all parsing within a seccomp jail. It
also leads to hard-to-diagnose issues because USDT probes won't be registered
and an application might have already started up which needs to be traced.

Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-debug/dtrace/dtrace-2.0.1.1-r2.ebuild | 42 +++++++++++++++++++++++++------
 dev-debug/dtrace/dtrace-9999.ebuild       | 42 +++++++++++++++++++++++++------
 2 files changed, 70 insertions(+), 14 deletions(-)

diff --git a/dev-debug/dtrace/dtrace-2.0.1.1-r2.ebuild b/dev-debug/dtrace/dtrace-2.0.1.1-r2.ebuild
index 413cba677aed..3032bf884998 100644
--- a/dev-debug/dtrace/dtrace-2.0.1.1-r2.ebuild
+++ b/dev-debug/dtrace/dtrace-2.0.1.1-r2.ebuild
@@ -171,26 +171,54 @@ pkg_postinst() {
 	# We need a udev reload to pick up the CUSE device node rules.
 	udev_reload
 
-	# TODO: Restart it on upgrade? (it will carry across its own persistent state)
+	# TODO: One option for this is to detect when it's needed (DOF stash layout changes)
+	# and then e.g. sleep and restart for the user.
 	if [[ -n ${REPLACING_VERSIONS} ]]; then
 		# TODO: Make this more intelligent wrt comparison
 		if systemd_is_booted ; then
-			einfo "Restart the DTrace 'dtprobed' service after upgrades:"
+			einfo "Restart the DTrace 'dtprobed' service after upgrades"
+			einfo "once all dtraces are stopped with:"
 			einfo " systemctl try-restart dtprobed"
 		else
-			einfo "Restart the DTrace 'dtprobed' service with:"
+			einfo "Restart the DTrace 'dtprobed' service after upgrades"
+			einfo "once all dtraces are stopped with:"
 			einfo " /etc/init.d/dtprobed restart"
 		fi
 	else
 		einfo "See https://wiki.gentoo.org/wiki/DTrace for getting started."
 
-		if systemd_is_booted ; then
-			einfo "Enable and start the DTrace 'dtprobed' service with:"
+		# We can't do magic for people with ROOT=.
+		if [[ -n ${ROOT} ]] ; then
+			einfo "Enable and start the DTrace 'dtprobed' service for systemd with:"
 			einfo " systemctl enable --now dtprobed"
-		else
-			einfo "Enable and start the DTrace 'dtprobed' service with:"
+			einfo
+			einfo "Enable and start the DTrace 'dtprobed' service for OpenRC with:"
 			einfo " rc-update add dtprobed"
 			einfo " /etc/init.d/dtprobed start"
+			return
+		fi
+
+		# For first installs, we enable the service and start it.
+		#
+		# This is unusual, but the behaviour without dtprobed running
+		# is untested/unsupported. It's not a network service, it
+		# has no configuration, reads a single device node, and
+		# does all parsing within a seccomp jail. It also leads
+		# to hard-to-diagnose issues because USDT probes won't
+		# be registered and an application might have already
+		# started up which needs to be traced.
+		if systemd_is_booted ; then
+			ebegin "Enabling & starting DTrace 'dtprobed' service"
+			systemctl enable --now dtprobed
+			eend $?
+		else
+			ebegin "Enabling DTrace 'dtprobed' service"
+			rc-update add dtprobed
+			eend $?
+
+			ebegin "Starting DTrace 'dtprobed' service"
+			rc-service start dtprobed
+			eend $?
 		fi
 	fi
 }

diff --git a/dev-debug/dtrace/dtrace-9999.ebuild b/dev-debug/dtrace/dtrace-9999.ebuild
index 1b544c426da4..9eb7d366c037 100644
--- a/dev-debug/dtrace/dtrace-9999.ebuild
+++ b/dev-debug/dtrace/dtrace-9999.ebuild
@@ -171,26 +171,54 @@ pkg_postinst() {
 	# We need a udev reload to pick up the CUSE device node rules.
 	udev_reload
 
-	# TODO: Restart it on upgrade? (it will carry across its own persistent state)
+	# TODO: One option for this is to detect when it's needed (DOF stash layout changes)
+	# and then e.g. sleep and restart for the user.
 	if [[ -n ${REPLACING_VERSIONS} ]]; then
 		# TODO: Make this more intelligent wrt comparison
 		if systemd_is_booted ; then
-			einfo "Restart the DTrace 'dtprobed' service after upgrades:"
+			einfo "Restart the DTrace 'dtprobed' service after upgrades"
+			einfo "once all dtraces are stopped with:"
 			einfo " systemctl try-restart dtprobed"
 		else
-			einfo "Restart the DTrace 'dtprobed' service with:"
+			einfo "Restart the DTrace 'dtprobed' service after upgrades"
+			einfo "once all dtraces are stopped with:"
 			einfo " /etc/init.d/dtprobed restart"
 		fi
 	else
 		einfo "See https://wiki.gentoo.org/wiki/DTrace for getting started."
 
-		if systemd_is_booted ; then
-			einfo "Enable and start the DTrace 'dtprobed' service with:"
+		# We can't do magic for people with ROOT=.
+		if [[ -n ${ROOT} ]] ; then
+			einfo "Enable and start the DTrace 'dtprobed' service for systemd with:"
 			einfo " systemctl enable --now dtprobed"
-		else
-			einfo "Enable and start the DTrace 'dtprobed' service with:"
+			einfo
+			einfo "Enable and start the DTrace 'dtprobed' service for OpenRC with:"
 			einfo " rc-update add dtprobed"
 			einfo " /etc/init.d/dtprobed start"
+			return
+		fi
+
+		# For first installs, we enable the service and start it.
+		#
+		# This is unusual, but the behaviour without dtprobed running
+		# is untested/unsupported. It's not a network service, it
+		# has no configuration, reads a single device node, and
+		# does all parsing within a seccomp jail. It also leads
+		# to hard-to-diagnose issues because USDT probes won't
+		# be registered and an application might have already
+		# started up which needs to be traced.
+		if systemd_is_booted ; then
+			ebegin "Enabling & starting DTrace 'dtprobed' service"
+			systemctl enable --now dtprobed
+			eend $?
+		else
+			ebegin "Enabling DTrace 'dtprobed' service"
+			rc-update add dtprobed
+			eend $?
+
+			ebegin "Starting DTrace 'dtprobed' service"
+			rc-service start dtprobed
+			eend $?
 		fi
 	fi
 }


             reply	other threads:[~2024-09-12  0:10 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-12  0:10 Sam James [this message]
  -- strict thread matches above, loose matches on Subject: below --
2025-03-25  8:14 [gentoo-commits] repo/gentoo:master commit in: dev-debug/dtrace/ Sam James
2025-03-08  8:41 Arthur Zamarin
2025-03-08  1:41 Sam James
2025-02-05  1:12 Sam James
2024-10-30 22:50 Sam James
2024-10-30 22:50 Sam James
2024-10-30 22:50 Sam James
2024-10-30 22:50 Sam James
2024-10-24  8:22 Arthur Zamarin
2024-10-24  2:37 Sam James
2024-09-12  1:06 Sam James
2024-09-12  0:43 Sam James
2024-09-12  0:42 Sam James
2024-09-12  0:42 Sam James
2024-09-12  0:38 Sam James
2024-09-12  0:38 Sam James
2024-09-12  0:30 Sam James
2024-09-11 23:59 Sam James
2024-09-11  3:35 Sam James
2024-09-10 13:58 Sam James
2024-08-30 18:13 Sam James
2024-08-25 18:49 Sam James
2024-08-22 12:54 Sam James
2024-08-22 12:36 Sam James
2024-08-22 12:36 Sam James
2024-08-22 12:22 Sam James
2024-08-20  1:49 Sam James
2024-08-20  1:49 Sam James
2024-08-20  1:49 Sam James
2024-08-19 23:27 Sam James
2024-08-19 20:16 Sam James
2024-08-18 22:59 Sam James
2024-08-18 21:47 Sam James
2024-08-18 21:42 Sam James
2024-08-18 21:36 Sam James

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1726099591.0b93226603134a169a41d1ae2213688167bd2b2c.sam@gentoo \
    --to=sam@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox