unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Efraim Flashner <efraim@flashner.co.il>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 27596@debbugs.gnu.org
Subject: [bug#27596] [PATCH] guix: lint: Add checker for new upstream versions.
Date: Tue, 1 Aug 2017 14:20:46 +0300	[thread overview]
Message-ID: <20170801112046.GG2406@macbook42.flashner.co.il> (raw)
In-Reply-To: <87h8ypocp1.fsf@gnu.org>


[-- Attachment #1.1: Type: text/plain, Size: 1246 bytes --]

On Thu, Jul 06, 2017 at 04:35:38PM +0200, Ludovic Courtès wrote:
> Efraim Flashner <efraim@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@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

[-- Attachment #1.2: 0001-guix-lint-Add-checker-for-new-upstream-versions.patch --]
[-- Type: text/plain, Size: 5469 bytes --]

From 136841864c883338381764ef09a6f4ec967949e7 Mon Sep 17 00:00:00 2001
From: Efraim Flashner <efraim@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.
---
 guix/scripts/lint.scm    | 16 ++++++++++++++++
 guix/scripts/refresh.scm | 20 +-------------------
 guix/upstream.scm        | 18 ++++++++++++++++++
 3 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm
index 04ab85299..6cfdf25e3 100644
--- a/guix/scripts/lint.scm
+++ b/guix/scripts/lint.scm
@@ -32,6 +32,7 @@
   #:use-module (guix licenses)
   #:use-module (guix records)
   #:use-module (guix ui)
+  #:use-module (guix upstream)
   #:use-module (guix utils)
   #:use-module (guix memoization)
   #:use-module (guix scripts)
@@ -72,6 +73,7 @@
             check-mirror-url
             check-license
             check-vulnerabilities
+            check-for-updates
             check-formatting
             run-checkers
 
@@ -821,6 +823,16 @@ from ~s: ~a (~s)~%")
                                  (string-join (map vulnerability-id unpatched)
                                               ", ")))))))))
 
+(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)))))))
+
 \f
 ;;;
 ;;; Source code formatting.
@@ -972,6 +984,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))))
diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm
index 5add64d8e..d638d744a 100644
--- a/guix/scripts/refresh.scm
+++ b/guix/scripts/refresh.scm
@@ -30,7 +30,6 @@
   #:use-module (guix packages)
   #:use-module (guix profiles)
   #:use-module (guix upstream)
-  #:use-module (guix discovery)
   #:use-module (guix graph)
   #:use-module (guix scripts graph)
   #:use-module (guix monads)
@@ -46,8 +45,7 @@
   #:use-module (srfi srfi-26)
   #:use-module (srfi srfi-37)
   #:use-module (ice-9 binary-ports)
-  #:export (guix-refresh
-            %updaters))
+  #:export (guix-refresh))
 
 \f
 ;;;
@@ -162,22 +160,6 @@ specified with `--select'.\n"))
 ;;; Updates.
 ;;;
 
-(define (importer-modules)
-  "Return the list of importer modules."
-  (cons (resolve-interface '(guix gnu-maintenance))
-        (all-modules (map (lambda (entry)
-                            `(,entry . "guix/import"))
-                          %load-path))))
-
-(define %updaters
-  ;; The list of publically-known updaters.
-  (delay (fold-module-public-variables (lambda (obj result)
-                                         (if (upstream-updater? obj)
-                                             (cons obj result)
-                                             result))
-                                       '()
-                                       (importer-modules))))
-
 (define (lookup-updater-by-name name)
   "Return the updater called NAME."
   (or (find (lambda (updater)
diff --git a/guix/upstream.scm b/guix/upstream.scm
index 5083e6b80..70b7e295f 100644
--- a/guix/upstream.scm
+++ b/guix/upstream.scm
@@ -20,6 +20,7 @@
 (define-module (guix upstream)
   #:use-module (guix records)
   #:use-module (guix utils)
+  #:use-module (guix discovery)
   #:use-module ((guix download)
                 #:select (download-to-store))
   #:use-module (guix gnupg)
@@ -54,6 +55,7 @@
             upstream-updater-predicate
             upstream-updater-latest
 
+            %updaters
             lookup-updater
 
             download-tarball
@@ -127,6 +129,22 @@ correspond to the same version."
   (pred        upstream-updater-predicate)
   (latest      upstream-updater-latest))
 
+(define (importer-modules)
+  "Return the list of importer modules."
+  (cons (resolve-interface '(guix gnu-maintenance))
+        (all-modules (map (lambda (entry)
+                            `(,entry . "guix/import"))
+                          %load-path))))
+
+(define %updaters
+  ;; The list of publically-known updaters.
+  (delay (fold-module-public-variables (lambda (obj result)
+                                         (if (upstream-updater? obj)
+                                             (cons obj result)
+                                             result))
+                                       '()
+                                       (importer-modules))))
+
 (define (lookup-updater package updaters)
   "Return an updater among UPDATERS that matches PACKAGE, or #f if none of
 them matches."
-- 
2.13.3


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-08-01 11:21 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-06 10:17 [bug#27596] [PATCH] guix: lint: Add checker for new upstream versions Efraim Flashner
2017-07-06 14:35 ` Ludovic Courtès
2017-08-01 11:20   ` Efraim Flashner [this message]
2017-08-22 13:17     ` Ludovic Courtès
2017-10-07 20:50       ` Ludovic Courtès
2017-10-08 19:49         ` Efraim Flashner
2017-10-09  7:28           ` Ludovic Courtès
2017-10-09 11:17             ` bug#27596: " Efraim Flashner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170801112046.GG2406@macbook42.flashner.co.il \
    --to=efraim@flashner.co.il \
    --cc=27596@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).