From adf0c531a845fb03c92e1f28e26e5c31adb95e4a Mon Sep 17 00:00:00 2001 From: Efraim Flashner 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 | 17 +++++++++++++++++ guix/scripts/refresh.scm | 20 +------------------- guix/upstream.scm | 18 ++++++++++++++++++ 3 files changed, 36 insertions(+), 19 deletions(-) diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index 57bbeec465..cd90257de3 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -33,6 +33,7 @@ (define-module (guix scripts lint) #: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) @@ -73,6 +74,7 @@ (define-module (guix scripts lint) check-mirror-url check-license check-vulnerabilities + check-for-updates check-formatting run-checkers @@ -826,6 +828,17 @@ (define (check-vulnerabilities package) (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 #f))) ; cannot find newer upstream release + ;;; ;;; Source code formatting. @@ -991,6 +1004,10 @@ (define %checkers (description "Check the Common Vulnerabilities and Exposures\ (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") diff --git a/guix/scripts/refresh.scm b/guix/scripts/refresh.scm index 5add64d8e8..d638d744af 100644 --- a/guix/scripts/refresh.scm +++ b/guix/scripts/refresh.scm @@ -30,7 +30,6 @@ (define-module (guix scripts refresh) #: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 @@ (define-module (guix scripts refresh) #:use-module (srfi srfi-26) #:use-module (srfi srfi-37) #:use-module (ice-9 binary-ports) - #:export (guix-refresh - %updaters)) + #:export (guix-refresh)) ;;; @@ -162,22 +160,6 @@ (define (show-help) ;;; 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 6ad52ac960..0fe3308876 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) @@ -55,6 +56,7 @@ (define-module (guix upstream) upstream-updater-predicate upstream-updater-latest + %updaters lookup-updater download-tarball @@ -146,6 +148,22 @@ (define-record-type* (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."