GNU bug report logs -
#58345
[PATCH 0/3] Customize PS1 on foreign distributions
Previous Next
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 58345 in the body.
You can then email your comments to 58345 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
guix-patches <at> gnu.org
:
bug#58345
; Package
guix-patches
.
(Fri, 07 Oct 2022 05:28:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
guix-patches <at> gnu.org
.
(Fri, 07 Oct 2022 05:28:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
Hi!
The following fixes a usability issue, which is that users entering 'guix
shell' or 'guix environment' would not have any visual feedback in the prompt
about where they are. I've tested it on three different foreign
distributions, and it worked well on all of them.
Thanks,
Maxim Cournoyer (3):
guix-install.sh: Improve prompt_yes_no procedure.
guix-install.sh: Introduce 'die' utility function.
guix-install.sh: Add Bash prompt customization option.
etc/guix-install.sh | 69 +++++++++++++++++++++++++++++++--------------
1 file changed, 48 insertions(+), 21 deletions(-)
--
2.37.3
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58345
; Package
guix-patches
.
(Fri, 07 Oct 2022 05:33:01 GMT)
Full text and
rfc822 format available.
Message #8 received at 58345 <at> debbugs.gnu.org (full text, mbox):
* etc/guix-install.sh (die): New function.
(chk_sys_arch): Use it.
(guix_get_bin_list, guix_get_bin, sys_create_store): Likewise.
---
etc/guix-install.sh | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 8c05d19657..6bf70b7941 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -99,6 +99,11 @@ _flush()
done
}
+die()
+{
+ _err "${ERR}$*"
+}
+
# Return true if user answered yes, false otherwise. It defaults to "yes"
# when a single newline character is input.
# $1: The prompt question.
@@ -230,8 +235,7 @@ chk_sys_arch()
local arch=powerpc64le
;;
*)
- _err "${ERR}Unsupported CPU type: ${arch}"
- exit 1
+ die "Unsupported CPU type: ${arch}"
esac
case "$os" in
@@ -239,8 +243,7 @@ chk_sys_arch()
local os=linux
;;
*)
- _err "${ERR}Your operation system (${os}) is not supported."
- exit 1
+ die "Your operation system (${os}) is not supported."
esac
ARCH_OS="${arch}-${os}"
@@ -295,8 +298,7 @@ guix_get_bin_list()
if [[ "${#bin_ver_ls}" -ne "0" ]]; then
_msg "${PAS}Release for your system: ${default_ver}"
else
- _err "${ERR}Could not obtain list of Guix releases."
- exit 1
+ die "Could not obtain list of Guix releases."
fi
# Use default to download according to the list and local ARCH_OS.
@@ -321,8 +323,7 @@ guix_get_bin()
"${url}/${bin_ver}.tar.xz" "${url}/${bin_ver}.tar.xz.sig"; then
_msg "${PAS}download completed."
else
- _err "${ERR}could not download ${url}/${bin_ver}.tar.xz."
- exit 1
+ die "could not download ${url}/${bin_ver}.tar.xz."
fi
pushd "${dl_path}" >/dev/null
@@ -330,8 +331,7 @@ guix_get_bin()
_msg "${PAS}Signature is valid."
popd >/dev/null
else
- _err "${ERR}could not verify the signature."
- exit 1
+ die "could not verify the signature."
fi
}
@@ -343,8 +343,7 @@ sys_create_store()
_debug "--- [ ${FUNCNAME[0]} ] ---"
if [[ -e "/var/guix" || -e "/gnu" ]]; then
- _err "${ERR}A previous Guix installation was found. Refusing to overwrite."
- exit 1
+ die "A previous Guix installation was found. Refusing to overwrite."
fi
cd "$tmp_path"
--
2.37.3
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58345
; Package
guix-patches
.
(Fri, 07 Oct 2022 05:33:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 58345 <at> debbugs.gnu.org (full text, mbox):
* etc/guix-install.sh (_flush): New function.
(prompt_yes_no): Clear input, then only read the first character, silently.
Add the [Yes/no] string to the message. When a newline is entered by the
user, treat it as the default value, which is "yes".
(chk_gpg_keyring): Remove "(yes/no)" from the prompt message.
(configure_substitute_discovery): Likewise.
(sys_authorize_build_farms): Likewise.
---
etc/guix-install.sh | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 300681e111..8c05d19657 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -9,7 +9,7 @@
# Copyright © 2020 Daniel Brooks <db48x <at> db48x.net>
# Copyright © 2021 Jakub Kądziołka <kuba <at> kadziolka.net>
# Copyright © 2021 Chris Marusich <cmmarusich <at> gmail.com>
-# Copyright © 2021 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
+# Copyright © 2021, 2022 Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
#
# This file is part of GNU Guix.
#
@@ -92,15 +92,25 @@ _debug()
fi
}
-# Return true if user answered yes, false otherwise.
+_flush()
+{
+ while read -t0; do
+ read -N1
+ done
+}
+
+# Return true if user answered yes, false otherwise. It defaults to "yes"
+# when a single newline character is input.
# $1: The prompt question.
prompt_yes_no() {
while true; do
- read -rp "$1 " yn
+ _flush
+ read -N1 -rsp "$1 [Y/n]" yn
case $yn in
- [Yy]*) return 0;;
- [Nn]*) return 1;;
- *) _msg "Please answer yes or no."
+ $'\n') echo && return 0;;
+ [Yy]*) echo && return 0;;
+ [Nn]*) echo && return 1;;
+ *) echo && _msg "Please answer yes or no."
esac
done
}
@@ -137,7 +147,7 @@ chk_gpg_keyring()
if ! gpg --dry-run --list-keys "$gpg_key_id" >/dev/null 2>&1; then
if prompt_yes_no "${INF}The following OpenPGP public key is \
required to verify the Guix binary signature: $gpg_key_id.
-Would you like me to fetch it for you? (yes/no)"; then
+Would you like me to fetch it for you?"; then
wget "https://sv.gnu.org/people/viewgpg.php?user_id=$user_id" \
--no-verbose -O- | gpg --import -
else
@@ -254,7 +264,7 @@ chk_sys_nscd()
configure_substitute_discovery() {
if grep -q -- '--discover=no' "$1" && \
prompt_yes_no "Would you like the Guix daemon to automatically \
-discover substitute servers on the local network? (yes/no)"; then
+discover substitute servers on the local network?"; then
sed -i 's/--discover=no/--discover=yes/' "$1"
fi
}
@@ -490,7 +500,7 @@ sys_enable_guix_daemon()
sys_authorize_build_farms()
{ # authorize the public key of the build farm
if prompt_yes_no "Permit downloading pre-built package binaries from the \
-project's build farm? (yes/no)"; then
+project's build farm?"; then
guix archive --authorize \
< ~root/.config/guix/current/share/guix/ci.guix.gnu.org.pub \
&& _msg "${PAS}Authorized public key for ci.guix.gnu.org"
--
2.37.3
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58345
; Package
guix-patches
.
(Fri, 07 Oct 2022 05:33:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 58345 <at> debbugs.gnu.org (full text, mbox):
* etc/guix-install.sh (sys_customize_bashrc): New function.
(main): Use it.
---
etc/guix-install.sh | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 6bf70b7941..2b304d1bdc 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -566,6 +566,23 @@ sys_create_shell_completion()
_msg "${PAS}installed shell completion"
}
+sys_customize_bashrc()
+{
+ prompt_yes_no "Customize users Bash shell prompt for Guix?" || return
+ for bashrc in /home/*/.bashrc /root/.bashrc; do
+ test -f "$bashrc" || continue
+ grep -Fq '$GUIX_ENVIRONMENT' "$bashrc" && continue
+ cp "${bashrc}" "${bashrc}.bak"
+ echo '
+if [ -n "$GUIX_ENVIRONMENT" ]; then
+ if [[ $PS1 =~ (.*)"\\$" ]]; then
+ PS1="${BASH_REMATCH[1]} [env]\\\$ "
+ fi
+fi
+' >> "$bashrc"
+ done
+ _msg "${PAS}Bash shell prompt successfully customized for Guix"
+}
welcome()
{
@@ -635,6 +652,7 @@ main()
sys_authorize_build_farms
sys_create_init_profile
sys_create_shell_completion
+ sys_customize_bashrc
_msg "${INF}cleaning up ${tmp_path}"
rm -r "${tmp_path}"
--
2.37.3
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58345
; Package
guix-patches
.
(Fri, 07 Oct 2022 08:35:03 GMT)
Full text and
rfc822 format available.
Message #17 received at 58345 <at> debbugs.gnu.org (full text, mbox):
Hi Maxim,
On ven., 07 oct. 2022 at 01:32, Maxim Cournoyer <maxim.cournoyer <at> gmail.com> wrote:
> * etc/guix-install.sh (sys_customize_bashrc): New function.
> (main): Use it.
Nice idea!
> +sys_customize_bashrc()
> +{
> + prompt_yes_no "Customize users Bash shell prompt for Guix?" || return
> + for bashrc in /home/*/.bashrc /root/.bashrc; do
> + test -f "$bashrc" || continue
> + grep -Fq '$GUIX_ENVIRONMENT' "$bashrc" && continue
> + cp "${bashrc}" "${bashrc}.bak"
> + echo '
Maybe comment, something like:
# Automatically added by Guix install script
> +if [ -n "$GUIX_ENVIRONMENT" ]; then
> + if [[ $PS1 =~ (.*)"\\$" ]]; then
> + PS1="${BASH_REMATCH[1]} [env]\\\$ "
> + fi
> +fi
> +' >> "$bashrc"
> + done
> + _msg "${PAS}Bash shell prompt successfully customized for Guix"
> +}
LGTM!
Cheers,
simon
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58345
; Package
guix-patches
.
(Fri, 07 Oct 2022 08:36:02 GMT)
Full text and
rfc822 format available.
Message #20 received at 58345 <at> debbugs.gnu.org (full text, mbox):
Hi Maxim,
On ven., 07 oct. 2022 at 01:31, Maxim Cournoyer <maxim.cournoyer <at> gmail.com> wrote:
> +die()
> +{
> + _err "${ERR}$*"
> +}
> +
[...]
> - _err "${ERR}Unsupported CPU type: ${arch}"
> - exit 1
> + die "Unsupported CPU type: ${arch}"
This new script using ’die’, does it exit correctly and return an
appropriated exit code on failure?
Cheers,
simon
Information forwarded
to
guix-patches <at> gnu.org
:
bug#58345
; Package
guix-patches
.
(Fri, 07 Oct 2022 12:24:02 GMT)
Full text and
rfc822 format available.
Message #23 received at 58345 <at> debbugs.gnu.org (full text, mbox):
Hello,
zimoun <zimon.toutoune <at> gmail.com> writes:
> Hi Maxim,
>
> On ven., 07 oct. 2022 at 01:31, Maxim Cournoyer <maxim.cournoyer <at> gmail.com> wrote:
>
>> +die()
>> +{
>> + _err "${ERR}$*"
>> +}
>> +
>
> [...]
>
>> - _err "${ERR}Unsupported CPU type: ${arch}"
>> - exit 1
>> + die "Unsupported CPU type: ${arch}"
>
> This new script using ’die’, does it exit correctly and return an
> appropriated exit code on failure?
Good catch, I had forgotten to include "exit 1" after the _err call in
die().
Fixed!
--
Thanks,
Maxim
Reply sent
to
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
:
You have taken responsibility.
(Fri, 07 Oct 2022 12:30:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
:
bug acknowledged by developer.
(Fri, 07 Oct 2022 12:30:02 GMT)
Full text and
rfc822 format available.
Message #28 received at 58345-done <at> debbugs.gnu.org (full text, mbox):
Hello,
zimoun <zimon.toutoune <at> gmail.com> writes:
> Hi Maxim,
>
> On ven., 07 oct. 2022 at 01:32, Maxim Cournoyer <maxim.cournoyer <at> gmail.com> wrote:
>> * etc/guix-install.sh (sys_customize_bashrc): New function.
>> (main): Use it.
>
> Nice idea!
>
>> +sys_customize_bashrc()
>> +{
>> + prompt_yes_no "Customize users Bash shell prompt for Guix?" || return
>> + for bashrc in /home/*/.bashrc /root/.bashrc; do
>> + test -f "$bashrc" || continue
>> + grep -Fq '$GUIX_ENVIRONMENT' "$bashrc" && continue
>> + cp "${bashrc}" "${bashrc}.bak"
>> + echo '
>
> Maybe comment, something like:
>
> # Automatically added by Guix install script
>> +if [ -n "$GUIX_ENVIRONMENT" ]; then
>> + if [[ $PS1 =~ (.*)"\\$" ]]; then
>> + PS1="${BASH_REMATCH[1]} [env]\\\$ "
>> + fi
>> +fi
>> +' >> "$bashrc"
>> + done
>> + _msg "${PAS}Bash shell prompt successfully customized for Guix"
>> +}
Good idea! Applied, like:
@@ -575,6 +575,7 @@ sys_customize_bashrc()
grep -Fq '$GUIX_ENVIRONMENT' "$bashrc" && continue
cp "${bashrc}" "${bashrc}.bak"
echo '
+# Automatically added by the Guix install script.
if [ -n "$GUIX_ENVIRONMENT" ]; then
if [[ $PS1 =~ (.*)"\\$" ]]; then
PS1="${BASH_REMATCH[1]} [env]\\\$ "
>
> LGTM!
Alright, the series have been pushed to master, and the script available
at https://guix.gnu.org/install.sh should soon reflect the changes.
Thanks for reviewing!
--
Maxim
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Sat, 05 Nov 2022 11:24:05 GMT)
Full text and
rfc822 format available.
This bug report was last modified 2 years and 278 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.