GNU bug report logs - #33134
[PATCH 0/1] guix-install.sh: Add ability to run it non-interactively.

Previous Next

Package: guix-patches;

Reported by: rsiddharth <s <at> ricketyspace.net>

Date: Wed, 24 Oct 2018 00:17:01 UTC

Severity: normal

Tags: patch

Done: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>

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 33134 in the body.
You can then email your comments to 33134 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#33134; Package guix-patches. (Wed, 24 Oct 2018 00:17:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to rsiddharth <s <at> ricketyspace.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 24 Oct 2018 00:17:02 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: guix-patches <at> gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively.
Date: Tue, 23 Oct 2018 20:15:42 -0400
I want to be able to run the guix-install.sh non-interactively[1] like this:

   echo "yy" | guix-install.sh

   (One "y" for "Press return to continue..." prompt, the other "y" for
   "Permit downloading pre-built package binaries from the project's build
   farms? (yes/no)" prompt).

Currently, the `read` in welcome function reads both the "y". I updated it to
read just one character.

[1]: https://git.ricketyspace.net/propellor/tree/config.hs?id=0cddd47ef#n640

rsiddharth (1):
  guix-install.sh: Update welcome.

 etc/guix-install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Wed, 24 Oct 2018 00:22:02 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 1/1] guix-install.sh: Update welcome.
Date: Tue, 23 Oct 2018 20:21:14 -0400
* etc/guix-install.sh (welcome): Read exactly one character from input.
---
 etc/guix-install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index ca6874ba0..cf839c20e 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -398,7 +398,7 @@ This script installs GNU Guix on your system
 https://www.gnu.org/software/guix/
 EOF
     echo -n "Press return to continue..."
-    read -r  ANSWER
+    read -N 1 -r  ANSWER
 }
 
 main()
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Wed, 24 Oct 2018 11:55:01 GMT) Full text and rfc822 format available.

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

