From 0ab212b9466d5aa3fe801c9137248703245d8513 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Tue, 24 Sep 2013 22:11:16 +0000 Subject: 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 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'guix') diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index 1d00e39540..1f21890fcd 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))) -- cgit v1.2.3 From 4b2bc804d861ff5ba550dac0b56f1fe44f079847 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Tue, 24 Sep 2013 22:18:09 +0000 Subject: 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(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index 90016a4496..442cef26da 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 1f21890fcd..dab3d5bb0c 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 f1f7ee6c7d..7130926404 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -111,6 +111,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" -- cgit v1.2.3 From 9ac9360d6e86e7d16756d8e28ce61e288551c2db Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Wed, 25 Sep 2013 01:55:27 +0000 Subject: 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 | 14 +++++++++----- tests/guix-package.sh | 3 +++ 2 files changed, 12 insertions(+), 5 deletions(-) (limited to 'guix') diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index dab3d5bb0c..66505f172f 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -956,11 +956,15 @@ more information.~%")) (('list-generations pattern) (define (list-generation number) (unless (zero? number) - (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"))) + (current (generation-number profile))) + (if (= number current) + (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 524ff32f17..5f97aff026 100644 --- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -119,6 +119,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" -- cgit v1.2.3 From de8bcdaeb5a828d8cee85f8700e23e15b49f4e24 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 25 Sep 2013 23:26:42 +0200 Subject: packages: Make the 'output' parameter of 'package-output' optional. * guix/packages.scm (package-output): Make the 'output' parameter optional. --- guix/packages.scm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/packages.scm b/guix/packages.scm index efec414675..9433fe9586 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -462,8 +462,8 @@ system identifying string)." #:outputs outputs #:system system (args)))))))) -(define* (package-output store package output - #:optional (system (%current-system))) +(define* (package-output store package + #:optional (output "out") (system (%current-system))) "Return the output path of PACKAGE's OUTPUT for SYSTEM---where OUTPUT is the symbolic output name, such as \"out\". Note that this procedure calls `package-derivation', which is costly." -- cgit v1.2.3