Re: [PATCH] guix package: Add '--list-generations'.

2013-09-21 Thread Ludovic Courtès
Commit 99882c6 modifies ‘--list-generations’ so that generations are
listed in numerical order:

--8<---cut here---start->8---
$ LC_ALL=fr_FR.utf8 ./pre-inst-env guix package --list-generations|grep ^G|head 
-13|tail -3
Generation 99   août 24 2013 10:37:50
Generation 100  août 25 2013 16:20:07
Generation 101  sept. 02 2013 13:36:45
--8<---cut here---end--->8---

Ludo’.



Re: [PATCH] guix package: Add '--list-generations'.

2013-09-19 Thread Ludovic Courtès
Nikita Karetnikov  skribis:

>>> Can I push the attached patch to ‘master’?
>
>> Yep!
>
> Done.

Great, thank you!

Ludo’.



Re: [PATCH] guix package: Add '--list-generations'.

2013-09-19 Thread Nikita Karetnikov
> That’s not necessarily a bug: it could be that generation 1 is just
> slightly more than 48 hours old (the time should also be displayed, I
> think.)

Right, that’s what I was trying to show.  Anyway, it shouldn’t be an
issue now.

OK, I added ‘~T’.

> This should be present tense overall (for example, s/will print/prints/,
> s/will output/outputs/, etc.)

Done.

>> Can I push the attached patch to ‘master’?

> Yep!

Done.


pgpHvLkn4plIe.pgp
Description: PGP signature


Re: [PATCH] guix package: Add '--list-generations'.

2013-09-19 Thread Ludovic Courtès
Nikita Karetnikov  skribis:

>> Ah so I was referring to recutils record sets (I thought you were
>> talking about SRFI-9 records or something.)  So what’s the question?
>> :-)
>
> I was trying to explain why we shouldn’t always output generations in
> the recutils format.  It works for ‘--search’ because there’s only one
> record.

Ah OK, makes sense.

>>> I’m attaching the patch.  Please don’t push it yet.  I’ve just found a
>>> bug.  On my machine, ‘guix package -p test -l 2d’ and ‘guix package -p
>>> test -l’ should return the same set of generations, but the fourth
>>> generation is shown twice in the former case.
>
>> OK.
>
> Fixed, but I found a new one.  We output a human-readable date but
> filter generations based on ‘ctime’.  This may cause problems in some
> cases.
>
> Let me try to demonstrate the problem.
>
> $ ./pre-inst-env guix package -p test -l
>
> Generation 1  Sep 16 2013
> Generation 2  Sep 16 2013
> Generation 3  Sep 16 2013
> Generation 4  Sep 16 2013
> Generation 5  Sep 16 2013
> Generation 6  Sep 17 2013
>
> And the last two days:
>
> $ ./pre-inst-env guix package -p test -l 2d
> Generation 2  Sep 16 2013
> Generation 3  Sep 16 2013
> Generation 4  Sep 16 2013
> Generation 5  Sep 16 2013
> Generation 6  Sep 17 2013
>
> See?  Even though the first five generations have the same date, the
> first one is not shown.

That’s not necessarily a bug: it could be that generation 1 is just
slightly more than 48 hours old (the time should also be displayed, I
think.)

>> I’d use @table rather than @itemize.
>
> IIUC, it can be used only with the following commands: “@code, @samp,
> @var, @option, or @kbd.” [1]  Neither command seems to match.

The manual says that @table “works with other commands besides those
explicitly mentioned”, so you could use @emph or @asis.

>> s/If you pass/Passing/
>> s/will return/specifies/
>
> This doesn’t sound right because the other sentences use “will.”

This should be present tense overall (for example, s/will print/prints/,
s/will output/outputs/, etc.)

> Can I push the attached patch to ‘master’?

Yep!

Thank you!

Ludo’.



[PATCH] guix package: Add '--list-generations'.

2013-09-18 Thread Nikita Karetnikov
> Ah so I was referring to recutils record sets (I thought you were
> talking about SRFI-9 records or something.)  So what’s the question?
> :-)

I was trying to explain why we shouldn’t always output generations in
the recutils format.  It works for ‘--search’ because there’s only one
record.

>> I’m attaching the patch.  Please don’t push it yet.  I’ve just found a
>> bug.  On my machine, ‘guix package -p test -l 2d’ and ‘guix package -p
>> test -l’ should return the same set of generations, but the fourth
>> generation is shown twice in the former case.

> OK.

Fixed, but I found a new one.  We output a human-readable date but
filter generations based on ‘ctime’.  This may cause problems in some
cases.

Let me try to demonstrate the problem.

