From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id cFzRORwFS2EK1gAAgWs5BA (envelope-from ) for ; Wed, 22 Sep 2021 12:27:40 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 4HypNRwFS2FRQAAAB5/wlQ (envelope-from ) for ; Wed, 22 Sep 2021 10:27:40 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 41A42EF3B for ; Wed, 22 Sep 2021 12:27:40 +0200 (CEST) Received: from localhost ([::1]:47914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSzTW-0004WS-5a for larch@yhetil.org; Wed, 22 Sep 2021 06:27:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47170) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSzSw-0004QW-Sy for bug-guix@gnu.org; Wed, 22 Sep 2021 06:27:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:37378) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mSzSw-0000bD-Kn for bug-guix@gnu.org; Wed, 22 Sep 2021 06:27:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mSzSw-0007qs-Gv for bug-guix@gnu.org; Wed, 22 Sep 2021 06:27:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#50597: different fixed-output when using =?UTF-8?Q?=E2=80=99--with-source=E2=80=99?= transformation Resent-From: Ludovic =?UTF-8?Q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Wed, 22 Sep 2021 10:27:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50597 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: zimoun Received: via spool by 50597-submit@debbugs.gnu.org id=B50597.163230637230112 (code B ref 50597); Wed, 22 Sep 2021 10:27:02 +0000 Received: (at 50597) by debbugs.gnu.org; 22 Sep 2021 10:26:12 +0000 Received: from localhost ([127.0.0.1]:48924 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mSzS8-0007pc-80 for submit@debbugs.gnu.org; Wed, 22 Sep 2021 06:26:12 -0400 Received: from eggs.gnu.org ([209.51.188.92]:58088) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mSzS4-0007pL-H7 for 50597@debbugs.gnu.org; Wed, 22 Sep 2021 06:26:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:58834) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mSzRo-0007wN-7w; Wed, 22 Sep 2021 06:25:56 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=35966 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mSzRI-0007J6-Vr; Wed, 22 Sep 2021 06:25:45 -0400 From: Ludovic =?UTF-8?Q?Court=C3=A8s?= References: <86zgsecrzv.fsf@gmail.com> <87fsu1uaup.fsf@gnu.org> <86czp2cr63.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 1 =?UTF-8?Q?Vend=C3=A9miaire?= an 230 de la =?UTF-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 22 Sep 2021 12:25:12 +0200 In-Reply-To: <86czp2cr63.fsf@gmail.com> (zimoun's message of "Tue, 21 Sep 2021 09:40:36 +0200") Message-ID: <87bl4kj4af.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: 50597@debbugs.gnu.org Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1632306460; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post; bh=rD2loqPwB0d3A2sqJPjV5eRU/lZRo2QIWoIicPSuzFY=; b=siJyMMazQd7MSPMOjrS4rVT/sdztZaZEWmlM4j+1vsduim+HLKNhFn1jUOBoDfKZyR01lP JOGI84JAY7D8XrwDJQBUcSseiK3Gs0IWI6HbfcdBUx2GNp1wVp0Foi8Gsu86sC2GayYqC/ DtjfhQFhih6m9VXU0T8UMlfJixIdeCXQ2AVbiZjhehRJEz10V3x3QYqNHYjW55EPh9+gRp SlscH1FbXIgVKhTa/gv8MwWrRDngLKtVG03aEGeyCDT/lcXdHjs4uXK7YiYqf80Up+fVFq AdHJ6+ijfIfH5ph++bN1/q6bpaJMdY6RMKlIpPSLEvJ/taOLKMN1Yvq+tVCRsw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1632306460; a=rsa-sha256; cv=none; b=Ych9LkFqX+sduuG3RpPK9a7avI9tI5ZwTwXgoRKw396snEE8NOHkzoYezUHitkCWKyJCB8 NXQ8U90Eq+U3HsqQ5pfP71oWO4VHSnySS7Vw3U6nyvncIzy8p38C54NbDxDjkw7/yZ4liV Zfn+zlifGuet73xKbOFtVIDXh56YH5+wsWd6R4ORAjCpOIPgVoW8NlpZOUn4yIYh7WawGq cNO+Ggdup2mt4gk9djpmEwtruA3/9fAAFCHnk2SEg8Lo+mdWGh3ZpK25RGL4sWenIFNIAQ 1CLE13+jkYLzM9Hne3F774XmTx1GdWTUMCI1z1WiQbonLfDuFsPM81V8D6971w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Spam-Score: -2.79 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=pass (policy=none) header.from=gnu.org; spf=pass (aspmx1.migadu.com: domain of bug-guix-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=bug-guix-bounces@gnu.org X-Migadu-Queue-Id: 41A42EF3B X-Spam-Score: -2.79 X-Migadu-Scanner: scn0.migadu.com X-TUID: jJaXhZWMyB2W --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi, zimoun skribis: > On Sat, 18 Sep 2021 at 18:06, Ludovic Court=C3=A8s wrote: >> zimoun skribis: >> >>> Why the store item of source tarball is it different when applying the >>> transformation? >>> >>> Maxime provided a clue [1]. >> >> Maxime is right: =E2=80=98--with-source=E2=80=99 passes #:recursive? #t = unconditionally, >> whereas it=E2=80=99s usually #f for a =E2=80=98url-fetch=E2=80=99 kind o= f URI. > > Thanks for confirming. Why is it different? Because we want =E2=80=98--with-source=E2=80=99 to also work with directori= es (see comment in =E2=80=98package-with-source=E2=80=99). >> 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=E2=80=A6) lives at the same store location=E2=80=A6 > > $ 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 =E2=80=9Crecursive=E2=80=9D an= d 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=E2=80=99s not enough to get the same derivation: we=E2=80=99d al= so need to return a fixed-output derivation rather than a plain store file name. (See also .) To be continued=E2=80=A6 Ludo=E2=80=99. --=-=-= Content-Type: text/x-patch Content-Disposition: inline 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?))))))) ;;; --=-=-=--