all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [PATCH] substitute: Print a warning in case of store directory mismatch
@ 2015-11-26 21:54 Hynek Urban
  2015-11-27 23:06 ` Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Hynek Urban @ 2015-11-26 21:54 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 726 bytes --]

Hi,

attached is a simple patch that should print out a warning when a
substitute server is ignored due to a customized store directory.

Motivation: I was checking out guix for the first time a few days ago; I
built it using the --with-store-dir configure option and subsequently,
substitutes were not downloaded. I was baffled for some time because I
thought I did everything according to the manual and yet I couldn't get
the substitute downloads to work (with no indication why).

I suppose the actual reason is quite apparent to people with some
knowledge about guix but for a new user it is not (at least if I may
judge from my own experience). Perhaps this patch will save someone a
little bit of time.

Regards,
Hynek

[-- Attachment #2: 0001-substitute-Print-a-warning-in-case-of-store-director.patch --]
[-- Type: text/x-patch, Size: 3247 bytes --]

From cf9703770b6db07b1826a9f9082c061919b6d061 Mon Sep 17 00:00:00 2001
From: Hynek Urban <hynek.urban@fragaria.cz>
Date: Thu, 26 Nov 2015 22:38:32 +0100
Subject: [PATCH] substitute: Print a warning in case of store directory
 mismatch.

    * guix/scripts/substitute.scm (fetch-narinfos): Print a warning in case
      store directory differs between local installation and the substitute
      server.
---
 guix/scripts/substitute.scm | 45 ++++++++++++++++++++++++---------------------
 1 file changed, 24 insertions(+), 21 deletions(-)

diff --git a/guix/scripts/substitute.scm b/guix/scripts/substitute.scm
index 964df94..53e9321 100755
--- a/guix/scripts/substitute.scm
+++ b/guix/scripts/substitute.scm
@@ -569,27 +569,30 @@ if file doesn't exist, and the narinfo otherwise."
     (download-cache-info url))
 
   (and cache-info
-       (string=? (cache-info-store-directory cache-info)
-                 (%store-prefix))
-       (let ((uri (string->uri url)))
-         (case (and=> uri uri-scheme)
-           ((http)
-            (let ((requests (map (cut narinfo-request url <>) paths)))
-              (update-progress!)
-              (let ((result (http-multiple-get url
-                                               handle-narinfo-response '()
-                                               requests)))
-                (newline (current-error-port))
-                result)))
-           ((file #f)
-            (let* ((base  (string-append (uri-path uri) "/"))
-                   (files (map (compose (cut string-append base <> ".narinfo")
-                                        store-path-hash-part)
-                               paths)))
-              (filter-map (cut narinfo-from-file <> url) files)))
-           (else
-            (leave (_ "~s: unsupported server URI scheme~%")
-                   (if uri (uri-scheme uri) url)))))))
+      (let ((cache-store-directory (cache-info-store-directory cache-info))
+        (uri (string->uri url)))
+        (if (string=? cache-store-directory (%store-prefix))
+            (case (and=> uri uri-scheme)
+              ((http)
+               (let ((requests (map (cut narinfo-request url <>) paths)))
+                 (update-progress!)
+                 (let ((result (http-multiple-get url
+                                                  handle-narinfo-response '()
+                                                  requests)))
+                   (newline (current-error-port))
+                   result)))
+              ((file #f)
+               (let* ((base (string-append (uri-path uri) "/"))
+                      (get-filename (cut string-append base <> ".narinfo"))
+                      (files (map (compose get-filename store-path-hash-part)
+                                   paths)))
+                 (filter-map (cut narinfo-from-file <> url) files)))
+              (else
+               (leave (_ "~s: unsupported server URI scheme~%")
+                      (if uri (uri-scheme uri) url))))
+            (begin
+              (warning (_ "skipping ~a due to store directory mismatch~%") url)
+              #f)))))
 
 (define (lookup-narinfos cache paths)
   "Return the narinfos for PATHS, invoking the server at CACHE when no
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] substitute: Print a warning in case of store directory mismatch
  2015-11-26 21:54 [PATCH] substitute: Print a warning in case of store directory mismatch Hynek Urban
@ 2015-11-27 23:06 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2015-11-27 23:06 UTC (permalink / raw)
  To: Hynek Urban; +Cc: guix-devel

Hynek Urban <hynek.urban@gmail.com> skribis:

> Motivation: I was checking out guix for the first time a few days ago; I
> built it using the --with-store-dir configure option and subsequently,
> substitutes were not downloaded. I was baffled for some time because I
> thought I did everything according to the manual and yet I couldn't get
> the substitute downloads to work (with no indication why).
>
> I suppose the actual reason is quite apparent to people with some
> knowledge about guix but for a new user it is not (at least if I may
> judge from my own experience). Perhaps this patch will save someone a
> little bit of time.

I see, that makes a lot of sense.

> From cf9703770b6db07b1826a9f9082c061919b6d061 Mon Sep 17 00:00:00 2001
> From: Hynek Urban <hynek.urban@fragaria.cz>
> Date: Thu, 26 Nov 2015 22:38:32 +0100
> Subject: [PATCH] substitute: Print a warning in case of store directory
>  mismatch.
>
>     * guix/scripts/substitute.scm (fetch-narinfos): Print a warning in case
>       store directory differs between local installation and the substitute
>       server.

Commit ae4427e does the same thing slightly differently.

Thank you!

Ludo’.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-11-27 23:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-26 21:54 [PATCH] substitute: Print a warning in case of store directory mismatch Hynek Urban
2015-11-27 23:06 ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.