GNU bug report logs - #27596
[PATCH] guix: lint: Add checker for new upstream versions.

Previous Next

Package: guix-patches;

Reported by: Efraim Flashner <efraim <at> flashner.co.il>

Date: Thu, 6 Jul 2017 10:18:01 UTC

Severity: normal

Tags: patch

Done: Efraim Flashner <efraim <at> flashner.co.il>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27596 in the body.
You can then email your comments to 27596 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#27596; Package guix-patches. (Thu, 06 Jul 2017 10:18:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Efraim Flashner <efraim <at> flashner.co.il>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Thu, 06 Jul 2017 10:18:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: guix-patches <at> gnu.org
Subject: [PATCH] guix: lint: Add checker for new upstream versions.
Date: Thu,  6 Jul 2017 13:17:23 +0300
* guix/scripts/lint.scm (check-for-updates): New procedure.
(%checkers): Add it.
---
 guix/scripts/lint.scm | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 04ab85299..665db158c 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -35,6 +35,7 @@
   #:use-module (guix utils)
   #:use-module (guix memoization)
   #:use-module (guix scripts)
+  #:use-module (guix scripts refresh)
   #:use-module (guix gnu-maintenance)
   #:use-module (guix monads)
   #:use-module (guix cve)
@@ -72,6 +73,7 @@
             check-mirror-url
             check-license
             check-vulnerabilities
+            check-for-updates
             check-formatting
             run-checkers
 
@@ -821,6 +823,10 @@ from ~s: ~a (~s)~%")
                                  (string-join (map vulnerability-id unpatched)
                                               ", ")))))))))
 
+(define (check-for-updates package)
+  "Check if there is an update available for PACKAGE."
+  (guix-refresh (package-name package)))
+
 
 ;;;
 ;;; Source code formatting.
@@ -972,6 +978,10 @@ or a list thereof")
  (CVE) database")
      (check       check-vulnerabilities))
    (lint-checker
+     (name        'refresh)
+     (description "Check the package for new upstream releases")
+     (check       check-for-updates))
+   (lint-checker
      (name        'formatting)
      (description "Look for formatting issues in the source")
      (check       check-formatting))))
-- 
2.13.2





Information forwarded to guix-patches <at> gnu.org:
bug#27596; Package guix-patches. (Thu, 06 Jul 2017 14:36:01 GMT) Full text and rfc822 format available.

