summary refs log tree commit diff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2020-07-20 21:26:51 +0200
committerLudovic Courtès <ludo@gnu.org>2020-07-20 23:25:10 +0200
commit59a47fb67853dd28891376fc970699f11c0f972f (patch)
treedbc154cdefee7ee9fb46ca6b8ebd980f53b6d98e
parent1c26219f94b388a35f0ae93060806319958906ef (diff)
downloadguix-59a47fb67853dd28891376fc970699f11c0f972f.tar.gz
gnu-maintenance: 'kernel.org' and 'savannah' updaters rewrite URLs.
This makes sure they return 'mirror://' URLs rather that URLs pointing
to the specific mirror they talk to.

* guix/gnu-maintenance.scm (url-prefix-rewrite)
(adjusted-upstream-source): New procedures.
(latest-savannah-release, latest-kernel.org-release): Use it.
-rw-r--r--guix/gnu-maintenance.scm41
1 files changed, 32 insertions, 9 deletions
diff --git a/guix/gnu-maintenance.scm b/guix/gnu-maintenance.scm
index 702848ed95..2a85504425 100644
--- a/guix/gnu-maintenance.scm
+++ b/guix/gnu-maintenance.scm
@@ -615,6 +615,22 @@ releases are on gnu.org."
 (define gnu-hosted?
   (url-prefix-predicate "mirror://gnu/"))
 
+(define (url-prefix-rewrite old new)
+  "Return a one-argument procedure that rewrites URL prefix OLD to NEW."
+  (lambda (url)
+    (if (string-prefix? old url)
+        (string-append new (string-drop url (string-length old)))
+        url)))
+
+(define (adjusted-upstream-source source rewrite-url)
+  "Rewrite URLs in SOURCE by apply REWRITE-URL to each of them."
+  (upstream-source
+   (inherit source)
+   (urls (map rewrite-url (upstream-source-urls source)))
+   (signature-urls (and=> (upstream-source-signature-urls source)
+                          (lambda (urls)
+                            (map rewrite-url urls))))))
+
 (define savannah-package?
   (url-prefix-predicate "mirror://savannah/"))
 
@@ -628,10 +644,13 @@ releases are on gnu.org."
   "Return the latest release of PACKAGE."
   (let* ((uri       (string->uri (origin-uri (package-source package))))
          (package   (package-upstream-name package))
-         (directory (dirname (uri-path uri))))
-    (latest-html-release package
-                         #:base-url %savannah-base
-                         #:directory directory)))
+         (directory (dirname (uri-path uri)))
+         (rewrite   (url-prefix-rewrite %savannah-base
+                                        "mirror://savannah")))
+    (adjusted-upstream-source (latest-html-release package
+                                                   #:base-url %savannah-base
+                                                   #:directory directory)
+                              rewrite)))
 
 (define (latest-xorg-release package)
   "Return the latest release of PACKAGE."
@@ -655,11 +674,15 @@ releases are on gnu.org."
 
   (let* ((uri       (string->uri (origin-uri (package-source package))))
          (package   (package-upstream-name package))
-         (directory (dirname (uri-path uri))))
-    (latest-html-release package
-                         #:base-url %kernel.org-base
-                         #:directory directory
-                         #:file->signature file->signature)))
+         (directory (dirname (uri-path uri)))
+         (rewrite   (url-prefix-rewrite %kernel.org-base
+                                        "mirror://kernel.org")))
+    (adjusted-upstream-source (latest-html-release package
+                                                   #:base-url %kernel.org-base
+                                                   #:directory directory
+                                                   #:file->signature
+                                                   file->signature)
+                              rewrite)))
 
 (define %gnu-updater
   ;; This is for everything at ftp.gnu.org.