[PATCH 0/3] Fix uninstall script

  • Done
  • quality assurance status badge
Details
2 participants
  • David Boilleau
  • Ludovic Courtès
Owner
unassigned
Submitted by
David Boilleau
Severity
normal
D
D
David Boilleau wrote on 8 Nov 14:41 +0100
(address . guix-patches@gnu.org)(name . David Boilleau)(address . david_boilleau@gmx.fr)
cover.1731055803.git.david_boilleau@gmx.fr
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
D
D
David Boilleau wrote on 8 Nov 15:10 +0100
[PATCH 1/3] guix-install.sh: Test if gnu-store.mount exists before removing the unit
(address . 74258@debbugs.gnu.org)(name . David Boilleau)(address . david_boilleau@gmx.fr)
2a447bdebd8520746ff31f34b87801938e8af17c.1731055803.git.david_boilleau@gmx.fr
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(-)

Toggle diff (13 lines)
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
D
D
David Boilleau wrote on 8 Nov 15:10 +0100
[PATCH 2/3] guix-install.sh: Replace `ROOT_HOME` with `~root`
(address . 74258@debbugs.gnu.org)(name . David Boilleau)(address . david_boilleau@gmx.fr)
1a9aa88fcacc1c9b2f173a0aa8a6aa7327a3a2b7.1731055803.git.david_boilleau@gmx.fr
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(-)

Toggle diff (37 lines)
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
D
D
David Boilleau wrote on 8 Nov 15:10 +0100
[PATCH 3/3] guix-install.sh: Run the uninstall even if already partially done
(address . 74258@debbugs.gnu.org)(name . David Boilleau)(address . david_boilleau@gmx.fr)
f9fc83a267f697dcf5d8c8ddf5fee81131629801.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(-)

Toggle diff (43 lines)
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
L
L
Ludovic Courtès wrote on 14 Nov 15:41 +0100
Re: [bug#74258] [PATCH 0/3] Fix uninstall script
(name . David Boilleau)(address . david_boilleau@gmx.fr)(address . 74258-done@debbugs.gnu.org)
87v7wpop1n.fsf@gnu.org
Hi David,

David Boilleau <david_boilleau@gmx.fr> skribis:

Toggle quote (19 lines)
> 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’.
Closed
?
Your comment

This issue is archived.

To comment on this conversation send an email to 74258@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 74258
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch