GNU bug report logs - #51307
[PATCH 0/2] guix hash: eases conversion

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: guix-patches; Reported by: zimoun <zimon.toutoune@HIDDEN>; Keywords: patch; dated Wed, 20 Oct 2021 16:51:01 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.

Message received at 51307 <at> debbugs.gnu.org:


Received: (at 51307) by debbugs.gnu.org; 30 Oct 2021 15:48:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 11:48:55 2021
Received: from localhost ([127.0.0.1]:58206 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgqbH-0007r4-1i
	for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 11:48:55 -0400
Received: from mail-wr1-f48.google.com ([209.85.221.48]:36413)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1mgqbF-0007qp-Hm
 for 51307 <at> debbugs.gnu.org; Sat, 30 Oct 2021 11:48:53 -0400
Received: by mail-wr1-f48.google.com with SMTP id s13so14266471wrb.3
 for <51307 <at> debbugs.gnu.org>; Sat, 30 Oct 2021 08:48:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:in-reply-to:references:date:message-id
 :mime-version:content-transfer-encoding;
 bh=wg8lcnmThwI4lkWMat/GkomoUBjNHgc7NwKoOrjIrVY=;
 b=pn5CJprzeT7KYxHc9jWwauqgxHZ7bWZb5cflsPEDjn0H7sryMwEgXOp4Wiy1J3JW1T
 5vlu5+rbOYlTYiZwFLps+cgtzJsNHQsDpTMe7R8VOJuwrk4AHb2Nooy/aRjLYJFY/zdE
 +93VhUGp+g+jjGbdluyeLfYpywqc0fOf151A8dkE23HkI+MZ/P7vXiExdq19/TqjJAVD
 Kz8iIt3AmL3EbpTspOrZYunXadgQOC7WDfOVnX3UJd5EM95zBCoxlOB2383kLhGcxIxq
 6UmtfH6RdaOVovgbfNaYbevgv0VbkR1F9XHgpO8nHDJl+Tq1tVDS3PIqRunJDS0Vp52U
 cKfQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date
 :message-id:mime-version:content-transfer-encoding;
 bh=wg8lcnmThwI4lkWMat/GkomoUBjNHgc7NwKoOrjIrVY=;
 b=012U+3jp8+zUxMdS5TmqtmM3PflZ9yphe9JajzEgs/mYvpVv4a//QtaKMXih7DMH0m
 q6yr+O/LuZwyjPzRw+f6njuqp3q5QMdMTcNUKHpOAxtMb5NOKwTr5zMMWEWxbPjRniqu
 EnUbiZDNxuzXwOI5/zjTJrtjByc7UQGwlvGgpDfPb94Cr2OvxwML625zYf0aGzQFr98A
 jdJOeAbujxvpC6vIMmPesRI3/ms4KNTe/4doRqAJfksBBz4huzpdyM7xr2u28HTOvimA
 vgiq85rO8NruVQ0Iwe2xwbop1dH0rKYwzBJdN5CGbQ6iJy4BTuWwawddTxluieAq1Mqn
 NDjQ==
X-Gm-Message-State: AOAM531lQw7xijqLgLAueGkuEilH0NTiebA1SMLXYTBIKciBxdzXjqzp
 YygbZQGiTAGW+LsSv2y0h7YnRjNGeZ0=
X-Google-Smtp-Source: ABdhPJya8Wq+tPpdkal4oZ3VXPrDkO19KYxJ9kY0O4oVGiJXV6JHxHOzi4o02NGjF2DZ+dtAcwosNA==
X-Received: by 2002:a5d:468f:: with SMTP id u15mr9132360wrq.171.1635608927551; 
 Sat, 30 Oct 2021 08:48:47 -0700 (PDT)
Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e])
 by smtp.gmail.com with ESMTPSA id y5sm11007251wrd.75.2021.10.30.08.48.46
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 30 Oct 2021 08:48:47 -0700 (PDT)
From: zimoun <zimon.toutoune@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#51307: [PATCH 0/2] guix hash: eases conversion
In-Reply-To: <875ytetvt1.fsf_-_@HIDDEN>
References: <20211020165020.3358311-1-zimon.toutoune@HIDDEN>
 <20211020165435.3358398-1-zimon.toutoune@HIDDEN>
 <875ytetvt1.fsf_-_@HIDDEN>
Date: Sat, 30 Oct 2021 17:40:59 +0200
Message-ID: <86cznmldv8.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 51307
Cc: 51307 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Ludo,

On Sat, 30 Oct 2021 at 16:46, Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:
> zimoun <zimon.toutoune@HIDDEN> skribis:
>
>> * guix/scripts/hash.scm (guix-hash): Allow several files.
>> [directory?]: New procedure.
>> [file-hash]: Catch system-error.
>> [hash-to-display]: New procedure.
>
> Nice! Could you update guix.texi and tests/guix-hash.texi?

I will once we agree and reach consensus. ;-)


