GNU bug report logs - #43769
[PATCH 0/2] guix-install.sh: Minor first user-experience tweaks

Previous Next

Package: guix-patches;

Reported by: zimoun <zimon.toutoune <at> gmail.com>

Date: Fri, 2 Oct 2020 17:36:01 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 43769 in the body.
You can then email your comments to 43769 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#43769; Package guix-patches. (Fri, 02 Oct 2020 17:36:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to zimoun <zimon.toutoune <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 02 Oct 2020 17:36:01 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH 0/2] guix-install.sh: Minor first user-experience tweaks
Date: Fri,  2 Oct 2020 19:35:37 +0200
Dear,

These 2 patches are proposal for the point #1 and #3 in [1].  The errorin
patch 2/2 about 'nscd' should be turned into a simple warning and so adds:
WARN=[color WARN color] in orange, similarly to PASS and ERR.  WDYT?


[1]: <http://issues.guix.gnu.org/issue/43744>


All the best,
simon

zimoun (2):
  guix-install.sh: Add symbolic links for supported shell completions.
  guix-install.sh: Check the daemon 'nscd' and suggest it.

 etc/guix-install.sh | 46 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)


base-commit: db194f714a8beb155c508c06e346c7c2322e7053
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Fri, 02 Oct 2020 17:41:01 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: 43769 <at> debbugs.gnu.org
Cc: zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH 1/2] guix-install.sh: Add symbolic links for supported shell
 completions.
Date: Fri,  2 Oct 2020 19:40:30 +0200
Fixes <https://bugs.gnu.org/43744>.

* etc/guix-install.sh (sys_create_shell_completion): New function to add
system wide all the symlinks for supported shell completions.
---
 etc/guix-install.sh | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index eb7205a261..a5da198eb0 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -5,6 +5,7 @@
 # Copyright © 2018 Efraim Flashner <efraim <at> flashner.co.il>
 # Copyright © 2019, 2020 Tobias Geerinckx-Rice <me <at> tobias.gr>
 # Copyright © 2020 Morgan Smith <Morgan.J.Smith <at> outlook.com>
+# Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com>
 #
 # This file is part of GNU Guix.
 #
@@ -459,6 +460,36 @@ export XDG_DATA_DIRS="$GUIX_PROFILE/share:${XDG_DATA_DIRS:-/usr/local/share/:/us
 EOF
 }
 
