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.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 74258 in the body.
You can then email your comments to 74258 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#74258; Package guix-patches. (Fri, 08 Nov 2024 13:56:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to David Boilleau <david_boilleau <at> gmx.fr>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 08 Nov 2024 13:56:02 GMT) Full text and rfc822 format available.

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

From: David Boilleau <david_boilleau <at> gmx.fr>
To: guix-patches <at> gnu.org
Cc: David Boilleau <david_boilleau <at> gmx.fr>
Subject: [PATCH 0/3] Fix uninstall script
Date: Fri,  8 Nov 2024 14:41:12 +0100
I installed Guix on Ubuntu 24.04 with the script guix-install.sh, then I
tried to uninstall it by running `guix-install.sh --uninstall`. The
uninstall failed three times:
1. The unit gnu-store.mount was not suppressed, because the prior test
on the gnu-store.mount file failed.
2. The variable ROOT_HOME did not exist, so /root/.guix-profile,
/root/.config/guix and /root/.cache/guix were not suppressed.
3. The "guixbuilder" users were already removed due to the previous
attempts, so the script failed to remove them and exited here. Same when
it tried to remove the service guix-daemon.service.

Here are propositions to fix all of this.

David Boilleau (3):
  guix-install.sh: Test if gnu-store.mount exists before removing the
    unit
  guix-install.sh: Replace `ROOT_HOME` with `~root`
  guix-install.sh: Run the uninstall even if already partially done

 etc/guix-install.sh | 36 +++++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 15 deletions(-)


base-commit: 673b924ac1e30a5d498e28859af365cf2bb4a508
--
2.43.0





Information forwarded to guix-patches <at> gnu.org:
bug#74258; Package guix-patches. (Fri, 08 Nov 2024 18:46:02 GMT) Full text and rfc822 format available.

Message #8 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 1/3] guix-install.sh: Test if gnu-store.mount exists before
 removing the unit
Date: Fri,  8 Nov 2024 15:10:22 +0100
The file /etc/systemd/system/gnu-store.mount has permissions 664, since the
`install_unit()` function installed it so. So the test prior to removing the
matching Systemd unit should not be wether this file is executable, otherwise
it will always fail. The relevant test is on the file existence.

* etc/guix-install.sh (sys_delete_guix_daemon): Test if gnu-store.mount file
exists rather than if it is executable.

Change-Id: Ic7cc186618b0b92fccf49a3b27805756a9126b89
---
 etc/guix-install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 9d9c294d75..e97190d964 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -576,7 +576,7 @@ sys_delete_guix_daemon()
             _msg "${INF}removing guix-daemon"
             rm -f /etc/systemd/system/guix-daemon.service

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





Information forwarded to guix-patches <at> gnu.org:
bug#74258; Package guix-patches. (Fri, 08 Nov 2024 18:46:03 GMT) Full text and rfc822 format available.

Message #11 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 2/3] guix-install.sh: Replace `ROOT_HOME` with `~root`
Date: Fri,  8 Nov 2024 15:10:23 +0100
The `ROOT_HOME` variable is natively absent from some systems, however the form
`~root`, which is used by the install functions in this same file, works.

* etc/guix-install.sh (sys_delete_store, sys_delete_guix_daemon)
(sys_delete_user_profiles): Replace `ROOT_HOME` with `~root`.

Change-Id: Ia867e271ac4c5557d9708235fee028bccce68342
---
 etc/guix-install.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index e97190d964..7fb5ac63c5 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -410,8 +410,8 @@ sys_delete_store()
     _msg "${INF}removing /gnu"
     rm -rf /gnu

-    _msg "${INF}removing ${ROOT_HOME}/.config/guix"
-    rm -rf ${ROOT_HOME}/.config/guix
+    _msg "${INF}removing ~root/.config/guix"
+    rm -rf ~root/.config/guix
 }

 sys_create_build_user()
@@ -594,7 +594,7 @@ sys_delete_guix_daemon()
             ;;
         NA|*)
             _msg "${ERR}unsupported init system; disable, stop and remove the daemon manually:"
-            echo "  ${ROOT_HOME}/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"
+            echo "  ~root/.config/guix/current/bin/guix-daemon --build-users-group=guixbuild"
             ;;
     esac

@@ -743,9 +743,9 @@ sys_delete_init_profile()

 sys_delete_user_profiles()
 {
-    _msg "${INF}removing ${ROOT_HOME}/.guix-profile"
-    rm -f ${ROOT_HOME}/.guix-profile
-    rm -rf ${ROOT_HOME}/.cache/guix
+    _msg "${INF}removing ~root/.guix-profile"
+    rm -f ~root/.guix-profile
+    rm -rf ~root/.cache/guix

     _msg "${INF}removing .guix-profile, .cache/guix and .config/guix of all /home users"
     for user in `ls -1 /home`; do
--
2.43.0





Information forwarded to guix-patches <at> gnu.org:
bug#74258; Package guix-patches. (Fri, 08 Nov 2024 18:46:03 GMT) Full text and rfc822 format available.

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





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Thu, 14 Nov 2024 14:43:02 GMT) Full text and rfc822 format available.

Notification sent to David Boilleau <david_boilleau <at> gmx.fr>:
bug acknowledged by developer. (Thu, 14 Nov 2024 14:43:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: David Boilleau <david_boilleau <at> gmx.fr>
Cc: 74258-done <at> debbugs.gnu.org
Subject: Re: [bug#74258] [PATCH 0/3] Fix uninstall script
Date: Thu, 14 Nov 2024 15:41:56 +0100
Hi David,

David Boilleau <david_boilleau <at> gmx.fr> skribis:

> I installed Guix on Ubuntu 24.04 with the script guix-install.sh, then I
> tried to uninstall it by running `guix-install.sh --uninstall`. The
> uninstall failed three times:
> 1. The unit gnu-store.mount was not suppressed, because the prior test
> on the gnu-store.mount file failed.
> 2. The variable ROOT_HOME did not exist, so /root/.guix-profile,
> /root/.config/guix and /root/.cache/guix were not suppressed.
> 3. The "guixbuilder" users were already removed due to the previous
> attempts, so the script failed to remove them and exited here. Same when
> it tried to remove the service guix-daemon.service.
>
> Here are propositions to fix all of this.
>
> David Boilleau (3):
>   guix-install.sh: Test if gnu-store.mount exists before removing the
>     unit
>   guix-install.sh: Replace `ROOT_HOME` with `~root`
>   guix-install.sh: Run the uninstall even if already partially done

This looks good to me.

Applied, thank you for spotting the problems and for fixing them!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 13 Dec 2024 12:24:13 GMT) Full text and rfc822 format available.

This bug report was last modified 248 days ago.

Previous Next


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