>> -      (with-error-handling
>> -        (if (assoc-ref opts 'recursive?)
>> +      (if (and (assoc-ref opts 'recursive?)
>> +               (directory? file))
>
> This change is not related to the main purpose of the patch.
>
> More importantly, note that =E2=80=98--recursive=E2=80=99 is not limited =
to directories:
> it preserves file properties (directory, executable, or regular), so
> it=E2=80=99s also useful for executable files for instance.  It can also =
be used
> for regular files, even if it=E2=80=99s less useful.

I understand.  Could you provide concrete examples when it is not
directory?  In order to see if there is a pattern.

>> +    (define (hash-to-display thing)
>> +      (match thing
>> +        ((? file-exists? file)
>> +         (fmt (file-hash file)))
>> +        ("-" (with-error-handling
>> +               (fmt (port-hash (assoc-ref opts 'hash-algorithm)
>> +                               (current-input-port)))))
>
> I=E2=80=99d swap the order of the two clauses and remove the call to
> =E2=80=98file-exists?=E2=80=99: if the file doesn=E2=80=99t exist, =E2=80=
=98file-hash=E2=80=99 will raise an
> error.

I can swap order but not remove file-exists?  Otherwise, the next clause=E2=
=80=A6

>> +        (x
>> +         (leave (G_ "wrong argument~%")))))

will never happen.  And some tests are failing.

>> +    (for-each
>> +     (lambda (arg)
>> +       (format #t "~a~%" (hash-to-display arg)))
>
> Or just (compose display hash-to-display) ?
>
> Maybe s/hash-to-display/formatted-hash/.

Thanks.  Indeed both are better. :-)


> Could you send an updated patch?

Yes, but before, from my understanding, we should agree on the goal of
such patch. :-)  See the two other replies.

Cheers,
simon




Information forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.

Message received at 51307 <at> debbugs.gnu.org:


Received: (at 51307) by debbugs.gnu.org; 30 Oct 2021 15:37:54 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 11:37:54 2021
Received: from localhost ([127.0.0.1]:58179 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgqQc-0005Iv-FU
	for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 11:37:54 -0400
Received: from mail-wr1-f47.google.com ([209.85.221.47]:40729)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1mgqQb-0005Ij-G4
 for 51307 <at> debbugs.gnu.org; Sat, 30 Oct 2021 11:37:53 -0400
Received: by mail-wr1-f47.google.com with SMTP id r8so8592028wra.7
 for <51307 <at> debbugs.gnu.org>; Sat, 30 Oct 2021 08:37:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:in-reply-to:references:date:message-id
 :mime-version:content-transfer-encoding;
 bh=RE6aTBKB+2nvnVDyUkiurUGvR+9PpCZRQ1Prmaz5wsQ=;
 b=DQDKTNeBc+rGru29wTkOyT8kbThtd3660ZdTGYGdDNcIKEhFInsYOWma08CH4v53DQ
 RLK0uQP6214ieJTShRViUwhlhZLci0pRgOI9MAeCaKeIn6h+vWV8f1TWq2rdMqATt8bt
 O8ljIvmgKzxsOTIAUTVy59kZuRciNU88N/R7HTN+BfEiRXIS603mFS7stPHZvpgbB8yl
 hQAePLBjhRKcKWYG3c/ziWQbr9+isiCB+i6cxc5scb+jVxesAPrb+/YajtUzS13WXQvV
 JeY0x5Jj5NaqUjj7T6Z8mmxbMbBFsO3Ys8VYc5ebzlWuTN5SXdM4emf0tU7k50EEh6A/
 5LTQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date
 :message-id:mime-version:content-transfer-encoding;
 bh=RE6aTBKB+2nvnVDyUkiurUGvR+9PpCZRQ1Prmaz5wsQ=;
 b=BDsxczh99NUgRAM8VNbrt4AVTdtGK/kBBRqgpknS/c590w1IdeJVXWlsXvLyMCeiu/
 w7O1RBqTC+ODyTqhgSx4WbyidHnVoc8ey+gbwTo/KJeP69BBOH6ajMNGzpZv3ZtVPV2C
 4h1PKqo5bxxU/hQXYmiM5oScar0aCvrPtoc4ZVwSDFYKbQrf2oSB5AR0xE/I/xgt232h
 fGP9DISdwM7dGyuyWQf0xUoYDrK8GMRlgxK0Iwh4RnSy/ynfqr7p3Dql2J/Q5iPKp1ao
 DaNypyut1GZLxnBLjoJRc1oVYixE4kuFrD14xEXbEutU69j+Zt0/ymkS04svXqJgr9B6
 x/QA==
X-Gm-Message-State: AOAM533rk58llJidB7jz8WYR0Bjk0ONseofdoVsHLdZl2lLz9DepzyDH
 Ud1DNiC/G+tC8X3rHVoSNT+xPIUUu58=
X-Google-Smtp-Source: ABdhPJzv8THvNJoCTYIpOEzaWt1n4GO7VSRrvrSvs+j/ZJNAz4oGdRfDo+8o+wdXWpMZnB0/BSaILQ==
X-Received: by 2002:adf:ec45:: with SMTP id w5mr8732272wrn.183.1635608267592; 
 Sat, 30 Oct 2021 08:37:47 -0700 (PDT)
Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e])
 by smtp.gmail.com with ESMTPSA id 13sm11646601wrz.38.2021.10.30.08.37.46
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 30 Oct 2021 08:37:47 -0700 (PDT)
From: zimoun <zimon.toutoune@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#51307: [PATCH 0/2] guix hash: eases conversion
In-Reply-To: <871r42tvoy.fsf_-_@HIDDEN>
References: <20211020165435.3358398-1-zimon.toutoune@HIDDEN>
 <20211020165435.3358398-2-zimon.toutoune@HIDDEN>
 <871r42tvoy.fsf_-_@HIDDEN>
Date: Sat, 30 Oct 2021 17:34:55 +0200
Message-ID: <86h7cyle5c.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 51307
Cc: 51307 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)


On Sat, 30 Oct 2021 at 16:48, Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:
> zimoun <zimon.toutoune@HIDDEN> skribis:
>
>> * guix/scripts/hash.scm (guix-hash)[package?]: New procedure.
>> [hash-to-display]: Use it.
>> * tests/guix-hash.scm: New test.
>> ---
>>  guix/scripts/hash.scm | 19 +++++++++++++++++--
>>  tests/guix-hash.sh    | 10 ++++++++++
>>  2 files changed, 27 insertions(+), 2 deletions(-)
>>
>> diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
>> index f3363549d3..4f0d41629f 100644
>> --- a/guix/scripts/hash.scm
>> +++ b/guix/scripts/hash.scm
>> @@ -22,6 +22,9 @@
>>=20=20
>>  (define-module (guix scripts hash)
>>    #:use-module (gcrypt hash)
>> +  #:use-module ((gnu packages) #:select (find-best-packages-by-name))
>> +  #:use-module (guix packages)
>> +  #:use-module ((guix utils) #:select (package-name->name+version))
>
> I think I would prefer to keep (guix scripts hash) bare-bones, not
> depending on the package machinery.

I understand but I do not have better to propose. :-)


> Most of the time one can run:
>
>   guix hash $(guix build -S PACKAGE)

First, it is not true.  For instance,

        $ guix hash $(guix build -S graphviz)
        00skvq94xanwmprz5073mhmssz953dwf7h23p5czrpgd5s7hy444

and this hash does not correspond to the hash used by
Disarchive. Because =E2=80=9Cguix build -S=E2=80=9D does not return what Gu=
ix downloads
but what Guix builds.  The cover letter provides another example for the
package =E2=80=99ceph=E2=80=99.

Each time a patch or a snippet is added to origin, then it is not true.

Second, it requires to download for hashing.  When the hash is already
in the source.  I would like to avoid unnecessary downloads.  I mean, it
is ok to download for a couple of packages.  But it becomes impractical
for batch of 1200 (or more).


> It=E2=80=99s not quite what you want if the package has patches or a snip=
pet,
> but that=E2=80=99s okay IMO.

No, that=E2=80=99s not OK. :-)  Because, it becomes really annoying.  I hav=
e to
open gnu/packages, then recompose URL, then download and hash with the
right format.  Too many manual and boring steps when all is there.  Just
require CLI to be displayed.

Cheers,
simon

PS:
That=E2=80=99s what the cover letter was explaining.  Sorry if it was badly
worded or unclear.




Information forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.

Message received at 51307 <at> debbugs.gnu.org:


Received: (at 51307) by debbugs.gnu.org; 30 Oct 2021 15:28:02 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 11:28:02 2021
Received: from localhost ([127.0.0.1]:58170 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgqH4-00051T-5t
	for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 11:28:02 -0400
Received: from mail-wr1-f53.google.com ([209.85.221.53]:38426)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1mgqGw-00050M-Ku
 for 51307 <at> debbugs.gnu.org; Sat, 30 Oct 2021 11:27:55 -0400
Received: by mail-wr1-f53.google.com with SMTP id u18so21398929wrg.5
 for <51307 <at> debbugs.gnu.org>; Sat, 30 Oct 2021 08:27:54 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:in-reply-to:references:date:message-id
 :mime-version:content-transfer-encoding;
 bh=V6vCoXb8RfNoHY5Rjuog64H7cMKEaBqQtnOc8Rilz2I=;
 b=ZvrsChQm/dZYBEvTteUjlKJWTZy3f1jBo7MnfMJVXJoAT6zZg/wolxbiU417GP54nk
 CFkDkVbDYtVwPM0IhtxsLxC7KtF56XOC4AAhxOsTLL+R62gvBCRWujD6VrDVhKZhb4iX
 QHj4sf2VHnIhMbHb36ncAcL783Zb0mRzP1bMznfEsr6PczjZijAeBm8H5zvK7QLW97/j
 5EmUVyM6p1IFzIc7ERcJzbnyoub7sw3j73pufpYS51Dk78CVr+pW/hKBQ9wfQ2jehXI0
 OdU8jgyRck0JVgzKGaqXRvb2wnBJ/Si5mNBrkhBYuvREkO7yh9R4SVH2Vg+OA8i8ha7N
 GDkg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date
 :message-id:mime-version:content-transfer-encoding;
 bh=V6vCoXb8RfNoHY5Rjuog64H7cMKEaBqQtnOc8Rilz2I=;
 b=kw4V82VkDs6lj6wLj7rEiLm/1/81zrUnDZQWRE/v+1LQ7eReZBxzsJjFS522ALy2On
 3OqDplomYayzuu+MFQIH/cokc7DjLF8UzGD5Qk5X7/2ACwLG5XN/RFzX9qWlStj1ezxE
 rBJBJ/JrbPbnS16GoLyRr0oOjk2UrjSOk4CRamLEdSGaU6/Prx12vFHIVTySQBgcRczj
 rkTaQy+LpsBv/EjbufF8EYTNvDzkbYVhaZXQUS2W+sHL4qHm+jnPeP2wQqltBP7w8L9/
 4SVdLbXTkuwE1XvuxpJeQCcVHQbq/SE5h3PqbNk2ctpL5P7D47evHKb46TOKw7pNjvOe
 vtIw==
X-Gm-Message-State: AOAM533o/m3AjO3kPDSHG3xK+PkSdGUH7jBwXOEaArINfDy7gmdksX0D
 DVtduzqvxgtg6UnGikiaBSMR8qFoS1w=
X-Google-Smtp-Source: ABdhPJwk2S1+417nK548SKqoCM4QPhWgrPqHE57Iz7qw+bSpruiHS4HcjubgdtLwdoiuhZH8OX67iA==
X-Received: by 2002:adf:d0cf:: with SMTP id z15mr23135819wrh.219.1635607668857; 
 Sat, 30 Oct 2021 08:27:48 -0700 (PDT)
Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e])
 by smtp.gmail.com with ESMTPSA id j17sm1517967wrw.63.2021.10.30.08.27.48
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 30 Oct 2021 08:27:48 -0700 (PDT)
From: zimoun <zimon.toutoune@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#51307: [PATCH 0/2] guix hash: eases conversion
In-Reply-To: <86tugyleub.fsf@HIDDEN>
References: <20211020165020.3358311-1-zimon.toutoune@HIDDEN>
 <87wnlusgwy.fsf@HIDDEN> <86tugyleub.fsf@HIDDEN>
Date: Sat, 30 Oct 2021 17:24:34 +0200
Message-ID: <86pmrmleml.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 51307
Cc: 51307 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Re,

On Sat, 30 Oct 2021 at 17:19, zimoun <zimon.toutoune@HIDDEN> wrote:

>> 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.  ;-)

[...]

> 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.

Ah, I forgot.   Zen of Python says,

        Now is better than never.

and the proposed patch does =E2=80=9Cnow=E2=80=9D the things I need and thi=
s hypothetical
other subcommand falls into =E2=80=9Cnever=E2=80=9D. :-)


Cheers,
simon





Information forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.

Message received at 51307 <at> debbugs.gnu.org:


Received: (at 51307) by debbugs.gnu.org; 30 Oct 2021 15:27:56 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 11:27:56 2021
Received: from localhost ([127.0.0.1]:58167 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgqGx-00050m-P4
	for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 11:27:56 -0400
Received: from mail-wm1-f47.google.com ([209.85.128.47]:51075)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1mgqGv-00050J-Gm
 for 51307 <at> debbugs.gnu.org; Sat, 30 Oct 2021 11:27:53 -0400
Received: by mail-wm1-f47.google.com with SMTP id 133so1110163wme.0
 for <51307 <at> debbugs.gnu.org>; Sat, 30 Oct 2021 08:27:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:in-reply-to:references:date:message-id
 :mime-version:content-transfer-encoding;
 bh=v+Ibs/l/f+XV1/PwBR1Z0B0FiXxQDSMX9HEqpW8qAgc=;
 b=CY6C5gkiqVn9NOfEhtICrlkAzVGL/BbmlgKFTFp1jR+1md/YL22NDK5DTzoZtsVILd
 Tnnc7vXrHIUzmt8CHJ5vsT7vN/spN1dF6RXZFPYiqrgx77yF+a5+T8D4RBw3PpV72r9h
 Qjiy9PIFxqmKbEVDR7W/VHp5qCOCjj2YMuPhxlM2C+YfYxEx7GAzsjD3A+uTbE55jKtt
 NkU1PtlVoykAXHMbIqowq/r1WJeG+kqnrJyxBS974kHjHMq0amXbzNPgzBL96kszzkkn
 hwfN8VGnqd/joJmRdwnInDCdCJN1v7nTAvX0qizUAHddsA8KG04oZSwhcldQQ3ZrBTV/
 3AlQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date
 :message-id:mime-version:content-transfer-encoding;
 bh=v+Ibs/l/f+XV1/PwBR1Z0B0FiXxQDSMX9HEqpW8qAgc=;
 b=qouKNO0TmkzXMrl7BzzcORf6rPgdf394EJ7JzcLrut/5ICIv57KHys1CXwr0k3wIp3
 MsyBHV9fcmRMRf7LPslSLhOIEuop8FfP0dVFlyG7mzixJ0On5Km40a9w6mMs0sQggERw
 2GLSxsPxoozTrt4YaacSVFOGNQC4BDSQjtJDKVbyKSXLmjJ/RKTU/zNavD4fRUE1Bwje
 aON4Dn2KXKNARu6o2EJdgbi/DMsRu+WzUJdFPpFJp6Lzc3hhgOgkZMc5uj/zYzEWuDlV
 gHJKLT9bmscv/Ntc+yLrwB+f0ZGJg+6yauDkyz0P7rcetxOoH3Bf+Ei1jcubI8869KNx
 WXRA==
X-Gm-Message-State: AOAM53340LYTaLmYgi7HHAvuOZ6l0TXi9DRg+7gU6mlJSMVTJbZUIc6/
 Enj41ts93dfzHtAs9wl17xn56UF+tQ4=
X-Google-Smtp-Source: ABdhPJxEYIVjmwjpA7Psrdh0FJf2pJZoYboQPK0AgdYyu0LO+k11DYKOnDgsqLxCsjoZzmJDhs0fcQ==
X-Received: by 2002:a1c:9851:: with SMTP id a78mr6600128wme.116.1635607667595; 
 Sat, 30 Oct 2021 08:27:47 -0700 (PDT)
Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e])
 by smtp.gmail.com with ESMTPSA id n9sm8173586wmq.6.2021.10.30.08.27.46
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Sat, 30 Oct 2021 08:27:47 -0700 (PDT)
From: zimoun <zimon.toutoune@HIDDEN>
To: Ludovic =?utf-8?Q?Court=C3=A8s?= <ludo@HIDDEN>
Subject: Re: bug#51307: [PATCH 0/2] guix hash: eases conversion
In-Reply-To: <87wnlusgwy.fsf@HIDDEN>
References: <20211020165020.3358311-1-zimon.toutoune@HIDDEN>
 <87wnlusgwy.fsf@HIDDEN>
