guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: guix-commits
Subject: 03/05: import: Do not assume that 'package-source' returns an origin.
Date: Fri, 3 Jul 2020 17:54:11 -0400 (EDT)

civodul pushed a commit to branch master
in repository guix.

commit f54cbc0e1b84a5b3785d3b4734600387dde82be9
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Fri Jul 3 22:48:04 2020 +0200

    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/gnu-maintenance.scm  | 21 ++++++++++++---------
 guix/import/github.scm    | 33 ++++++++++++++++++---------------
 guix/import/launchpad.scm | 21 +++++++++++----------
 3 files changed, 41 insertions(+), 34 deletions(-)

diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm
index ef06770..9fe229f 100644
--- a/guix/gnu-maintenance.scm
+++ b/guix/gnu-maintenance.scm
@@ -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))))))
 
 
 ;;;
diff --git a/guix/import/github.scm b/guix/import/github.scm
index 7136e7a..95a792d 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 <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."
diff --git a/guix/import/launchpad.scm b/guix/import/launchpad.scm
index 1a15f28..c737583 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."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]