From: Efraim Flashner <efraim <at> flashner.co.il>
To: rsiddharth <s <at> ricketyspace.net>
Cc: 33134 <at> debbugs.gnu.org
Subject: Re: [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it
 non-interactively.
Date: Wed, 24 Oct 2018 14:54:43 +0300
[Message part 1 (text/plain, inline)]
On Tue, Oct 23, 2018 at 08:15:42PM -0400, rsiddharth wrote:
> I want to be able to run the guix-install.sh non-interactively[1] like this:
> 
>    echo "yy" | guix-install.sh
> 
>    (One "y" for "Press return to continue..." prompt, the other "y" for
>    "Permit downloading pre-built package binaries from the project's build
>    farms? (yes/no)" prompt).
> 
> Currently, the `read` in welcome function reads both the "y". I updated it to
> read just one character.
> 

would this work? echo "y\ny" | guix-install.sh

-- 
Efraim Flashner   <efraim <at> flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Wed, 24 Oct 2018 13:25:02 GMT) Full text and rfc822 format available.

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

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 33134 <at> debbugs.gnu.org, rsiddharth <s <at> ricketyspace.net>
Subject: Re: [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it
 non-interactively.
Date: Wed, 24 Oct 2018 15:24:03 +0200
rsiddharth, Efraim,

Efraim Flashner wrote:
> On Tue, Oct 23, 2018 at 08:15:42PM -0400, rsiddharth wrote:
>> I want to be able to run the guix-install.sh 
>> non-interactively[1] like this:
>> 
>>    echo "yy" | guix-install.sh
>> 
>>    (One "y" for "Press return to continue..." prompt, the other 
>>    "y" for
>>    "Permit downloading pre-built package binaries from the 
>>    project's build
>>    farms? (yes/no)" prompt).
>> 
>> Currently, the `read` in welcome function reads both the "y". I 
>> updated it to
>> read just one character.
>> 
>
> would this work? echo "y\ny" | guix-install.sh

Not quite, but

 $ echo -e "y\ny" | guix-install.sh

will. Or the more conventional

 $ yes | guix-install.sh # untested

providing guix-install.sh doesn't choke on that infinite stream of 
"y"s. Which it might, and even if it doesn't now, there's no 
guarantee that this dirty hack won't break the future.

If this is something we want to support, it could be done more 
better through a '--non-interactive' or '--force' flag that skips 
these and any future prompts at the source.

Non?

T G-R




Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Wed, 24 Oct 2018 13:28:02 GMT) Full text and rfc822 format available.

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

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: 33134 <at> debbugs.gnu.org, rsiddharth <s <at> ricketyspace.net>
Subject: Re: [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it
 non-interactively.
Date: Wed, 24 Oct 2018 16:27:51 +0300
[Message part 1 (text/plain, inline)]
On Wed, Oct 24, 2018 at 03:24:03PM +0200, Tobias Geerinckx-Rice wrote:
> rsiddharth, Efraim,
> 
> Efraim Flashner wrote:
> > On Tue, Oct 23, 2018 at 08:15:42PM -0400, rsiddharth wrote:
> > > I want to be able to run the guix-install.sh non-interactively[1]
> > > like this:
> > > 
> > >    echo "yy" | guix-install.sh
> > > 
> > >    (One "y" for "Press return to continue..." prompt, the other
> > > "y" for
> > >    "Permit downloading pre-built package binaries from the
> > > project's build
> > >    farms? (yes/no)" prompt).
> > > 
> > > Currently, the `read` in welcome function reads both the "y". I
> > > updated it to
> > > read just one character.
> > > 
> > 
> > would this work? echo "y\ny" | guix-install.sh
> 
> Not quite, but
> 
>  $ echo -e "y\ny" | guix-install.sh
> 
> will. Or the more conventional
> 
>  $ yes | guix-install.sh # untested
> 
> providing guix-install.sh doesn't choke on that infinite stream of "y"s.
> Which it might, and even if it doesn't now, there's no guarantee that this
> dirty hack won't break the future.

This actually made me snort. "Alright! I get it! You really want it!"

> 
> If this is something we want to support, it could be done more better
> through a '--non-interactive' or '--force' flag that skips these and any
> future prompts at the source.
> 
> Non?
> 
> T G-R

This is actually something I was thinking of a while ago. I use github
as a mirror, and I definately wouldn't be against using their CI system
to install guix, 'guix pull', 'guix build -f guix.scm'.

-- 
Efraim Flashner   <efraim <at> flashner.co.il>   אפרים פלשנר
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Sat, 03 Nov 2018 01:11:02 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 0/5] Add auto yes/no switch to guix-install.sh
Date: Fri,  2 Nov 2018 21:10:19 -0400
The following patch series adds "auto yes/no" switch to the guix-install.sh
script.

It works like this:

   guix-install.sh -y

   [ for non-interactively answering 'yes' to all y/n prompts ]

   guix-install.sh -n

   [ for non-interactively answering 'no' to all y/n prompts ]

   If either the -y or the -n switch is provided, the script will skip the
   "Press return to continue..." prompt.

I'm not a bash expert; if there is a better way to do this, let me know. I
would be happy to refactor and send a fresh patch series.

rsiddharth (5):
  guix-install.sh: Update welcome.
  guix-install.sh: Add parse_args.
  guix-install.sh: Update main.
  guix-install.sh: Update welcome.
  guix-install.sh: Update sys_authorize_build_farms.

 etc/guix-install.sh | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Sat, 03 Nov 2018 01:11:02 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 1/5] guix-install.sh: Update welcome.
Date: Fri,  2 Nov 2018 21:10:34 -0400
* etc/guix-install.sh (welcome): Read exactly one character from input.
---
 etc/guix-install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index ca6874ba0..cf839c20e 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -398,7 +398,7 @@ This script installs GNU Guix on your system
 https://www.gnu.org/software/guix/
 EOF
     echo -n "Press return to continue..."
-    read -r  ANSWER
+    read -N 1 -r  ANSWER
 }
 
 main()
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Sat, 03 Nov 2018 01:11:03 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 2/5] guix-install.sh: Add parse_args.
Date: Fri,  2 Nov 2018 21:10:48 -0400
* etc/guix-install.sh (parse_args): New function.
---
 etc/guix-install.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index cf839c20e..d16f8ac59 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -370,6 +370,21 @@ sys_authorize_build_farms()
     done
 }
 
+parse_args()
+{
+    local args_num=$#
+
+    if [ $args_num -lt 1 ]; then
+        return
+    fi
+
+    # process -y / -n arg.
+    export AUTO_YN=${1:1:1}
+    if [ -z $AUTO_YN ]; then
+        export AUTO_YN=""
+    fi
+}
+
 welcome()
 {
     cat<<"EOF"
-- 
2.19.1





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

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 3/5] guix-install.sh: Update main.
Date: Fri,  2 Nov 2018 21:10:57 -0400
* etc/guix-install.sh (main): Call parse_args.
---
 etc/guix-install.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index d16f8ac59..c817b6dd8 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -418,6 +418,8 @@ EOF
 
 main()
 {
+    parse_args $@
+
     local tmp_path
     welcome
 
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Sat, 03 Nov 2018 01:12:02 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 4/5] guix-install.sh: Update welcome.
Date: Fri,  2 Nov 2018 21:11:20 -0400
* etc/guix-install.sh (welcome): Don't prompt if AUTO_YN is set.
---
 etc/guix-install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index c817b6dd8..9bf52db41 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -413,7 +413,7 @@ This script installs GNU Guix on your system
 https://www.gnu.org/software/guix/
 EOF
     echo -n "Press return to continue..."