Date: Sat, 30 Oct 2021 17:19:56 +0200
Message-ID: <86tugyleub.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 51307
Cc: 51307 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

Hi Ludo,

On Sat, 30 Oct 2021 at 16:53, Ludovic Court=C3=A8s <ludo@HIDDEN> wrote:
> zimoun <zimon.toutoune@HIDDEN> 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-po=
int.
>>     That=E2=80=99s what the first patch correct.
>
> That=E2=80=99s expected: =E2=80=98--recursive=E2=80=99 uses a different c=
omputation 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.


>> Then, working on Disarchive which uses base16 as encoding, it is annoying
>> 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 upst=
ream:
>>
>>   $ ./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 packag=
e, or computing
> that of the =E2=80=98ceph=E2=80=99 file?  I=E2=80=99m sure the Zen of Pyt=
hon 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.  Better said, the ambiguity is
from =E2=80=9Cguix build --source=E2=80=9D where it is not predictable befo=
rehand what
it will return.

For instance, can you guess what =E2=80=9Cguix build -S graphviz=E2=80=9D r=
eturns? ;-)
And can you guess the hash?


> Do you think there=E2=80=99s another place where we could provide helpers=
 for
> the die-hard Disarchive hackers among us?  Maybe we could get =E2=80=98gu=
ix 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 reque=
st and saving
to SWH; as olasd said at the time, IIRC. :-) However, the good is that
=E2=80=9Cguix lint <pkg>=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=9Cgu=
ix
archival=E2=80=9D doing all these plumbings: save, display hashes, upstream=
 URL,
