Re: Generation 0
Nikita Karetnikov skribis: > Anyway, can I push this patch? Yes, please push. > From 00188949e6c49592f6f2dc30bf21731ae142afc0 Mon Sep 17 00:00:00 2001 > From: Nikita Karetnikov > Date: Thu, 26 Sep 2013 02:00:06 + > Subject: [PATCH 1/3] guix package: Exit with 0 when there is nothing to list. > > * guix/scripts/package.scm (guix-package)[process-query]: Exit with 0 > when there are no generations containing packages or no profiles. > --- > guix/scripts/package.scm |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm > index 66505f1..ed1e72c 100644 > --- a/guix/scripts/package.scm > +++ b/guix/scripts/package.scm > @@ -983,7 +983,7 @@ more information.~%")) > ((string-null? pattern) > (let ((numbers (generation-numbers profile))) >(if (equal? numbers '(0)) > - (exit 1) > + (exit 0) >(for-each list-generation numbers > ((matching-generations pattern profile) > => Ludo’.
Re: Generation 0
>> There are two cases: >> >> 1. A generation does not exist. >> >> 2. The profile points to the zeroth generation, and there are no other >>generations. >> >> ‘tests/guix-package.sh’ tests the first case. Should we test the second >> case too? What would be the best way to do so? > The second case is valid. Thus it’s OK for --list-generations to not > print anything, but it must exit with 0. > Likewise, --delete-generations should do nothing and exit with 0 with > the only generation that would be deleted is Generation 0. > Does it make sense? I was asking a different question, that is, whether we should test both cases in ‘tests/guix-package.sh’ or it’s OK to test only the first case. Currently, there’s a test for the first case. (Note that by the word “cases” I mean the ‘cond’ cases.) Anyway, can I push this patch? From 00188949e6c49592f6f2dc30bf21731ae142afc0 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Thu, 26 Sep 2013 02:00:06 + Subject: [PATCH 1/3] guix package: Exit with 0 when there is nothing to list. * guix/scripts/package.scm (guix-package)[process-query]: Exit with 0 when there are no generations containing packages or no profiles. --- guix/scripts/package.scm |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 66505f1..ed1e72c 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -983,7 +983,7 @@ more information.~%")) ((string-null? pattern) (let ((numbers (generation-numbers profile))) (if (equal? numbers '(0)) - (exit 1) + (exit 0) (for-each list-generation numbers ((matching-generations pattern profile) => -- 1.7.9.5 pgpMpMoVZSJxL.pgp Description: PGP signature
Re: Generation 0
Nikita Karetnikov skribis: >>> What about these patches? Should the first patch also test the >>> following case? >>> >>> +(let ((numbers (generation-numbers profile))) >>> + (if (equal? numbers '(0)) >>> + (exit 1) >>> + (for-each list-generation numbers > >> The first patch below already contains that snippet, so I’m not sure >> what you mean. > > There are two cases: > > 1. A generation does not exist. > > 2. The profile points to the zeroth generation, and there are no other >generations. > > ‘tests/guix-package.sh’ tests the first case. Should we test the second > case too? What would be the best way to do so? The second case is valid. Thus it’s OK for --list-generations to not print anything, but it must exit with 0. Likewise, --delete-generations should do nothing and exit with 0 with the only generation that would be deleted is Generation 0. Does it make sense? Ludo’.
Re: Generation 0
>> What about these patches? Should the first patch also test the >> following case? >> >> +(let ((numbers (generation-numbers profile))) >> + (if (equal? numbers '(0)) >> + (exit 1) >> + (for-each list-generation numbers > The first patch below already contains that snippet, so I’m not sure > what you mean. There are two cases: 1. A generation does not exist. 2. The profile points to the zeroth generation, and there are no other generations. ‘tests/guix-package.sh’ tests the first case. Should we test the second case too? What would be the best way to do so? Note that you can’t specify the pattern in that case because of the (string-null? pattern) bit. pgpJjM6fs4hiB.pgp Description: PGP signature
Re: Generation 0
Nikita Karetnikov skribis: > What about these patches? Should the first patch also test the > following case? > > +(let ((numbers (generation-numbers profile))) > + (if (equal? numbers '(0)) > + (exit 1) > + (for-each list-generation numbers The first patch below already contains that snippet, so I’m not sure what you mean. > From f42056aa768a405a893b5846dad8f8fa576b1156 Mon Sep 17 00:00:00 2001 > From: Nikita Karetnikov > Date: Tue, 24 Sep 2013 22:11:16 + > Subject: [PATCH 1/2] guix package: Exit with 1 when a generation cannot be > listed. > > * guix/scripts/package.scm (guix-package)[process-query]: Exit with 1 > when a generation does not exist or the profile points to the zeroth > generation. > * tests/guix-package.sh: Test the former case. OK, please push. > From bea0168c28932921e6e2d6dcf3e9a26c555b698c Mon Sep 17 00:00:00 2001 > From: Nikita Karetnikov > Date: Tue, 24 Sep 2013 22:18:09 + > Subject: [PATCH 2/2] guix package: Do not list the zeroth generation. > > * guix/scripts/package.scm (guix-package)[process-query]: Change > 'list-generation' to not list the zeroth generation. > * tests/guix-package.sh: Test it. > * doc/guix.texi (Invoking guix package): Document it, and use the > right term when talking about generations. OK, push as well. Thanks, Ludo’.
Re: Generation 0
What about these patches? Should the first patch also test the following case? +(let ((numbers (generation-numbers profile))) + (if (equal? numbers '(0)) + (exit 1) + (for-each list-generation numbers From f42056aa768a405a893b5846dad8f8fa576b1156 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Tue, 24 Sep 2013 22:11:16 + Subject: [PATCH 1/2] guix package: Exit with 1 when a generation cannot be listed. * guix/scripts/package.scm (guix-package)[process-query]: Exit with 1 when a generation does not exist or the profile points to the zeroth generation. * tests/guix-package.sh: Test the former case. --- guix/scripts/package.scm | 11 --- tests/guix-package.sh|4 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 1d00e39..1f21890 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -977,11 +977,16 @@ more information.~%")) (leave (_ "profile '~a' does not exist~%") profile)) ((string-null? pattern) -(for-each list-generation - (generation-numbers profile))) +(let ((numbers (generation-numbers profile))) + (if (equal? numbers '(0)) + (exit 1) + (for-each list-generation numbers ((matching-generations pattern profile) => -(cut for-each list-generation <>)) +(lambda (numbers) + (if (null-list? numbers) + (exit 1) + (for-each list-generation numbers (else (leave (_ "invalid syntax: ~a~%") pattern))) diff --git a/tests/guix-package.sh b/tests/guix-package.sh index b09a9c0..f1f7ee6 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -85,6 +85,10 @@ then test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \ = " guile-bootstrap" +# Exit with 1 when a generation does not exist. +if guix package -p "$profile" --list-generations=42; +then false; else true; fi + # Remove a package. guix package --bootstrap -p "$profile" -r "guile-bootstrap" test -L "$profile-3-link" -- 1.7.9.5 From bea0168c28932921e6e2d6dcf3e9a26c555b698c Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Tue, 24 Sep 2013 22:18:09 + Subject: [PATCH 2/2] guix package: Do not list the zeroth generation. * guix/scripts/package.scm (guix-package)[process-query]: Change 'list-generation' to not list the zeroth generation. * tests/guix-package.sh: Test it. * doc/guix.texi (Invoking guix package): Document it, and use the right term when talking about generations. --- doc/guix.texi|8 guix/scripts/package.scm |2 +- tests/guix-package.sh|3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 90016a4..442cef2 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -583,9 +583,8 @@ When combined with options such as @code{--install}, roll back occurs before any other actions. When rolling back from the first generation that actually contains -installed packages, the profile is made to point to the @dfn{empty -profile}, also known as @dfn{profile zero}---i.e., it contains no files -apart from its own meta-data. +installed packages, the profile is made to point to the @dfn{zeroth +generation}, which contains no files apart from its own meta-data. Installing, removing, or upgrading packages from a generation that has been rolled back to overwrites previous future generations. Thus, the @@ -683,7 +682,8 @@ Multiple Outputs}), and the source location of its definition. @itemx -l [@var{pattern}] Return a list of generations along with their creation dates; for each generation, show the installed packages, with the most recently -installed packages shown last. +installed packages shown last. Note that the zeroth generation is never +shown. For each installed package, print the following items, separated by tabs: the name of a package, its version string, the part of the package diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 1f21890..dab3d5b 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -955,7 +955,7 @@ more information.~%")) (match (assoc-ref opts 'query) (('list-generations pattern) (define (list-generation number) - (begin + (unless (zero? number) (format #t (_ "Generation ~a\t~a~%") number (date->string (time-utc->date diff --git a/tests/guix-package.sh b/tests/guix-package.sh index f1f7ee6..7130926 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.s
Re: Generation 0
Nikita Karetnikov skribis: >>> I think we should change ‘--list-generations’ to not output the zeroth >>> generation. Even though it could be present in the profile, users >>> shouldn’t be concerned about it. > >> Agreed. > > Can I push these patches to ‘master’? Should I document that the zeroth > generation is always ignored? Why not. There’s already a mention of “profile zero” (which should be changed to “generation zero”) under ‘--roll-back’ in the manual. > From 7fc042876bf00031d6b36b8d697984ce1ee1700e Mon Sep 17 00:00:00 2001 > From: Nikita Karetnikov > Date: Mon, 23 Sep 2013 22:56:21 + > Subject: [PATCH 1/3] tests: Test that '--list-generations' may not output > anything. Make sure to add a commit log. > --- > tests/guix-package.sh |3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/tests/guix-package.sh b/tests/guix-package.sh > index b09a9c0..e2c0374 100644 > --- a/tests/guix-package.sh > +++ b/tests/guix-package.sh > @@ -85,6 +85,9 @@ then > test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" > \ > = " guile-bootstrap" > > +# Do not output anything when a generation does not exist. > +test -z "`guix package -p "$profile" -l 42`" I’d rather test the exit code instead of/in addition to the output. Does it exit with 1? I think it should. > + (or (zero? number) > + (begin > + (format #t (_ "Generation ~a\t~a~%") number OK, but rather use (unless (zero? number) (format #t ...) ...) > From 64b01b6414d42b9b495059223e5312d9d01ba860 Mon Sep 17 00:00:00 2001 > From: Nikita Karetnikov > Date: Tue, 24 Sep 2013 00:36:51 + > Subject: [PATCH 3/3] tests: Use 'test -z' to check that a string equals zero. > > --- > tests/guix-package.sh |2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) OK. Thanks, Ludo’.
[PATCH] guix package: Show which generation is the current one. (was: Generation 0)
Will these lines be i18n’d? I fail to configure the locales properly, so I can’t check. + (format #t "~a\t(current)~%" header) + (format #t "~a~%" header))) Can I push this patch to ‘master’? (It should be applied on top of the other three.) From 7759ad3ad89d236e766639c0875540e60a503d16 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Tue, 24 Sep 2013 05:41:32 + Subject: [PATCH] guix package: Show which generation is the current one. * guix/scripts/package.scm (guix-package)[process-query]: Show that a generation is the current one if the profile points to it. * tests/guix-package.sh: Test it. --- guix/scripts/package.scm | 17 - tests/guix-package.sh|3 +++ 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 9ed499d..a8dfcbc 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -955,13 +955,20 @@ more information.~%")) (match (assoc-ref opts 'query) (('list-generations pattern) (define (list-generation number) + (define (current-generation? number) + (let ((generation (format #f "~a-~a-link" profile number))) + (string=? (readlink profile) generation))) + (or (zero? number) (begin - (format #t (_ "Generation ~a\t~a~%") number - (date->string - (time-utc->date - (generation-time profile number)) - "~b ~d ~Y ~T")) + (let ((header (format #f (_ "Generation ~a\t~a") number + (date->string +(time-utc->date + (generation-time profile number)) +"~b ~d ~Y ~T" + (if (current-generation? number) + (format #t "~a\t(current)~%" header) + (format #t "~a~%" header))) (for-each (match-lambda ((name version output location _) (format #t " ~a\t~a\t~a\t~a~%" diff --git a/tests/guix-package.sh b/tests/guix-package.sh index 2b8b146..74deb3a 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -118,6 +118,9 @@ then test "`readlink_base "$profile"`" = "$profile-1-link" test -x "$profile/bin/guile" && ! test -x "$profile/bin/make" +# Check that the first generation is the current one. +test "`guix package -p "$profile" -l 1 | cut -f3 | head -n1`" = "(current)" + # Roll-back to generation 0, and install---all at once. guix package --bootstrap -p "$profile" --roll-back -i guile-bootstrap test "`readlink_base "$profile"`" = "$profile-1-link" -- 1.7.9.5 pgp5Xhebr6pC2.pgp Description: PGP signature
Re: Generation 0
>> I think we should change ‘--list-generations’ to not output the zeroth >> generation. Even though it could be present in the profile, users >> shouldn’t be concerned about it. > Agreed. Can I push these patches to ‘master’? Should I document that the zeroth generation is always ignored? From 7fc042876bf00031d6b36b8d697984ce1ee1700e Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Mon, 23 Sep 2013 22:56:21 + Subject: [PATCH 1/3] tests: Test that '--list-generations' may not output anything. --- tests/guix-package.sh |3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/guix-package.sh b/tests/guix-package.sh index b09a9c0..e2c0374 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -85,6 +85,9 @@ then test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" \ = " guile-bootstrap" +# Do not output anything when a generation does not exist. +test -z "`guix package -p "$profile" -l 42`" + # Remove a package. guix package --bootstrap -p "$profile" -r "guile-bootstrap" test -L "$profile-3-link" -- 1.7.9.5 From ac4c69fea488e4028f3957986104159fca467ecb Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Mon, 23 Sep 2013 23:31:15 + Subject: [PATCH 2/3] guix package: Do not list the zeroth generation. * guix/scripts/package.scm(guix-package)[process-query]: Change 'list-generation' to not list the zeroth generation. * tests/guix-package.sh: Test it. --- guix/scripts/package.scm | 35 ++- tests/guix-package.sh|3 +++ 2 files changed, 21 insertions(+), 17 deletions(-) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 1d00e39..9ed499d 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -955,23 +955,24 @@ more information.~%")) (match (assoc-ref opts 'query) (('list-generations pattern) (define (list-generation number) - (begin - (format #t (_ "Generation ~a\t~a~%") number - (date->string - (time-utc->date - (generation-time profile number)) - "~b ~d ~Y ~T")) - (for-each (match-lambda -((name version output location _) - (format #t " ~a\t~a\t~a\t~a~%" - name version output location))) - - ;; Show most recently installed packages last. - (reverse -(manifest-packages - (profile-manifest - (format #f "~a-~a-link" profile number) - (newline))) + (or (zero? number) + (begin + (format #t (_ "Generation ~a\t~a~%") number + (date->string + (time-utc->date + (generation-time profile number)) + "~b ~d ~Y ~T")) + (for-each (match-lambda +((name version output location _) + (format #t " ~a\t~a\t~a\t~a~%" + name version output location))) + + ;; Show most recently installed packages last. + (reverse +(manifest-packages + (profile-manifest + (format #f "~a-~a-link" profile number) + (newline (cond ((not (file-exists? profile)) ; XXX: race condition (leave (_ "profile '~a' does not exist~%") diff --git a/tests/guix-package.sh b/tests/guix-package.sh index e2c0374..b4bd414 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -110,6 +110,9 @@ then test "`readlink_base "$profile"`" = "$profile-0-link" done +# Test that '--list-generations' does not output the zeroth generation. +test -z "`guix package -p "$profile" -l 0`" + # Reinstall after roll-back to the empty profile. guix package --bootstrap -p "$profile" -e "$boot_make" test "`readlink_base "$profile"`" = "$profile-1-link" -- 1.7.9.5 From 64b01b6414d42b9b495059223e5312d9d01ba860 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Tue, 24 Sep 2013 00:36:51 + Subject: [PATCH 3/3] tests: Use 'test -z' to check that a string equals zero. --- tests/guix-package.sh |2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/guix-package.sh b/tests/guix-package.sh index b4bd414..2b8b146 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -79,7 +79,7 @@ then # Search. test "`guix package -s "An example GNU package" | grep ^name:`" = \ "name: hello" -test "`guix package -s "n0t4r341p4ck4g3"`" = "" +test -z "`guix package -s "n0t4r341p4ck4g3"`" # List generations. test "`guix packa
Re: Generation 0
Nikita Karetnikov skribis: >> I think it should be impossible to remove Generation 0 through the >> command-line tools, because that generation exists precisely so that the >> profile always points to something valid. > >> So yes, ‘--delete-generations’ must ignore Generation 0. > > Right, I agree. But some might expect it to delete the profile as well. > Should we have a separate tool for this? We have one; it’s called ‘rm’. :-) Ludo’.
Re: Generation 0
>> I think we should change ‘--list-generations’ to not output the zeroth >> generation. Even though it could be present in the profile, users >> shouldn’t be concerned about it. > Agreed. Good. > I think it should be impossible to remove Generation 0 through the > command-line tools, because that generation exists precisely so that the > profile always points to something valid. > So yes, ‘--delete-generations’ must ignore Generation 0. Right, I agree. But some might expect it to delete the profile as well. Should we have a separate tool for this? pgpvK2mmLXuba.pgp Description: PGP signature
Re: Generation 0
Nikita Karetnikov skribis: > I think we should change ‘--list-generations’ to not output the zeroth > generation. Even though it could be present in the profile, users > shouldn’t be concerned about it. Agreed. > Currently, ‘--delete-generations’ ignores the zeroth generation. Other > options seem even more confusing: > > 1. If you don’t have any other generations and delete it, profile >couldn’t point to anything. > > 2. If you delete it along with the profile, users might be confused (or >angry). > > WDYT? I think it should be impossible to remove Generation 0 through the command-line tools, because that generation exists precisely so that the profile always points to something valid. So yes, ‘--delete-generations’ must ignore Generation 0. Ludo’.
Generation 0 (was: [PATCH] guix package: Add '--delete-generations'.)
I think we should change ‘--list-generations’ to not output the zeroth generation. Even though it could be present in the profile, users shouldn’t be concerned about it. Currently, ‘--delete-generations’ ignores the zeroth generation. Other options seem even more confusing: 1. If you don’t have any other generations and delete it, profile couldn’t point to anything. 2. If you delete it along with the profile, users might be confused (or angry). WDYT? pgpcGbxPthIuz.pgp Description: PGP signature