$ ./pre-inst-env guix package -p test -l

Generation 1Sep 16 2013
Generation 2Sep 16 2013
Generation 3Sep 16 2013
Generation 4Sep 16 2013
Generation 5Sep 16 2013
Generation 6Sep 17 2013

And the last two days:

$ ./pre-inst-env guix package -p test -l 2d
Generation 2Sep 16 2013
Generation 3Sep 16 2013
Generation 4Sep 16 2013
Generation 5Sep 16 2013
Generation 6Sep 17 2013

See?  Even though the first five generations have the same date, the
first one is not shown.

I believe that this bug is now fixed.

I incorporated all your suggestions except the following ones.

> I’d use @table rather than @itemize.

IIUC, it can be used only with the following commands: “@code, @samp,
@var, @option, or @kbd.” [1]  Neither command seems to match.

> s/If you pass/Passing/
> s/will return/specifies/

This doesn’t sound right because the other sentences use “will.”

Can I push the attached patch to ‘master’?

[1] https://gnu.org/software/texinfo/manual/texinfo/texinfo.html#index-table

From 65a2d978e1b74cde953e81109dad33f2562e8294 Mon Sep 17 00:00:00 2001
From: Nikita Karetnikov 
Date: Thu, 19 Sep 2013 00:36:05 +0000
Subject: [PATCH] guix package: Add '--list-generations'.

* guix/scripts/package.scm: Import (srfi srfi-19).
  (generation-time, matching-generations): New functions.
  (show-help): Add '--list-generations'.
  (%options): Likewise.
  (guix-package)[process-query]: Add support for '--list-generations'.
* guix/ui.scm: Import (srfi srfi-19) and (ice-9 regex).
  (string->generations, string->duration): New functions.
* tests/guix-package.sh: Test '--list-generations'.
* tests/ui.scm: Import (srfi srfi-19).
  Test 'string->generations' and 'string->duration'.
* doc/guix.texi (Invoking guix-package): Document '--list-generations'.
---
 doc/guix.texi|   33 ++
 guix/scripts/package.scm |  107 ++
 guix/ui.scm  |   68 +
 tests/guix-package.sh|4 ++
 tests/ui.scm |   85 
 5 files changed, 297 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 5d1b780..680e629 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -606,6 +606,39 @@ library are installed in the profile, then @code{--search-paths} will
 suggest setting these variables to @code{@var{profile}/include} and
 @code{@var{profile}/lib}, respectively.
 
+@item --list-generations[=@var{pattern}]
+@itemx -l [@var{pattern}]
+Return a list of generations along with their creation dates.
+
+For each installed package, print the following items, separated by
+tabs: the name of a package, its version string, the part of the package
+that is installed (@pxref{Packages with Multiple Outputs}), and the
+location of this package in the store.
+
+When @var{pattern} is used, the command returns only matching
+generations.  Valid patterns include:
+
+@itemize
+@item @emph{Integers and comma-separated integers}.  Both patterns denote
+generation numbers.  For instance, @code{--list-generations=1} will
+return the first one.
+
+And @code{--list-generations=1,8,2} will output three generations in the
+specified order.  Neither spaces nor trailing commas are allowed.
+
+@item @emph{Ranges}.  @code{--list-generations=2..9} will print the
+specified generations and everything in between.  Note that the
+start of a range must be lesser than its end.
+
+It is also possible to omit the endpoint.  For example,
+@code{--list-generations=2..}, will output all generations starting from
+the second one.
+
+@item @emph{Durations}.  You can also get the last @emph{N}@tie{}days, weeks,
+or months by passing an integer along with the first letter of the
+duration, e.g., @code{--list-generations=20d}.
+@end itemize
+
 @item --profile=@var{profile}
 @itemx -p @var{profile}
 Use @var{profile} instead of the user's default profile.
diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm
index 1393ca3..1cff9b0 100644
--- a/guix/scripts/package.scm
+++ b/guix/scripts/package.scm
@@ -34,6 +34,7 @@
   #:use-mo

Re: PRELIMINARY: [PATCH] guix package: Add '--list-generations'.

2013-09-18 Thread Ludovic Courtès
Nikita Karetnikov  skribis:

> 3. ‘guix package -l -p test’ returns ‘guix package: error: test:
>extraneous argument’.  (However, the same happens with ‘-I’.)

That’s because -p is interpreted as the optional argument to -l, and so
‘test’ is considered an extra argument.

Ludo’.



Re: PRELIMINARY: [PATCH] guix package: Add '--list-generations'.

2013-09-18 Thread Ludovic Courtès
Nikita Karetnikov  skribis:

>> Not sure what you mean by “two record sets”.
>
> “You can have two record sets: one for generations, one for
> packages.” [1]

Ah so I was referring to recutils record sets (I thought you were
talking about SRFI-9 records or something.)  So what’s the question?
:-)

>>> Why do you suggest to put ‘string->duration’ into (guix ui)?
>
>> Because it’s a user-interface function.
>
> Done.  However, I think it would be better to write more generic
> procedures if we want to place them in separate modules, so they can be
> reused.  (I can replace the current version with a more generic one if
> you want.)

Well, ‘string->duration’ is just as generic as ‘string->number’.

However I agree ‘string->generation’ could remain internal to
(guix scripts package).  No big deal though.

> I’m attaching the patch.  Please don’t push it yet.  I’ve just found a
> bug.  On my machine, ‘guix package -p test -l 2d’ and ‘guix package -p
> test -l’ should return the same set of generations, but the fourth
> generation is shown twice in the former case.

OK.

> Other issues:
>
> 1. ‘false-if-exception’ in ‘generation-ctime’.
>
> 2. A race condition (marked with XXX).
>
> 3. ‘guix package -l -p test’ returns ‘guix package: error: test:
>extraneous argument’.  (However, the same happens with ‘-I’.)
>
> 4. There must be a better way to write the test in
>‘tests/guix-package.sh’.

[...]

> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -606,6 +606,42 @@ library are installed in the profile, then 
> @code{--search-paths} will
>  suggest setting these variables to @code{@var{profile}/include} and
>  @code{@var{profile}/lib}, respectively.
>  
> +@item --list-generations[=@var{regexp}]
> +@itemx -l [@var{regexp}]

s/regexp/pattern/

> +Return a list of generations along with their creation dates.
> +
> +For each installed package, print the following items, separated by
> +tabs: the name of a package, its version string, the part of the package
> +that is installed (@pxref{Packages with Multiple Outputs}), and the
> +location of this package in the store.
> +
> +When @var{regexp} is used, the command returns only matching
> +generations.  Valid patterns include:
> +
> +@itemize
> +@item @emph{Integers and comma-separated integers}.  Both patterns will 
> simply
> +return the corresponding generations.  For instance,
> +@code{--list-generations=1} will return the first one.

I’d use @table rather than @itemize.

Wording: a pattern doesn’t “return” anything, so perhaps:

  These patterns denote generation numbers.

> +If you pass @code{--list-generations=1,8,2}, the command will return
> +three generations in the specified order.  Neither spaces nor trailing
> +commas are allowed.

s/If you pass/Passing/
s/will return/specifies/