disarchive URL, etc.

WDYT?

Cheers,
simon




Information forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.

Message received at 51307 <at> debbugs.gnu.org:


Received: (at 51307) by debbugs.gnu.org; 30 Oct 2021 14:53:26 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 10:53:26 2021
Received: from localhost ([127.0.0.1]:58142 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgpjZ-00042H-OX
	for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 10:53:25 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38976)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1mgpjY-000425-D7
 for 51307 <at> debbugs.gnu.org; Sat, 30 Oct 2021 10:53:24 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:55006)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1mgpjT-0008R4-20; Sat, 30 Oct 2021 10:53:19 -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=S9PEHJ4sYAlFwxKInelHg1Pou2XCJLRkkRRanF7T+Jw=; b=nyIXtGDhb+Yyq87ZpBcL
 9a+QSvHJNK+nlOc6t1MzzP5DHvjXt4waSGAXWpRc+ihzBnGjLZMHTCwXmiLA4wPjqV399asMy1fRX
 NVaMWuqG7f2QnLjm2CgfB0/vBrQAzeClDwROP3NTKxA7K67ju7dElulEIwfw1oE3oKjhja4LsfOnu
 yHHnHGqwHUSSBi2F/JNVXjA2E1AQ+Un6DWnCKFccmu8bOinOoHexlChL6VToI0SL1+yDnwjOSyBBa
 2tnXtcbrP8da7HTkULSolcEG0fwAKnTt0CBy/1JDxrWk4WSfAA7Go6yNH14gjYEgVE4mjoV87HM6x
 PwBkQ+ZW7MxMpA==;
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55428 helo=ribbon)
 by fencepost.gnu.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1mgpjS-0002ac-HQ; Sat, 30 Oct 2021 10:53:18 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: zimoun <zimon.toutoune@HIDDEN>
Subject: Re: bug#51307: [PATCH 0/2] guix hash: eases conversion
References: <20211020165020.3358311-1-zimon.toutoune@HIDDEN>
Date: Sat, 30 Oct 2021 16:53:17 +0200
In-Reply-To: <20211020165020.3358311-1-zimon.toutoune@HIDDEN> (zimoun's
 message of "Wed, 20 Oct 2021 18:50:20 +0200")
Message-ID: <87wnlusgwy.fsf@HIDDEN>
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 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

zimoun <zimon.toutoune@HIDDEN> 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-poi=
nt.
>     That=E2=80=99s what the first patch correct.

That=E2=80=99s expected: =E2=80=98--recursive=E2=80=99 uses a different com=
putation method,
including file metadata (technically, it serializes the file as a nar
and computes the hash of the nar).

[...]

> Then, working on Disarchive which uses base16 as encoding, it is annoying
> 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 upstr=
eam:
>
>   $ ./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 package,=
 or computing
that of the =E2=80=98ceph=E2=80=99 file?  I=E2=80=99m sure the Zen of Pytho=
n has something on
ambiguity.  ;-)

Do you think there=E2=80=99s another place where we could provide helpers f=
or
the die-hard Disarchive hackers among us?  Maybe we could get =E2=80=98guix=
 lint
-c archival=E2=80=99 to print Disarchive URLs upon failure, and that=E2=80=
=99d already
help?

WDYT?

Thanks!

Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.

Message received at 51307 <at> debbugs.gnu.org:


Received: (at 51307) by debbugs.gnu.org; 30 Oct 2021 14:48:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 10:48:55 2021
Received: from localhost ([127.0.0.1]:58137 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgpfD-0003uY-5y
	for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 10:48:55 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38418)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1mgpfB-0003uK-IB
 for 51307 <at> debbugs.gnu.org; Sat, 30 Oct 2021 10:48:54 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:54952)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1mgpf6-0007wY-4V; Sat, 30 Oct 2021 10:48:48 -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=SghBQjzJax+JS2n3X19tz98zmU9Xv645OZEbXIvNcp8=; b=P+NZXISB5yupucGCC80J
 ZaVzAVUpoBFFL9mfNpG85PlDR7sQQNC/5yirQyBIxOy66OswL9AJp8UTnhrIYzRXjXn/Ppk2snbnh
 HQwVr0IVAvPlKnwkJeSm4EFzDLh5DO99Jko7L09IMIA6lhOLKAnuivJlfU+eLVPzXcQ/UfKLSPGmJ
 GJTom0C4jFCmccXgpnea0w0g2eha2YCLEnX7SlKmRQ99AxrmfdfBrQNn8dUg4jCuGn97h4+s6yM1o
 NNHnbOkPD8zJwbTObgFvPAu3lD1KmeJD9zEzIbgsdqJaHGlfs3T8grS6Fdfwpwu0WUk4wouTU/GTT
 yM+qwD1AX3Rpbw==;
Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=55426 helo=ribbon)
 by fencepost.gnu.org with esmtpsa
 (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1)
 (envelope-from <ludo@HIDDEN>)
 id 1mgpf5-0002AW-Lr; Sat, 30 Oct 2021 10:48:47 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: zimoun <zimon.toutoune@HIDDEN>
