From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp12.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms8.migadu.com with LMTPS id YFAvNCbLLmVanQAAauVa8A:P1 (envelope-from ) for ; Tue, 17 Oct 2023 19:57:59 +0200 Received: from aspmx1.migadu.com ([2001:41d0:403:478a::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp12.migadu.com with LMTPS id YFAvNCbLLmVanQAAauVa8A (envelope-from ) for ; Tue, 17 Oct 2023 19:57:58 +0200 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 60746570D9 for ; Tue, 17 Oct 2023 19:57:58 +0200 (CEST) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="MAfE/Ant"; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1697565478; 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: dkim-signature; bh=syAVNQTi/enekLVKGRMJ2FKc0iAepgiVrbvXijCGxBk=; b=THDLpBP05eri556YVWyHjqF+Y/Y6viYuJFRdrJ9DJ9TNKpzcioBERfSCoesxvnKGLDWsaF KXGKADgvNDJhJr4blTvZ0uDtQy6Cwyz9uiGtKTxruwv+uLLgOPj7V0C1FBbfqyQWwBv6nY x4jeqAvxG1OUiluaY0IKdnQEV4Xit7Gh3+8/m5FcviPmrTV/GV7D+NlNArCwdWcLzlYwhU qj9TbgKOrI3bxaFQzBcx08x4IWtYsSCUhenlKtwl/70kCLUZYo3jeC2t2MVSL0g1Vpiva5 HwL9oZljRx480A1Z+DDJCM9P4e5SxMuVvUqE11AsfMtXoAW0hEE4CjlC+mCwlg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1697565478; a=rsa-sha256; cv=none; b=VT9AYNMaatpdf43TQYA1a9dK3f9rqCs3rl2HXXkAF8+pNMzZsnXWKd7lyveXY/iKK01ZK8 PldpFHpC1ENoI/RlR6MXooEvWMMLoFHlkhP3fH/gavfsb8wJd2pRqj0CzTpVk9wjGV8F+8 85ZS3ooHpPIKtT2WjhMjIy5QPtHGg6HiUh7z3aquNoOqJI6J1r0jA0FwXeleLFnCEkWEh6 aLZzsWstu00VVqG0u4thf3xi+zLIx6a0ZoKDCFlbkzDiQ6Rpb3svO9WEgl3vPL7YnT47we ya/YdWTFAO/9nl6hbhqUYWpJGIvJW3yWfreyYSaLrERfqxCTRWgKJ9ZrxCjG+A== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20230601 header.b="MAfE/Ant"; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qsoK3-0006Ta-HO; Tue, 17 Oct 2023 13:57:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qsoK1-0006TF-O3 for bug-guix@gnu.org; Tue, 17 Oct 2023 13:57:37 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qsoK1-0003De-Dx for bug-guix@gnu.org; Tue, 17 Oct 2023 13:57:37 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qsoKQ-0003nb-Fk for bug-guix@gnu.org; Tue, 17 Oct 2023 13:58:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#65979: incorrect =?UTF-8?Q?=E2=80=9Cguix_?= =?UTF-8?Q?hash=E2=80=9D?= for FastQC Resent-From: Simon Tournier Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Tue, 17 Oct 2023 17:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65979 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: Ludovic =?UTF-8?Q?Court=C3=A8s?= Cc: 65979@debbugs.gnu.org Received: via spool by 65979-submit@debbugs.gnu.org id=B65979.169756542814534 (code B ref 65979); Tue, 17 Oct 2023 17:58:02 +0000 Received: (at 65979) by debbugs.gnu.org; 17 Oct 2023 17:57:08 +0000 Received: from localhost ([127.0.0.1]:60993 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qsoJY-0003mL-0i for submit@debbugs.gnu.org; Tue, 17 Oct 2023 13:57:08 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]:41380) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qsoJV-0003lq-Cd for 65979@debbugs.gnu.org; Tue, 17 Oct 2023 13:57:06 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-32da02fca9aso1055775f8f.1 for <65979@debbugs.gnu.org>; Tue, 17 Oct 2023 10:56:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1697565394; x=1698170194; darn=debbugs.gnu.org; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=syAVNQTi/enekLVKGRMJ2FKc0iAepgiVrbvXijCGxBk=; b=MAfE/Ant0sU2mVv59uFXfmW1hqyTY8IjWrdmxuIy82IRsx2UbyjgJSDegEEpKiykTn v1A73Pj/2KTz1pHin7WhQleU32aLKDufeiJ7Xs1QIfDcTRjaFjH3McG63Ug8DM8K2GPm dTfpIJEYsJ2juvuFNDMX/EEsWMzqwP6lri/hHK8OVMNkzcVJkDtamCFKrrbvOeY4rpHk 7m1N8+Qr4dHXe06HeDOjLsgy3QixGb0pTfqSgy93vfOPMFuVuNZwMpyvF01MFWzzjGea EG3vL316Yh51M7jx5Eg4/gHr305KZOUJlA8OeBnAR3uDubLTYeAX93kVv/KqdcnaGOnR Fb+w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697565394; x=1698170194; h=mime-version:message-id:date:references:in-reply-to:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=syAVNQTi/enekLVKGRMJ2FKc0iAepgiVrbvXijCGxBk=; b=gbWfW39ndq0V9Gaa0M38pYdXpQefkqNxY56rXILmtRBZijhUOyI1dkaD/WXWlgCsn9 7hW7205CRwpdVb2uKffs9JZoQF7C3XT9rxTmOx4irh/ih2PSZ+eKAD/HWiP5uKSV5Jmx KI91632WtwvMYfMZJIWRvBbeaY12tmIba/wkBzBBtSUAn2g+uUFG0MOD+gDllFWBD46w o+D6/mDu/sZ2r/nflPXtY8pI0e/GwwmOvLlzZ58CEzVKVZSA3olDbuYjVx2+GBP+2Rxu x5cOhDRx5mwPrlsiSwiwyI+y+Ei5iOS88nL0JnuQewRD18LkfJoA3DwYI3ncbgb0J5Eu gaug== X-Gm-Message-State: AOJu0Yx4HVvdJknAeuTfeLZig/NC6lLOBJGHhoGLHduWURk/39EwrrQZ mmGHA+kjv2rXehXSmHFPZbd7i6eu0zU= X-Google-Smtp-Source: AGHT+IH/470UJLUhh12W+/MuhkyB4cI7bBd16BlKLtsrPAT3EBAwY32v5PvJlJAUNIh5U4fzb8FvhQ== X-Received: by 2002:adf:fc07:0:b0:32d:c242:71ac with SMTP id i7-20020adffc07000000b0032dc24271acmr2551355wrr.1.1697565393822; Tue, 17 Oct 2023 10:56:33 -0700 (PDT) Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id v14-20020a5d4a4e000000b0032196c508e3sm267341wrs.53.2023.10.17.10.56.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Oct 2023 10:56:33 -0700 (PDT) From: Simon Tournier In-Reply-To: <87pm252h3c.fsf@gnu.org> References: <87v8ccd7oy.fsf@gmail.com> <87fs313x92.fsf@gmail.com> <87pm252h3c.fsf@gnu.org> Date: Tue, 17 Oct 2023 19:56:28 +0200 Message-ID: <87r0ltp1yr.fsf@gmail.com> 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: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-Spam-Score: 2.84 X-Migadu-Queue-Id: 60746570D9 X-Migadu-Scanner: mx0.migadu.com X-Migadu-Spam-Score: 2.84 X-TUID: p2awabpMQOkG --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Ludo, On Tue, 26 Sep 2023 at 15:34, Ludovic Court=C3=A8s wrote: > My take is that it=E2=80=99s OK to keep =E2=80=98vcs-file?=E2=80=99 as is= : the best we could do > would be to add complicated heuristics in the hope corner cases like > this one would be better dealt with, but it wouldn=E2=80=99t be bullet-pr= oof > anyway. Hum, I am probably pig-headed here. :-) I propose the change below. Well, it does not appear to me a complicated heuristics but I am biased. The idea is to detect at the repository root what is the kind of VCS, just by checking if .git (or .hg or .svn or etc.) exists or not. Then, only exclude this kind=E2=80=A6 = and not the whole list. And I think this way is almost bullet-proof, no? Or could you provide some contrived examples? WDYT? Obviously, this fixes the issue: --8<---------------cut here---------------start------------->8--- $ guix hash -rx /tmp/FastQC 0jyk90kg6s62w3dn6qjx9nrawjs12qx172lii0yxbvsfylhnx479 $ ./pre-inst-env guix hash -rx /tmp/FastQC 00y9drm0bkpxw8xfl8ysss18jmnhj8blgqgr6fpa58rkpfcbg8qk $ grep -A 15 'define-public fastqc' gnu/packages/bioinformatics.scm | grep = -C 1 base32 (sha256 (base32 "00y9drm0bkpxw8xfl8ysss18jmnhj8blgqgr6fpa58rkpfcbg8qk")) --8<---------------cut here---------------end--------------->8--- And I do not observe a regression using a couple of tests. Cheers, simon --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-scripts-hash-Handle-repository-several-VCS-folders.patch Content-Transfer-Encoding: quoted-printable Content-Description: p.patch >From 1bf6555e6a89248f079437b842dbaff9c107de9a Mon Sep 17 00:00:00 2001 Message-Id: <1bf6555e6a89248f079437b842dbaff9c107de9a.1697562942.git.zimon.= toutoune@gmail.com> From: Simon Tournier Date: Tue, 17 Oct 2023 18:53:04 +0200 Subject: [PATCH] scripts: hash: Handle repository several VCS folders. Fixes . Reported by Simon Tournier * guix/hash.scm (vcs-file?): Add optional argument for passing VCS kind of = the file/repository. (file-hash*): Adjust accordingly. * guix/scripts/hash.scm (guix-hash)[file-hash]: Detect VCS kind of the file/repository and passes it. --- guix/hash.scm | 18 ++++++++++++------ guix/scripts/hash.scm | 18 +++++++++++++----- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/guix/hash.scm b/guix/hash.scm index 3cb68e5c44..8fff51e8f1 100644 --- a/guix/hash.scm +++ b/guix/hash.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright =C2=A9 2021 Sarah Morgensen ;;; Copyright =C2=A9 2022 Maxime Devos +;;; Copyright =C2=A9 2023 Simon Tournier ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,21 +26,26 @@ (define-module (guix hash) #:export (vcs-file? file-hash*)) =20 -(define (vcs-file? file stat) - "Returns true if FILE is a version control system file." +(define* (vcs-file? file stat + #:optional + (vcses (list ".bzr" ".git" ".hg" ".svn" "CVS"))) + "Returns true if FILE matches a version control system from the list VCS= ES." (case (stat:type stat) ((directory) - (member (basename file) '(".bzr" ".git" ".hg" ".svn" "CVS"))) + (member (basename file) vcses)) ((regular) - ;; Git sub-modules have a '.git' file that is a regular text file. - (string=3D? (basename file) ".git")) + (if (member ".git" vcses) + ;; Git sub-modules have a '.git' file that is a regular text file. + (string=3D? (basename file) ".git") + #f)) (else #f))) =20 (define* (file-hash* file #:key (algorithm (hash-algorithm sha256)) (recursive? 'auto) - (select? (negate vcs-file?))) + (select? (negate (lambda (file stat) + (vcs-file? file stat))))) "Compute the hash of FILE with ALGORITHM. =20 Symbolic links are only dereferenced if RECURSIVE? is false. diff --git a/guix/scripts/hash.scm b/guix/scripts/hash.scm index 7197d3965c..ed96e6a7e1 100644 --- a/guix/scripts/hash.scm +++ b/guix/scripts/hash.scm @@ -3,7 +3,7 @@ ;;; Copyright =C2=A9 2013 Nikita Karetnikov ;;; Copyright =C2=A9 2016 Jan Nieuwenhuizen ;;; Copyright =C2=A9 2018 Tim Gesthuizen -;;; Copyright =C2=A9 2021 Simon Tournier +;;; Copyright =C2=A9 2021, 2023 Simon Tournier ;;; Copyright =C2=A9 2021 Sarah Morgensen ;;; ;;; This file is part of GNU Guix. @@ -181,9 +181,6 @@ (define-command (guix-hash . args) (_ #f)) (reverse opts))) (fmt (assq-ref opts 'format)) - (select? (if (assq-ref opts 'exclude-vcs?) - (negate vcs-file?) - (const #t))) (algorithm (assoc-ref opts 'hash-algorithm)) (serializer (assoc-ref opts 'serializer))) =20 @@ -193,7 +190,18 @@ (define-command (guix-hash . args) (catch 'system-error (lambda _ (with-error-handling - (serializer file algorithm select?))) + (let* ((vcses (fold (lambda (vcs result) + (if (file-exists? (string-append file "/= " vcs)) + (cons vcs result) + result)) + '() + (list ".bzr" ".git" ".hg" ".svn" "CVS"))) + (select? (if (assq-ref opts 'exclude-vcs?) + (negate (lambda (file stat) + (vcs-file? file stat + vcses))) + (const #t)))) + (serializer file algorithm select?)))) (lambda args (leave (G_ "~a ~a~%") file base-commit: dcc5c34504c94732c135a85fb4db40ca9796270e --=20 2.38.1 --=-=-=--