import: Do not assume that 'package-source' returns an origin.

* guix/gnu-maintenance.scm (gnu-package?): Check whether
'package-source' returns an origin.
* guix/import/github.scm (updated-github-url): Likewise.
* guix/import/launchpad.scm (updated-launchpad-url): Likewise.
This commit is contained in:
Ludovic Courtès 2020-07-03 22:48:04 +02:00
parent 00290e7365
commit f54cbc0e1b
No known key found for this signature in database
GPG Key ID: 090B11993D9AEBB5
3 changed files with 41 additions and 34 deletions

View File

@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2012, 2013 Nikita Karetnikov <nikita@karetnikov.org>
;;;
;;; This file is part of GNU Guix.
@ -207,14 +207,17 @@ network to check in GNU's database."
(member host '("www.gnu.org" "gnu.org"))))))
(or (gnu-home-page? package)
(let ((url (and=> (package-source package) origin-uri))
(name (package-upstream-name package)))
(case (and (string? url) (mirror-type url))
((gnu) #t)
((non-gnu) #f)
(else
(and (member name (map gnu-package-name (official-gnu-packages)))
#t))))))))
(match (package-source package)
((? origin? origin)
(let ((url (origin-uri origin))
(name (package-upstream-name package)))
(case (and (string? url) (mirror-type url))
((gnu) #t)
((non-gnu) #f)
(else
(and (member name (map gnu-package-name (official-gnu-packages)))
#t)))))
(_ #f))))))
;;;

View File

@ -1,6 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2016 Ben Woodcroft <donttrustben@gmail.com>
;;; Copyright © 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2018 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2019 Arun Isaac <arunisaac@systemreboot.net>
;;; Copyright © 2019 Efraim Flashner <efraim@flashner.co.il>
@ -90,20 +90,23 @@ false if none is recognized"
(#t #f))) ; Some URLs are not recognised.
#f))
(let ((source-uri (and=> (package-source old-package) origin-uri))
(fetch-method (and=> (package-source old-package) origin-method)))
(cond
((eq? fetch-method download:url-fetch)
(match source-uri
((? string?)
(updated-url source-uri))
((source-uri ...)
(find updated-url source-uri))))
((and (eq? fetch-method download:git-fetch)
(string-prefix? "https://github.com/"
(download:git-reference-url source-uri)))
(download:git-reference-url source-uri))
(else #f))))
(match (package-source old-package)
((? origin? origin)
(let ((source-uri (origin-uri origin))
(fetch-method (origin-method origin)))
(cond
((eq? fetch-method download:url-fetch)
(match source-uri
((? string?)
(updated-url source-uri))
((source-uri ...)
(find updated-url source-uri))))
((and (eq? fetch-method download:git-fetch)
(string-prefix? "https://github.com/"
(download:git-reference-url source-uri)))
(download:git-reference-url source-uri))
(else #f))))
(_ #f)))
(define (github-package? package)
"Return true if PACKAGE is a package from GitHub, else false."

View File

@ -57,16 +57,17 @@ false if none is recognized"
"/" new-version "/+download/" repo "-" new-version ext))
(#t #f))))) ; Some URLs are not recognised.
(let ((source-uri (and=> (package-source old-package) origin-uri))
(fetch-method (and=> (package-source old-package) origin-method)))
(cond
((eq? fetch-method download:url-fetch)
(match source-uri
((? string?)
(updated-url source-uri))
((source-uri ...)
(find updated-url source-uri))))
(else #f))))
(match (package-source old-package)
((? origin? origin)
(let ((source-uri (origin-uri origin))
(fetch-method (origin-method origin)))
(and (eq? fetch-method download:url-fetch)
(match source-uri
((? string?)
(updated-url source-uri))
((source-uri ...)
(find updated-url source-uri))))))
(_ #f)))
(define (launchpad-package? package)
"Return true if PACKAGE is a package from Launchpad, else false."