[PATCH 0/2] guix-install.sh: Minor first user-experience tweaks

  • Done
  • quality assurance status badge
Details
3 participants
  • Ludovic Courtès
  • Tobias Geerinckx-Rice
  • zimoun
Owner
unassigned
Submitted by
zimoun
Severity
normal
Z
Z
zimoun wrote on 2 Oct 2020 19:35
(address . guix-patches@gnu.org)(name . zimoun)(address . zimon.toutoune@gmail.com)
20201002173537.12045-1-zimon.toutoune@gmail.com
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?




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
Z
Z
zimoun wrote on 2 Oct 2020 19:40
[PATCH 1/2] guix-install.sh: Add symbolic links for supported shell completions.
(address . 43769@debbugs.gnu.org)(name . zimoun)(address . zimon.toutoune@gmail.com)
20201002174030.13819-1-zimon.toutoune@gmail.com

* 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(+)

Toggle diff (59 lines)
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
Z
Z
zimoun wrote on 2 Oct 2020 19:42
[PATCH 2/2] guix-install.sh: Check the daemon 'nscd' and suggest it.
(address . 43769@debbugs.gnu.org)(name . zimoun)(address . zimon.toutoune@gmail.com)
20201002174211.14467-1-zimon.toutoune@gmail.com

* 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(+)

Toggle diff (34 lines)
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
Z
Z
zimoun wrote on 3 Oct 2020 20:44
[PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions.
(address . 43769@debbugs.gnu.org)(name . zimoun)(address . zimon.toutoune@gmail.com)
20201003184447.9542-1-zimon.toutoune@gmail.com

* 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(+)

Toggle diff (59 lines)
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
Z
Z
zimoun wrote on 3 Oct 2020 20:44
[PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
(address . 43769@debbugs.gnu.org)(name . zimoun)(address . zimon.toutoune@gmail.com)
20201003184447.9542-2-zimon.toutoune@gmail.com

* 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(-)

Toggle diff (102 lines)
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
T
T
Tobias Geerinckx-Rice wrote on 3 Oct 2020 21:11
Re: [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions.
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 43769@debbugs.gnu.org)
87pn5z9lb5.fsf@nckx
Zimoun,

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

Nitpick: s/create/install/

zimoun ???
Toggle quote (5 lines)
> + [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
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCX3jM3g0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15aAUBAJihwdBr5VVPWFmaEHVIhpiIDTJFqfTIePWXxlbw
bvadAQDqTJZza69KvA+FCJ3YdvlDLmdem2YBS/Y4e8V8PSRvAw==
=pdM5
-----END PGP SIGNATURE-----

T
T
Tobias Geerinckx-Rice wrote on 3 Oct 2020 21:14
Re: [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
(name . zimoun)(address . zimon.toutoune@gmail.com)(address . 43769@debbugs.gnu.org)
87mu139l5e.fsf@nckx
Zimoun,

zimoun ???
Toggle quote (5 lines)
> * 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.

Toggle quote (68 lines)
> 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
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCX3jNrQ0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15y+YBAOvBUaQM/r+2RgPv+dn6rjx0m2psAea/mSv6zybn
hx+eAP0XyNbQRZCbZyf+CuuJBKURYKpF9zof37oAhYw8NQq+BA==
=7xBj
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 5 Oct 2020 10:08
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)
87lfgl5c3f.fsf@gnu.org
Hi Tobias,

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

Toggle quote (9 lines)
> 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’.
L
L
Ludovic Courtès wrote on 5 Oct 2020 10:09
Re: [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions.
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)
87h7r95c1a.fsf@gnu.org
Hi,

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

Toggle quote (4 lines)
> 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’.
Z
Z
zimoun wrote on 5 Oct 2020 11:19
Re: [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
(name . Ludovic Courtès)(address . ludo@gnu.org)
CAJ3okZ3eDidZ_MUCa0DX5xPRYGc9QFhuFpxJhnnyqmP8QURhVA@mail.gmail.com
On Mon, 5 Oct 2020 at 10:08, Ludovic Courtès <ludo@gnu.org> wrote:
Toggle quote (14 lines)
> 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
Z
Z
zimoun wrote on 5 Oct 2020 11:23
Re: [bug#43769] [PATCH v2 1/2] guix-install.sh: Add symbolic links for supported shell completions.
(name . Ludovic Courtès)(address . ludo@gnu.org)
CAJ3okZ2EmZoJY4x8D1rkYAt=98xQzgnED1pjyo0u2PVrD8=mcQ@mail.gmail.com
On Mon, 5 Oct 2020 at 10:09, Ludovic Courtès <ludo@gnu.org> wrote:
Toggle quote (9 lines)
> 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
L
L
Ludovic Courtès wrote on 5 Oct 2020 14:02
(name . zimoun)(address . zimon.toutoune@gmail.com)
87a6x03mpm.fsf@gnu.org
zimoun <zimon.toutoune@gmail.com> skribis:

Toggle quote (13 lines)
> 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.)

Toggle quote (5 lines)
> 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’.
T
T
Tobias Geerinckx-Rice wrote on 5 Oct 2020 14:28
Re: [bug#43769] [PATCH v2 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
(address . 43769@debbugs.gnu.org)
878sckambe.fsf@nckx
Ludo', Zimoun,

Ludovic Courtès ???
Toggle quote (10 lines)
>> 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 ???
Toggle quote (3 lines)
> 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
-----BEGIN PGP SIGNATURE-----

iIMEARYKACsWIQT12iAyS4c9C3o4dnINsP+IT1VteQUCX3sRhQ0cbWVAdG9iaWFz
LmdyAAoJEA2w/4hPVW15xnwA/3ZfOGaOi4ugbO+Wwt+NdbFDsPEqSGVwTkbtoR88
C83iAP9m7lvBp/2XP8Cu8iQdBw9oU/XiwwWXn+7bTUrIISxGCA==
=2Ry2
-----END PGP SIGNATURE-----

Z
Z
zimoun wrote on 13 Oct 2020 18:45
(name . Tobias Geerinckx-Rice)(address . me@tobias.gr)
86o8l6jcrn.fsf@gmail.com
Toggle quote (18 lines)
>> 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

Toggle snippet (58 lines)
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
}
Z
Z
zimoun wrote on 13 Oct 2020 19:12
[PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
(address . 43769@debbugs.gnu.org)
20201013171204.14708-1-zimon.toutoune@gmail.com

* 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(+)

Toggle diff (42 lines)
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
Z
Z
zimoun wrote on 13 Oct 2020 19:12
[PATCH v3 1/2] guix-install.sh: Add symbolic links for supported shell completions.
(address . 43769@debbugs.gnu.org)
20201013171204.14708-2-zimon.toutoune@gmail.com

* 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(+)

Toggle diff (49 lines)
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
L
L
Ludovic Courtès wrote on 16 Oct 2020 11:39
Re: [PATCH v3 2/2] guix-install.sh: Check the service 'nscd' and suggest it.
(name . zimoun)(address . zimon.toutoune@gmail.com)
87k0vq8q7p.fsf@gnu.org
Hello,

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

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

[...]

Toggle quote (5 lines)
>
> * etc/guix-install.sh (sys_create_shell_completion): New function to add
> system wide all the symlinks for supported shell completions.

Applied, thanks!

Ludo’.
Closed
?