-    read -N 1 -r  ANSWER
+    [[ -n $AUTO_YN ]] || read -N 1 -r  ANSWER
 }
 
 main()
-- 
2.19.1





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

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 5/5] guix-install.sh: Update sys_authorize_build_farms.
Date: Fri,  2 Nov 2018 21:11:38 -0400
* etc/guix-install.sh (sys_authorize_build_farms): Don't prompt
if AUTO_YN is set.
---
 etc/guix-install.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 9bf52db41..18adc17a2 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -355,8 +355,11 @@ sys_enable_guix_daemon()
 
 sys_authorize_build_farms()
 { # authorize the public keys of the two build farms
+    local yn=$AUTO_YN
+
     while true; do
-        read -p "Permit downloading pre-built package binaries from the project's build farms? (yes/no) " yn
+        [[ -n $yn ]] || read -p "Permit downloading pre-built package binaries from the project's build farms? (yes/no) " yn
+
         case $yn in
             [Yy]*) guix archive --authorize < "${ROOT_HOME}/.guix-profile/share/guix/hydra.gnu.org.pub" &&
                          _msg "${PAS}Authorized public key for hydra.gnu.org";
@@ -365,7 +368,7 @@ sys_authorize_build_farms()
                    break;;
             [Nn]*) _msg "${INF}Skipped authorizing build farm public keys"
                    break;;
-            *) _msg "Please answer yes or no.";
+            *) _msg "Please answer yes or no."; yn=""
         esac
     done
 }
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Tue, 06 Nov 2018 11:28:02 GMT) Full text and rfc822 format available.

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

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: rsiddharth <s <at> ricketyspace.net>
Cc: 33134 <at> debbugs.gnu.org
Subject: Re: [bug#33134] [PATCH 2/5] guix-install.sh: Add parse_args.
Date: Tue, 6 Nov 2018 12:27:52 +0100
[Message part 1 (text/plain, inline)]
Hi,

> +    # process -y / -n arg.
> +    export AUTO_YN=${1:1:1}
> +    if [ -z $AUTO_YN ]; then
> +        export AUTO_YN=""
> +    fi

Why "export" ? Now all the child processes get it, making their environment
different from before.  This makes parse_args have system-wide side effects.

If we wanted to export it, we could do it explicitly after parse_args has
been called.
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Tue, 06 Nov 2018 11:29:01 GMT) Full text and rfc822 format available.

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

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: rsiddharth <s <at> ricketyspace.net>
Cc: 33134 <at> debbugs.gnu.org
Subject: Re: [bug#33134] [PATCH 3/5] guix-install.sh: Update main.
Date: Tue, 6 Nov 2018 12:28:29 +0100
[Message part 1 (text/plain, inline)]
On Fri,  2 Nov 2018 21:10:57 -0400
rsiddharth <s <at> ricketyspace.net> wrote:

> * etc/guix-install.sh (main): Call parse_args.
> ---
>  etc/guix-install.sh | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/etc/guix-install.sh b/etc/guix-install.sh
> index d16f8ac59..c817b6dd8 100755
> --- a/etc/guix-install.sh
> +++ b/etc/guix-install.sh
> @@ -418,6 +418,8 @@ EOF
>  
>  main()
>  {
> +    parse_args $@
> +

Should be

   "$@"

with quotes
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Tue, 06 Nov 2018 11:32:01 GMT) Full text and rfc822 format available.

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

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: rsiddharth <s <at> ricketyspace.net>
Cc: 33134 <at> debbugs.gnu.org
Subject: Re: [bug#33134] [PATCH 5/5] guix-install.sh: Update
 sys_authorize_build_farms.
Date: Tue, 6 Nov 2018 12:31:08 +0100
[Message part 1 (text/plain, inline)]
Hi,

On Fri,  2 Nov 2018 21:11:38 -0400
rsiddharth <s <at> ricketyspace.net> wrote:

> -            *) _msg "Please answer yes or no.";
> +            *) _msg "Please answer yes or no."; yn=""

Does this make it conditionally interactive?  Would it be better to "exit 1" here?
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Tue, 06 Nov 2018 11:33:02 GMT) Full text and rfc822 format available.

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