Subject: Re: bug#51307: [PATCH 0/2] guix hash: eases conversion
References: <20211020165435.3358398-1-zimon.toutoune@HIDDEN>
 <20211020165435.3358398-2-zimon.toutoune@HIDDEN>
Date: Sat, 30 Oct 2021 16:48:45 +0200
In-Reply-To: <20211020165435.3358398-2-zimon.toutoune@HIDDEN> (zimoun's
 message of "Wed, 20 Oct 2021 18:54:35 +0200")
Message-ID: <871r42tvoy.fsf_-_@HIDDEN>
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 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

zimoun <zimon.toutoune@HIDDEN> skribis:

> * guix/scripts/hash.scm (guix-hash)[package?]: New procedure.
> [hash-to-display]: Use it.
> * tests/guix-hash.scm: New test.
> ---
>  guix/scripts/hash.scm | 19 +++++++++++++++++--
>  tests/guix-hash.sh    | 10 ++++++++++
>  2 files changed, 27 insertions(+), 2 deletions(-)
>
> diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
> index f3363549d3..4f0d41629f 100644
> --- a/guix/scripts/hash.scm
> +++ b/guix/scripts/hash.scm
> @@ -22,6 +22,9 @@
>=20=20
>  (define-module (guix scripts hash)
>    #:use-module (gcrypt hash)
> +  #:use-module ((gnu packages) #:select (find-best-packages-by-name))
> +  #:use-module (guix packages)
> +  #:use-module ((guix utils) #:select (package-name->name+version))

I think I would prefer to keep (guix scripts hash) bare-bones, not
depending on the package machinery.

Most of the time one can run:

  guix hash $(guix build -S PACKAGE)

It=E2=80=99s not quite what you want if the package has patches or a snippe=
t,
but that=E2=80=99s okay IMO.

WDYT?

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.

Message received at 51307 <at> debbugs.gnu.org:


Received: (at 51307) by debbugs.gnu.org; 30 Oct 2021 14:46:28 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Oct 30 10:46:28 2021
Received: from localhost ([127.0.0.1]:58132 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mgpcp-0003ns-OI
	for submit <at> debbugs.gnu.org; Sat, 30 Oct 2021 10:46:27 -0400
Received: from eggs.gnu.org ([209.51.188.92]:38104)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>) id 1mgpco-0003nf-NF
 for 51307 <at> debbugs.gnu.org; Sat, 30 Oct 2021 10:46:26 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e]:54912)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1mgpcj-0006PW-EZ; Sat, 30 Oct 2021 10:46:21 -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=+tjRRrur6psz8e3ZD6i2AQyVIudKbWKoNfY00cNSW5I=; b=bc14r2ezY1Ovs3oQ7X5Z
 Anv9iwwHbMCAWCOvU3i+Jc33pXG7YgKAaGj5uhU/R4ceU+OVhJBxZVW5miwOm7g8+cn9SBz+vXXXf
 1bm8fFRSb86dxflrHtNdwdkeVsog3P34qwxUhI6wEIusufai4ti8lNlrZlfkFlCM2jBVz0qdwPI+T
 FwJcUQYkaJ2dDZ40KnBT428Na8JEkKXXiUL9C3dtSRPGgfVlkb7yrIyas6FOpgExBOtWdw7ZBuP43
 6h/hLUQcq15uwL1B55DL6BIn1XMYI+AwP68e+w4X+u5gwRupDFLPCyUmbkqXdsj3qD/zIirLDDNXz
 uCMPdmpDxFlwQg==;
Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:55488
 helo=ribbon)
 by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1mgpcj-0001yG-23; Sat, 30 Oct 2021 10:46:21 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: zimoun <zimon.toutoune@HIDDEN>
Subject: Re: bug#51307: [PATCH 0/2] guix hash: eases conversion
References: <20211020165020.3358311-1-zimon.toutoune@HIDDEN>
 <20211020165435.3358398-1-zimon.toutoune@HIDDEN>
Date: Sat, 30 Oct 2021 16:46:18 +0200
In-Reply-To: <20211020165435.3358398-1-zimon.toutoune@HIDDEN> (zimoun's
 message of "Wed, 20 Oct 2021 18:54:34 +0200")
Message-ID: <875ytetvt1.fsf_-_@HIDDEN>
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 <at> debbugs.gnu.org
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -3.3 (---)

Hi,

zimoun <zimon.toutoune@HIDDEN> skribis:

> * guix/scripts/hash.scm (guix-hash): Allow several files.
> [directory?]: New procedure.
> [file-hash]: Catch system-error.
> [hash-to-display]: New procedure.

Nice! Could you update guix.texi and tests/guix-hash.texi?

