all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: David Boilleau via Guix-patches via <guix-patches@gnu.org>
To: 74258@debbugs.gnu.org
Cc: David Boilleau <david_boilleau@gmx.fr>
Subject: [bug#74258] [PATCH 3/3] guix-install.sh: Run the uninstall even if already partially done
Date: Fri,  8 Nov 2024 15:10:24 +0100	[thread overview]
Message-ID: <f9fc83a267f697dcf5d8c8ddf5fee81131629801.1731055803.git.david_boilleau@gmx.fr> (raw)
In-Reply-To: <cover.1731055803.git.david_boilleau@gmx.fr>

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





  parent reply	other threads:[~2024-11-08 18:46 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-08 13:41 [bug#74258] [PATCH 0/3] Fix uninstall script David Boilleau via Guix-patches via
2024-11-08 14:10 ` [bug#74258] [PATCH 1/3] guix-install.sh: Test if gnu-store.mount exists before removing the unit David Boilleau via Guix-patches via
2024-11-08 14:10 ` [bug#74258] [PATCH 2/3] guix-install.sh: Replace `ROOT_HOME` with `~root` David Boilleau via Guix-patches via
2024-11-08 14:10 ` David Boilleau via Guix-patches via [this message]
2024-11-14 14:41 ` bug#74258: [PATCH 0/3] Fix uninstall script Ludovic Courtès

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=f9fc83a267f697dcf5d8c8ddf5fee81131629801.1731055803.git.david_boilleau@gmx.fr \
    --to=guix-patches@gnu.org \
    --cc=74258@debbugs.gnu.org \
    --cc=david_boilleau@gmx.fr \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.