From: "Ludovic Courtès" <ludo@gnu.org>
To: zimoun <zimon.toutoune@gmail.com>
Cc: 50597@debbugs.gnu.org
Subject: bug#50597: different fixed-output when using ’--with-source’ transformation
Date: Wed, 22 Sep 2021 12:25:12 +0200 [thread overview]
Message-ID: <87bl4kj4af.fsf@gnu.org> (raw)
In-Reply-To: <86czp2cr63.fsf@gmail.com> (zimoun's message of "Tue, 21 Sep 2021 09:40:36 +0200")
[-- Attachment #1: Type: text/plain, Size: 1690 bytes --]
Hi,
zimoun <zimon.toutoune@gmail.com> skribis:
> On Sat, 18 Sep 2021 at 18:06, Ludovic Courtès <ludo@gnu.org> wrote:
>> zimoun <zimon.toutoune@gmail.com> skribis:
>>
>>> Why the store item of source tarball is it different when applying the
>>> transformation?
>>>
>>> Maxime provided a clue [1].
>>
>> Maxime is right: ‘--with-source’ passes #:recursive? #t unconditionally,
>> whereas it’s usually #f for a ‘url-fetch’ kind of URI.
>
> Thanks for confirming. Why is it different?
Because we want ‘--with-source’ to also work with directories (see
comment in ‘package-with-source’).
>> What we could do is make it #t if and only if the URL denotes a local
>> file and that file is a directory. I think that would achieve what you
>> want without any observable regression in practice.
>
> What I expect is that 2 (fixed-output) files with the same hash
> (0ssi1w…) lives at the same store location…
>
> $ guix hash /gnu/store/chariqd6k0sli3s7vcl4q3al0crirz5v-hello-2.10.tar.gz
> 0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i
>
> $ guix hash /gnu/store/hbdalsf5lpf01x4dcknwx6xbn6n5km6k-hello-2.10.tar.gz
> 0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i
The difference here is that one is marked as “recursive” and the other
is not.
The patch below does one I suggested earlier: passing #:recursive? #t if
and only if we know the source is a directory.
However it’s not enough to get the same derivation: we’d also need
<downloaded-file> to return a fixed-output derivation rather than a
plain store file name. (See also <https://issues.guix.gnu.org/49696>.)
To be continued…
Ludo’.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: Type: text/x-patch, Size: 1725 bytes --]
diff --git a/guix/transformations.scm b/guix/transformations.scm
index 5ae1977cb2..e0f5579c28 100644
--- a/guix/transformations.scm
+++ b/guix/transformations.scm
@@ -46,6 +46,7 @@
#:use-module (srfi srfi-37)
#:use-module (ice-9 match)
#:use-module (ice-9 vlist)
+ #:autoload (web uri) (string->uri uri-scheme uri-path)
#:export (options->transformation
manifest-entry-with-transformations
@@ -106,15 +107,25 @@ extensions."
(define* (package-with-source p uri #:optional version)
"Return a package based on P but with its source taken from URI. Extract
the new package's version number from URI."
- (let ((base (tarball-base-name (basename uri))))
+ (let ((base (tarball-base-name (basename uri)))
+ (file (match (string->uri uri)
+ (#f uri)
+ (uri (and (eq? 'file (uri-scheme uri))
+ (uri-path uri))))))
(let-values (((_ version*)
(hyphen-package-name->name+version base)))
(package (inherit p)
(version (or version version*
(package-version p)))
- ;; Use #:recursive? #t to allow for directories.
- (source (downloaded-file uri #t))))))
+ ;; Default to #:recursive? #f to match what 'url-fetch' does,
+ ;; but use #t when URI denotes a directory.
+ (source (let ((recursive?
+ (and file
+ (match (stat file #f)
+ (#f #t)
+ (st (eq? 'directory (stat:type st)))))))
+ (downloaded-file uri recursive?)))))))
\f
;;;
next prev parent reply other threads:[~2021-09-22 10:27 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-15 5:44 bug#50597: different fixed-output when using ’--with-source’ transformation zimoun
2021-09-18 16:06 ` Ludovic Courtès
2021-09-18 17:35 ` Maxime Devos
2021-09-21 7:40 ` zimoun
2021-09-22 10:25 ` Ludovic Courtès [this message]
2021-10-13 9:31 ` zimoun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://guix.gnu.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bl4kj4af.fsf@gnu.org \
--to=ludo@gnu.org \
--cc=50597@debbugs.gnu.org \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).