From: Danny Milosavljevic <dannym <at> scratchpost.org>
To: rsiddharth <s <at> ricketyspace.net>
Cc: 33134 <at> debbugs.gnu.org
Subject: Re: [bug#33134] [PATCH 1/5] guix-install.sh: Update welcome.
Date: Tue, 6 Nov 2018 12:32:32 +0100
[Message part 1 (text/plain, inline)]
On Fri,  2 Nov 2018 21:10:34 -0400
rsiddharth <s <at> ricketyspace.net> wrote:

> * etc/guix-install.sh (welcome): Read exactly one character from input.
> ---
>  etc/guix-install.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/etc/guix-install.sh b/etc/guix-install.sh
> index ca6874ba0..cf839c20e 100755
> --- a/etc/guix-install.sh
> +++ b/etc/guix-install.sh
> @@ -398,7 +398,7 @@ This script installs GNU Guix on your system
>  https://www.gnu.org/software/guix/
>  EOF
>      echo -n "Press return to continue..."
> -    read -r  ANSWER
> +    read -N 1 -r  ANSWER

While it's nice for the interactive user, doesn't this break

  yes | ./guix-install.sh

because now it doesn't wait for the newline?
[Message part 2 (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Fri, 09 Nov 2018 04:14:02 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh
Date: Thu,  8 Nov 2018 23:13:01 -0500
Thanks Danny, I've refactored the patch based on your feedack.

Danny Milosavljevic wrote:

>> +    # process -y / -n arg.
>> +    export AUTO_YN=${1:1:1}
>> +    if [ -z $AUTO_YN ]; then
>> +        export AUTO_YN=""
>> +    fi

> Why "export" ? Now all the child processes get it, making their environment
> different from before.  This makes parse_args have system-wide side effects.

Remove the `export`.

>> ...
>>  
>>  main()
>>  {
>> +    parse_args $@
>> +

> Should be
>
>   "$@"
>
>with quotes

Done.

>> ...
>> ...
>>  https://www.gnu.org/software/guix/
>>  EOF
>>      echo -n "Press return to continue..."
>> -    read -r  ANSWER
>> +    read -N 1 -r  ANSWER

> While it's nice for the interactive user, doesn't this break
>
>  yes | ./guix-install.sh
>
> because now it doesn't wait for the newline?

Yes, it would break `yes | ./guix-install.sh`. I've removed `-N 1` from the `read` statement.


>> -            *) _msg "Please answer yes or no.";
>> +            *) _msg "Please answer yes or no."; yn=""

> Does this make it conditionally interactive?  Would it be better to "exit 1" here?

When the user is running the script interactively and answers, say "Oui", we
arrive at the:

                 *) _msg "Please answer yes or no.";

case. After this, we go to the beginning of the loop:

                 [[ -n $yn ]] || read -p "Permit downloading pre-built package binaries from the project's build farms? (yes/no) " yn

Since $yn is "Oui" `[[ -n $yn ]]` will evaluate to true, the user won't be
prompted again, we'll go back to:

                 *) _msg "Please answer yes or no."

and this will repeat infinitely.

The `yn=""` was added:

                 *) _msg "Please answer yes or no."; yn=""

to reset the value of yn, so that `[[ -n $yn ]]` will evaluate to false and
the user will be prompted again for answer.

rsiddharth (4):
  guix-install.sh: Add parse_args.
  guix-install.sh: Update main.
  guix-install.sh: Update welcome.
  guix-install.sh: Update sys_authorize_build_farms.

 etc/guix-install.sh | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Fri, 09 Nov 2018 04:15:02 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 1/4] guix-install.sh: Add parse_args.
Date: Thu,  8 Nov 2018 23:14:37 -0500
* etc/guix-install.sh (parse_args): New function.
---
 etc/guix-install.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index ca6874ba0..3191d1be9 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -370,6 +370,21 @@ sys_authorize_build_farms()
     done
 }
 
