all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#43769] [PATCH 0/2] guix-install.sh: Minor first user-experience tweaks
@ 2020-10-02 17:35 zimoun
  2020-10-02 17:40 ` [bug#43769] [PATCH 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
                   ` (3 more replies)
  0 siblings, 4 replies; 17+ messages in thread
From: zimoun @ 2020-10-02 17:35 UTC (permalink / raw)
  To: 43769; +Cc: zimoun

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





^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH 1/2] guix-install.sh: Add symbolic links for supported shell completions.
  2020-10-02 17:35 [bug#43769] [PATCH 0/2] guix-install.sh: Minor first user-experience tweaks zimoun
@ 2020-10-02 17:40 ` zimoun
  2020-10-02 17:42 ` [bug#43769] [PATCH 2/2] guix-install.sh: Check the daemon 'nscd' and suggest it zimoun
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: zimoun @ 2020-10-02 17:40 UTC (permalink / raw)
  To: 43769; +Cc: zimoun

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@flashner.co.il>
 # Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 # Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
+# Copyright © 2020 Simon Tournier <zimon.toutoune@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





^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH 2/2] guix-install.sh: Check the daemon 'nscd' and suggest it.
  2020-10-02 17:35 [bug#43769] [PATCH 0/2] guix-install.sh: Minor first user-experience tweaks zimoun
  2020-10-02 17:40 ` [bug#43769] [PATCH 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
@ 2020-10-02 17:42 ` zimoun
  2020-10-03 18:44 ` [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
  2020-10-13 17:12 ` [bug#43769] [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it zimoun
  3 siblings, 0 replies; 17+ messages in thread
From: zimoun @ 2020-10-02 17:42 UTC (permalink / raw)
  To: 43769; +Cc: zimoun

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





^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions.
  2020-10-02 17:35 [bug#43769] [PATCH 0/2] guix-install.sh: Minor first user-experience tweaks zimoun
  2020-10-02 17:40 ` [bug#43769] [PATCH 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
  2020-10-02 17:42 ` [bug#43769] [PATCH 2/2] guix-install.sh: Check the daemon 'nscd' and suggest it zimoun
@ 2020-10-03 18:44 ` zimoun
  2020-10-03 18:44   ` [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it zimoun
  2020-10-03 19:11   ` [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions Tobias Geerinckx-Rice via Guix-patches via
  2020-10-13 17:12 ` [bug#43769] [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it zimoun
  3 siblings, 2 replies; 17+ messages in thread
From: zimoun @ 2020-10-03 18:44 UTC (permalink / raw)
  To: 43769; +Cc: zimoun

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@flashner.co.il>
 # Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 # Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
+# Copyright © 2020 Simon Tournier <zimon.toutoune@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





^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
  2020-10-03 18:44 ` [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
@ 2020-10-03 18:44   ` zimoun
  2020-10-03 19:14     ` Tobias Geerinckx-Rice via Guix-patches via
  2020-10-03 19:11   ` [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions Tobias Geerinckx-Rice via Guix-patches via
  1 sibling, 1 reply; 17+ messages in thread
From: zimoun @ 2020-10-03 18:44 UTC (permalink / raw)
  To: 43769; +Cc: zimoun

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





^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions.
  2020-10-03 18:44 ` [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
  2020-10-03 18:44   ` [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it zimoun
@ 2020-10-03 19:11   ` Tobias Geerinckx-Rice via Guix-patches via
  2020-10-05  8:09     ` Ludovic Courtès
  1 sibling, 1 reply; 17+ messages in thread
From: Tobias Geerinckx-Rice via Guix-patches via @ 2020-10-03 19:11 UTC (permalink / raw)
  To: zimoun; +Cc: 43769

[-- Attachment #1: Type: text/plain, Size: 514 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
  2020-10-03 18:44   ` [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it zimoun
@ 2020-10-03 19:14     ` Tobias Geerinckx-Rice via Guix-patches via
  2020-10-05  8:08       ` Ludovic Courtès
  0 siblings, 1 reply; 17+ messages in thread
From: Tobias Geerinckx-Rice via Guix-patches via @ 2020-10-03 19:14 UTC (permalink / raw)
  To: zimoun; +Cc: 43769

[-- Attachment #1: Type: text/plain, Size: 2529 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
  2020-10-03 19:14     ` Tobias Geerinckx-Rice via Guix-patches via
@ 2020-10-05  8:08       ` Ludovic Courtès
  2020-10-05  9:19         ` zimoun
  2020-10-05 12:28         ` Tobias Geerinckx-Rice via Guix-patches via
  0 siblings, 2 replies; 17+ messages in thread
From: Ludovic Courtès @ 2020-10-05  8:08 UTC (permalink / raw)
  To: Tobias Geerinckx-Rice; +Cc: 43769, zimoun

Hi Tobias,

Tobias Geerinckx-Rice <me@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’.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions.
  2020-10-03 19:11   ` [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions Tobias Geerinckx-Rice via Guix-patches via
@ 2020-10-05  8:09     ` Ludovic Courtès
  2020-10-05  9:23       ` zimoun
  0 siblings, 1 reply; 17+ messages in thread
From: Ludovic Courtès @ 2020-10-05  8:09 UTC (permalink / raw)
  To: Tobias Geerinckx-Rice; +Cc: 43769, zimoun

Hi,

Tobias Geerinckx-Rice <me@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’.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
  2020-10-05  8:08       ` Ludovic Courtès
@ 2020-10-05  9:19         ` zimoun
  2020-10-05 12:28         ` Tobias Geerinckx-Rice via Guix-patches via
  1 sibling, 0 replies; 17+ messages in thread
From: zimoun @ 2020-10-05  9:19 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Tobias Geerinckx-Rice, 43769

On Mon, 5 Oct 2020 at 10:08, Ludovic Courtès <ludo@gnu.org> wrote:
> Tobias Geerinckx-Rice <me@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




^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions.
  2020-10-05  8:09     ` Ludovic Courtès
@ 2020-10-05  9:23       ` zimoun
  2020-10-05 12:02         ` Ludovic Courtès
  0 siblings, 1 reply; 17+ messages in thread
From: zimoun @ 2020-10-05  9:23 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Tobias Geerinckx-Rice, 43769

On Mon, 5 Oct 2020 at 10:09, Ludovic Courtès <ludo@gnu.org> wrote:
> Tobias Geerinckx-Rice <me@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




^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions.
  2020-10-05  9:23       ` zimoun
@ 2020-10-05 12:02         ` Ludovic Courtès
  0 siblings, 0 replies; 17+ messages in thread
From: Ludovic Courtès @ 2020-10-05 12:02 UTC (permalink / raw)
  To: zimoun; +Cc: Tobias Geerinckx-Rice, 43769

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

> On Mon, 5 Oct 2020 at 10:09, Ludovic Courtès <ludo@gnu.org> wrote:
>> Tobias Geerinckx-Rice <me@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’.




^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
  2020-10-05  8:08       ` Ludovic Courtès
  2020-10-05  9:19         ` zimoun
@ 2020-10-05 12:28         ` Tobias Geerinckx-Rice via Guix-patches via
  2020-10-13 16:45           ` zimoun
  1 sibling, 1 reply; 17+ messages in thread
From: Tobias Geerinckx-Rice via Guix-patches via @ 2020-10-05 12:28 UTC (permalink / raw)
  To: Ludovic Courtès, zimoun; +Cc: 43769

[-- Attachment #1: Type: text/plain, Size: 1168 bytes --]

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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
  2020-10-05 12:28         ` Tobias Geerinckx-Rice via Guix-patches via
@ 2020-10-13 16:45           ` zimoun
  0 siblings, 0 replies; 17+ messages in thread
From: zimoun @ 2020-10-13 16:45 UTC (permalink / raw)
  To: Tobias Geerinckx-Rice; +Cc: Ludovic Courtès, 43769


>> 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---




^ permalink raw reply	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
  2020-10-02 17:35 [bug#43769] [PATCH 0/2] guix-install.sh: Minor first user-experience tweaks zimoun
                   ` (2 preceding siblings ...)
  2020-10-03 18:44 ` [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
@ 2020-10-13 17:12 ` zimoun
  2020-10-13 17:12   ` [bug#43769] [PATCH v3 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
  2020-10-16  9:39   ` bug#43769: [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it Ludovic Courtès
  3 siblings, 2 replies; 17+ messages in thread
From: zimoun @ 2020-10-13 17:12 UTC (permalink / raw)
  To: 43769; +Cc: ludo, me, zimoun

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





^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [bug#43769] [PATCH v3 1/2] guix-install.sh: Add symbolic links for supported shell completions.
  2020-10-13 17:12 ` [bug#43769] [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it zimoun
@ 2020-10-13 17:12   ` zimoun
  2020-10-16  9:39   ` bug#43769: [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it Ludovic Courtès
  1 sibling, 0 replies; 17+ messages in thread
From: zimoun @ 2020-10-13 17:12 UTC (permalink / raw)
  To: 43769; +Cc: ludo, me, zimoun

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@flashner.co.il>
 # Copyright © 2019, 2020 Tobias Geerinckx-Rice <me@tobias.gr>
 # Copyright © 2020 Morgan Smith <Morgan.J.Smith@outlook.com>
+# Copyright © 2020 Simon Tournier <zimon.toutoune@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





^ permalink raw reply related	[flat|nested] 17+ messages in thread

* bug#43769: [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
  2020-10-13 17:12 ` [bug#43769] [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it zimoun
  2020-10-13 17:12   ` [bug#43769] [PATCH v3 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
@ 2020-10-16  9:39   ` Ludovic Courtès
  1 sibling, 0 replies; 17+ messages in thread
From: Ludovic Courtès @ 2020-10-16  9:39 UTC (permalink / raw)
  To: zimoun; +Cc: me, 43769-done

Hello,

zimoun <zimon.toutoune@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’.




^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-10-16  9:40 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-02 17:35 [bug#43769] [PATCH 0/2] guix-install.sh: Minor first user-experience tweaks zimoun
2020-10-02 17:40 ` [bug#43769] [PATCH 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
2020-10-02 17:42 ` [bug#43769] [PATCH 2/2] guix-install.sh: Check the daemon 'nscd' and suggest it zimoun
2020-10-03 18:44 ` [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
2020-10-03 18:44   ` [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it zimoun
2020-10-03 19:14     ` Tobias Geerinckx-Rice via Guix-patches via
2020-10-05  8:08       ` Ludovic Courtès
2020-10-05  9:19         ` zimoun
2020-10-05 12:28         ` Tobias Geerinckx-Rice via Guix-patches via
2020-10-13 16:45           ` zimoun
2020-10-03 19:11   ` [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions Tobias Geerinckx-Rice via Guix-patches via
2020-10-05  8:09     ` Ludovic Courtès
2020-10-05  9:23       ` zimoun
2020-10-05 12:02         ` Ludovic Courtès
2020-10-13 17:12 ` [bug#43769] [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it zimoun
2020-10-13 17:12   ` [bug#43769] [PATCH v3 1/2] guix-install.sh: Add symbolic links for supported shell completions zimoun
2020-10-16  9:39   ` bug#43769: [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it Ludovic Courtès

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.