> -      (with-error-handling
> -        (if (assoc-ref opts 'recursive?)
> +      (if (and (assoc-ref opts 'recursive?)
> +               (directory? file))

This change is not related to the main purpose of the patch.

More importantly, note that =E2=80=98--recursive=E2=80=99 is not limited to=
 directories:
it preserves file properties (directory, executable, or regular), so
it=E2=80=99s also useful for executable files for instance.  It can also be=
 used
for regular files, even if it=E2=80=99s less useful.

> +    (define (hash-to-display thing)
> +      (match thing
> +        ((? file-exists? file)
> +         (fmt (file-hash file)))
> +        ("-" (with-error-handling
> +               (fmt (port-hash (assoc-ref opts 'hash-algorithm)
> +                               (current-input-port)))))

I=E2=80=99d swap the order of the two clauses and remove the call to
=E2=80=98file-exists?=E2=80=99: if the file doesn=E2=80=99t exist, =E2=80=
=98file-hash=E2=80=99 will raise an
error.

> +        (x
> +         (leave (G_ "wrong argument~%")))))
> +
> +    (for-each
> +     (lambda (arg)
> +       (format #t "~a~%" (hash-to-display arg)))

Or just (compose display hash-to-display) ?

Maybe s/hash-to-display/formatted-hash/.

Could you send an updated patch?

Thanks,
Ludo=E2=80=99.




Information forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.

Message received at 51307 <at> debbugs.gnu.org:


Received: (at 51307) by debbugs.gnu.org; 20 Oct 2021 16:54:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 20 12:54:51 2021
Received: from localhost ([127.0.0.1]:55359 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mdErb-0007SP-DL
	for submit <at> debbugs.gnu.org; Wed, 20 Oct 2021 12:54:51 -0400
Received: from mail-wr1-f45.google.com ([209.85.221.45]:36707)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1mdErY-0007S3-Tg
 for 51307 <at> debbugs.gnu.org; Wed, 20 Oct 2021 12:54:49 -0400
Received: by mail-wr1-f45.google.com with SMTP id o20so48413176wro.3
 for <51307 <at> debbugs.gnu.org>; Wed, 20 Oct 2021 09:54:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:date:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=WydHqYw6Dw85SFFZAywbmj0Idl7DO7jpycThEmU3aGM=;
 b=O6+QbwDZYqGJ4O1mCFRV9O5wyyHPBWqI6CByRPvtWQuNZB+Uib0GYzy0/WVmQkkbYO
 BMWGA+0bxztDy7u+flXoe8gak5KLZ452vuth1wOcvQFQqa3Tbf+haj88Am3+d191oF8m
 Zhx7WpItGqRRO5g7v0aSR1iIkldx9MD1VOGVvP+nO2wOWj3Dhq55ug1RX1ToNPYwavQs
 lsmg3/6Y+qp51bW4xLIJ3ndiH5ueW8HBMfbTcy1w7T7OArbKLCeF5WzQuGA8MxcXN9rx
 7JJmJScYoPKlS9uxeizLLo0D3XFvUjjWfYxC6WJCGq0fLDf9ertg6ZYtDriZubw+1q3n
 bVCA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=WydHqYw6Dw85SFFZAywbmj0Idl7DO7jpycThEmU3aGM=;
 b=ER7MT/IwBmkPvguUjrFFnyy9AU3/dsH3Jqzxs8saOLYkKJmwc7RsQRJJrkFvs91kXu
 je+xR/PpXsSl2E8/0VvbatzlvsDznDjr3j82KKykFSOQfruJpvXpCKn7SdNsIt/PzZci
 8kQfCL+cHMb49oMAZa77paegAhJRDhO1Cv5Tj/48oCHkcPu0Jcgw91hsXnVRAG2zNchn
 DReam0T67X2GiiNE3vcDv1JipRivzkIGqx2PbPwd6mvTRTYbZjvA9cY/QMhCuMcAfimN
 Hvyl/OzNLrFMLAWd+J3mDFyzgwAUsEi/7GKTLVhh8BJMSHnBSA+6nA4d12lr/s2Bu8/M
 ZOmA==
X-Gm-Message-State: AOAM533vMx9o9BWqbjeK0t6tWRUeYbwj/dKCzJ9GYReqR/XSPuZdttlr
 NxM44/TokgFMPT1cfLhqnGfk7VI9rQU=
X-Google-Smtp-Source: ABdhPJyuyhStVb83QEVr+jaXqkC7mmOW2Gmm1E13hqScvRhWKaJD0l6VNLt0a5DN0Aya5cnknexhqQ==
X-Received: by 2002:adf:a54f:: with SMTP id j15mr485809wrb.218.1634748883217; 
 Wed, 20 Oct 2021 09:54:43 -0700 (PDT)
Received: from localhost.localdomain ([193.48.40.117])
 by smtp.gmail.com with ESMTPSA id o11sm3639977wry.0.2021.10.20.09.54.42
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 20 Oct 2021 09:54:42 -0700 (PDT)
From: zimoun <zimon.toutoune@HIDDEN>
To: 51307 <at> debbugs.gnu.org
Subject: [PATCH 2/2] scripts: hash: Support file or package.
Date: Wed, 20 Oct 2021 18:54:35 +0200
Message-Id: <20211020165435.3358398-2-zimon.toutoune@HIDDEN>
X-Mailer: git-send-email 2.32.0
In-Reply-To: <20211020165435.3358398-1-zimon.toutoune@HIDDEN>
References: <20211020165435.3358398-1-zimon.toutoune@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 51307
Cc: zimoun <zimon.toutoune@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/hash.scm (guix-hash)[package?]: New procedure.
[hash-to-display]: Use it.
* tests/guix-hash.scm: New test.
---
 guix/scripts/hash.scm | 19 +++++++++++++++++--
 tests/guix-hash.sh    | 10 ++++++++++
 2 files changed, 27 insertions(+), 2 deletions(-)

diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index f3363549d3..4f0d41629f 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -22,6 +22,9 @@
 
 (define-module (guix scripts hash)
   #:use-module (gcrypt hash)
+  #:use-module ((gnu packages) #:select (find-best-packages-by-name))
+  #:use-module (guix packages)
+  #:use-module ((guix utils) #:select (package-name->name+version))
   #:use-module (guix serialization)
   #:use-module (guix ui)
   #:use-module (guix scripts)
@@ -48,8 +51,8 @@ (define %default-options
     (hash-algorithm . ,(hash-algorithm sha256))))
 
 (define (show-help)
-  (display (G_ "Usage: guix hash [OPTION] FILE
-Return the cryptographic hash of FILE.\n"))
+  (display (G_ "Usage: guix hash [OPTION] FILE-OR-PACKAGE
+Return the cryptographic hash of FILE-OR-PACKAGE.\n"))
   (newline)
   (display (G_ "\
 Supported formats: 'base64', 'nix-base32' (default), 'base32',
@@ -141,6 +144,12 @@ (define (directory? file)
       ((directory) #t)
       (else #f)))
 
+  (define (package? spec)
+    (let-values (((name version) (package-name->name+version spec)))
+      (match (find-best-packages-by-name name version)
+        ((package) package)
+        (_ #f))))
+
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
                             (('argument . value)
@@ -182,6 +191,12 @@ (define (hash-to-display thing)
         ("-" (with-error-handling
                (fmt (port-hash (assoc-ref opts 'hash-algorithm)
                                (current-input-port)))))
+        ((? package? spec)
+         (let* ((package (package? spec))
+                (origin (package-source package))
+                (content-hash (origin-hash origin))
+                (hash (content-hash-value content-hash)))
+           (fmt hash)))
         (x
          (leave (G_ "wrong argument~%")))))
 
diff --git a/tests/guix-hash.sh b/tests/guix-hash.sh
index c4461fa955..41bd2b1588 100644
--- a/tests/guix-hash.sh
+++ b/tests/guix-hash.sh
@@ -1,6 +1,7 @@
 # GNU Guix --- Functional package management for GNU
 # Copyright © 2013, 2014, 2016, 2020, 2021 Ludovic Courtès <ludo@HIDDEN>
 # Copyright © 2016 Jan Nieuwenhuizen <janneke@HIDDEN>
+# Copyright © 2021 Simon Tournier <zimon.toutoune@HIDDEN>
 #
 # This file is part of GNU Guix.
 #
@@ -65,3 +66,12 @@ test `guix hash -r $tmpdir -x` = 10k1lw41wyrjf9mxydi0is5nkpynlsvgslinics4ppir13g
 # Without '-r', this should fail.
 ! guix hash "$tmpdir"
 
+cat > "$tmpdir/foo.scm"<<EOF
+(use-modules (guix packages)
+             (gnu packages base)
+             (guix base16))
+(format #t "~a~%"
+        (bytevector->base16-string
+         (content-hash-value (origin-hash (package-source hello)))))
+EOF
+test `guix hash hello -f base16` = `guix repl -- $tmpdir/foo.scm`
-- 
2.32.0





Information forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.

Message received at 51307 <at> debbugs.gnu.org:


Received: (at 51307) by debbugs.gnu.org; 20 Oct 2021 16:54:51 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 20 12:54:51 2021
Received: from localhost ([127.0.0.1]:55357 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mdErb-0007SN-0p
	for submit <at> debbugs.gnu.org; Wed, 20 Oct 2021 12:54:51 -0400
Received: from mail-wr1-f50.google.com ([209.85.221.50]:45632)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1mdErY-0007S2-MJ
 for 51307 <at> debbugs.gnu.org; Wed, 20 Oct 2021 12:54:49 -0400
Received: by mail-wr1-f50.google.com with SMTP id r10so48265346wra.12
 for <51307 <at> debbugs.gnu.org>; Wed, 20 Oct 2021 09:54:48 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=OCiq+B8eY3dy24gREyN0p0VuTvCUjlqt45JBpT64X1g=;
 b=iiZDbFfXtEJuoUFA5jn2VuLREdMKQv5qEclE5TvRv9yA4v/EH/O+Yy5kbpQzIFyyjh
 /jsSEJQsNCGVFop2/SNYOajwd0sMEiynuJNeKaTWo6RaHS3+ecHAAV4xNG5GTOPJkc+A
 0zD6EKwLAy2TcMXyOgrjLVRCyoovOxRdciPWWEFlBez2AN+Cz3uBOSA9T/vQ4FvpD+PZ
 22ZF/v/BmkuMzkpApf/aV9C5YgFbSOZmeKWDab+XD2XQiVtF9ttX/QHu3gejsVllZmtA
 ECsmDcIO4tlmBzLCe2jHMY6kaWkQxtHqamulAaWw/hIBcpbVRKqvZBhDCW2hQIExopNK
 baSw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=OCiq+B8eY3dy24gREyN0p0VuTvCUjlqt45JBpT64X1g=;
 b=h3kCHEqOxYE7b9hnQkD4kizwqxyshmH3okR5KbhHr5hKYTPw0AZDEDf8qFyM/S0/Nn
 0OzOE80Yevyrw64d0dYdvGiIN8HTgCbo+20mN/NHQXazSfEARQIJqiZEcz6IQNNpq2vV
 NRnCYv0xRedUh4EAuVbkk9PKHOCJUIpeN8HUIy2kijvLW/JRY5w3hA+3GikzwCpWr9Vb
 ITWi7dhOFJkgy8DpErRFOENvhQs1ttkUxU4KQLrBhFGcnVE+4FrbvP6+/hDt5euNTUZW
 C+woVyPk1KOXj5xcYE8/cAEpA8nFj3PbCeBfPjzc6cKEFVdC9eTnai9P6eHAHO6U/j52
 iRPg==
X-Gm-Message-State: AOAM531SqonA7N09H4ur0xz72sU//zfbh5UiMk+ttKLEBWacQC4TBww8
 BOQllvtUbDhZwkhROnmPt+bT43APUh0=
X-Google-Smtp-Source: ABdhPJzEeEPHMwjPY8fy3pK763EZ5pD3BaG0siPnvRRUbHiZzSgP3tRkL/PeaAjbwMWmA1JH8nWnKg==
X-Received: by 2002:a5d:47cb:: with SMTP id o11mr487718wrc.184.1634748882763; 
 Wed, 20 Oct 2021 09:54:42 -0700 (PDT)
Received: from localhost.localdomain ([193.48.40.117])
 by smtp.gmail.com with ESMTPSA id o11sm3639977wry.0.2021.10.20.09.54.42
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 20 Oct 2021 09:54:42 -0700 (PDT)
From: zimoun <zimon.toutoune@HIDDEN>
To: 51307 <at> debbugs.gnu.org
Subject: [PATCH 1/2] scripts: hash: Improve error handling.
Date: Wed, 20 Oct 2021 18:54:34 +0200
Message-Id: <20211020165435.3358398-1-zimon.toutoune@HIDDEN>
X-Mailer: git-send-email 2.32.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 51307
Cc: zimoun <zimon.toutoune@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -1.0 (-)

* guix/scripts/hash.scm (guix-hash): Allow several files.
[directory?]: New procedure.
[file-hash]: Catch system-error.
[hash-to-display]: New procedure.
---
 guix/scripts/hash.scm | 56 +++++++++++++++++++++++++++----------------
 1 file changed, 36 insertions(+), 20 deletions(-)

diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm
index b8622373cc..f3363549d3 100644
--- a/guix/scripts/hash.scm
+++ b/guix/scripts/hash.scm
@@ -3,6 +3,7 @@
 ;;; Copyright © 2013 Nikita Karetnikov <nikita@HIDDEN>
 ;;; Copyright © 2016 Jan Nieuwenhuizen <janneke@HIDDEN>
 ;;; Copyright © 2018 Tim Gesthuizen <tim.gesthuizen@HIDDEN>
+;;; Copyright © 2021 Simon Tournier <zimon.toutoune@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -135,6 +136,11 @@ (define (vcs-file? file stat)
       (else
        #f)))
 
+  (define (directory? file)
+    (case (stat:type (stat file))
+      ((directory) #t)
+      (else #f)))
+
   (let* ((opts (parse-options))
          (args (filter-map (match-lambda
                             (('argument . value)
@@ -149,27 +155,37 @@ (define (vcs-file? file stat)
     (define (file-hash file)
       ;; Compute the hash of FILE.
       ;; Catch and gracefully report possible '&nar-error' conditions.
-      (with-error-handling
-        (if (assoc-ref opts 'recursive?)
+      (if (and (assoc-ref opts 'recursive?)
+               (directory? file))
+          (with-error-handling
             (let-values (((port get-hash)
                           (open-hash-port (assoc-ref opts 'hash-algorithm))))
               (write-file file port #:select? select?)
               (force-output port)
-              (get-hash))
-            (match file
-              ("-" (port-hash (assoc-ref opts 'hash-algorithm)
-                              (current-input-port)))
-              (_   (call-with-input-file file
-                     (cute port-hash (assoc-ref opts 'hash-algorithm)
-                           <>)))))))
-
-    (match args
-      ((file)
-       (catch 'system-error
-         (lambda ()
-           (format #t "~a~%" (fmt (file-hash file))))
-         (lambda args
-           (leave (G_ "~a~%")
-                  (strerror (system-error-errno args))))))
-      (x
-       (leave (G_ "wrong number of arguments~%"))))))
+              (get-hash)))
+          (catch 'system-error
+            (lambda _
+              (call-with-input-file file
+                (cute port-hash (assoc-ref opts 'hash-algorithm)
+                      <>)))
+            (lambda args
+              (when (directory? file)
+                (display-hint (G_ "Try @option{--recursive}.")))
+              (leave (G_ "~a ~a~%")
+                     file
+                     (strerror (system-error-errno args)))))))
+
+    (define (hash-to-display thing)
+      (match thing
+        ((? file-exists? file)
+         (fmt (file-hash file)))
+        ("-" (with-error-handling
+               (fmt (port-hash (assoc-ref opts 'hash-algorithm)
+                               (current-input-port)))))
+        (x
+         (leave (G_ "wrong argument~%")))))
+
+    (for-each
+     (lambda (arg)
+       (format #t "~a~%" (hash-to-display arg)))
+     args)))
-- 
2.32.0





Information forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 20 Oct 2021 16:50:38 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Oct 20 12:50:38 2021
Received: from localhost ([127.0.0.1]:55347 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1mdEnW-0007Lh-5w
	for submit <at> debbugs.gnu.org; Wed, 20 Oct 2021 12:50:38 -0400
Received: from lists.gnu.org ([209.51.188.17]:49358)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>) id 1mdEnU-0007LZ-FM
 for submit <at> debbugs.gnu.org; Wed, 20 Oct 2021 12:50:37 -0400
Received: from eggs.gnu.org ([2001:470:142:3::10]:54788)
 by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <zimon.toutoune@HIDDEN>)
 id 1mdEnU-00005R-7a
 for guix-patches@HIDDEN; Wed, 20 Oct 2021 12:50:36 -0400
Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]:50945)
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128)
 (Exim 4.90_1) (envelope-from <zimon.toutoune@HIDDEN>)
 id 1mdEnS-0003CK-Jv
 for guix-patches@HIDDEN; Wed, 20 Oct 2021 12:50:35 -0400
Received: by mail-wm1-x334.google.com with SMTP id o24so12909662wms.0
 for <guix-patches@HIDDEN>; Wed, 20 Oct 2021 09:50:33 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=hl4YRx3tRT2y77Hxao98lVhlM9QWSE6hlk1KGV/G+vg=;
 b=qY6lSHs+0fAsCzrTr+2dbEXRS0sqSAobHszEIzuf4m7zJvctdu0Az4DuKqVRf/o5QD
 I7QfVqmLHdhTFIsl/st5zg2ZgaXJnxLPAcxWFLiOc7TTYnT/IRPGWeHY9WjsgejxOQPx
 2H8GXkKkuMv+92Ikrq/vRecVIBa3No+YX0Qsm9IJF25NOgri6R0qiRggvj3y02T0t5iW
 IwFuMjZbnAtlP7FSOrY/BROh3yqAPzybEvZj92F9A+xwmnvWeGwC4xdjbypLa4tEX8SC
 vvwJRbnGJlUAAp5c3yfuKDxbyCTwh5L3LlYjqLvId3IhgDFEmzpRdlA9twNhYUF41s/F
 NwAg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version
 :content-transfer-encoding;
 bh=hl4YRx3tRT2y77Hxao98lVhlM9QWSE6hlk1KGV/G+vg=;
 b=fWhnf4lXbedU2ZLzLRXNgcZ5kHokFDHKAjiZAONzoojOyLH5cuGvjRdZgpvkkjFAbC
 q6IGM1pJiEFS7g7h1F7Py6OKsGBiaPKsjCKH3Ca5H/BsAUTPz1Q47QdOmCULkP4GK76m
 Jc/nJXRnZo34T5i9JMsVApebaxsFBB7p4sJrFnTKYlfg1KWAX/YW4qiZi8bSpogDzMBo
 GppmB+/zxrV1LLkNOkky32yOYodDsfB4YP1+r1Q6/an/Rft9fMBQKeyhkpZl2d6QJqzK
 YgBc9Z7bzFA+gei+q+6/mrCqJVDAhlNg7p/nzquXrMAMGQ69OMBrxgN1DpuWkIXt++FT
 zvpg==
X-Gm-Message-State: AOAM533MPQeKHQDQK0OT2z76WkCZXnoj/pHfOQ7v5LeBfnx10T2bPPan
 JbAZRk/mWw/xhsdMB8e9OE8vurdY/ho=
X-Google-Smtp-Source: ABdhPJy9LxXOSsPhVYv9Q8TsW7Op7k8rSkcGWtY/EGjKU80F+RZ3GzAwMVnDCmY8YjPhYWx+HDTZfA==
X-Received: by 2002:a7b:c08b:: with SMTP id r11mr351448wmh.167.1634748632625; 
 Wed, 20 Oct 2021 09:50:32 -0700 (PDT)
Received: from localhost.localdomain ([193.48.40.117])
 by smtp.gmail.com with ESMTPSA id r205sm2565688wma.3.2021.10.20.09.50.31
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 20 Oct 2021 09:50:32 -0700 (PDT)
From: zimoun <zimon.toutoune@HIDDEN>
To: guix-patches@HIDDEN
Subject: [PATCH 0/2] guix hash: eases conversion
Date: Wed, 20 Oct 2021 18:50:20 +0200
Message-Id: <20211020165020.3358311-1-zimon.toutoune@HIDDEN>
X-Mailer: git-send-email 2.32.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Received-SPF: pass client-ip=2a00:1450:4864:20::334;
 envelope-from=zimon.toutoune@HIDDEN; helo=mail-wm1-x334.google.com
X-Spam_score_int: -20
X-Spam_score: -2.1
X-Spam_bar: --
X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001,
 RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001,
 SPF_PASS=-0.001 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: zimoun <zimon.toutoune@HIDDEN>
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.18
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <https://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <https://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <https://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -2.3 (--)

Hi,

The first patch is a tiny improvement on the error handling.

 1. The current situation does not correctly handle error because of
    ’with-error-handling’.
 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-point.
    That’s what the first patch correct.

Moreover, it is possible to pass several arguments,

--8<---------------cut here---------------start------------->8---
$ find . -maxdepth 1 -type d | xargs guix hash -r
guix hash: erreur : nombre d'arguments incorrect

$ find . -maxdepth 1 -type d | xargs ./pre-inst-env guix hash -r
1rzh9b4b4qc5nf4mq601jr2p3xsw690q6d4137ymgq0an9xsli9v
1cgdvnjlh1ziwb12ax2wcrs7ddr44c2nhjali1v3ilsv7fsm79fq
0x64hc3jqq1jwbym5gvcbnsck4v08xxa3kr44m9961nsml1rpmld
03gzaccd1cws05sf469l9ghf9mhxqsnlkkbr859l13alba5isirb
1qmmppfg65wdzcg137hg62ic31ykzvgb26brcv77is1nszvrqm14
1ajw5s2ykyyvpaisv8xbd8rn77q1whk2fxmyfqn3qyzxjf8vw7sz
1fjnk5hsfvsyahf997f6nca5c01jh7gm590xcx2d2adjj2vm51r2
0hm8s9hc6c4x32v3ff0kz7npd1n2i3ld6p69ya68wxfhhkhwpg6r
1k1y2hax62r2jj7j8vk8wx6mhww42g77x1fp7iy151alplv6mi23
1c3dg3mfl4kg0px7rdj52qyxkpn00sdaf7z1bxib4n2wy175gd9m
15680dqbzr7dcngyqblyzqnr5s74rka4qh76n2pdfndd9gc81j0h
0hvlnas7grx69hrxbxz3zw9z80wr02m2c0lbjs0kcxv6wv3da871
1zvw0k4gl3sj3hagp415iy0dcqx8c1k3zwph3n1xcg0z2ljfqpl2
--8<---------------cut here---------------end--------------->8---



Then, working on Disarchive which uses base16 as encoding, it is annoying
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 upstream:

  $ ./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).

For instance, now it is really cheap to do:

--8<---------------cut here---------------start------------->8---
guix package -A | cut -f1 | grep julia | xargs ./pre-inst-env guix hash -f base16
--8<---------------cut here---------------end--------------->8---


All the best,
simon



zimoun (2):
  scripts: hash: Improve error handling.
  scripts: hash: Support file or package.

 guix/scripts/hash.scm | 75 ++++++++++++++++++++++++++++++-------------
 tests/guix-hash.sh    | 10 ++++++
 2 files changed, 63 insertions(+), 22 deletions(-)


base-commit: 19d3cfec72720a4a1339be3d14f4d88ae5bd59f4
--
2.32.0




Acknowledgement sent to zimoun <zimon.toutoune@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#51307; Package guix-patches. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Sat, 30 Oct 2021 16:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.