+parse_args()
+{
+    local args_num=$#
+
+    if [ $args_num -lt 1 ]; then
+        return
+    fi
+
+    # process -y / -n arg.
+    AUTO_YN=${1:1:1}
+    if [ -z $AUTO_YN ]; then
+        AUTO_YN=""
+    fi
+}
+
 welcome()
 {
     cat<<"EOF"
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Fri, 09 Nov 2018 04:16:01 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 2/4] guix-install.sh: Update main.
Date: Thu,  8 Nov 2018 23:15:07 -0500
* etc/guix-install.sh (main): Call parse_args.
---
 etc/guix-install.sh | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 3191d1be9..23c5f5da2 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -418,6 +418,8 @@ EOF
 
 main()
 {
+    parse_args "$@"
+
     local tmp_path
     welcome
 
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Fri, 09 Nov 2018 04:16:02 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 3/4] guix-install.sh: Update welcome.
Date: Thu,  8 Nov 2018 23:15:19 -0500
* etc/guix-install.sh (welcome): Don't prompt if AUTO_YN is set.
---
 etc/guix-install.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 23c5f5da2..16686ff89 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -413,7 +413,7 @@ This script installs GNU Guix on your system
 https://www.gnu.org/software/guix/
 EOF
     echo -n "Press return to continue..."
-    read -r  ANSWER
+    [[ -n $AUTO_YN ]] || read -r  ANSWER
 }
 
 main()
-- 
2.19.1





Information forwarded to guix-patches <at> gnu.org:
bug#33134; Package guix-patches. (Fri, 09 Nov 2018 04:16:02 GMT) Full text and rfc822 format available.

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

From: rsiddharth <s <at> ricketyspace.net>
To: 33134 <at> debbugs.gnu.org
Cc: rsiddharth <s <at> ricketyspace.net>
Subject: [PATCH 4/4] guix-install.sh: Update sys_authorize_build_farms.
Date: Thu,  8 Nov 2018 23:15:34 -0500
* etc/guix-install.sh (sys_authorize_build_farms): Don't prompt
if AUTO_YN is set.
---
 etc/guix-install.sh | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/etc/guix-install.sh b/etc/guix-install.sh
index 16686ff89..cbcf5316d 100755
--- a/etc/guix-install.sh
+++ b/etc/guix-install.sh
@@ -355,8 +355,11 @@ sys_enable_guix_daemon()
 
 sys_authorize_build_farms()
 { # authorize the public keys of the two build farms
+    local yn=$AUTO_YN
+
     while true; do
-        read -p "Permit downloading pre-built package binaries from the project's build farms? (yes/no) " yn
+        [[ -n $yn ]] || read -p "Permit downloading pre-built package binaries from the project's build farms? (yes/no) " yn
+
         case $yn in
             [Yy]*) guix archive --authorize < "${ROOT_HOME}/.guix-profile/share/guix/hydra.gnu.org.pub" &&
                          _msg "${PAS}Authorized public key for hydra.gnu.org";
@@ -365,7 +368,7 @@ sys_authorize_build_farms()
                    break;;
             [Nn]*) _msg "${INF}Skipped authorizing build farm public keys"
                    break;;
-            *) _msg "Please answer yes or no.";
+            *) _msg "Please answer yes or no."; yn=""
         esac
     done
 }
-- 
2.19.1





Reply sent to Maxim Cournoyer <maxim.cournoyer <at> gmail.com>:
You have taken responsibility. (Tue, 13 Jul 2021 12:03:02 GMT) Full text and rfc822 format available.

Notification sent to rsiddharth <s <at> ricketyspace.net>:
bug acknowledged by developer. (Tue, 13 Jul 2021 12:03:02 GMT) Full text and rfc822 format available.

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

From: Maxim Cournoyer <maxim.cournoyer <at> gmail.com>
To: rsiddharth <s <at> ricketyspace.net>
Cc: 33134-done <at> debbugs.gnu.org
Subject: Re: bug#33134: [PATCH 0/1] guix-install.sh: Add ability to run it
 non-interactively.
Date: Tue, 13 Jul 2021 08:01:58 -0400
Hello,

rsiddharth <s <at> ricketyspace.net> writes:

> I want to be able to run the guix-install.sh non-interactively[1] like this:
>
>    echo "yy" | guix-install.sh
>
>    (One "y" for "Press return to continue..." prompt, the other "y" for
>    "Permit downloading pre-built package binaries from the project's build
>    farms? (yes/no)" prompt).
>
> Currently, the `read` in welcome function reads both the "y". I updated it to
> read just one character.
>
> [1]: https://git.ricketyspace.net/propellor/tree/config.hs?id=0cddd47ef#n640
>
> rsiddharth (1):
>   guix-install.sh: Update welcome.
>
>  etc/guix-install.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

The guix-install.sh saw some imrovements in v1.3.0 that makes it support
the non-interactive 'yes | sudo ./guix-install.sh' use case.  I think it
obsoletes this patch.

Closing, but feel free to send a new patch series if I missed anything.

Thank you,

Maxim




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 11 Aug 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 255 days ago.

Previous Next


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