From mboxrd@z Thu Jan 1 00:00:00 1970 From: Nikita Karetnikov Subject: Re: Generation 0 Date: Wed, 25 Sep 2013 02:29:53 +0400 Message-ID: <871u4d97ku.fsf@karetnikov.org> References: <87vc2o4qwc.fsf@gnu.org> <87y57kljro.fsf@karetnikov.org> <87hae81uvo.fsf@gnu.org> <87li2oslzh.fsf_-_@karetnikov.org> <87hadcr4sh.fsf_-_@karetnikov.org> <8738ow5zif.fsf@gnu.org> <87vc1r6nu0.fsf@karetnikov.org> <87eh8ebdba.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/signed; boundary="==-=-="; micalg=pgp-sha1; protocol="application/pgp-signature" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:57868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOb2d-0000W1-Tt for guix-devel@gnu.org; Tue, 24 Sep 2013 18:25:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOb2c-0001Bi-EY for guix-devel@gnu.org; Tue, 24 Sep 2013 18:25:11 -0400 In-Reply-To: <87eh8ebdba.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 24 Sep 2013 14:43:05 +0200") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel@gnu.org --==-=-= Content-Type: multipart/mixed; boundary="=-=-=" --=-=-= 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)))) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-guix-package-Exit-with-1-when-a-generation-cannot-be.patch Content-Transfer-Encoding: quoted-printable From=20f42056aa768a405a893b5846dad8f8fa576b1156 Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Tue, 24 Sep 2013 22:11:16 +0000 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. =2D-- 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 =2D-- 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) =2D (for-each list-generation =2D (generation-numbers profile))) + (let ((numbers (generation-numbers profile))) + (if (equal? numbers '(0)) + (exit 1) + (for-each list-generation numbers)))) ((matching-generations pattern profile) =3D> =2D (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 =2D-- 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= `" \ =3D " guile-bootstrap" =20 + # Exit with 1 when a generation does not exist. + if guix package -p "$profile" --list-generations=3D42; + then false; else true; fi + # Remove a package. guix package --bootstrap -p "$profile" -r "guile-bootstrap" test -L "$profile-3-link" =2D-=20 1.7.9.5 --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0002-guix-package-Do-not-list-the-zeroth-generation.patch Content-Transfer-Encoding: quoted-printable From=20bea0168c28932921e6e2d6dcf3e9a26c555b698c Mon Sep 17 00:00:00 2001 From: Nikita Karetnikov Date: Tue, 24 Sep 2013 22:18:09 +0000 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. =2D-- 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 =2D-- a/doc/guix.texi +++ b/doc/guix.texi @@ -583,9 +583,8 @@ When combined with options such as @code{--install}, ro= ll back occurs before any other actions. =20 When rolling back from the first generation that actually contains =2Dinstalled packages, the profile is made to point to the @dfn{empty =2Dprofile}, also known as @dfn{profile zero}---i.e., it contains no files =2Dapart 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. =20 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 defi= nition. @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 =2Dinstalled packages shown last. +installed packages shown last. Note that the zeroth generation is never +shown. =20 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 =2D-- 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) =2D (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 =2D-- a/tests/guix-package.sh +++ b/tests/guix-package.sh @@ -111,6 +111,9 @@ then test "`readlink_base "$profile"`" =3D "$profile-0-link" done =20 + # 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"`" =3D "$profile-1-link" =2D-=20 1.7.9.5 --=-=-=-- --==-=-= Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) iQIcBAEBAgAGBQJSQhJkAAoJEM+IQzI9IQ380d4P/Ay5sj13juMB8eP3g+w/USYX yVq2WhC16NKxnBVXP9I+kxxp56A5rxDMCj5uZMj9jcyGZxnEQLh5vvAl47zOkDdb q1bJERGoBRAjrQ/ARXERPsDX6Mt28IoKNfYmmWTdx8DT4lTD6nH18PGxGBQfvXRo 47Q2d/5ciIUZnCR83ZOCjDHKdJtG0XtpQT4xsJuufYBu+yBTzQ8K4k2MIPlrQ+Aw 55KBqOTsq8RirgQDS/AxEEwFCmWQiEe0ZkgXRgqzWhXP6iQFTPV0YqGvRXXkS6uP XQXoykrlmAuOwhbUuSTUJA8Pv9VfH1+bG8qbZZ2kQNGyzHR/wX5Azs2DASdx88Am mXiwZ/gLsWWN2f131bRhuJnBHaVos/OTQLWq9m+eYsGrX6M9/T1JQ1GNB2auKa9W dK8i9S35gQpudu3qdMbTvfABTaaPJEwFPsjbya1+yf0xPqqVpaTErgr/r1AUtK7z VtvwLf9Ln4ISuc45IBirsOd2x8gM5YuUfLvCtKs/5S9OJ1P6BRPTWGrVunpdUXQJ RkapypI13a+cnQNdHqDCdVKYUW+MUbA7SEOpovJTr9BKlarmU5KTU5jssDvdUm7D WsWydtuIGULgK3m59t5FZFCMDPygS8irV6HaWRUQomMrAlpFQA3nDmWcdaZlEZZh 8HVcVZycu7foVvg8bg5B =uKjL -----END PGP SIGNATURE----- --==-=-=--