+sys_create_shell_completion()
+{ # Symlink supported shell completions system-wide
+
+    var_guix=/var/guix/profiles/per-user/root/current-guix
+    bash_completion=/etc/bash_completion.d
+    zsh_completion=/usr/share/zsh/site-functions
+    fish_completion=/usr/share/fish/vendor_completions.d
+
+    while true; do
+        read -p "Install shell completion? (yes/no)" yn
+        case $yn in
+            [Yy]*)
+                { # Just in case
+                  for dir_shell in $bash_completion $zsh_completion $fish_completion; do
+                      [ -d "$dir_shell" ] || mkdir -p $dir_shell
+                  done;
+
+                  ln -sf ${var_guix}/etc/bash_completion.d/* "$bash_completion";
+                  ln -sf ${var_guix}/share/zsh/site-functions/* "$zsh_completion";
+                  ln -sf ${var_guix}/share/fish/vendor_completions.d/* "$fish_completion"; } &&
+                    _msg "${PAS}Installed shell completion"
+                break;;
+            [Nn]*) _msg "${INF}Skipped shell completion installation"
+                   break;;
+            *) _msg "Please answer yes or no.";
+        esac
+    done
+}
+
+
 welcome()
 {
     cat<<"EOF"
@@ -516,6 +547,7 @@ main()
     sys_enable_guix_daemon
     sys_authorize_build_farms
     sys_create_init_profile
+    sys_create_shell_completion
 
     _msg "${INF}cleaning up ${tmp_path}"
     rm -r "${tmp_path}"
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Fri, 02 Oct 2020 17:43:01 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: 43769 <at> debbugs.gnu.org
Cc: zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH 2/2] guix-install.sh: Check the daemon 'nscd' and suggest it.
Date: Fri,  2 Oct 2020 19:42:11 +0200
Fixes <https://bugs.gnu.org/43744>.

* etc/guix-install.sh (chk_sys_nscd): New function to check if the daemon
'nscd is running, otherwise suggest to install distribution-wide.
---
 etc/guix-install.sh | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index a5da198eb0..3860ab3cdc 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -200,6 +200,18 @@ chk_sys_arch()
     ARCH_OS="${arch}-${os}"
 }
 
+chk_sys_nscd()
+{ # Check if nscd is up and suggest to start it or install it
+
+    if [ "$(type -P pidof)" ]; then
+        if [ ! "$(pidof nscd)" ]; then
+            _msg "${ERR}We recommand to install the daemon 'nscd' via your distribution..."
+            _msg "${ERR}...or to start it."
+            _msg "${ERR}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
+        fi
+    fi
+}
+
 # ------------------------------------------------------------------------------
 #+MAIN
 
@@ -552,6 +564,8 @@ main()
     _msg "${INF}cleaning up ${tmp_path}"
     rm -r "${tmp_path}"
 
+    chk_sys_nscd
+
     _msg "${PAS}Guix has successfully been installed!"
     _msg "${INF}Run 'info guix' to read the manual."
 
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Sat, 03 Oct 2020 18:46:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: 43769 <at> debbugs.gnu.org
Cc: zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported
 shell completions.
Date: Sat,  3 Oct 2020 20:44:46 +0200
Fixes <https://bugs.gnu.org/43744>.

* etc/guix-install.sh (sys_create_shell_completion): New function to add
system wide all the symlinks for supported shell completions.
---
 etc/guix-install.sh | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index eb7205a261..a5da198eb0 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -5,6 +5,7 @@
 # Copyright © 2018 Efraim Flashner <efraim <at> flashner.co.il>
 # Copyright © 2019, 2020 Tobias Geerinckx-Rice <me <at> tobias.gr>
 # Copyright © 2020 Morgan Smith <Morgan.J.Smith <at> outlook.com>
+# Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com>
 #
 # This file is part of GNU Guix.
 #
@@ -459,6 +460,36 @@ export XDG_DATA_DIRS="$GUIX_PROFILE/share:${XDG_DATA_DIRS:-/usr/local/share/:/us
 EOF
 }
 
+sys_create_shell_completion()
+{ # Symlink supported shell completions system-wide
+
+    var_guix=/var/guix/profiles/per-user/root/current-guix
+    bash_completion=/etc/bash_completion.d
+    zsh_completion=/usr/share/zsh/site-functions
+    fish_completion=/usr/share/fish/vendor_completions.d
+
+    while true; do
+        read -p "Install shell completion? (yes/no)" yn
+        case $yn in
+            [Yy]*)
+                { # Just in case
+                  for dir_shell in $bash_completion $zsh_completion $fish_completion; do
+                      [ -d "$dir_shell" ] || mkdir -p $dir_shell
+                  done;
+
+                  ln -sf ${var_guix}/etc/bash_completion.d/* "$bash_completion";
+                  ln -sf ${var_guix}/share/zsh/site-functions/* "$zsh_completion";
+                  ln -sf ${var_guix}/share/fish/vendor_completions.d/* "$fish_completion"; } &&
+                    _msg "${PAS}Installed shell completion"
+                break;;
+            [Nn]*) _msg "${INF}Skipped shell completion installation"
+                   break;;
+            *) _msg "Please answer yes or no.";
+        esac
+    done
+}
+
+
 welcome()
 {
     cat<<"EOF"
@@ -516,6 +547,7 @@ main()
     sys_enable_guix_daemon
     sys_authorize_build_farms
     sys_create_init_profile
+    sys_create_shell_completion
 
     _msg "${INF}cleaning up ${tmp_path}"
     rm -r "${tmp_path}"
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Sat, 03 Oct 2020 18:46:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: 43769 <at> debbugs.gnu.org
Cc: zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest
 it.
Date: Sat,  3 Oct 2020 20:44:47 +0200
Fixes <https://bugs.gnu.org/43744>.

* etc/guix-install.sh (chk_sys_nscd): New function to check if the service
'nscd is running, otherwise suggest to install distribution-wide.
---
 etc/guix-install.sh | 66 ++++++++++++++++++++++++++++-----------------
 1 file changed, 41 insertions(+), 25 deletions(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index a5da198eb0..5bda31de2e 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -55,6 +55,7 @@ REQUIRE=(
 
 PAS=$'[ \033[32;1mPASS\033[0m ] '
 ERR=$'[ \033[31;1mFAIL\033[0m ] '
+WAR=$'[ \033[33;1mWARN\033[0m ] '
 INF="[ INFO ] "
 
 DEBUG=0
@@ -200,6 +201,19 @@ chk_sys_arch()
     ARCH_OS="${arch}-${os}"
 }
 
+chk_sys_nscd()
+{ # Check if nscd is up and suggest to start it or install it
+    if [ "$(type -P pidof)" ]; then
+        if [ ! "$(pidof nscd)" ]; then
+            _msg "${WAR}We recommend installing and/or starting your distribution 'nscd' service"
+            _msg "${WAR}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
+        fi
+    else
+        _msg "${INF}We cannot determine if your distribution 'nscd' service is running"
+        _msg "${INF}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
+    fi
+}
+
 # ------------------------------------------------------------------------------
 #+MAIN
 
@@ -523,40 +537,42 @@ EOF
 
 main()
 {
-    local tmp_path
-    welcome
+    # local tmp_path
+    # welcome
+
+    # _msg "Starting installation ($(date))"
 
-    _msg "Starting installation ($(date))"
+    # chk_term
+    # chk_require "${REQUIRE[@]}"
+    # chk_gpg_keyring
+    # chk_init_sys
+    # chk_sys_arch
 
-    chk_term
-    chk_require "${REQUIRE[@]}"
-    chk_gpg_keyring
-    chk_init_sys
-    chk_sys_arch
+    # _msg "${INF}system is ${ARCH_OS}"
 
-    _msg "${INF}system is ${ARCH_OS}"
+    # umask 0022
+    # tmp_path="$(mktemp -t -d guix.XXX)"
 
-    umask 0022
-    tmp_path="$(mktemp -t -d guix.XXX)"
+    # guix_get_bin_list "${GNU_URL}"
+    # guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
 
-    guix_get_bin_list "${GNU_URL}"
-    guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
+    # sys_create_store "${BIN_VER}.tar.xz" "${tmp_path}"
+    # sys_create_build_user
+    # sys_enable_guix_daemon
+    # sys_authorize_build_farms
+    # sys_create_init_profile
+    # sys_create_shell_completion
 
-    sys_create_store "${BIN_VER}.tar.xz" "${tmp_path}"
-    sys_create_build_user
-    sys_enable_guix_daemon
-    sys_authorize_build_farms
-    sys_create_init_profile
-    sys_create_shell_completion
+    # _msg "${INF}cleaning up ${tmp_path}"
+    # rm -r "${tmp_path}"
 
-    _msg "${INF}cleaning up ${tmp_path}"
-    rm -r "${tmp_path}"
+    chk_sys_nscd
 
-    _msg "${PAS}Guix has successfully been installed!"
-    _msg "${INF}Run 'info guix' to read the manual."
+    # _msg "${PAS}Guix has successfully been installed!"
+    # _msg "${INF}Run 'info guix' to read the manual."
 
-    # Required to source /etc/profile in desktop environments.
-    _msg "${INF}Please log out and back in to complete the installation."
+    # # Required to source /etc/profile in desktop environments.
+    # _msg "${INF}Please log out and back in to complete the installation."
  }
 
 main "$@"
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Sat, 03 Oct 2020 19:12:01 GMT) Full text and rfc822 format available.

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

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 43769 <at> debbugs.gnu.org
Subject: Re: [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links
 for supported shell completions.
Date: Sat, 03 Oct 2020 21:11:26 +0200
[Message part 1 (text/plain, inline)]
Zimoun,

Thanks!  Shell code always looks ugly to me, so LGTM if it works 
:-)

Nitpick: s/create/install/

zimoun 写道:
> +            [Nn]*) _msg "${INF}Skipped shell completion 
> installation"
> +                   break;;
> +            *) _msg "Please answer yes or no.";

Why bother the user with this?  We don't ask before installing 
/etc/profile.d/guix.sh, or enabling the daemon, and we shouldn't 
offer similar meaningless choices just for the sake of it.

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Sat, 03 Oct 2020 19:16:02 GMT) Full text and rfc822 format available.

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

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: 43769 <at> debbugs.gnu.org
Subject: Re: [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service
 'nscd' and suggest it.
Date: Sat, 03 Oct 2020 21:14:53 +0200
[Message part 1 (text/plain, inline)]
Zimoun,

zimoun 写道:
> * etc/guix-install.sh (chk_sys_nscd): New function to check if 
> the service
> 'nscd is running, otherwise suggest to install 
> distribution-wide.

If we must have a new interactive prompt in this series, this 
seems like the better place: we know enough about the host (init) 
system to auto-enable nscd on most of them, if the user so wishes.

>  main()
>  {
> -    local tmp_path
> -    welcome
> +    # local tmp_path
> +    # welcome
> +
> +    # _msg "Starting installation ($(date))"
>  
> -    _msg "Starting installation ($(date))"
> +    # chk_term
> +    # chk_require "${REQUIRE[@]}"
> +    # chk_gpg_keyring
> +    # chk_init_sys
> +    # chk_sys_arch
>  
> -    chk_term
> -    chk_require "${REQUIRE[@]}"
> -    chk_gpg_keyring
> -    chk_init_sys
> -    chk_sys_arch
> +    # _msg "${INF}system is ${ARCH_OS}"
>  
> -    _msg "${INF}system is ${ARCH_OS}"
> +    # umask 0022
> +    # tmp_path="$(mktemp -t -d guix.XXX)"
>  
> -    umask 0022
> -    tmp_path="$(mktemp -t -d guix.XXX)"
> +    # guix_get_bin_list "${GNU_URL}"
> +    # guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
>  
> -    guix_get_bin_list "${GNU_URL}"
> -    guix_get_bin "${GNU_URL}" "${BIN_VER}" "$tmp_path"
> +    # sys_create_store "${BIN_VER}.tar.xz" "${tmp_path}"
> +    # sys_create_build_user
> +    # sys_enable_guix_daemon
> +    # sys_authorize_build_farms
> +    # sys_create_init_profile
> +    # sys_create_shell_completion
>  
> -    sys_create_store "${BIN_VER}.tar.xz" "${tmp_path}"
> -    sys_create_build_user
> -    sys_enable_guix_daemon
> -    sys_authorize_build_farms
> -    sys_create_init_profile
> -    sys_create_shell_completion
> +    # _msg "${INF}cleaning up ${tmp_path}"
> +    # rm -r "${tmp_path}"
>  
> -    _msg "${INF}cleaning up ${tmp_path}"
> -    rm -r "${tmp_path}"
> +    chk_sys_nscd
>  
> -    _msg "${PAS}Guix has successfully been installed!"
> -    _msg "${INF}Run 'info guix' to read the manual."
> +    # _msg "${PAS}Guix has successfully been installed!"
> +    # _msg "${INF}Run 'info guix' to read the manual."
>  
> -    # Required to source /etc/profile in desktop environments.
> -    _msg "${INF}Please log out and back in to complete the 
> installation."
> +    # # Required to source /etc/profile in desktop 
> environments.
> +    # _msg "${INF}Please log out and back in to complete the 
> installation."
>   }

?

Debugging left-overs?

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Mon, 05 Oct 2020 08:09:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: 43769 <at> debbugs.gnu.org, zimoun <zimon.toutoune <at> gmail.com>
Subject: Re: [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service
 'nscd' and suggest it.
Date: Mon, 05 Oct 2020 10:08:36 +0200
Hi Tobias,

Tobias Geerinckx-Rice <me <at> tobias.gr> skribis:

> zimoun 写道:
>> * etc/guix-install.sh (chk_sys_nscd): New function to check if the
>> service
>> 'nscd is running, otherwise suggest to install distribution-wide.
>
> If we must have a new interactive prompt in this series, this seems
> like the better place: we know enough about the host (init) system to
> auto-enable nscd on most of them, if the user so wishes.

In practice, you enable nscd by running ‘apt install nscd’ or similar,
and I think we cannot guess what the right command is.  WDYT?

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Mon, 05 Oct 2020 08:11:02 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: 43769 <at> debbugs.gnu.org, zimoun <zimon.toutoune <at> gmail.com>
Subject: Re: [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links
 for supported shell completions.
Date: Mon, 05 Oct 2020 10:09:53 +0200
Hi,

Tobias Geerinckx-Rice <me <at> tobias.gr> skribis:

> Why bother the user with this?  We don't ask before installing
> /etc/profile.d/guix.sh, or enabling the daemon, and we shouldn't 
> offer similar meaningless choices just for the sake of it.

Yeah, I think we can install completions without asking (but still
printing a line about it.)

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Mon, 05 Oct 2020 09:20:01 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Tobias Geerinckx-Rice <me <at> tobias.gr>, 43769 <at> debbugs.gnu.org
Subject: Re: [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service
 'nscd' and suggest it.
Date: Mon, 5 Oct 2020 11:19:28 +0200
On Mon, 5 Oct 2020 at 10:08, Ludovic Courtès <ludo <at> gnu.org> wrote:
> Tobias Geerinckx-Rice <me <at> tobias.gr> skribis:
>
> > zimoun 写道:
> >> * etc/guix-install.sh (chk_sys_nscd): New function to check if the
> >> service
> >> 'nscd is running, otherwise suggest to install distribution-wide.
> >
> > If we must have a new interactive prompt in this series, this seems
> > like the better place: we know enough about the host (init) system to
> > auto-enable nscd on most of them, if the user so wishes.
>
> In practice, you enable nscd by running ‘apt install nscd’ or similar,
> and I think we cannot guess what the right command is.  WDYT?

Yeah, I have tried in an unsent yet v3 to ask and then try to start
the service depending on the init system if nscd is not running.  And
if it fails, ask to install it.  That's the best we can do, IMHO.
Maybe it is over engineering and a simple INFO/WARN is enough.  WDYT?

All the best,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Mon, 05 Oct 2020 09:24:01 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: Tobias Geerinckx-Rice <me <at> tobias.gr>, 43769 <at> debbugs.gnu.org
Subject: Re: [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links
 for supported shell completions.
Date: Mon, 5 Oct 2020 11:23:22 +0200
On Mon, 5 Oct 2020 at 10:09, Ludovic Courtès <ludo <at> gnu.org> wrote:
> Tobias Geerinckx-Rice <me <at> tobias.gr> skribis:
>
> > Why bother the user with this?  We don't ask before installing
> > /etc/profile.d/guix.sh, or enabling the daemon, and we shouldn't
> > offer similar meaningless choices just for the sake of it.
>
> Yeah, I think we can install completions without asking (but still
> printing a line about it.)

As we talked with nckx yesterday on IRC, from my point of view, it is
impolite to install stuff behind the user.  Well, to be concrete, I
suggest either: a) add a comment in the Warning Note in the manual
saying that /etc/profile.d and shell competitions will be installed or
b) ask a global question in guix-install.sh about these.  WDYT?
I do not have a strong opinion and the patch doing what you are both
suggesting is ready. ;-)

All the best,
simon




Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Mon, 05 Oct 2020 12:03:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: Tobias Geerinckx-Rice <me <at> tobias.gr>, 43769 <at> debbugs.gnu.org
Subject: Re: [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links
 for supported shell completions.
Date: Mon, 05 Oct 2020 14:02:13 +0200
zimoun <zimon.toutoune <at> gmail.com> skribis:

> On Mon, 5 Oct 2020 at 10:09, Ludovic Courtès <ludo <at> gnu.org> wrote:
>> Tobias Geerinckx-Rice <me <at> tobias.gr> skribis:
>>
>> > Why bother the user with this?  We don't ask before installing
>> > /etc/profile.d/guix.sh, or enabling the daemon, and we shouldn't
>> > offer similar meaningless choices just for the sake of it.
>>
>> Yeah, I think we can install completions without asking (but still
>> printing a line about it.)
>
> As we talked with nckx yesterday on IRC, from my point of view, it is
> impolite to install stuff behind the user.

Like Tobias wrote, the script is already doing that.  (It’s also
widespread practice these days: favor ease of use and installation speed
over fine-grained user control.)

> Well, to be concrete, I suggest either: a) add a comment in the
> Warning Note in the manual saying that /etc/profile.d and shell
> competitions will be installed or b) ask a global question in
> guix-install.sh about these.  WDYT?

I think it’s fine to just drop the completion files in the right place:
it’s what users expect.  But we should still have an INFO line saying
these are being installed, as a matter of transparency.

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Mon, 05 Oct 2020 12:29:02 GMT) Full text and rfc822 format available.

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

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Ludovic Courtès <ludo <at> gnu.org>, zimoun
 <zimon.toutoune <at> gmail.com>
Cc: 43769 <at> debbugs.gnu.org
Subject: Re: [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service
 'nscd' and suggest it.
Date: Mon, 05 Oct 2020 14:28:53 +0200
[Message part 1 (text/plain, inline)]
Ludo', Zimoun,

Ludovic Courtès 写道:
>> If we must have a new interactive prompt in this series, this 
>> seems
>> like the better place: we know enough about the host (init) 
>> system to
>> auto-enable nscd on most of them, if the user so wishes.
>
> In practice, you enable nscd by running ‘apt install nscd’ or 
> similar,
> and I think we cannot guess what the right command is.  WDYT?

I agree: I was under the assumption that nscd is commonly 
installed as part of the base OS, but disabled by default at the 
init system level.  If that's not likely to be true, don't let's 
bother.

Zimoun 写道:
> ask and then try to start the service depending on the init 
> system if nscd is not running

If the distro equivalent of ‘service start nscd’ works in the 
*common* case, I like it.  Otherwise a warning/suggestion to 
manually install & enable it is fine.

My general point was that guix-install.sh should do as much as it 
can with the information it already has ($INIT_SYS) and be 
consistent in using it, not that we start sniffing 
$LEGACY_PKG_MANAGER too :-)

Thanks for your work so far, Simon,

T G-R
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Tue, 13 Oct 2020 16:46:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: Ludovic Courtès <ludo <at> gnu.org>, 43769 <at> debbugs.gnu.org
Subject: Re: [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service
 'nscd' and suggest it.
Date: Tue, 13 Oct 2020 18:45:16 +0200
>> In practice, you enable nscd by running ‘apt install nscd’ or similar,
>> and I think we cannot guess what the right command is.  WDYT?
>
> I agree: I was under the assumption that nscd is commonly installed as part of
> the base OS, but disabled by default at the init system level.  If that's not
> likely to be true, don't let's bother.

>> ask and then try to start the service depending on the init system if nscd
>> is not running
>
> If the distro equivalent of ‘service start nscd’ works in the *common* case, I
> like it.  Otherwise a warning/suggestion to manually install & enable it is
> fine.
>
> My general point was that guix-install.sh should do as much as it can with the
> information it already has ($INIT_SYS) and be consistent in using it, not that
> we start sniffing $LEGACY_PKG_MANAGER too :-)

As said, I have tried somehting like this uglyness… but it’s wrong!  It
is overcomplicated and if the package is installed, then it is highly
probable that is running.  I mean 2 kind of users:

 - the noob as me: “Please install nscd” and the I do “aptitude install
   nscd” and my distro takes care of everything (start it etc.)
   
 - the control-freak: they knows what to do with the message “Please
   install nscd”.

And we can try to guess the distro… but again it is overcomplicated.


So it’s not useful.  A message is enough.  Please give a look at v3.

Thanks,
simon

--8<---------------cut here---------------start------------->8---
sys_enable_nscd()
{ # Check if nscd is up and suggest to start it or install it
    flag=""
    if [ "$(type -P pidof)" ]; then
        if [ ! "$(pidof nscd)" ]; then
            _msg "${INF}We recommend installing and/or starting your distribution 'nscd' service"
            while true; do
                read -p "Permit to try starting your 'nscd' service? (yes/no) " yn
                case $yn in
                    [Yy]*) case "$INIT_SYS" in
                               upstart)
                                   { initctl reload-configuration;
                                     /etc/init/ &&
                                         start nscd; } &&
                                       _msg "${PAS}enabled 'nscd' service via upstart"
                                   ;;
                               systemd)
                                   if [ ( systemctl daemon-reload &&
                                              systemctl enable nscd &&
                                              systemctl start nscd; ) ]; then
                                       _msg "${PAS}enabled 'nscd' service via systemd";
                                   else
                                       flag=failure
                                   fi

                                   ;;
                               sysv-init)
                                   { update-rc.d nscd defaults &&
                                         update-rc.d nscd enable &&
                                         service nscd start; } &&
                                       _msg "${PAS}enabled 'nscd' service via sysv"
                                   ;;
                               openrc)
                                   { rc-update add nscd default &&
                                        rc-service nscd start; } &&
                                       _msg "${PAS}enabled 'nscd' service via OpenRC"
                                   ;;
                               NA|*)
                                   _msg "${ERR}unsupported init system; run the 'ncsd' service manually"
                                   ;;
                           esac;
                           break;;
                    [Nn]*) _msg "${INF}Skipped 'nscd' service"
                           flag=failure
                           break;;
                    *) _msg "Please answer yes or no.";
                esac
            done
        fi
    else
        _msg "${WAR}We cannot determine1 if your distribution 'nscd' service is running"
        failure=failure
    fi
    if [[ $flag == failure ]]; then
        _msg "${WAR}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
    fi
}
--8<---------------cut here---------------end--------------->8---




Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Tue, 13 Oct 2020 17:13:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: 43769 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org, me <at> tobias.gr, zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest
 it.
Date: Tue, 13 Oct 2020 19:12:03 +0200
Fixes <https://bugs.gnu.org/43744>.

* etc/guix-install.sh (chk_sys_nscd): New function to check if the service
'nscd is running, otherwise suggest to install distribution-wide.
---
 etc/guix-install.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index f51a1b653f..7f0dd00e53 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -55,6 +55,7 @@ REQUIRE=(
 
 PAS=$'[ \033[32;1mPASS\033[0m ] '
 ERR=$'[ \033[31;1mFAIL\033[0m ] '
+WAR=$'[ \033[33;1mWARN\033[0m ] '
 INF="[ INFO ] "
 
 DEBUG=0
@@ -200,6 +201,19 @@ chk_sys_arch()
     ARCH_OS="${arch}-${os}"
 }
 
+chk_sys_nscd()
+{ # Check if nscd is up and suggest to start it or install it
+    if [ "$(type -P pidof)" ]; then
+        if [ ! "$(pidof nscd)" ]; then
+            _msg "${WAR}We recommend installing and/or starting your distribution 'nscd' service"
+            _msg "${WAR}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
+        fi
+    else
+        _msg "${INF}We cannot determine if your distribution 'nscd' service is running"
+        _msg "${INF}Please read 'info guix \"Application Setup\"' about \"Name Service Switch\""
+    fi
+}
+
 # ------------------------------------------------------------------------------
 #+MAIN
 
@@ -523,6 +537,7 @@ main()
     chk_gpg_keyring
     chk_init_sys
     chk_sys_arch
+    chk_sys_nscd
 
     _msg "${INF}system is ${ARCH_OS}"
 
-- 
2.28.0





Information forwarded to guix-patches <at> gnu.org:
bug#43769; Package guix-patches. (Tue, 13 Oct 2020 17:13:02 GMT) Full text and rfc822 format available.

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

From: zimoun <zimon.toutoune <at> gmail.com>
To: 43769 <at> debbugs.gnu.org
Cc: ludo <at> gnu.org, me <at> tobias.gr, zimoun <zimon.toutoune <at> gmail.com>
Subject: [PATCH v3 1/2] guix-install.sh: Add symbolic links for supported
 shell completions.
Date: Tue, 13 Oct 2020 19:12:04 +0200
Fixes <https://bugs.gnu.org/43744>.

* etc/guix-install.sh (sys_create_shell_completion): New function to add
system wide all the symlinks for supported shell completions.
---
 etc/guix-install.sh | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index eb7205a261..f51a1b653f 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -5,6 +5,7 @@
 # Copyright © 2018 Efraim Flashner <efraim <at> flashner.co.il>
 # Copyright © 2019, 2020 Tobias Geerinckx-Rice <me <at> tobias.gr>
 # Copyright © 2020 Morgan Smith <Morgan.J.Smith <at> outlook.com>
+# Copyright © 2020 Simon Tournier <zimon.toutoune <at> gmail.com>
 #
 # This file is part of GNU Guix.
 #
@@ -459,6 +460,26 @@ export XDG_DATA_DIRS="$GUIX_PROFILE/share:${XDG_DATA_DIRS:-/usr/local/share/:/us
 EOF
 }
 
+sys_create_shell_completion()
+{ # Symlink supported shell completions system-wide
+
+    var_guix=/var/guix/profiles/per-user/root/current-guix
+    bash_completion=/etc/bash_completion.d
+    zsh_completion=/usr/share/zsh/site-functions
+    fish_completion=/usr/share/fish/vendor_completions.d
+
+    { # Just in case
+        for dir_shell in $bash_completion $zsh_completion $fish_completion; do
+            [ -d "$dir_shell" ] || mkdir -p $dir_shell
+        done;
+
+        ln -sf ${var_guix}/etc/bash_completion.d/* "$bash_completion";
+        ln -sf ${var_guix}/share/zsh/site-functions/* "$zsh_completion";
+        ln -sf ${var_guix}/share/fish/vendor_completions.d/* "$fish_completion"; } &&
+        _msg "${PAS}installed shell completion"
+}
+
+
 welcome()
 {
     cat<<"EOF"
@@ -516,6 +537,7 @@ main()
     sys_enable_guix_daemon
     sys_authorize_build_farms
     sys_create_init_profile
+    sys_create_shell_completion
 
     _msg "${INF}cleaning up ${tmp_path}"
     rm -r "${tmp_path}"
-- 
2.28.0





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Fri, 16 Oct 2020 09:40:01 GMT) Full text and rfc822 format available.

Notification sent to zimoun <zimon.toutoune <at> gmail.com>:
bug acknowledged by developer. (Fri, 16 Oct 2020 09:40:01 GMT) Full text and rfc822 format available.

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

From: Ludovic Courtès <ludo <at> gnu.org>
To: zimoun <zimon.toutoune <at> gmail.com>
Cc: me <at> tobias.gr, 43769-done <at> debbugs.gnu.org
Subject: Re: [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and
 suggest it.
Date: Fri, 16 Oct 2020 11:39:22 +0200
Hello,

zimoun <zimon.toutoune <at> gmail.com> skribis:

> Fixes <https://bugs.gnu.org/43744>.
>
> * etc/guix-install.sh (chk_sys_nscd): New function to check if the service
> 'nscd is running, otherwise suggest to install distribution-wide.

[...]

> Fixes <https://bugs.gnu.org/43744>.
>
> * etc/guix-install.sh (sys_create_shell_completion): New function to add
> system wide all the symlinks for supported shell completions.

Applied, thanks!

Ludo’.




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

This bug report was last modified 4 years and 277 days ago.

Previous Next


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