gsmartcontrol: fix runtime smartctl lookup (#491101)

This commit is contained in:
Aleksana 2026-03-06 15:48:54 +00:00 committed by GitHub
commit 4e3cfe20e5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 34 additions and 42 deletions

View file

@ -1,33 +0,0 @@
diff --git a/data/gsmartcontrol-root.in b/data/gsmartcontrol-root.in
--- a/data/gsmartcontrol-root.in
+++ b/data/gsmartcontrol-root.in
@@ -8,7 +8,7 @@
# Run gsmartcontrol with root, asking for root password first.
# export GSMARTCONTROL_SU to override a su command (e.g. "kdesu -c").
-EXEC_BIN="@prefix@/sbin/gsmartcontrol";
+EXEC_BIN="@prefix@/bin/gsmartcontrol";
prog_name="gsmartcontrol"
@@ -118,7 +118,7 @@
# Add @prefix@/sbin as well (freebsd seems to require it).
# Note that beesu won't show a GUI login box if /usr/sbin is before /usr/bin,
# so add it first as well.
-EXTRA_PATHS="/usr/bin:/usr/sbin:/usr/local/sbin:@prefix@/sbin";
+EXTRA_PATHS="/usr/bin:/usr/sbin:/usr/local/sbin:@prefix@/bin";
export PATH="$EXTRA_PATHS:$PATH"
diff --git a/src/Makefile.am b/src/Makefile.am
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -24,7 +24,7 @@
# endif
-sbin_PROGRAMS = gsmartcontrol
+bin_PROGRAMS = gsmartcontrol
gsmartcontrol_LDADD = $(top_builddir)/src/applib/libapplib.a \
$(top_builddir)/src/libdebug/libdebug.a \

View file

@ -0,0 +1,18 @@
diff --git a/src/gui/gsc_main_window.cpp b/src/gui/gsc_main_window.cpp
index a5a6ac9..2d7a1f7 100644
--- a/src/gui/gsc_main_window.cpp
+++ b/src/gui/gsc_main_window.cpp
@@ -955,8 +955,13 @@ void GscMainWindow::run_update_drivedb()
if (smartctl_binary.is_absolute()) {
update_binary_path = smartctl_binary.parent_path() / update_binary_path;
}
- argv = {"xterm", "-hold", "-e", hz::fs_path_to_string(update_binary_path)};
+
+ gui_show_error_dialog(
+ _("Error Updating Drive Database"),
+ _("Updating drivedb from GSmartControl is unavailable in nixpkgs because smartmontools in the Nix store is immutable. Please update your NixOS or nixpkgs channel/flake inputs to get a newer drive database."),
+ this);
+ return;
}
try {

View file

@ -3,12 +3,12 @@
stdenv,
fetchFromGitHub,
smartmontools,
adwaita-icon-theme,
cmake,
gtkmm3,
makeWrapper,
pkg-config,
wrapGAppsHook3,
pcre-cpp,
adwaita-icon-theme,
# xterm,
}:
stdenv.mkDerivation (finalAttrs: {
@ -22,6 +22,10 @@ stdenv.mkDerivation (finalAttrs: {
hash = "sha256-eLzwFZ1PYqijFTxos9Osf7A2v4C8toM+TGV4/bU82NE=";
};
patches = [
./nixos-update-drivedb-message.patch
];
postPatch = ''
substituteInPlace data/gsmartcontrol.in.desktop \
--replace-fail "@CMAKE_INSTALL_FULL_BINDIR@/" ""
@ -30,21 +34,24 @@ stdenv.mkDerivation (finalAttrs: {
nativeBuildInputs = [
cmake
pkg-config
wrapGAppsHook3
makeWrapper
];
buildInputs = [
gtkmm3
pcre-cpp
adwaita-icon-theme
];
enableParallelBuilding = true;
preFixup = ''
gappsWrapperArgs+=(
--prefix PATH : "${lib.makeBinPath [ smartmontools ]}"
)
postFixup = ''
wrapProgram $out/bin/gsmartcontrol \
--prefix PATH : ${
lib.makeBinPath [
smartmontools
# xterm # For `update-smart-drivedb`, which does not make sense in NixOS as it tries to overwrite /usr/share/smartmontools/drivedb.h
]
}
'';
meta = {