From debbugs-submit-bounces@debbugs.gnu.org Sun Oct 31 10:03:11 2021 Received: (at 51307) by debbugs.gnu.org; 31 Oct 2021 14:03:11 +0000 Received: from localhost ([127.0.0.1]:60954 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mhBQV-0001VB-3o for submit@debbugs.gnu.org; Sun, 31 Oct 2021 10:03:11 -0400 Received: from eggs.gnu.org ([209.51.188.92]:33604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mhBQT-0001Uz-SQ for 51307@debbugs.gnu.org; Sun, 31 Oct 2021 10:03:10 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:54372) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhBQO-0003Ym-ME; Sun, 31 Oct 2021 10:03:04 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=7dEW5Ustj2akb5TApah1PlVOPFtyPu+oRCVzbgjkoa4=; b=n9OoVMxyyeQ+WWPvOIE3 fCVcInt/I13qtjJEQZ3k5dtvHPW+iv8oidQiX4trn/Q1Vf1M9y7LvIdB7UhOlqj/TQB8A9xaZ8Mra nmh+GxXGLtfPyks0gVcA9RUT0uypDNTUbfDEf4g/lYBrLY5Ho+ogUelzaGTyzUUvCdza2PBdKbgAq U0R014vSpDyz1J82JCTT3+KBdWjXAnSKR1hulaiELlTpQ2YzqdHkJpOSq+U2Vvnb42XdKWjpelbr+ z5Re7G2NL7mYWwD1JOlwDlRlTYAXp8MEUZgu79MUdC+YnPQGjMEboM8a6Oc6O/+tIEhl7RHnxxSLX 2+xafQo40J/JFA==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:55506 helo=ribbon) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mhBQO-0002JZ-9z; Sun, 31 Oct 2021 10:03:04 -0400 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: bug#51307: [PATCH 0/2] guix hash: eases conversion References: <20211020165020.3358311-1-zimon.toutoune@gmail.com> <87wnlusgwy.fsf@gnu.org> <86tugyleub.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 10 Brumaire 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: Sun, 31 Oct 2021 15:03:01 +0100 In-Reply-To: <86tugyleub.fsf@gmail.com> (zimoun's message of "Sat, 30 Oct 2021 17:19:56 +0200") Message-ID: <87mtmppa0a.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 51307 Cc: 51307@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! zimoun skribis: > On Sat, 30 Oct 2021 at 16:53, Ludovic Court=C3=A8s wrote: >> zimoun skribis: >> >>> 2. Using the option recursive changes the result for tarball, as with: >>> >>> $ guix hash $(guix build hello -S) >>> 0ssi1wpaf7plaswqqjwigppsg5fyh99vdlb9kzl7c9lng89ndq1i >>> >>> $ guix hash $(guix build hello -S) --recursive >>> 1qx3qqk86vgdvpqkhpgzq3gfcxmys29wzfizjb9asn4crbn503x9 >>> >>> And I am not able to imagine a case. To me, it should be a fixed-p= oint. >>> That=E2=80=99s what the first patch correct. >> >> That=E2=80=99s expected: =E2=80=98--recursive=E2=80=99 uses a different = computation method, >> including file metadata (technically, it serializes the file as a nar >> and computes the hash of the nar). > > Yes, but that=E2=80=99s odd. It should be the same computation method for > tarballs. Nothing is recursive for a tarball therefore, the option > should be skipped. This proposal is perhaps not the best approach > although I lacked of imagination about corner cases. The way I see it, =E2=80=98guix hash=E2=80=99 is a low-level tool and it sh= ould do what I ask for and not try to second-guess. >>> Then, working on Disarchive which uses base16 as encoding, it is annoyi= ng >>> twice, >>> >>> a) because it requires to download when all the sources >>> b) because it sometimes requires to apply patches >>> >>> Compare, >>> >>> $ guix hash $(guix build ceph -S) >>> 0ppd362s177cc47g75v0k27j7aaf27qc31cbbh0j2g30wmhl8gj7 >>> >>> with the checksum in the package definition: >>> 0lmdri415hqczc9565s5m5568pnj97ipqxgnw6085kps0flwq5zh. >>> >>> With the second patch, it becomes easy to convert the checksum from ups= tream: >>> >>> $ ./pre-inst-env guix hash ceph -f base16 >>> f017cca903face8280e1f6757ce349d25e644aa945175312fb0cc31248ccad52 >>> >>> and nothing is downloaded. Get the checksum of what Guix really builds= is >>> done via the current way, for instance, >>> >>> $ guix hash $(guix build ceph -S) -f base16 >>> 473e4461e5603c21015c8b85c1f0114ea9238f986097f30e61ec9ca08519ed5e >>> >>> and the second patch allows to convert the checksum from the package >>> definition (without downloading). >> >> Ah yes, got it. (I should read messages in the right order, oops!) >> >> An obvious problem with the interface you propose is that it=E2=80=99s >> ambiguous: are you printing the hash of the =E2=80=98ceph=E2=80=99 packa= ge, or computing >> that of the =E2=80=98ceph=E2=80=99 file? I=E2=80=99m sure the Zen of Py= thon has something on >> ambiguity. ;-) > > The patch is printing the hash of upstream and it is the only hash which > matters =E2=80=93 speaking both about packaging and about Disarchive. > Therefore, there is no ambiguity here. Sorry, I think I wasn=E2=80=99t clear. Consider this: touch ceph guix hash ceph What does it print? If the result depends on external context (the presence or not of a =E2=80=98ceph=E2=80=99 file in $PWD), that=E2=80=99s a brittle interface IM= O. This could be addressed by requiring users to be explicit, along these lines: guix hash ceph # compute the hash of the file called =E2=80=98ceph=E2= =80=99 guix hash -P ceph # print the hash of the =E2=80=98ceph=E2=80=99 package But there=E2=80=99s another issue with the interface: =E2=80=98guix hash -P= ceph=E2=80=99 would merely print the hash as it appears in the package definition. Thus =E2=80=98-H=E2=80=99 and =E2=80=98-r=E2=80=99 would have no effect, which c= an be confusing. > For instance, can you guess what =E2=80=9Cguix build -S graphviz=E2=80=9D= returns? ;-) I=E2=80=99m aware it returns the source after applying patches and snippets= ; I understand the shortcomings you mention quite well and I don=E2=80=99t deny there=E2=80=99s a need. :-) My comment is on the interface. >> Do you think there=E2=80=99s another place where we could provide helper= s for >> the die-hard Disarchive hackers among us? Maybe we could get =E2=80=98g= uix lint >> -c archival=E2=80=99 to print Disarchive URLs upon failure, and that=E2= =80=99d already >> help? > > To me, =E2=80=9Cguix hash=E2=80=9D is about hashing therefore it appears = to me the right > place for getting the hash of something. For instance, I do not find > =E2=80=9Cguix lint -c archival=E2=80=9D the right place for sending a req= uest and saving > to SWH; as olasd said at the time, IIRC. :-) However, the good is that > =E2=80=9Cguix lint =E2=80=9D just works (for archiving). :-) > > Last, I do not want Diarchive URLs upon failure, I would like hashes and > upstream URLs on request. :-) > > Well, I do not know. What could be better? Another subcommand =E2=80=9C= guix > archival=E2=80=9D doing all these plumbings: save, display hashes, upstre= am URL, > disarchive URL, etc. Yes, maybe? I don=E2=80=99t know. I think it=E2=80=99s important to take = a step back: perhaps we=E2=80=99re in need of a better tool around SWH and Disarchive, r= ather than just a tool that displays a hash. We already have all the APIs to do these things anyway, so if we clarify the use case, we can surely glue things together to build a tool that will be more convenient. (Maybe you=E2=80=99ve already written scripts to help you?) For example, if the use case is =E2=80=9Cis this tarball in Disarchive=E2= =80=9D, this is answered by =E2=80=98guix lint -c archival=E2=80=99, but perhaps we need a = more low-level or more focused tool in that area? Regarding base16: that too isn=E2=80=99t set in stone. Commit 3cb5ae8577db28b2c6013b9d9ecf99cb696e3432 provides more flexibility, so we don=E2=80=99t have to stick to base16. I hope this perspective is useful! Ludo=E2=80=99.