GNU bug report logs - #74258
[PATCH 0/3] Fix uninstall script

Previous Next

Package: guix-patches;

Reported by: David Boilleau <david_boilleau <at> gmx.fr>

Date: Fri, 8 Nov 2024 13:56:02 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


Message #14 received at 74258 <at> debbugs.gnu.org (full text, mbox):

From: David Boilleau <david_boilleau <at> gmx.fr>
To: 74258 <at> debbugs.gnu.org
Cc: David Boilleau <david_boilleau <at> gmx.fr>
Subject: [PATCH 3/3] guix-install.sh: Run the uninstall even if already
 partially done
Date: Fri,  8 Nov 2024 15:10:24 +0100
Removing users, groups or Systemd units fails if they are already absent,
causing the uninstall script to exit. The goal here is to make the uninstall
always run entirely, whatever parts are already done.

* etc/guix-install.sh (sys_delete_build_user): Test if users and groups exist
before deleting them.
(sys_delete_guix_daemon): Test if /etc/systemd/system/guix-daemon.service file
exists before removing the matching Systemd unit.

Change-Id: Ibffb1f1b39de675542fb8057af21ecaea1b53d4c
---
 etc/guix-install.sh | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 7fb5ac63c5..f07b2741bb 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -451,11 +451,15 @@ sys_create_build_user()
 sys_delete_build_user()
 {
     for i in $(seq -w 1 10); do
-        userdel -f guixbuilder${i}
+        if id -u "guixbuilder${i}" &>/dev/null; then
+            userdel -f guixbuilder${i}
+        fi
     done

     _msg "${INF}delete group guixbuild"
-    groupdel -f guixbuild
+    if getent group guixbuild &>/dev/null; then
+        groupdel -f guixbuild
+    fi
 }

 sys_enable_guix_daemon()
@@ -569,12 +573,14 @@ sys_delete_guix_daemon()
             ;;

         systemd)
-            _msg "${INF}disabling guix-daemon"
-            systemctl disable guix-daemon
-            _msg "${INF}stopping guix-daemon"
-            systemctl stop guix-daemon
-            _msg "${INF}removing guix-daemon"
-            rm -f /etc/systemd/system/guix-daemon.service
+            if [ -f /etc/systemd/system/guix-daemon.service ]; then
+                _msg "${INF}disabling guix-daemon"
+                systemctl disable guix-daemon
+                _msg "${INF}stopping guix-daemon"
+                systemctl stop guix-daemon
+                _msg "${INF}removing guix-daemon"
+                rm -f /etc/systemd/system/guix-daemon.service
+            fi

             if [ -f /etc/systemd/system/gnu-store.mount ]; then
                 _msg "${INF}disabling gnu-store.mount"
--
2.43.0





This bug report was last modified 249 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.