pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: pkg/59702: sysutils/btop: multiple issues in btop-1.4.5



On Sat, 11 Oct 2025, Thomas Klausner wrote:

Two questions:

1. can you please upstream this?


I can; if fox@ doesn't do it. He's both the package maintainer and the author
of the NetBSD port according to the copyright in `src/netbsd/btop_collect.cpp'

(My C++ skillz are nothing to write home about...)

2. does your build also end up with the foreground colour set to light
gray/white? Any ideas how to fix this?


You'll have to show me a screenshot, Thomas. My build looks OK.
btop(1) autosaves any config. changes (type 'm' for menu), so try deleting
your `~/.config/btop/' to get a default config.

I would've suspected some theme issue, except themes don't work on NetBSD!

Fix:

---START patch---
diff -urN btop-1.4.5.orig/src/btop.cpp btop-1.4.5/src/btop.cpp
--- btop-1.4.5.orig/src/btop.cpp	2025-09-19 20:29:22.000000000 +0000
+++ btop-1.4.5/src/btop.cpp	2025-10-12 12:39:45.135765518 +0000
@@ -46,6 +46,12 @@
 	#include <limits.h>
 #endif

+#ifdef __NetBSD__
+	#include <sys/param.h>
+	#include <sys/sysctl.h>
+	#include <unistd.h>
+#endif
+
 #include "btop_cli.hpp"
 #include "btop_shared.hpp"
 #include "btop_tools.hpp"
@@ -877,6 +883,19 @@
 		if(!_NSGetExecutablePath(buf, &bufsize))
 			Global::self_path = fs::path(buf).remove_filename();
 	}
+#elif __NetBSD__
+	{
+		int mib[4];
+		char buf[PATH_MAX];
+		size_t bufsize = sizeof buf;
+
+		mib[0] = CTL_KERN;
+		mib[1] = KERN_PROC_ARGS;
+		mib[2] = getpid();
+		mib[3] = KERN_PROC_PATHNAME;
+		if (sysctl(mib, 4, buf, &bufsize, NULL, 0) == 0)
+			Global::self_path = fs::path(buf).remove_filename();
+	}
 #endif
 	if (std::error_code ec; not Global::self_path.empty()) {
 		Theme::theme_dir = fs::canonical(Global::self_path / "../share/btop/themes", ec);
@@ -884,7 +903,12 @@
 	}
 	//? If relative path failed, check two most common absolute paths
 	if (Theme::theme_dir.empty()) {
-		for (auto theme_path : {"/usr/local/share/btop/themes", "/usr/share/btop/themes"}) {
+		for (auto theme_path : {
+#ifdef __NetBSD__
+			"/usr/pkg/share/btop/themes",
+#endif
+			"/usr/local/share/btop/themes", "/usr/share/btop/themes"
+		}) {
 			if (fs::is_directory(fs::path(theme_path)) and access(theme_path, R_OK) != -1) {
 				Theme::theme_dir = fs::path(theme_path);
 				break;
diff -urN btop-1.4.5.orig/src/btop_menu.cpp btop-1.4.5/src/btop_menu.cpp
--- btop-1.4.5.orig/src/btop_menu.cpp	2025-09-19 20:29:22.000000000 +0000
+++ btop-1.4.5/src/btop_menu.cpp	2025-10-12 12:37:56.670049020 +0000
@@ -214,6 +214,9 @@
 				"Set color theme.",
 				"",
 				"Choose from all theme files in (usually)",
+#ifdef __NetBSD__
+				"\"/usr/pkg/share/btop/themes\",",
+#endif
 				"\"/usr/[local/]share/btop/themes\" and",
 				"\"~/.config/btop/themes\".",
 				"",
---END patch---

-RVP


Home | Main Index | Thread Index | Old Index