diff options
Diffstat (limited to 'guix/scripts')
-rw-r--r-- | guix/scripts/lint.scm | 13 | ||||
-rw-r--r-- | guix/scripts/package.scm | 33 |
2 files changed, 31 insertions, 15 deletions
diff --git a/guix/scripts/lint.scm b/guix/scripts/lint.scm index f296f8a00e..e2cc965951 100644 --- a/guix/scripts/lint.scm +++ b/guix/scripts/lint.scm @@ -1,7 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2014 Cyril Roelandt <tipecaml@gmail.com> ;;; Copyright © 2014, 2015 Eric Bavier <bavier@member.fsf.org> -;;; Copyright © 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2015 Mathieu Lirzin <mthl@openmailbox.org> ;;; ;;; This file is part of GNU Guix. @@ -593,7 +593,16 @@ Common Platform Enumeration (CPE) name." (define package-vulnerabilities (let ((lookup (delay (vulnerabilities->lookup-proc - (current-vulnerabilities))))) + ;; Catch networking errors to allow network-less + ;; operation. + (catch 'getaddrinfo-error + (lambda () + (current-vulnerabilities)) + (lambda (key errcode) + (warn (_ "failed to lookup NIST host: ~a~%") + (gai-strerror errcode)) + (warn (_ "assuming no CVE vulnerabilities~%")) + '())))))) (lambda (package) "Return a list of vulnerabilities affecting PACKAGE." ((force lookup) diff --git a/guix/scripts/package.scm b/guix/scripts/package.scm index d0b5abd0e2..02eb600c43 100644 --- a/guix/scripts/package.scm +++ b/guix/scripts/package.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014, 2015 Ludovic Courtès <ludo@gnu.org> +;;; Copyright © 2012, 2013, 2014, 2015, 2016 Ludovic Courtès <ludo@gnu.org> ;;; Copyright © 2013 Nikita Karetnikov <nikita@karetnikov.org> ;;; Copyright © 2013, 2015 Mark H Weaver <mhw@netris.org> ;;; Copyright © 2014 Alex Kost <alezost@gmail.com> @@ -230,21 +230,24 @@ specified in MANIFEST, a manifest object." ;;; Package specifications. ;;; -(define (find-packages-by-description rx) - "Return the list of packages whose name, synopsis, or description matches -RX." +(define (find-packages-by-description regexps) + "Return the list of packages whose name matches one of REGEXPS, or whose +synopsis or description matches all of REGEXPS." (define version<? (negate version>=?)) + (define (matches-all? str) + (every (cut regexp-exec <> str) regexps)) + + (define (matches-one? str) + (find (cut regexp-exec <> str) regexps)) + (sort (fold-packages (lambda (package result) - (define matches? - (cut regexp-exec rx <>)) - - (if (or (matches? (package-name package)) + (if (or (matches-one? (package-name package)) (and=> (package-synopsis package) - (compose matches? P_)) + (compose matches-all? P_)) (and=> (package-description package) - (compose matches? P_))) + (compose matches-all? P_))) (cons package result) result)) '()) @@ -696,11 +699,15 @@ processed, #f otherwise." (package-name p2)))))) #t)) - (('search regexp) - (let ((regexp (make-regexp* regexp regexp/icase))) + (('search _) + (let* ((patterns (filter-map (match-lambda + (('query 'search rx) rx) + (_ #f)) + opts)) + (regexps (map (cut make-regexp* <> regexp/icase) patterns))) (leave-on-EPIPE (for-each (cute package->recutils <> (current-output-port)) - (find-packages-by-description regexp))) + (find-packages-by-description regexps))) #t)) (('show requested-name) |