* [bug#74258] [PATCH 1/3] guix-install.sh: Test if gnu-store.mount exists before removing the unit
2024-11-08 13:41 [bug#74258] [PATCH 0/3] Fix uninstall script David Boilleau via Guix-patches via
@ 2024-11-08 14:10 ` 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
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: David Boilleau via Guix-patches via @ 2024-11-08 14:10 UTC (permalink / raw)
To: 74258; +Cc: David Boilleau
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#74258] [PATCH 2/3] guix-install.sh: Replace `ROOT_HOME` with `~root`
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 ` David Boilleau via Guix-patches via
2024-11-08 14:10 ` [bug#74258] [PATCH 3/3] guix-install.sh: Run the uninstall even if already partially done David Boilleau via Guix-patches via
2024-11-14 14:41 ` bug#74258: [PATCH 0/3] Fix uninstall script Ludovic Courtès
3 siblings, 0 replies; 5+ messages in thread
From: David Boilleau via Guix-patches via @ 2024-11-08 14:10 UTC (permalink / raw)
To: 74258; +Cc: David Boilleau
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [bug#74258] [PATCH 3/3] guix-install.sh: Run the uninstall even if already partially done
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
2024-11-14 14:41 ` bug#74258: [PATCH 0/3] Fix uninstall script Ludovic Courtès
3 siblings, 0 replies; 5+ messages in thread
From: David Boilleau via Guix-patches via @ 2024-11-08 14:10 UTC (permalink / raw)
To: 74258; +Cc: David Boilleau
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
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#74258: [PATCH 0/3] Fix uninstall script
2024-11-08 13:41 [bug#74258] [PATCH 0/3] Fix uninstall script David Boilleau via Guix-patches via
` (2 preceding siblings ...)
2024-11-08 14:10 ` [bug#74258] [PATCH 3/3] guix-install.sh: Run the uninstall even if already partially done David Boilleau via Guix-patches via
@ 2024-11-14 14:41 ` Ludovic Courtès
3 siblings, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2024-11-14 14:41 UTC (permalink / raw)
To: David Boilleau; +Cc: 74258-done
Hi David,
David Boilleau <david_boilleau@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’.
^ permalink raw reply [flat|nested] 5+ messages in thread