all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively.
@ 2018-10-24  0:15 rsiddharth
  2018-10-24  0:21 ` [bug#33134] [PATCH 1/1] guix-install.sh: Update welcome rsiddharth
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: rsiddharth @ 2018-10-24  0:15 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

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

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

* [bug#33134] [PATCH 1/1] guix-install.sh: Update welcome.
  2018-10-24  0:15 [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively rsiddharth
@ 2018-10-24  0:21 ` rsiddharth
  2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: rsiddharth @ 2018-10-24  0:21 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively.
  2018-10-24  0:15 [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively rsiddharth
  2018-10-24  0:21 ` [bug#33134] [PATCH 1/1] guix-install.sh: Update welcome rsiddharth
@ 2018-10-24 11:54 ` Efraim Flashner
  2018-10-24 13:24   ` Tobias Geerinckx-Rice
                     ` (6 more replies)
  2018-11-09  4:13 ` [bug#33134] [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh rsiddharth
  2021-07-13 12:01 ` bug#33134: [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Maxim Cournoyer
  3 siblings, 7 replies; 21+ messages in thread
From: Efraim Flashner @ 2018-10-24 11:54 UTC (permalink / raw)
  To: rsiddharth; +Cc: 33134

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

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

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

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

* [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively.
  2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
@ 2018-10-24 13:24   ` Tobias Geerinckx-Rice
  2018-10-24 13:27     ` Efraim Flashner
  2018-11-03  1:10   ` [bug#33134] [PATCH 0/5] Add auto yes/no switch to guix-install.sh rsiddharth
                     ` (5 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: Tobias Geerinckx-Rice @ 2018-10-24 13:24 UTC (permalink / raw)
  To: Efraim Flashner; +Cc: 33134, rsiddharth

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

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

* [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively.
  2018-10-24 13:24   ` Tobias Geerinckx-Rice
@ 2018-10-24 13:27     ` Efraim Flashner
  0 siblings, 0 replies; 21+ messages in thread
From: Efraim Flashner @ 2018-10-24 13:27 UTC (permalink / raw)
  To: Tobias Geerinckx-Rice; +Cc: 33134, rsiddharth

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

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

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

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

* [bug#33134] [PATCH 0/5] Add auto yes/no switch to guix-install.sh
  2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
  2018-10-24 13:24   ` Tobias Geerinckx-Rice
@ 2018-11-03  1:10   ` rsiddharth
  2018-11-03  1:10   ` [bug#33134] [PATCH 1/5] guix-install.sh: Update welcome rsiddharth
                     ` (4 subsequent siblings)
  6 siblings, 0 replies; 21+ messages in thread
From: rsiddharth @ 2018-11-03  1:10 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

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

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

* [bug#33134] [PATCH 1/5] guix-install.sh: Update welcome.
  2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
  2018-10-24 13:24   ` Tobias Geerinckx-Rice
  2018-11-03  1:10   ` [bug#33134] [PATCH 0/5] Add auto yes/no switch to guix-install.sh rsiddharth
@ 2018-11-03  1:10   ` rsiddharth
  2018-11-06 11:32     ` Danny Milosavljevic
  2018-11-03  1:10   ` [bug#33134] [PATCH 2/5] guix-install.sh: Add parse_args rsiddharth
                     ` (3 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: rsiddharth @ 2018-11-03  1:10 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* [bug#33134] [PATCH 2/5] guix-install.sh: Add parse_args.
  2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
                     ` (2 preceding siblings ...)
  2018-11-03  1:10   ` [bug#33134] [PATCH 1/5] guix-install.sh: Update welcome rsiddharth
@ 2018-11-03  1:10   ` rsiddharth
  2018-11-06 11:27     ` Danny Milosavljevic
  2018-11-03  1:10   ` [bug#33134] [PATCH 3/5] guix-install.sh: Update main rsiddharth
                     ` (2 subsequent siblings)
  6 siblings, 1 reply; 21+ messages in thread
From: rsiddharth @ 2018-11-03  1:10 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* [bug#33134] [PATCH 3/5] guix-install.sh: Update main.
  2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
                     ` (3 preceding siblings ...)
  2018-11-03  1:10   ` [bug#33134] [PATCH 2/5] guix-install.sh: Add parse_args rsiddharth
@ 2018-11-03  1:10   ` rsiddharth
  2018-11-06 11:28     ` Danny Milosavljevic
  2018-11-03  1:11   ` [bug#33134] [PATCH 4/5] guix-install.sh: Update welcome rsiddharth
  2018-11-03  1:11   ` [bug#33134] [PATCH 5/5] guix-install.sh: Update sys_authorize_build_farms rsiddharth
  6 siblings, 1 reply; 21+ messages in thread
From: rsiddharth @ 2018-11-03  1:10 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* [bug#33134] [PATCH 4/5] guix-install.sh: Update welcome.
  2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
                     ` (4 preceding siblings ...)
  2018-11-03  1:10   ` [bug#33134] [PATCH 3/5] guix-install.sh: Update main rsiddharth
@ 2018-11-03  1:11   ` rsiddharth
  2018-11-03  1:11   ` [bug#33134] [PATCH 5/5] guix-install.sh: Update sys_authorize_build_farms rsiddharth
  6 siblings, 0 replies; 21+ messages in thread
From: rsiddharth @ 2018-11-03  1:11 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* [bug#33134] [PATCH 5/5] guix-install.sh: Update sys_authorize_build_farms.
  2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
                     ` (5 preceding siblings ...)
  2018-11-03  1:11   ` [bug#33134] [PATCH 4/5] guix-install.sh: Update welcome rsiddharth
@ 2018-11-03  1:11   ` rsiddharth
  2018-11-06 11:31     ` Danny Milosavljevic
  6 siblings, 1 reply; 21+ messages in thread
From: rsiddharth @ 2018-11-03  1:11 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* [bug#33134] [PATCH 2/5] guix-install.sh: Add parse_args.
  2018-11-03  1:10   ` [bug#33134] [PATCH 2/5] guix-install.sh: Add parse_args rsiddharth
@ 2018-11-06 11:27     ` Danny Milosavljevic
  0 siblings, 0 replies; 21+ messages in thread
From: Danny Milosavljevic @ 2018-11-06 11:27 UTC (permalink / raw)
  To: rsiddharth; +Cc: 33134

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

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.

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [bug#33134] [PATCH 3/5] guix-install.sh: Update main.
  2018-11-03  1:10   ` [bug#33134] [PATCH 3/5] guix-install.sh: Update main rsiddharth
@ 2018-11-06 11:28     ` Danny Milosavljevic
  0 siblings, 0 replies; 21+ messages in thread
From: Danny Milosavljevic @ 2018-11-06 11:28 UTC (permalink / raw)
  To: rsiddharth; +Cc: 33134

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

On Fri,  2 Nov 2018 21:10:57 -0400
rsiddharth <s@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

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [bug#33134] [PATCH 5/5] guix-install.sh: Update sys_authorize_build_farms.
  2018-11-03  1:11   ` [bug#33134] [PATCH 5/5] guix-install.sh: Update sys_authorize_build_farms rsiddharth
@ 2018-11-06 11:31     ` Danny Milosavljevic
  0 siblings, 0 replies; 21+ messages in thread
From: Danny Milosavljevic @ 2018-11-06 11:31 UTC (permalink / raw)
  To: rsiddharth; +Cc: 33134

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

Hi,

On Fri,  2 Nov 2018 21:11:38 -0400
rsiddharth <s@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?

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [bug#33134] [PATCH 1/5] guix-install.sh: Update welcome.
  2018-11-03  1:10   ` [bug#33134] [PATCH 1/5] guix-install.sh: Update welcome rsiddharth
@ 2018-11-06 11:32     ` Danny Milosavljevic
  0 siblings, 0 replies; 21+ messages in thread
From: Danny Milosavljevic @ 2018-11-06 11:32 UTC (permalink / raw)
  To: rsiddharth; +Cc: 33134

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

On Fri,  2 Nov 2018 21:10:34 -0400
rsiddharth <s@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?

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

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

* [bug#33134] [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh
  2018-10-24  0:15 [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively rsiddharth
  2018-10-24  0:21 ` [bug#33134] [PATCH 1/1] guix-install.sh: Update welcome rsiddharth
  2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
@ 2018-11-09  4:13 ` rsiddharth
  2018-11-09  4:14   ` [bug#33134] [PATCH 1/4] guix-install.sh: Add parse_args rsiddharth
                     ` (3 more replies)
  2021-07-13 12:01 ` bug#33134: [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Maxim Cournoyer
  3 siblings, 4 replies; 21+ messages in thread
From: rsiddharth @ 2018-11-09  4:13 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

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

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

* [bug#33134] [PATCH 1/4] guix-install.sh: Add parse_args.
  2018-11-09  4:13 ` [bug#33134] [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh rsiddharth
@ 2018-11-09  4:14   ` rsiddharth
  2018-11-09  4:15   ` [bug#33134] [PATCH 2/4] guix-install.sh: Update main rsiddharth
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 21+ messages in thread
From: rsiddharth @ 2018-11-09  4:14 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* [bug#33134] [PATCH 2/4] guix-install.sh: Update main.
  2018-11-09  4:13 ` [bug#33134] [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh rsiddharth
  2018-11-09  4:14   ` [bug#33134] [PATCH 1/4] guix-install.sh: Add parse_args rsiddharth
@ 2018-11-09  4:15   ` rsiddharth
  2018-11-09  4:15   ` [bug#33134] [PATCH 3/4] guix-install.sh: Update welcome rsiddharth
  2018-11-09  4:15   ` [bug#33134] [PATCH 4/4] guix-install.sh: Update sys_authorize_build_farms rsiddharth
  3 siblings, 0 replies; 21+ messages in thread
From: rsiddharth @ 2018-11-09  4:15 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* [bug#33134] [PATCH 3/4] guix-install.sh: Update welcome.
  2018-11-09  4:13 ` [bug#33134] [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh rsiddharth
  2018-11-09  4:14   ` [bug#33134] [PATCH 1/4] guix-install.sh: Add parse_args rsiddharth
  2018-11-09  4:15   ` [bug#33134] [PATCH 2/4] guix-install.sh: Update main rsiddharth
@ 2018-11-09  4:15   ` rsiddharth
  2018-11-09  4:15   ` [bug#33134] [PATCH 4/4] guix-install.sh: Update sys_authorize_build_farms rsiddharth
  3 siblings, 0 replies; 21+ messages in thread
From: rsiddharth @ 2018-11-09  4:15 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* [bug#33134] [PATCH 4/4] guix-install.sh: Update sys_authorize_build_farms.
  2018-11-09  4:13 ` [bug#33134] [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh rsiddharth
                     ` (2 preceding siblings ...)
  2018-11-09  4:15   ` [bug#33134] [PATCH 3/4] guix-install.sh: Update welcome rsiddharth
@ 2018-11-09  4:15   ` rsiddharth
  3 siblings, 0 replies; 21+ messages in thread
From: rsiddharth @ 2018-11-09  4:15 UTC (permalink / raw)
  To: 33134; +Cc: rsiddharth

* 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

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

* bug#33134: [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively.
  2018-10-24  0:15 [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively rsiddharth
                   ` (2 preceding siblings ...)
  2018-11-09  4:13 ` [bug#33134] [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh rsiddharth
@ 2021-07-13 12:01 ` Maxim Cournoyer
  3 siblings, 0 replies; 21+ messages in thread
From: Maxim Cournoyer @ 2021-07-13 12:01 UTC (permalink / raw)
  To: rsiddharth; +Cc: 33134-done

Hello,

rsiddharth <s@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




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

end of thread, other threads:[~2021-07-13 12:03 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-24  0:15 [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively rsiddharth
2018-10-24  0:21 ` [bug#33134] [PATCH 1/1] guix-install.sh: Update welcome rsiddharth
2018-10-24 11:54 ` [bug#33134] [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Efraim Flashner
2018-10-24 13:24   ` Tobias Geerinckx-Rice
2018-10-24 13:27     ` Efraim Flashner
2018-11-03  1:10   ` [bug#33134] [PATCH 0/5] Add auto yes/no switch to guix-install.sh rsiddharth
2018-11-03  1:10   ` [bug#33134] [PATCH 1/5] guix-install.sh: Update welcome rsiddharth
2018-11-06 11:32     ` Danny Milosavljevic
2018-11-03  1:10   ` [bug#33134] [PATCH 2/5] guix-install.sh: Add parse_args rsiddharth
2018-11-06 11:27     ` Danny Milosavljevic
2018-11-03  1:10   ` [bug#33134] [PATCH 3/5] guix-install.sh: Update main rsiddharth
2018-11-06 11:28     ` Danny Milosavljevic
2018-11-03  1:11   ` [bug#33134] [PATCH 4/5] guix-install.sh: Update welcome rsiddharth
2018-11-03  1:11   ` [bug#33134] [PATCH 5/5] guix-install.sh: Update sys_authorize_build_farms rsiddharth
2018-11-06 11:31     ` Danny Milosavljevic
2018-11-09  4:13 ` [bug#33134] [PATCH 0/4] [Refactor 0] Add auto yes/no switch to guix-install.sh rsiddharth
2018-11-09  4:14   ` [bug#33134] [PATCH 1/4] guix-install.sh: Add parse_args rsiddharth
2018-11-09  4:15   ` [bug#33134] [PATCH 2/4] guix-install.sh: Update main rsiddharth
2018-11-09  4:15   ` [bug#33134] [PATCH 3/4] guix-install.sh: Update welcome rsiddharth
2018-11-09  4:15   ` [bug#33134] [PATCH 4/4] guix-install.sh: Update sys_authorize_build_farms rsiddharth
2021-07-13 12:01 ` bug#33134: [PATCH 0/1] guix-install.sh: Add ability to run it non-interactively Maxim Cournoyer

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.