[PATCH] substitutes: keep base's uri-path for Properly construct URL.

  • Done
  • quality assurance status badge
Details
4 participants
  • Z572
  • Zhu Zihao
  • Ludovic Courtès
  • Peng Mei Yu
Owner
unassigned
Submitted by
Z572
Severity
normal
Z
(address . guix-patches@gnu.org)
tencent_91AE3668F32215362BE62F45C7B6BCA02405@qq.com
Hello,

Sorry for my english, and i'm not sure ChangeLog is right.

https://mirror.sjtu.edu.cn/guixuse customize script to mirror official
substitutes server, at /guix not in / . narinfo-request will forget add /guix to url, so i
can't use substitutes from them, this patch fix it.
From 7fe17965d5336d55ec8b1b7471cbbb34b12e9a0b Mon Sep 17 00:00:00 2001
From: Z572 <873216071@qq.com>
Date: Wed, 27 Oct 2021 21:28:24 +0800
Subject: [PATCH] substitutes: keep base's uri-path for Properly construct URL.

substitutes (narinfo-request): keep BASE's uri-path for properly construct url.

some substitutes server don't use guix publish, them use customize scripts to
mirror official server, if them look likes https://example.com/guix,
narinfo-request will lost /guix .
---
guix/substitutes.scm | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

