From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42408) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dcVEV-0008CW-E2 for guix-patches@gnu.org; Tue, 01 Aug 2017 07:21:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dcVET-0007KK-VM for guix-patches@gnu.org; Tue, 01 Aug 2017 07:21:03 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:33484) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1dcVET-0007K5-Sf for guix-patches@gnu.org; Tue, 01 Aug 2017 07:21:01 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1dcVET-0000mC-LT for guix-patches@gnu.org; Tue, 01 Aug 2017 07:21:01 -0400 Subject: [bug#27596] [PATCH] guix: lint: Add checker for new upstream versions. Resent-Message-ID: Date: Tue, 1 Aug 2017 14:20:46 +0300 From: Efraim Flashner Message-ID: <20170801112046.GG2406@macbook42.flashner.co.il> References: <20170706101723.3349-1-efraim@flashner.co.il> <87h8ypocp1.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="u/L2/WlOHZg+YGU4" Content-Disposition: inline In-Reply-To: <87h8ypocp1.fsf@gnu.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 27596@debbugs.gnu.org --u/L2/WlOHZg+YGU4 Content-Type: multipart/mixed; boundary="kHRd/tpU31Zn62xO" Content-Disposition: inline --kHRd/tpU31Zn62xO Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Jul 06, 2017 at 04:35:38PM +0200, Ludovic Court=C3=A8s wrote: > Efraim Flashner skribis: >=20 > > * guix/scripts/lint.scm (check-for-updates): New procedure. > > (%checkers): Add it. >=20 > Good idea. >=20 > > +(define (check-for-updates package) > > + "Check if there is an update available for PACKAGE." > > + (guix-refresh (package-name package))) >=20 > I think we should use the (guix upstream) API directly because > =E2=80=98guix-refresh=E2=80=99 can call =E2=80=98exit=E2=80=99 and it for= mats messages in a way that is > not consistent with the rest of =E2=80=98guix lint=E2=80=99. >=20 > To do that I think we=E2=80=99ll first have to move =E2=80=98%updaters=E2= =80=99 to (guix > upstream), probably turning it into a procedure. >=20 > WDYT? >=20 > Thanks, > Ludo=E2=80=99. >=20 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}' --=20 Efraim Flashner =D7=90=D7=A4=D7=A8=D7=99=D7=9D = =D7=A4=D7=9C=D7=A9=D7=A0=D7=A8 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --kHRd/tpU31Zn62xO Content-Type: text/plain; charset=utf-8 Content-Disposition: attachment; filename="0001-guix-lint-Add-checker-for-new-upstream-versions.patch" Content-Transfer-Encoding: quoted-printable =46rom 136841864c883338381764ef09a6f4ec967949e7 Mon Sep 17 00:00:00 2001 =46rom: 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 =66rom 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 =20 @@ -821,6 +823,16 @@ from ~s: ~a (~s)~%") (string-join (map vulnerability-id unpatc= hed) ", "))))))))) =20 +(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))))))) + =0C ;;; ;;; 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)) =20 =0C ;;; @@ -162,22 +160,6 @@ specified with `--select'.\n")) ;;; Updates. ;;; =20 -(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 =20 + %updaters lookup-updater =20 download-tarball @@ -127,6 +129,22 @@ correspond to the same version." (pred upstream-updater-predicate) (latest upstream-updater-latest)) =20 +(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." --=20 2.13.3 --kHRd/tpU31Zn62xO-- --u/L2/WlOHZg+YGU4 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAlmAZAUACgkQQarn3Mo9 g1HPYw/9HUrIJu30vjCYJI40Szn+YspjdjT5MZe7by+gYqABizSED7ilAnTiStqe l3o5OXk/UB3F1EyJrMXGXUWLvCbUhjTVeP6mXudX7Ea5Z3pU3dh5/73ynXGgGqDz dNuOqDrUNro+JiGfzWYiQcDU9nybBvEnkP4sxqv0BkQqOX3+uBtCejy/xshHQikg D9lBiS/Fvp4g1zos+BtA9gCeBKjLFigGqaypjXXlblk3FxMYf58GO5UTc8/lptG6 22ci8WOYrWjqR9RFLu47u24pUUWJZSRC6Qr/HBiU/xlyfW+JE3MyNkozXWO9waHU 85Ddvzyw8rmGa+tv/lGlPzTuEATsCWOwHSDRfGkHVG8+2LeJo5pFSg6lrI+3+q/E HoKHQORORSV6o9WjNMrYnsWq4kFrsyfnPodI8EbjrIWO8sEpcVN3AiovDdHWyiSN +26LBGovC+ztexNi6c9dQ1ROnBXOuPQOUIN1FkmLXvFoOeHc94y+OJWqxHv4DMi+ XUbBLemP79if9cZYFPVqtcPQlTEfKYGVXV67ZHzsDPSJdrkLrxc3oqq0Dt0A/Hb5 uuP8iDaw7BPSpM3GYxyHk/0kmLcG6xUY/Q9RCDvDnPc8PyMDuo6HPHhby9O7dHfw Y4w+kcIR2+eLkd7FugPIUyuX8p72IHjZEKFfCa2h3chdNNJHd08= =IdCo -----END PGP SIGNATURE----- --u/L2/WlOHZg+YGU4--