> @@ -441,6 +502,9 @@ Install, remove, or upgrade PACKAGES in a single 
> transaction.\n"))
>--roll-backroll back to the previous generation"))
>(display (_ "
>--search-paths display needed environment variable definitions"))
> +  (display (_ "
> +  -l  --list-generations[=REGEXP]
> + list generations matching REGEXP"))

Should be “-l, --list-generations”, with a comma.
s/REGEXP/PATTERN/

> --- a/tests/guix-package.sh
> +++ b/tests/guix-package.sh
> @@ -81,6 +81,10 @@ then
>  "name: hello"
>  test "`guix package -s "n0t4r341p4ck4g3"`" = ""
>  
> +# List generations.
> +test "`guix package -p "$profile" -l | cut -f1 | grep guile | head -n1`" 
> \
> += "  guile-bootstrap"

That’s OK.  You could also grep the string “generation 1” (assuming
we’re running in the C locale, dunno if it’s the case.)

> +(test-equal "infinite end range"

s/infinite/indefinite/

Looks like this is ready to get in!

Ludo’.



Re: PRELIMINARY: [PATCH] guix package: Add '--list-generations'.

2013-09-18 Thread Nikita Karetnikov
> I’ve just found a bug.  On my machine, ‘guix package -p test -l 2d’
> and ‘guix package -p test -l’ should return the same set of
> generations, but the fourth generation is shown twice in the former
> case.

Generations 4 and 5 have the same creation date for some reason:

scheme@(guix ui)> dates-generations
$4 = ((1379357250 . 1) (1379364436 . 2) (1379364463 . 3) (1379364530 . 4) 
(1379364530 . 5) (1379419461 . 6))

Since this line

(map (cut assoc-ref dates-generations <>)

returns the first entry with the given key, the fourth generation is
printed twice.

I’ll try to replace the alist with something else.


pgploKIAGj9qP.pgp
Description: PGP signature


PRELIMINARY: [PATCH] guix package: Add '--list-generations'.

2013-09-17 Thread Nikita Karetnikov
> I think it’s reasonable to have a first milestone without recutils
> output.

OK.

> Not sure what you mean by “two record sets”.

“You can have two record sets: one for generations, one for
packages.” [1]

> I see two use cases: one where you just want human-friendly output, for
> when one is glancing at the available generations, and one that is more
> amenable to Unix pipelines for post-processing.  Recutils output is for
> the latter case.

Right.

>> I still think that someone may benefit from the recutils format.  So
>> let’s allow the ‘recutils’ argument that would list all generations in
>> that format [1] and use the following format [2] for everything else:
>>
>>   generation 1 Dec 16 2013
>> guile2.0.7 out,debuggnu/packages/guile.scm
>> hello2.8   out  gnu/packages/base.scm
>>
>>   generation 2 May 7 2013
>> guile2.0.9 out  gnu/packages/guile.scm
>>
>> Is it OK?

> Yes.

>> Should it point to the store instead of (gnu packages …)?

> Yes, I think so.

Done.

>> Why do you suggest to put ‘string->duration’ into (guix ui)?

> Because it’s a user-interface function.

Done.  However, I think it would be better to write more generic
procedures if we want to place them in separate modules, so they can be
reused.  (I can replace the current version with a more generic one if
you want.)

>> I installed Nix 1.5.3. and ran the command:
>>
>> error: setting synchronous mode: unable to open database file

> Problem with permissions on the SQLite database, I guess.

I “fixed” it by deleting the store and reinstalling Guix.

I’m attaching the patch.  Please don’t push it yet.  I’ve just found a
bug.  On my machine, ‘guix package -p test -l 2d’ and ‘guix package -p
test -l’ should return the same set of generations, but the fourth
generation is shown twice in the former case.

Other issues:

1. ‘false-if-exception’ in ‘generation-ctime’.

2. A race condition (marked with XXX).

3. ‘guix package -l -p test’ returns ‘guix package: error: test:
   extraneous argument’.  (However, the same happens with ‘-I’.)

4. There must be a better way to write the test in
   ‘tests/guix-package.sh’.

[1] https://lists.gnu.org/archive/html/guix-devel/2013-08/msg00173.html

From 27e73d3d86ca7abfbc470f3561c059d730314821 Mon Sep 17 00:00:00 2001
From: Nikita Karetnikov 
Date: Tue, 17 Sep 2013 23:56:10 +
Subject: [PATCH] guix package: Add '--list-generations'.

* guix/scripts/package.scm: Import (srfi srfi-19).
  (generation-ctime, matching-generations): New functions.
  (show-help): Add '--list-generations'.
  (%options): Likewise.
  (guix-package)[process-query]: Add support for '--list-generations'.
* guix/ui.scm: Import (srfi srfi-19) and (ice-9 regex).
  (string->generations, string->duration): New functions.
* tests/guix-package.sh: Test '--list-generations'.
* tests/ui.scm: Import (srfi srfi-19).
  Test 'string->generations' and 'string->duration'.
* doc/guix.texi (Invoking guix-package): Document '--list-generations'.
---
 doc/guix.texi|   36 +
 guix/scripts/package.scm |  100 ++
 guix/ui.scm  |   68 +++
 tests/guix-package.sh|4 ++
 tests/ui.scm |   85 +++
 5 files changed, 293 insertions(+)

diff --git a/doc/guix.texi b/doc/guix.texi
index 5d1b780..ebf80b4 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -606,6 +606,42 @@ library are installed in the profile, then @code{--search-paths} will
 suggest setting these variables to @code{@var{profile}/include} and
 @code{@var{profile}/lib}, respectively.
 
+@item --list-generations[=@var{regexp}]
+@itemx -l [@var{regexp}]
+Return a list of generations along with their creation dates.
+
+For each installed package, print the following items, separated by
+tabs: the name of a package, its version string, the part of the package
+that is installed (@pxref{Packages with Multiple Outputs}), and the
+location of this package in the store.
+
+When @var{regexp} is used, the command returns only matching
+generations.  Valid patterns include:
+
+@itemize
+@item @emph{Integers and comma-separated integers}.  Both patterns will simply
+return the corresponding generations.  For instance,
+@code{--list-generations=1} will return the first one.
+
+If you pass @code{--list-generations=1,8,2}, the command will return
+three generations in the specified order.  Neither spaces nor trailing
+commas are allowed.
+
+@item @emph{Ranges}.  @code{--list-generations=2..9} will print the
+specified generations and everything in between.  Note that the
+start of a range must be lesser than its end.
+
+It is also possible to omit the endpoint.  For example,
+@cod