Toggle diff (24 lines)
diff --git a/guix/substitutes.scm b/guix/substitutes.scm
index a5c554acff..bfbd29623e 100644
--- a/guix/substitutes.scm
+++ b/guix/substitutes.scm
@@ -3,6 +3,7 @@
;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.org>
;;; Copyright © 2018 Kyle Meyer <kyle@kyleam.com>
;;; Copyright © 2020 Christopher Baines <mail@cbaines.net>
+;;; Copyright © 2021 Zheng Junjie <873216071@qq.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -158,7 +159,8 @@ (define (narinfo-request cache-url path)
"Return an HTTP request for the narinfo of PATH at CACHE-URL."
(let* ((base (string->uri cache-url))
(ref (build-relative-ref
- #:path (string-append (store-path-hash-part path) ".narinfo")))
+ #:path (string-append (uri-path base) "/"
+ (store-path-hash-part path) ".narinfo")))
(url (resolve-uri-reference ref base))
(headers '((User-Agent . "GNU Guile"))))
(build-request url #:method 'GET #:headers headers)))
--
2.33.1
--
over
Z
(address . 51441@debbugs.gnu.org)
tencent_58AC8EBF2E1DA972BC92AEDAB04D98D4BA07@qq.com
it just fix fetch narinfos url, substitute still don't download, later i
will try fix it.

Z572 via Guix-patches via <guix-patches@gnu.org> writes:

Toggle quote (48 lines)
> Hello,
>
> Sorry for my english, and i'm not sure ChangeLog is right.
>
> https://mirror.sjtu.edu.cn/guix use customize script to mirror official
> substitutes server, at /guix not in / . narinfo-request will forget add /guix to url, so i
> can't use substitutes from them, this patch fix it.
>
> From 7fe17965d5336d55ec8b1b7471cbbb34b12e9a0b Mon Sep 17 00:00:00 2001
> From: Z572 <873216071@qq.com>
> Date: Wed, 27 Oct 2021 21:28:24 +0800
> Subject: [PATCH] substitutes: keep base's uri-path for Properly construct URL.
>
> substitutes (narinfo-request): keep BASE's uri-path for properly construct url.
>
> some substitutes server don't use guix publish, them use customize scripts to
> mirror official server, if them look likes https://example.com/guix ,
> narinfo-request will lost /guix .
> ---
> guix/substitutes.scm | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/guix/substitutes.scm b/guix/substitutes.scm
> index a5c554acff..bfbd29623e 100644
> --- a/guix/substitutes.scm
> +++ b/guix/substitutes.scm
> @@ -3,6 +3,7 @@
> ;;; Copyright © 2014 Nikita Karetnikov <nikita@karetnikov.org>
> ;;; Copyright © 2018 Kyle Meyer <kyle@kyleam.com>
> ;;; Copyright © 2020 Christopher Baines <mail@cbaines.net>
> +;;; Copyright © 2021 Zheng Junjie <873216071@qq.com>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -158,7 +159,8 @@ (define (narinfo-request cache-url path)
> "Return an HTTP request for the narinfo of PATH at CACHE-URL."
> (let* ((base (string->uri cache-url))
> (ref (build-relative-ref
> - #:path (string-append (store-path-hash-part path) ".narinfo")))
> + #:path (string-append (uri-path base) "/"
> + (store-path-hash-part path) ".narinfo")))
> (url (resolve-uri-reference ref base))
> (headers '((User-Agent . "GNU Guile"))))
> (build-request url #:method 'GET #:headers headers)))
> --
> 2.33.1


--
over
Z
(name . Z572)(address . 873216071@qq.com)(address . 51441@debbugs.gnu.org)
tencent_9048B5509BCDA9CC59177F193A80E5DA2508@qq.com
Z572 via Guix-patches via <guix-patches@gnu.org> writes:

Toggle quote (4 lines)
> it just fix fetch narinfos url, substitute still don't download, later i
> will try fix it.
>

Because guix-daemon is old , it fork a old `guix substitute`, use old
(guix substitutes) module. so just need update guix-daemon:

1. guix system reconfigure path/to/config
2. herd restart guix-daemon

substitute will download.

It Works On My Machine :)

--
over
P
P
Peng Mei Yu wrote on 29 Oct 2021 06:18
(name . Z572)(address . 873216071@qq.com)(address . 51441@debbugs.gnu.org)
8735ok31lf.fsf@xqzp.net
Hi,

Z572 via Guix-patches via writes:

Toggle quote (12 lines)
> @@ -158,7 +159,8 @@ (define (narinfo-request cache-url path)
> "Return an HTTP request for the narinfo of PATH at CACHE-URL."
> (let* ((base (string->uri cache-url))
> (ref (build-relative-ref
> - #:path (string-append (store-path-hash-part path) ".narinfo")))
> + #:path (string-append (uri-path base) "/"
> + (store-path-hash-part path) ".narinfo")))
> (url (resolve-uri-reference ref base))
> (headers '((User-Agent . "GNU Guile"))))
> (build-request url #:method 'GET #:headers headers)))
> --

It seems that the root cause for the problem is that cache-url lacks a
trailing slash. Therefore the last path component is stripped from
`base` when we compute (resolve-uri-reference ref base). So I think
ensuring cache-url ends with a slash ("/") is a better approach.


--
Peng Mei Yu
Z
(name . Peng Mei Yu)(address . pengmeiyu@riseup.net)(address . 51441@debbugs.gnu.org)
tencent_64A49B42A91659157F393A2BE5B42568B508@qq.com
Peng Mei Yu <pengmeiyu@riseup.net> writes:

Toggle quote (21 lines)
> Hi,
>
> Z572 via Guix-patches via writes:
>
>> @@ -158,7 +159,8 @@ (define (narinfo-request cache-url path)
>> "Return an HTTP request for the narinfo of PATH at CACHE-URL."
>> (let* ((base (string->uri cache-url))
>> (ref (build-relative-ref
>> - #:path (string-append (store-path-hash-part path) ".narinfo")))
>> + #:path (string-append (uri-path base) "/"
>> + (store-path-hash-part path) ".narinfo")))
>> (url (resolve-uri-reference ref base))
>> (headers '((User-Agent . "GNU Guile"))))
>> (build-request url #:method 'GET #:headers headers)))
>> --
>
> It seems that the root cause for the problem is that cache-url lacks a
> trailing slash. Therefore the last path component is stripped from
> `base` when we compute (resolve-uri-reference ref base). So I think
> ensuring cache-url ends with a slash ("/") is a better approach.

Yes, you are right.

--
over
Z
Z
Zhu Zihao wrote on 10 Nov 2021 12:30
Re: [PATCH] substitutes: keep base's uri-path for Properly construct URL.
(address . 51441@debbugs.gnu.org)(name . Ludovic Courtès)(address . ludo@gnu.org)
865yt0dz7v.fsf@163.com
Can someone help review this patch? Thx a lot!.
--
Retrieve my PGP public key:

gpg --recv-keys D47A9C8B2AE3905B563D9135BE42B352A9F6821F

Zihao
-----BEGIN PGP SIGNATURE-----

iIsEARYIADMWIQTUepyLKuOQW1Y9kTW+QrNSqfaCHwUCYYutdBUcYWxsX2J1dF9s
YXN0QDE2My5jb20ACgkQvkKzUqn2gh83wwEA4T9Dlm7i1J6UgWDu2G6Hn3HNGmTz
0+hKUE0NL2b+ht0A/RbhAUf/iHY3IkoWq3gDWDRJkbZjo7mgl4gI/KS4k98F
=yO77
-----END PGP SIGNATURE-----

L
L
Ludovic Courtès wrote on 12 Dec 2021 00:34
Re: bug#51441: [PATCH] substitutes: keep base's uri-path for Properly construct URL.
(name . Peng Mei Yu)(address . pengmeiyu@riseup.net)
87sfuy4sxf.fsf_-_@gnu.org
Hi,

Peng Mei Yu <pengmeiyu@riseup.net> skribis:

Toggle quote (19 lines)
> Z572 via Guix-patches via writes:
>
>> @@ -158,7 +159,8 @@ (define (narinfo-request cache-url path)
>> "Return an HTTP request for the narinfo of PATH at CACHE-URL."
>> (let* ((base (string->uri cache-url))
>> (ref (build-relative-ref
>> - #:path (string-append (store-path-hash-part path) ".narinfo")))
>> + #:path (string-append (uri-path base) "/"
>> + (store-path-hash-part path) ".narinfo")))
>> (url (resolve-uri-reference ref base))
>> (headers '((User-Agent . "GNU Guile"))))
>> (build-request url #:method 'GET #:headers headers)))
>> --
>
> It seems that the root cause for the problem is that cache-url lacks a
> trailing slash. Therefore the last path component is stripped from
> `base` when we compute (resolve-uri-reference ref base). So I think
> ensuring cache-url ends with a slash ("/") is a better approach.

Indeed. I’ve implemented your suggestion in
e68466de122d94ac3fa75aae234cd5fd89482a5a, and commit
cba0395c99005f94e4ccd6c058362af7443dab12 makes a related adjustment.

Note that we still need to update the ‘guix’ package so you can benefit
from the bug fix. In the meantime you have to pass that trailing slash.

Thank you, and sorry for the delay!

Ludo’.
Closed
?