Message #8 received at 27596 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 27596 <at> debbugs.gnu.org
Subject: Re: [bug#27596] [PATCH] guix: lint: Add checker for new upstream
 versions.
Date: Thu, 06 Jul 2017 16:35:38 +0200
Efraim Flashner <efraim <at> flashner.co.il> skribis:

> * guix/scripts/lint.scm (check-for-updates): New procedure.
> (%checkers): Add it.

Good idea.

> +(define (check-for-updates package)
> +  "Check if there is an update available for PACKAGE."
> +  (guix-refresh (package-name package)))

I think we should use the (guix upstream) API directly because
‘guix-refresh’ can call ‘exit’ and it formats messages in a way that is
not consistent with the rest of ‘guix lint’.

To do that I think we’ll first have to move ‘%updaters’ to (guix
upstream), probably turning it into a procedure.

WDYT?

Thanks,
Ludo’.





Information forwarded to guix-patches <at> gnu.org:
bug#27596; Package guix-patches. (Tue, 01 Aug 2017 11:21:01 GMT) Full text and rfc822 format available.

Message #11 received at 27596 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27596 <at> debbugs.gnu.org
Subject: Re: [bug#27596] [PATCH] guix: lint: Add checker for new upstream
 versions.
Date: Tue, 1 Aug 2017 14:20:46 +0300
[Message part 1 (text/plain, inline)]
On Thu, Jul 06, 2017 at 04:35:38PM +0200, Ludovic Courtès wrote:
> Efraim Flashner <efraim <at> flashner.co.il> skribis:
> 
> > * guix/scripts/lint.scm (check-for-updates): New procedure.
> > (%checkers): Add it.
> 
> Good idea.
> 
> > +(define (check-for-updates package)
> > +  "Check if there is an update available for PACKAGE."
> > +  (guix-refresh (package-name package)))
> 
> I think we should use the (guix upstream) API directly because
> ‘guix-refresh’ can call ‘exit’ and it formats messages in a way that is
> not consistent with the rest of ‘guix lint’.
> 
> To do that I think we’ll first have to move ‘%updaters’ to (guix
> upstream), probably turning it into a procedure.
> 
> WDYT?
> 
> Thanks,
> Ludo’.
> 

This actually wasn't too bad. I had to move %updaters and another
function to guix/upstream, and then I copied the code for checking the
upstream version vs the current version and tried to shorten it a bit.

I tested it with 'guix lint -c refresh perl{,-svg}'

-- 
Efraim Flashner   <efraim <at> 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
[0001-guix-lint-Add-checker-for-new-upstream-versions.patch (text/plain, attachment)]
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#27596; Package guix-patches. (Tue, 22 Aug 2017 13:19:02 GMT) Full text and rfc822 format available.

Message #14 received at 27596 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 27596 <at> debbugs.gnu.org
Subject: Re: [bug#27596] [PATCH] guix: lint: Add checker for new upstream
 versions.
Date: Tue, 22 Aug 2017 15:17:58 +0200
Hi Efraim,

Sorry for the delay.

Efraim Flashner <efraim <at> flashner.co.il> skribis:

> From 136841864c883338381764ef09a6f4ec967949e7 Mon Sep 17 00:00:00 2001
> From: Efraim Flashner <efraim <at> flashner.co.il>
> Date: Thu, 6 Jul 2017 09:13:31 +0300
> Subject: [PATCH] guix: lint: Add checker for new upstream versions.
>
> * guix/scripts/lint.scm (check-for-updates): New procedure.
> (%checkers): Add it.
> * guix/scripts/refresh.scm (importer-modules, %updaters): Move
> from here ...
> * guix/upstream.scm: ... to here.

[...]

> +(define (check-for-updates package)
> +  "Check if there is an update available for PACKAGE."
> +  (match (package-latest-release package (force %updaters))
> +    ((? upstream-source? source)
> +     (when (version>? (upstream-source-version source)
> +                      (package-version package))
> +       (emit-warning package
> +                     (format #f (G_ "can be upgraded to ~a~%")
> +                             (upstream-source-version source)))))))

I think you can (1) use ‘package-latest-release*’ which ensures that the
returned version is newer, and (2) add a case for #f since
‘package-latest-release*’ can return #f.

Apart from that it LGTM, thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27596; Package guix-patches. (Sat, 07 Oct 2017 20:51:01 GMT) Full text and rfc822 format available.

Message #17 received at 27596 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 27596 <at> debbugs.gnu.org
Subject: Re: [bug#27596] [PATCH] guix: lint: Add checker for new upstream
 versions.
Date: Sat, 07 Oct 2017 22:50:21 +0200
Ping!  :-)

ludo <at> gnu.org (Ludovic Courtès) skribis:

> Hi Efraim,
>
> Sorry for the delay.
>
> Efraim Flashner <efraim <at> flashner.co.il> skribis:
>
>> From 136841864c883338381764ef09a6f4ec967949e7 Mon Sep 17 00:00:00 2001
>> From: Efraim Flashner <efraim <at> flashner.co.il>
>> Date: Thu, 6 Jul 2017 09:13:31 +0300
>> Subject: [PATCH] guix: lint: Add checker for new upstream versions.
>>
>> * guix/scripts/lint.scm (check-for-updates): New procedure.
>> (%checkers): Add it.
>> * guix/scripts/refresh.scm (importer-modules, %updaters): Move
>> from here ...
>> * guix/upstream.scm: ... to here.
>
> [...]
>
>> +(define (check-for-updates package)
>> +  "Check if there is an update available for PACKAGE."
>> +  (match (package-latest-release package (force %updaters))
>> +    ((? upstream-source? source)
>> +     (when (version>? (upstream-source-version source)
>> +                      (package-version package))
>> +       (emit-warning package
>> +                     (format #f (G_ "can be upgraded to ~a~%")
>> +                             (upstream-source-version source)))))))
>
> I think you can (1) use ‘package-latest-release*’ which ensures that the
> returned version is newer, and (2) add a case for #f since
> ‘package-latest-release*’ can return #f.
>
> Apart from that it LGTM, thank you!
>
> Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27596; Package guix-patches. (Sun, 08 Oct 2017 19:50:02 GMT) Full text and rfc822 format available.

Message #20 received at 27596 <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27596 <at> debbugs.gnu.org
Subject: Re: [bug#27596] [PATCH] guix: lint: Add checker for new upstream
 versions.
Date: Sun, 8 Oct 2017 22:49:04 +0300
[Message part 1 (text/plain, inline)]
On Sat, Oct 07, 2017 at 10:50:21PM +0200, Ludovic Courtès wrote:
> Ping!  :-)
> 
> ludo <at> gnu.org (Ludovic Courtès) skribis:
> 
> > Hi Efraim,
> >
> > Sorry for the delay.
> >
> > Efraim Flashner <efraim <at> flashner.co.il> skribis:
> >
> >> From 136841864c883338381764ef09a6f4ec967949e7 Mon Sep 17 00:00:00 2001
> >> From: Efraim Flashner <efraim <at> flashner.co.il>
> >> Date: Thu, 6 Jul 2017 09:13:31 +0300
> >> Subject: [PATCH] guix: lint: Add checker for new upstream versions.
> >>
> >> * guix/scripts/lint.scm (check-for-updates): New procedure.
> >> (%checkers): Add it.
> >> * guix/scripts/refresh.scm (importer-modules, %updaters): Move
> >> from here ...
> >> * guix/upstream.scm: ... to here.
> >
> > [...]
> >
> >> +(define (check-for-updates package)
> >> +  "Check if there is an update available for PACKAGE."
> >> +  (match (package-latest-release package (force %updaters))
> >> +    ((? upstream-source? source)
> >> +     (when (version>? (upstream-source-version source)
> >> +                      (package-version package))
> >> +       (emit-warning package
> >> +                     (format #f (G_ "can be upgraded to ~a~%")
> >> +                             (upstream-source-version source)))))))
> >
> > I think you can (1) use ‘package-latest-release*’ which ensures that the
> > returned version is newer, and (2) add a case for #f since
> > ‘package-latest-release*’ can return #f.
> >
> > Apart from that it LGTM, thank you!
> >
> > Ludo’.

I've been working on it with package-latest-release*, and its nice not
having to reimplement the logic, but I can't get it to return the newest
version of the upstream-package. I got it to return a useful message
with:

(define (check-for-updates package)
  (if (package-latest-release* package (force %updaters))
       (emit-warning package
                     (format #f (G_ "can be upgraded to ~a~%")
                             (upstream-source-version (package-latest-release package (force %updaters)))))
       #t))

but I've already checked if there's an upstream release, I shouldn't
need to check a second time. package-latest-release* returns true/false,
so if I want to print the version to upgrade to I need to check it a
second time. package-latest-release returns an <upstream-source> which
is more easily queried for the latest upstream version.

-- 
Efraim Flashner   <efraim <at> 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
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#27596; Package guix-patches. (Mon, 09 Oct 2017 07:29:01 GMT) Full text and rfc822 format available.

Message #23 received at 27596 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Efraim Flashner <efraim <at> flashner.co.il>
Cc: 27596 <at> debbugs.gnu.org
Subject: Re: [bug#27596] [PATCH] guix: lint: Add checker for new upstream
 versions.
Date: Mon, 09 Oct 2017 09:28:04 +0200
Hello!

Efraim Flashner <efraim <at> flashner.co.il> skribis:

> On Sat, Oct 07, 2017 at 10:50:21PM +0200, Ludovic Courtès wrote:

[...]

>> >> +(define (check-for-updates package)
>> >> +  "Check if there is an update available for PACKAGE."
>> >> +  (match (package-latest-release package (force %updaters))
>> >> +    ((? upstream-source? source)
>> >> +     (when (version>? (upstream-source-version source)
>> >> +                      (package-version package))
>> >> +       (emit-warning package
>> >> +                     (format #f (G_ "can be upgraded to ~a~%")
>> >> +                             (upstream-source-version source)))))))
>> >
>> > I think you can (1) use ‘package-latest-release*’ which ensures that the
>> > returned version is newer, and (2) add a case for #f since
>> > ‘package-latest-release*’ can return #f.
>> >
>> > Apart from that it LGTM, thank you!
>> >
>> > Ludo’.
>
> I've been working on it with package-latest-release*, and its nice not
> having to reimplement the logic, but I can't get it to return the newest
> version of the upstream-package. I got it to return a useful message
> with:
>
> (define (check-for-updates package)
>   (if (package-latest-release* package (force %updaters))
>        (emit-warning package
>                      (format #f (G_ "can be upgraded to ~a~%")
>                              (upstream-source-version (package-latest-release package (force %updaters)))))
>        #t))
>
> but I've already checked if there's an upstream release, I shouldn't
> need to check a second time. package-latest-release* returns true/false,


AFAICS ‘package-latest-release*’ returns #f or an <upstream-source>:

--8<---------------cut here---------------start------------->8---
scheme@(guile-user)> (package-latest-release* binutils (force %updaters))
$4 = #<<upstream-source> package: "binutils" version: "2.29.1" urls: ("mirror://gnu/binutils/binutils-2.29.1.tar.gz" "mirror://gnu/binutils/binutils-2.29.1.tar.lz" "mirror://gnu/binutils/binutils-2.29.1.tar.bz2" "mirror://gnu/binutils/binutils-2.29.1.tar.xz") signature-urls: ("mirror://gnu/binutils/binutils-2.29.1.tar.gz.sig" "mirror://gnu/binutils/binutils-2.29.1.tar.lz.sig" "mirror://gnu/binutils/binutils-2.29.1.tar.bz2.sig" "mirror://gnu/binutils/binutils-2.29.1.tar.xz.sig")>
--8<---------------cut here---------------end--------------->8---

So you can write:

  (match (package-latest-release* package (force %updaters))
    ((? upstream-source? source)
     …)
    (#f   ;cannot determine latest release
     #f))

HTH!

Ludo’.




Reply sent to Efraim Flashner <efraim <at> flashner.co.il>:
You have taken responsibility. (Mon, 09 Oct 2017 11:19:02 GMT) Full text and rfc822 format available.

Notification sent to Efraim Flashner <efraim <at> flashner.co.il>:
bug acknowledged by developer. (Mon, 09 Oct 2017 11:19:02 GMT) Full text and rfc822 format available.

Message #28 received at 27596-done <at> debbugs.gnu.org (full text, mbox):

From: Efraim Flashner <efraim <at> flashner.co.il>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27596-done <at> debbugs.gnu.org
Subject: Re: [bug#27596] [PATCH] guix: lint: Add checker for new upstream
 versions.
Date: Mon, 9 Oct 2017 14:17:54 +0300
[Message part 1 (text/plain, inline)]
On Mon, Oct 09, 2017 at 09:28:04AM +0200, Ludovic Courtès wrote:
> Hello!
> 
> Efraim Flashner <efraim <at> flashner.co.il> skribis:
> 
> > On Sat, Oct 07, 2017 at 10:50:21PM +0200, Ludovic Courtès wrote:
> 
> [...]
> 
> >> >> +(define (check-for-updates package)
> >> >> +  "Check if there is an update available for PACKAGE."
> >> >> +  (match (package-latest-release package (force %updaters))
> >> >> +    ((? upstream-source? source)
> >> >> +     (when (version>? (upstream-source-version source)
> >> >> +                      (package-version package))
> >> >> +       (emit-warning package
> >> >> +                     (format #f (G_ "can be upgraded to ~a~%")
> >> >> +                             (upstream-source-version source)))))))
> >> >
> >> > I think you can (1) use ‘package-latest-release*’ which ensures that the
> >> > returned version is newer, and (2) add a case for #f since
> >> > ‘package-latest-release*’ can return #f.
> >> >
> >> > Apart from that it LGTM, thank you!
> >> >
> >> > Ludo’.
> >
> > I've been working on it with package-latest-release*, and its nice not
> > having to reimplement the logic, but I can't get it to return the newest
> > version of the upstream-package. I got it to return a useful message
> > with:
> >
> > (define (check-for-updates package)
> >   (if (package-latest-release* package (force %updaters))
> >        (emit-warning package
> >                      (format #f (G_ "can be upgraded to ~a~%")
> >                              (upstream-source-version (package-latest-release package (force %updaters)))))
> >        #t))
> >
> > but I've already checked if there's an upstream release, I shouldn't
> > need to check a second time. package-latest-release* returns true/false,
> 
> 
> AFAICS ‘package-latest-release*’ returns #f or an <upstream-source>:
> 
> --8<---------------cut here---------------start------------->8---
> scheme@(guile-user)> (package-latest-release* binutils (force %updaters))
> $4 = #<<upstream-source> package: "binutils" version: "2.29.1" urls: ("mirror://gnu/binutils/binutils-2.29.1.tar.gz" "mirror://gnu/binutils/binutils-2.29.1.tar.lz" "mirror://gnu/binutils/binutils-2.29.1.tar.bz2" "mirror://gnu/binutils/binutils-2.29.1.tar.xz") signature-urls: ("mirror://gnu/binutils/binutils-2.29.1.tar.gz.sig" "mirror://gnu/binutils/binutils-2.29.1.tar.lz.sig" "mirror://gnu/binutils/binutils-2.29.1.tar.bz2.sig" "mirror://gnu/binutils/binutils-2.29.1.tar.xz.sig")>
> --8<---------------cut here---------------end--------------->8---
> 
> So you can write:
> 
>   (match (package-latest-release* package (force %updaters))
>     ((? upstream-source? source)
>      …)
>     (#f   ;cannot determine latest release
>      #f))
> 
> HTH!
> 
> Ludo’.

I looked at the final diff between my earlier patch and my final
version, it pretty much added up to the lines you wrote above ;) I
should get myself a rubber duck, should help my debugging and reading
skills.


-- 
Efraim Flashner   <efraim <at> 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
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 06 Nov 2017 12:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 6 years and 165 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.