From f54cbc0e1b84a5b3785d3b4734600387dde82be9 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Fri, 3 Jul 2020 22:48:04 +0200 Subject: 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. --- guix/import/github.scm | 33 ++++++++++++++++++--------------- guix/import/launchpad.scm | 21 +++++++++++---------- 2 files changed, 29 insertions(+), 25 deletions(-) (limited to 'guix/import') diff --git a/guix/import/github.scm b/guix/import/github.scm index 7136e7a34f..95a792d0ca 100644 --- a/guix/import/github.scm +++ b/guix/import/github.scm @@ -1,6 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016 Ben Woodcroft -;;; Copyright © 2017, 2018, 2019 Ludovic Courtès +;;; Copyright © 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2018 Eric Bavier ;;; Copyright © 2019 Arun Isaac ;;; Copyright © 2019 Efraim Flashner @@ -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." diff --git a/guix/import/launchpad.scm b/guix/import/launchpad.scm index 1a15f28077..c7375837c7 100644 --- a/guix/import/launchpad.scm +++ b/guix/import/launchpad.scm @@ -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." -- cgit v1.2.3