GNU bug report logs - #63631
[PATCH] import: go: Handle subpackage versioning correctly.

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: Timo Wilken <guix@HIDDEN>; Keywords: moreinfo patch; dated Sun, 21 May 2023 21:20:02 UTC; Maintainer for guix-patches is guix-patches@HIDDEN.
Added tag(s) moreinfo. Request was from Christopher Baines <mail@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

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


Received: (at 63631) by debbugs.gnu.org; 16 Aug 2023 17:12:00 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Aug 16 13:12:00 2023
Received: from localhost ([127.0.0.1]:41963 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qWK3r-0005QJ-QR
	for submit <at> debbugs.gnu.org; Wed, 16 Aug 2023 13:12:00 -0400
Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]:40280)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <zimon.toutoune@HIDDEN>)
 id 1qWK3i-0005NC-4w; Wed, 16 Aug 2023 13:11:51 -0400
Received: by mail-wm1-x331.google.com with SMTP id
 5b1f17b1804b1-3fe8d816a40so10390875e9.1; 
 Wed, 16 Aug 2023 10:11:50 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=gmail.com; s=20221208; t=1692205904; x=1692810704;
 h=mime-version:message-id:date:references:in-reply-to:subject:cc:to
 :from:from:to:cc:subject:date:message-id:reply-to;
 bh=mPduG9+ksRVkvzA0Qa/2RSlV1qAxQ2THAGkRputDeZg=;
 b=kf/zrJ6sn6Ce3Oq1u2FvdL+MYum7ZsmvPAkyQHUiLrEjBKympdHsgZynQfGScDOF1o
 2BQN3fnzh1HRd5aoaYx6fyircREuPP8gLC31ioVVkE2SHrQCYUrIz3EfnUcQZgFCTfOU
 W/Y3aGZF9huYCSkRkYqx6mvoQF6bySXdDMOfY2ACbEldc2UDi+q9eMPT79htVNY+gXll
 3ZVxKoslNjhu0CxRLF2h7CVmH6wdTAXRGJHYAExX/B7fHK064983xkbUAQCQU/H9C0jW
 rz9bi0xkre8fRvpLGsZKeLUXkAKkidUp5wBb7pTpW6gQu/2K2y0sNrDOGMmt3LUXh5vR
 q2mg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20221208; t=1692205904; x=1692810704;
 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=mPduG9+ksRVkvzA0Qa/2RSlV1qAxQ2THAGkRputDeZg=;
 b=VbPNIfHCRrbiXpqYynSpl0ik5yE8GIx7z+1CNuj0/hN6YZc58ajBxNUCkVyNRwaVZW
 MBnYJrkYr/MS65yZiGeImwmxLM+gAftZ04zo2Tx6BfUiHTF/APQaZ7tQIPELMDdZ4T8j
 Vzd5fDpmJ62US3rgA7P8e+a4JJRNOve+ATE0a6o9kQJ8+0g7Z06xfnyyjt+wO/Nn+7ik
 zu3kzGUwNzR5YnjaWlu1Jd/Dh9FVd43Z4ion6/xOPPT/itrYscnsYH+3hi40NCST/SUI
 dGX9TdM+VGd2TpOd/dKSDat7P/xchu+fKQhYUEGH0F7r+BkGCK9fc3+hdnNC6A6RelEi
 Kfrg==
X-Gm-Message-State: AOJu0YyIpJnqhljehCVLaRbnZsK6h/L6ypcU6041Rj8HMugICWyzb1Ph
 2wDUzxu6SM07+1vKGCIctrUhy1hzX7w=
X-Google-Smtp-Source: AGHT+IHmilbFgjYL6fX4qMtQ41+nKvDUIBegmVp8/JhAgr/rcW2U0mhfwGfdJpaohGClqYJCSLltpQ==
X-Received: by 2002:a5d:67cc:0:b0:317:3d36:b2c1 with SMTP id
 n12-20020a5d67cc000000b003173d36b2c1mr1874230wrw.7.1692205904567; 
 Wed, 16 Aug 2023 10:11:44 -0700 (PDT)
Received: from pfiuh07 ([193.48.40.241]) by smtp.gmail.com with ESMTPSA id
 e15-20020adff34f000000b0031980ae286asm8026512wrp.70.2023.08.16.10.11.43
 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);
 Wed, 16 Aug 2023 10:11:44 -0700 (PDT)
From: Simon Tournier <zimon.toutoune@HIDDEN>
To: Timo Wilken <guix@HIDDEN>, Ludovic =?utf-8?Q?Court=C3=A8s?=
 <ludo@HIDDEN>
Subject: Re: bug#63001: bug#63631: [PATCH] import: go: Handle subpackage
 versioning correctly.
In-Reply-To: <CTF06XBYWPT0.1MV6QA1B2OB98@HIDDEN>
References: <6dd1de3dd4d968876fa55f5126056834c77b0244.1684703258.git.guix@HIDDEN>
 <87pm5xrbsg.fsf@HIDDEN> <CTF06XBYWPT0.1MV6QA1B2OB98@HIDDEN>
Date: Wed, 16 Aug 2023 17:59:53 +0200
Message-ID: <875y5ff05i.fsf@HIDDEN>
MIME-Version: 1.0
Content-Type: text/plain
X-Spam-Score: 0.0 (/)
X-Debbugs-Envelope-To: 63631
Cc: 63631 <at> debbugs.gnu.org, 64036 <at> debbugs.gnu.org, 63647 <at> debbugs.gnu.org,
 64035 <at> debbugs.gnu.org, 63001 <at> debbugs.gnu.org, 54097 <at> debbugs.gnu.org,
 wolf@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 (-)

Hi Timo,

On Sat, 17 Jun 2023 at 17:12, "Timo Wilken" <guix@HIDDEN> wrote:

>> What would you suggest?  Simon?
>
> Here's a brief comparison between Simon's patches and mine -- Simon's seem to
> contain fixes for a couple more things than mine currently does:
>
> 1. Simon sorts available versions in an error message; this can presumably be
>    merged independently since it doesn't conflict with other patches.
>
> 2. Simon always prepends a "SUBDIR/" prefix to the tag if found, whereas I try
>    to find the plain "vX" tag first, then fall back to "SUBDIR/vX". Judging by
>    https://go.dev/ref/mod#vcs-version, Simon's approach seems more correct.
>    I'll change my implementation to match and try it out.
>
> 3. For detecting the `module-path-subdirectory' in Simon's patches: that's the
>    same approach I used initially, but I found I have to try `(substring
>    module-path (string-length import-prefix))' first (to handle e.g.
>    cloud.google.com/go/*). This is one of the things I haven't submitted
>    yet...

Sorry if I have missed some patches or overlooked something.  Do you
plan to send another patch series handling all?


Cheers,
simon




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

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


Received: (at 63631) by debbugs.gnu.org; 17 Jun 2023 15:13:55 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sat Jun 17 11:13:55 2023
Received: from localhost ([127.0.0.1]:52277 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1qAXcg-0000Ei-KO
	for submit <at> debbugs.gnu.org; Sat, 17 Jun 2023 11:13:55 -0400
Received: from mx2.mythic-beasts.com ([46.235.227.24]:35093)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <timo@HIDDEN>)
 id 1qAXcc-0000EB-Cs; Sat, 17 Jun 2023 11:13:52 -0400
DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=twilken.net
 ; s=mythic-beasts-k1; h=To:From:Subject:Date;
 bh=pLlAjfqsoe+3U3a73MQeHAaM/uSI+UrqGsrVeSKy1QM=; b=zI4HPa8dV46Hjnio0YDducSSwZ
 M29u2+iSJgjnWkngcWfT9SjYDe9ZLcVAF6i1Ndo75UO/OHkpFsGhXUIm1L8Fz/B5Y6Tg3zjvoVFmy
 d2/oqU7XiJvDOnOICpI3cx5UJO/54X/q5T9ko6ub0/iW9+KHQrST+7gIUbsLEFePPVSChBnKxzIj0
 6vl4AibdV6yP/bGdLIvjcfMXs4yCOg/+eCxfY8y0t1VVKYU/YVdRUrSzYPgPYv7nhW0qOEJZKfPL7
 6rRHFmKh51WiRPEO/oUchLlUi9MFuV/F8pPh+ZAd9D/fTIovUzVWesUglqbjMlC1UubueYwa/EPQC
 NdDeVMug==;
Received: by mailhub-hex-d.mythic-beasts.com with esmtpsa (TLS1.3) tls
 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2)
 (envelope-from <timo@HIDDEN>)
 id 1qAXcS-004VRH-W7; Sat, 17 Jun 2023 16:13:41 +0100
Content-Type: multipart/signed;
 boundary=dc3bfcd0ce40fc9a1a65ded3476be064f73442d113438739c89741eeba4a;
 micalg=pgp-sha256; protocol="application/pgp-signature"
Date: Sat, 17 Jun 2023 17:12:58 +0200
Subject: Re: bug#63631: [PATCH] import: go: Handle subpackage versioning
 correctly.
From: "Timo Wilken" <guix@HIDDEN>
To: =?utf-8?q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
Message-Id: <CTF06XBYWPT0.1MV6QA1B2OB98@HIDDEN>
X-Mailer: aerc 0.14.0
References: <6dd1de3dd4d968876fa55f5126056834c77b0244.1684703258.git.guix@HIDDEN>
 <87pm5xrbsg.fsf@HIDDEN>
In-Reply-To: <87pm5xrbsg.fsf@HIDDEN>
X-BlackCat-Spam-Score: 16
X-Spam-Status: No, score=1.6
X-Spam-Score: 0.1 (/)
X-Debbugs-Envelope-To: 63631
Cc: 63631 <at> debbugs.gnu.org, 64036 <at> debbugs.gnu.org,
 Simon Tournier <zimon.toutoune@HIDDEN>, 63647 <at> debbugs.gnu.org,
 64035 <at> debbugs.gnu.org, 63001 <at> debbugs.gnu.org, 54097 <at> debbugs.gnu.org,
 wolf@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: -0.9 (/)

--dc3bfcd0ce40fc9a1a65ded3476be064f73442d113438739c89741eeba4a
Mime-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain; charset=UTF-8

Hi Ludo', (hi everyone,)

On Wed Jun 14, 2023 at 11:09 PM CEST, Ludovic Court=C3=A8s wrote:
> Timo Wilken <guix@HIDDEN> skribis:
> > Here's a patch that fixes the reported issue (bug#54097) for me. I've o=
nly
> > tested this on the github.com/googleapis/google-cloud-go/compute packag=
e so
> > far, though it seems to work there. Perhaps others have more testcases?
> >
> > I don't know enough about Go tooling to use it, so I've just patched th=
e Guile
> > logic of the importer. (I don't write Go, I just want to package stuff =
written
> > in it.) In terms of performance, at least the repo contents are apparen=
tly
> > cached by the first `git-checkout-hash' call, even if it fails, so the =
second
> > call doesn't have to redownload them.

I've been testing my patch further this weekend, and I have a couple more
patches in the pipeline; I suppose I ought to clean those up and submit the=
m.

In particular, I've got fixes for the following queued up locally:

1. Finding the `module-path-subdir' needs another case for e.g.
   cloud.google.com/go/*.

2. My patch sometimes generates an unnecessary `go-version->git-ref' call.

3. Go versions need to be parsed from go.mod, since some packages require a
   newer Go compiler than our default. This I've got a patch for, but this =
Go
   version also ought to propagate up the dependency tree. I haven't found =
an
   easy way to do that, since the importer seems to generate top-level
   packages first, before descending the dep tree...

4. `fetch-module-meta-data' ought to ignore 4xx HTTP errors to follow the
   spec; gonum.org/v1/gonum specifically depends on this behaviour.

I've been trying to recursively import github.com/matrix-org/dendrite, whic=
h
has a particularly large and hairy dependency tree. While I can now import =
it
without crashes, I can't build it from the imported package definitions yet=
 --
mainly because of lots of dependency cycles in the generated packages, but
there may be more issues hidden beneath that.

Still, I can recommend it as a test of everyone's importer patches, since
it'll find a lot of edge cases in importing alone!

> What you propose looks similar to part of the work Simon Tournier
> submitted at <https://issues.guix.gnu.org/63647>.

It seems lots of people have been working on the same problem -- in additio=
n
to Simon's patches, I found a patch submitted by Elbek (issues 64035 & 6403=
6;
Cc'd). I also forgot about the issue I submitted months ago (63001)...

> What would you suggest?  Simon?

Here's a brief comparison between Simon's patches and mine -- Simon's seem =
to
contain fixes for a couple more things than mine currently does:

1. Simon sorts available versions in an error message; this can presumably =
be
   merged independently since it doesn't conflict with other patches.

2. Simon always prepends a "SUBDIR/" prefix to the tag if found, whereas I =
try
   to find the plain "vX" tag first, then fall back to "SUBDIR/vX". Judging=
 by
   https://go.dev/ref/mod#vcs-version, Simon's approach seems more correct.
   I'll change my implementation to match and try it out.

3. For detecting the `module-path-subdirectory' in Simon's patches: that's =
the
   same approach I used initially, but I found I have to try `(substring
   module-path (string-length import-prefix))' first (to handle e.g.
   cloud.google.com/go/*). This is one of the things I haven't submitted
   yet...

> Thanks for the patch, Timo!

Thanks for your work in sorting through all of this, Ludo'!

Cheers,
Timo

--dc3bfcd0ce40fc9a1a65ded3476be064f73442d113438739c89741eeba4a
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAABCAAdFiEEU+w8BoVog92SNVvCL8eFBGgfabAFAmSNzaUACgkQL8eFBGgf
abDEaA//Y6k/Uckhvq+wllES0TjACxVG+2bY2E/wLZNoQShXF5Tn3ZQ9o2HOU7Gr
p8er/t/JkPLYm9w2MidUtvTms6qxp8H/YIZ12gzZ+GP/eoKa/iiqt42+KZvLS/Is
B2JWEcaJLFYy0w9nuubeuQpgcWEmxyk7/zb++GovD0tfYgczII3N1Z5fhRmeAj0N
FbKqfkBocxruYvBfcI5KhMV6Q1TjCwuAH+j2iwNmsiSnm7NTKbJxfCyO9+p5UF9w
O/em01p9J+Cg6EEFunwoi1pjoEAkVZCRtgaiP1SMgapq74UKKagvsWqMoW+JHpDf
uuiaVn1sLuTt+u9KGamYqaCj1NRcCfN7SjPxS7oTM4hsytVDmUB/eIHD6t3HntCP
Ev43fJKJwLoybQV0ptajnJggEEaEY1cegQG683jsD0ycrToh4YEhLe5fQsGhaLMA
7MSLjjf0K73BoFyZi+wYyfDPYqXRQmpb3Z6cKJPlF3v4IF13UtSxP0yBRdz930aI
1b1Q5khLQzQBI0fvxMNcZGPeA2RjPyNsXE8pKn9zEkIunzX9VYN8az++EjX928Ox
mmgjEUsLWMPCSMwGcEoZye6R5wJUG34LEkoQTbySf+314hlELPuGcLCatFgZZbXq
1Hn1upt13XYRYVCX/SXIpBJL9gdNbi2sSg8FVm4Aq+sQQqZzAKs=
=fjJn
-----END PGP SIGNATURE-----

--dc3bfcd0ce40fc9a1a65ded3476be064f73442d113438739c89741eeba4a--




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

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


Received: (at 63631) by debbugs.gnu.org; 14 Jun 2023 21:09:47 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Wed Jun 14 17:09:47 2023
Received: from localhost ([127.0.0.1]:45550 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q9XkR-0004r1-6D
	for submit <at> debbugs.gnu.org; Wed, 14 Jun 2023 17:09:47 -0400
Received: from eggs.gnu.org ([209.51.188.92]:42742)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ludo@HIDDEN>)
 id 1q9XkO-0004qY-TB; Wed, 14 Jun 2023 17:09:45 -0400
Received: from fencepost.gnu.org ([2001:470:142:3::e])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ludo@HIDDEN>)
 id 1q9XkH-0004vN-UY; Wed, 14 Jun 2023 17:09:37 -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=dSdA3DtXQsPoFBK1nu9YIiRoX1fKSVyF3CAiTtvJ3Ag=; b=CSYzUy1OF3nQO6NYSypv
 HM4AwqDmPv33nptVZL1fr7W5XOseD1w1xaNRsa2+4oU7CPI9nCPyU0pAw2znjTXABMLXtxUh7KB8g
 3YvHHDk9o9kCOfw67oScqWX4OvzO6KbdbdBwgXuy2Y+n3MaIvUxg7t/cA5BPmD4GoA+JIiDKzpsZu
 FPXcPxB7WqzRONx0siODTV+zZXwuGnqo7sZudo+QUKX9PggRa2sbxDUfXm7w+bzXUNO61YVCZHVAw
 5WmT8xUC+nNmZf0jDcT4lKabL2lgwg68LEi3RSZL64iwnfgPI4Y4TE4pOZUU2RqYhmklchuOcvk/K
 j36GpFdqYdnThA==;
Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201] 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 1q9XkH-0001Z1-FY; Wed, 14 Jun 2023 17:09:37 -0400
From: =?utf-8?Q?Ludovic_Court=C3=A8s?= <ludo@HIDDEN>
To: Timo Wilken <guix@HIDDEN>
Subject: Re: bug#63631: [PATCH] import: go: Handle subpackage versioning
 correctly.
References: <6dd1de3dd4d968876fa55f5126056834c77b0244.1684703258.git.guix@HIDDEN>
Date: Wed, 14 Jun 2023 23:09:35 +0200
In-Reply-To: <6dd1de3dd4d968876fa55f5126056834c77b0244.1684703258.git.guix@HIDDEN>
 (Timo Wilken's message of "Sun, 21 May 2023 23:18:08 +0200")
Message-ID: <87pm5xrbsg.fsf@HIDDEN>
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.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: 63631
Cc: 63647 <at> debbugs.gnu.org, 63631 <at> debbugs.gnu.org,
 Simon Tournier <zimon.toutoune@HIDDEN>, 54097 <at> debbugs.gnu.org,
 wolf@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: -3.3 (---)

Hi Timo,

Timo Wilken <guix@HIDDEN> skribis:

> Some Go source repositories (notably the Google Cloud SDK) contain multip=
le
> submodules and use a `refs/tags/<submodule>/<version>' tagging scheme.
>
> Fixes <https://bugs.gnu.org/54097>.
>
> * guix/import/go.scm (vcs->origin): Accept a module-path-suffix.
> (go-module->guix-package): Use the new parameter.
> ---
> Here's a patch that fixes the reported issue (bug#54097) for me. I've only
> tested this on the github.com/googleapis/google-cloud-go/compute package =
so
> far, though it seems to work there. Perhaps others have more testcases?
>
> I don't know enough about Go tooling to use it, so I've just patched the =
Guile
> logic of the importer. (I don't write Go, I just want to package stuff wr=
itten
> in it.) In terms of performance, at least the repo contents are apparently
> cached by the first `git-checkout-hash' call, even if it fails, so the se=
cond
> call doesn't have to redownload them.

What you propose looks similar to part of the work Simon Tournier
submitted at <https://issues.guix.gnu.org/63647>.

What would you suggest?  Simon?

Thanks for the patch, Timo!

Ludo=E2=80=99.




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

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


Received: (at submit) by debbugs.gnu.org; 21 May 2023 21:54:46 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 21 17:54:45 2023
Received: from localhost ([127.0.0.1]:32959 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q0r0n-0002JO-6Y
	for submit <at> debbugs.gnu.org; Sun, 21 May 2023 17:54:45 -0400
Received: from lists.gnu.org ([209.51.188.17]:48934)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <ws@HIDDEN>) id 1q0r0l-0002J2-0I
 for submit <at> debbugs.gnu.org; Sun, 21 May 2023 17:54:43 -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 <ws@HIDDEN>) id 1q0r0k-0002hV-MF
 for guix-patches@HIDDEN; Sun, 21 May 2023 17:54:42 -0400
Received: from wolfsden.cz ([37.205.8.62])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <ws@HIDDEN>) id 1q0r0i-0007Hu-Ok
 for guix-patches@HIDDEN; Sun, 21 May 2023 17:54:42 -0400
Received: by wolfsden.cz (Postfix, from userid 104)
 id EBF9225A96C; Sun, 21 May 2023 21:54:34 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail;
 t=1684706074; bh=7jZSQ6kPl4uZBrcrCMjCjeDmk7WiY/3V+1MatjIbtig=;
 h=Date:From:To:Cc:Subject:References:In-Reply-To;
 b=Av1Y3shEepVs1TcQ3YMvzcRZ9vOZQTy4Ib2LT8Vg2a4XBAhSvAJEFaDo+Orga4nbf
 2hEzsxlKbC1UfDirH7Kry2VfN8NrqaFTlY8ujSbp/zhgJiqffKE2ZjLXubOKCVZCW9
 yGFYIKIhI5WpHiAUKNzpKnTTAQpSNycOYKdaZpb3Yao6LuGEi3virJkDDMK06idZMP
 7u0ZEN9fKycaIHnRXF6J2DPbYjMzka/yLyn7tW3wPHhguxImnyp3KU6nzFmEfZSxjv
 y1lhVWkPFEWFwN07HBJuLylQqsUEEey7pyKupxGk0WLFTOwVkBHlCWnxpdIqfM1LHB
 eEmH/7T8nUxR2vmdYrHMLvUnePRWF52NpQjFLoEGaF6FmIDYCX6ODnbR14T7SqDmIe
 ycsUjJK/9spVcP+iJrD3t6G9eJvlNr6VZrpnBUqOYG4VyqDtx1WP3x60zG/0kE7iiq
 Gptw8OBUVZgKVYJi7I/VhL7IP91Y+daMaRW/DI7K56ElPTf7X+mem+hmfbygp0Wg/P
 ipblJjidqrbYsmHRpNZ0o6TEWcNHuy+EnO/PHPVENVBmZKEu0t/c9LGbch7u9UC34e
 8e4Vxc6cN55W7y+VFV6v/2cfTen/aj7JlP7VHcmXw6cN+IlaqspX4qnZayrgKspmw7
 r3TwtDRDdtUzIzVuuTpWsv+c=
X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on wolfsden
X-Spam-Level: 
X-Spam-Status: No, score=-0.9 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED,
 DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,
 T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=no autolearn_force=no
 version=3.4.6
Received: from localhost (unknown [128.0.188.242])
 by wolfsden.cz (Postfix) with ESMTPSA id 0EFE125A9EB;
 Sun, 21 May 2023 21:54:34 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=wolfsden.cz; s=mail;
 t=1684706074; bh=7jZSQ6kPl4uZBrcrCMjCjeDmk7WiY/3V+1MatjIbtig=;
 h=Date:From:To:Cc:Subject:References:In-Reply-To;
 b=Av1Y3shEepVs1TcQ3YMvzcRZ9vOZQTy4Ib2LT8Vg2a4XBAhSvAJEFaDo+Orga4nbf
 2hEzsxlKbC1UfDirH7Kry2VfN8NrqaFTlY8ujSbp/zhgJiqffKE2ZjLXubOKCVZCW9
 yGFYIKIhI5WpHiAUKNzpKnTTAQpSNycOYKdaZpb3Yao6LuGEi3virJkDDMK06idZMP
 7u0ZEN9fKycaIHnRXF6J2DPbYjMzka/yLyn7tW3wPHhguxImnyp3KU6nzFmEfZSxjv
 y1lhVWkPFEWFwN07HBJuLylQqsUEEey7pyKupxGk0WLFTOwVkBHlCWnxpdIqfM1LHB
 eEmH/7T8nUxR2vmdYrHMLvUnePRWF52NpQjFLoEGaF6FmIDYCX6ODnbR14T7SqDmIe
 ycsUjJK/9spVcP+iJrD3t6G9eJvlNr6VZrpnBUqOYG4VyqDtx1WP3x60zG/0kE7iiq
 Gptw8OBUVZgKVYJi7I/VhL7IP91Y+daMaRW/DI7K56ElPTf7X+mem+hmfbygp0Wg/P
 ipblJjidqrbYsmHRpNZ0o6TEWcNHuy+EnO/PHPVENVBmZKEu0t/c9LGbch7u9UC34e
 8e4Vxc6cN55W7y+VFV6v/2cfTen/aj7JlP7VHcmXw6cN+IlaqspX4qnZayrgKspmw7
 r3TwtDRDdtUzIzVuuTpWsv+c=
Received: from localhost (localhost [local])
 by localhost (OpenSMTPD) with ESMTPA id b10323c4;
 Sun, 21 May 2023 21:54:33 +0000 (UTC)
Date: Sun, 21 May 2023 23:54:33 +0200
From: wolf <wolf@HIDDEN>
To: Timo Wilken <guix@HIDDEN>
Subject: Re: [PATCH] import: go: Handle subpackage versioning correctly.
Message-ID: <ZGqTGVrlJsLi9hxW@ws>
References: <6dd1de3dd4d968876fa55f5126056834c77b0244.1684703258.git.guix@HIDDEN>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha512;
 protocol="application/pgp-signature"; boundary="iw7hpULjExUreuIc"
Content-Disposition: inline
In-Reply-To: <6dd1de3dd4d968876fa55f5126056834c77b0244.1684703258.git.guix@HIDDEN>
Received-SPF: none client-ip=37.205.8.62; envelope-from=ws@HIDDEN;
 helo=wolfsden.cz
X-Spam_score_int: -17
X-Spam_score: -1.8
X-Spam_bar: -
X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1,
 DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
 SPF_HELO_PASS=-0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01,
 UNPARSEABLE_RELAY=0.001 autolearn=no autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -2.0 (--)
X-Debbugs-Envelope-To: submit
Cc: 54097 <at> debbugs.gnu.org, guix-patches@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: -3.0 (---)


--iw7hpULjExUreuIc
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Hi,

What a coincidence, this week I happened to take a look at this same issue =
(in
my case I wanted to build terraform).  I failed to get it properly working,=
 so
I'm happy someone else took a look at it as well.

On 2023-05-21 23:18:08 +0200, Timo Wilken wrote:
> Some Go source repositories (notably the Google Cloud SDK) contain multip=
le
> submodules and use a `refs/tags/<submodule>/<version>' tagging scheme.
>=20
> Fixes <https://bugs.gnu.org/54097>.
>=20
> * guix/import/go.scm (vcs->origin): Accept a module-path-suffix.
> (go-module->guix-package): Use the new parameter.
> ---
> Here's a patch that fixes the reported issue (bug#54097) for me. I've only
> tested this on the github.com/googleapis/google-cloud-go/compute package =
so
> far, though it seems to work there. Perhaps others have more testcases?

Please give the github.com/Azure/go-autorest/tracing@HIDDEN a go.  My code
failed on it, and (assuming I applied the patch correctly) your does as wel=
l.
Here are reproduction steps to make it easier for you (please tell me if I =
did
something wrong):

    $ echo '(use-modules (guix packages) (guix git-download) (guix build-sy=
stem go) ((guix licenses) #:prefix license:))' >/tmp/x.scm
    $ ./pre-inst-env guix import go -r github.com/Azure/go-autorest/tracing=
@v0.6.0 >>/tmp/x.scm
    $ echo go-github-com-azure-go-autorest-tracing >>/tmp/x.scm
    $ guix build -f /tmp/x.scm
    [..]
    starting phase `unpack'
    `/gnu/store/857z63cfgclsh6g52vj9xnm7iv97yz97-go-github-com-azure-go-aut=
orest-tracing-0.6.0-checkout/.gitignore' -> `/tmp/guix-build-go-github-com-=
azure-go-autorest-tracing-0.6.0.drv-0/src/github.com/Azure/go-autorest/.git=
ignore'
    error: in phase 'unpack': uncaught exception:
    system-error "copy-file" "~A" ("Permission denied") (13)=20
    phase `unpack' failed after 0.0 seconds
    [..]

I will not pretend to have a full grasp on how (guix build-system go) works,
however my debugging lead me to the observation that it tries to unpack two
dependencies into one file system tree overlayed on top of each other.  I t=
hink
the current way (GO111MODULE=3Doff) of building of golang packages does not=
 play
very well with well, go modules.

Either the build system needs to be smarter about unpacking dependencies (a=
nd
doing it in a correct order), or we should start using go modules for the b=
uilds
(it can still be down offline, just the dependencies are in different paths=
).
The second approach is what I wanted to explore, but did not get to it yet =
(and
likely will not for a month or two).

>=20
> I don't know enough about Go tooling to use it, so I've just patched the =
Guile
> logic of the importer. (I don't write Go, I just want to package stuff wr=
itten
> in it.) In terms of performance, at least the repo contents are apparently
> cached by the first `git-checkout-hash' call, even if it fails, so the se=
cond
> call doesn't have to redownload them.
>=20
>  guix/import/go.scm | 56 +++++++++++++++++++++++++++++++++++-----------
>  1 file changed, 43 insertions(+), 13 deletions(-)
>=20
> diff --git a/guix/import/go.scm b/guix/import/go.scm
> index 0357e6a1eb..652ac58b6f 100644
> --- a/guix/import/go.scm
> +++ b/guix/import/go.scm
> @@ -7,6 +7,7 @@
>  ;;; Copyright =A9 2021 Xinglu Chen <public@HIDDEN>
>  ;;; Copyright =A9 2021 Sarah Morgensen <iskarian@HIDDEN>
>  ;;; Copyright =A9 2021 Simon Tournier <zimon.toutoune@HIDDEN>
> +;;; Copyright =A9 2023 Timo Wilken <guix@HIDDEN>
>  ;;;
>  ;;; This file is part of GNU Guix.
>  ;;;
> @@ -89,6 +90,7 @@ (define-module (guix import go)
> =20
>  ;;; TODO list
>  ;;; - get correct hash in vcs->origin for Mercurial and Subversion
> +;;; - handle subdir/vX.Y versioning in vcs->origin for Mercurial and Sub=
version
> =20
>  ;;; Code:
> =20
> @@ -513,29 +515,54 @@ (define* (git-checkout-hash url reference algorithm)
>                                            `(tag-or-commit . ,reference))=
)))
>      (file-hash* checkout #:algorithm algorithm #:recursive? #true)))
> =20
> -(define (vcs->origin vcs-type vcs-repo-url version)
> +(define (vcs->origin vcs-type vcs-repo-url module-path-suffix version)
>    "Generate the `origin' block of a package depending on what type of so=
urce
>  control system is being used."
>    (case vcs-type
>      ((git)
> -     (let ((plain-version? (string=3D? version (go-version->git-ref vers=
ion)))
> -           (v-prefixed?    (string-prefix? "v" version)))
> +     (let ((v-prefixed? (string-prefix? "v" version))
> +           (path-prefixed? #f)
> +           (trimmed-path-suffix (string-trim-both module-path-suffix #\/=
))
> +           (checkout-hash (false-if-git-not-found
> +                           (git-checkout-hash
> +                            vcs-repo-url
> +                            (go-version->git-ref version)
> +                            (hash-algorithm sha256)))))
> +       ;; If `checkout-hash' is false, that must mean that a tag named a=
fter
> +       ;; the version doesn't exist.  Some repos that contain submodules=
 use a
> +       ;; <submodule>/<version> tagging scheme instead, so try that.
> +       (unless checkout-hash
> +         (when (string=3D? "" trimmed-path-suffix)
> +           ;; If this isn't a submodule, <submodule>/<version> tagging m=
akes no sense.
> +           ;; Tell the user we couldn't find the original version.
> +           (raise
> +            (formatted-message (G_ "could not find git reference '~a' in=
 repository '~a'")
> +                               (go-version->git-ref version) vcs-repo-ur=
l)))
> +         (set! path-prefixed? #t)
> +         (set! checkout-hash (git-checkout-hash
> +                              vcs-repo-url
> +                              (go-version->git-ref
> +                               (string-append trimmed-path-suffix "/" ve=
rsion))
> +                              (hash-algorithm sha256))))
>         `(origin
>            (method git-fetch)
>            (uri (git-reference
>                  (url ,vcs-repo-url)
> -                ;; This is done because the version field of the package,
> -                ;; which the generated quoted expression refers to, has =
been
> -                ;; stripped of any 'v' prefixed.
> -                (commit ,(if (and plain-version? v-prefixed?)
> -                             '(string-append "v" version)
> -                             '(go-version->git-ref version)))))
> +                ;; The 'v' is prepended again because the version field =
of
> +                ;; the package, which the generated quoted expression re=
fers
> +                ;; to, has been stripped of any 'v' prefixed.
> +                (commit (go-version->git-ref
> +                         ,(cond
> +                           (path-prefixed?
> +                            `(string-append
> +                              ,trimmed-path-suffix "/"
> +                              ,@(if v-prefixed? '("v" version) '(version=
))))
> +                           (v-prefixed? '(string-append "v" version))
> +                           (else 'version))))))
>            (file-name (git-file-name name version))
>            (sha256
>             (base32
> -            ,(bytevector->nix-base32-string
> -              (git-checkout-hash vcs-repo-url (go-version->git-ref versi=
on)
> -                                 (hash-algorithm sha256))))))))
> +            ,(bytevector->nix-base32-string checkout-hash))))))
>      ((hg)
>       `(origin
>          (method hg-fetch)
> @@ -614,6 +641,9 @@ (define* (go-module->guix-package module-path #:key
>            (match:prefix (string-match "([\\./]v[0-9]+)?$" module-path)))
>           (guix-name (go-module->guix-package-name module-path))
>           (root-module-path (module-path->repository-root module-path))
> +         (module-path-suffix  ; subdirectory inside the source repo
> +          (substring module-path-sans-suffix
> +                     (string-prefix-length root-module-path module-path-=
sans-suffix)))
>           ;; The VCS type and URL are not included in goproxy information=
=2E For
>           ;; this we need to fetch it from the official module page.
>           (meta-data (fetch-module-meta-data root-module-path))
> @@ -627,7 +657,7 @@ (define* (go-module->guix-package module-path #:key
>          (name ,guix-name)
>          (version ,(strip-v-prefix version*))
>          (source
> -         ,(vcs->origin vcs-type vcs-repo-url version*))
> +         ,(vcs->origin vcs-type vcs-repo-url module-path-suffix version*=
))
>          (build-system go-build-system)
>          (arguments
>           '(#:import-path ,module-path
>=20
> base-commit: e499cb2c12d7f1c6d2f004364c9cc7bdb7e38cd5
> --=20
> 2.40.1
>

I did not really take a look at the scheme code, I'm still Guix and Scheme
beginner, so I'm very much not up to the task of doing actual code review.
Nevertheless, I hope my mail helps at least a bit.

Have a nice day,
W.

--=20
There are only two hard things in Computer Science:
cache invalidation, naming things and off-by-one errors.

--iw7hpULjExUreuIc
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEt4NJs4wUfTYpiGikL7/ufbZ/wakFAmRqkxkACgkQL7/ufbZ/
wamucg//aKKPWvermh5Y9aM+7NGoKaq2DqtFlIO+A32wnJcZQupMRWzKyRzfnT77
CXIwMuKwz53Dr6OaB2HP3oiXjREkISg1PdHUBAJ4ziJX+SAywlZihqjlh5698e1K
m0izXVjx3IIMjLqEv6EMCgAKLRG/4HpdGmG7oTtsMN0KGHD2Kufo1Mz3lR0zYUqx
LDciOb10EV7XyJvjeYHUKtzz8EzF4NQO4+S0gCY6kN1PYjFEx9wy9s996W+i7ngY
EZWMZLL1ppbQtmcDzdqjgLebZ5+/P8ZjmuuELBmuBtCaUhtu3ViOSC7ieOkVkD+m
8OWW078xqHYDiTWc9Qz6K/+PsTQUJxFJRro3cHXzPV+Go9gGer921Vr0Ua4r1cCg
K0WIuTjS2wMjIOdsnqPfPVWGiks6zVe07fQFze38OtcbfadVJe2fxCiBXHeq5p7p
kwhZDrtcMrlBE0moNaFjPC061EtW4s9BrsLPy1NszeGp+gW12/NUyUeLv3BK3gbM
8DvAQo7QYGioIB2H0xPewMj4mArMoDhbFlZZ0cnhqGrd3snir3XXZu0Cw4hSJQBt
uPIvS4XsTmCKWV4c11mYKW4T78iFkP7IFHV1JiIcLYP1W5E2fCZhcHMoUB+VFvcF
lU2v6NhJzuQuPeMB/Ngj4Dey1IXrs5SbvFsISpPOboL3nRuRGgQ=
=zjKZ
-----END PGP SIGNATURE-----

--iw7hpULjExUreuIc--




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

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


Received: (at submit) by debbugs.gnu.org; 21 May 2023 21:19:44 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun May 21 17:19:44 2023
Received: from localhost ([127.0.0.1]:32932 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.84_2)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1q0qSt-0001H8-L6
	for submit <at> debbugs.gnu.org; Sun, 21 May 2023 17:19:44 -0400
Received: from lists.gnu.org ([209.51.188.17]:54220)
 by debbugs.gnu.org with esmtp (Exim 4.84_2)
 (envelope-from <guix@HIDDEN>) id 1q0qSs-0001H0-BJ
 for submit <at> debbugs.gnu.org; Sun, 21 May 2023 17:19:43 -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 <guix@HIDDEN>) id 1q0qSs-0004OJ-4y
 for guix-patches@HIDDEN; Sun, 21 May 2023 17:19:42 -0400
Received: from mx2.mythic-beasts.com ([2a00:1098:0:82:1000:0:2:1])
 by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)
 (Exim 4.90_1) (envelope-from <guix@HIDDEN>) id 1q0qSq-0000Kb-8d
 for guix-patches@HIDDEN; Sun, 21 May 2023 17:19:41 -0400
Received: by mailhub-hex-d.mythic-beasts.com with esmtpsa (TLS1.3) tls
 TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2)
 (envelope-from <guix@HIDDEN>)
 id 1q0qSo-00C6Wa-E8; Sun, 21 May 2023 22:19:38 +0100
From: Timo Wilken <guix@HIDDEN>
To: guix-patches@HIDDEN,
	54097 <at> debbugs.gnu.org
Subject: [PATCH] import: go: Handle subpackage versioning correctly.
Date: Sun, 21 May 2023 23:18:08 +0200
Message-Id: <6dd1de3dd4d968876fa55f5126056834c77b0244.1684703258.git.guix@HIDDEN>
X-Mailer: git-send-email 2.40.1
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
X-BlackCat-Spam-Score: 9
X-Spam-Status: No, score=0.9
Received-SPF: pass client-ip=2a00:1098:0:82:1000:0:2:1;
 envelope-from=guix@HIDDEN; helo=mx2.mythic-beasts.com
X-Spam_score_int: -41
X-Spam_score: -4.2
X-Spam_bar: ----
X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3,
 SPF_HELO_PASS=-0.001, SPF_PASS=-0.001,
 T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no
X-Spam_action: no action
X-Spam-Score: -1.3 (-)
X-Debbugs-Envelope-To: submit
Cc: wolf@HIDDEN, Timo Wilken <guix@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 (--)

Some Go source repositories (notably the Google Cloud SDK) contain multiple
submodules and use a `refs/tags/<submodule>/<version>' tagging scheme.

Fixes <https://bugs.gnu.org/54097>.

* guix/import/go.scm (vcs->origin): Accept a module-path-suffix.
(go-module->guix-package): Use the new parameter.
---
Here's a patch that fixes the reported issue (bug#54097) for me. I've only
tested this on the github.com/googleapis/google-cloud-go/compute package so
far, though it seems to work there. Perhaps others have more testcases?

I don't know enough about Go tooling to use it, so I've just patched the Guile
logic of the importer. (I don't write Go, I just want to package stuff written
in it.) In terms of performance, at least the repo contents are apparently
cached by the first `git-checkout-hash' call, even if it fails, so the second
call doesn't have to redownload them.

 guix/import/go.scm | 56 +++++++++++++++++++++++++++++++++++-----------
 1 file changed, 43 insertions(+), 13 deletions(-)

diff --git a/guix/import/go.scm b/guix/import/go.scm
index 0357e6a1eb..652ac58b6f 100644
--- a/guix/import/go.scm
+++ b/guix/import/go.scm
@@ -7,6 +7,7 @@
 ;;; Copyright © 2021 Xinglu Chen <public@HIDDEN>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@HIDDEN>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@HIDDEN>
+;;; Copyright © 2023 Timo Wilken <guix@HIDDEN>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -89,6 +90,7 @@ (define-module (guix import go)
 
 ;;; TODO list
 ;;; - get correct hash in vcs->origin for Mercurial and Subversion
+;;; - handle subdir/vX.Y versioning in vcs->origin for Mercurial and Subversion
 
 ;;; Code:
 
@@ -513,29 +515,54 @@ (define* (git-checkout-hash url reference algorithm)
                                           `(tag-or-commit . ,reference)))))
     (file-hash* checkout #:algorithm algorithm #:recursive? #true)))
 
-(define (vcs->origin vcs-type vcs-repo-url version)
+(define (vcs->origin vcs-type vcs-repo-url module-path-suffix version)
   "Generate the `origin' block of a package depending on what type of source
 control system is being used."
   (case vcs-type
     ((git)
-     (let ((plain-version? (string=? version (go-version->git-ref version)))
-           (v-prefixed?    (string-prefix? "v" version)))
+     (let ((v-prefixed? (string-prefix? "v" version))
+           (path-prefixed? #f)
+           (trimmed-path-suffix (string-trim-both module-path-suffix #\/))
+           (checkout-hash (false-if-git-not-found
+                           (git-checkout-hash
+                            vcs-repo-url
+                            (go-version->git-ref version)
+                            (hash-algorithm sha256)))))
+       ;; If `checkout-hash' is false, that must mean that a tag named after
+       ;; the version doesn't exist.  Some repos that contain submodules use a
+       ;; <submodule>/<version> tagging scheme instead, so try that.
+       (unless checkout-hash
+         (when (string=? "" trimmed-path-suffix)
+           ;; If this isn't a submodule, <submodule>/<version> tagging makes no sense.
+           ;; Tell the user we couldn't find the original version.
+           (raise
+            (formatted-message (G_ "could not find git reference '~a' in repository '~a'")
+                               (go-version->git-ref version) vcs-repo-url)))
+         (set! path-prefixed? #t)
+         (set! checkout-hash (git-checkout-hash
+                              vcs-repo-url
+                              (go-version->git-ref
+                               (string-append trimmed-path-suffix "/" version))
+                              (hash-algorithm sha256))))
        `(origin
           (method git-fetch)
           (uri (git-reference
                 (url ,vcs-repo-url)
-                ;; This is done because the version field of the package,
-                ;; which the generated quoted expression refers to, has been
-                ;; stripped of any 'v' prefixed.
-                (commit ,(if (and plain-version? v-prefixed?)
-                             '(string-append "v" version)
-                             '(go-version->git-ref version)))))
+                ;; The 'v' is prepended again because the version field of
+                ;; the package, which the generated quoted expression refers
+                ;; to, has been stripped of any 'v' prefixed.
+                (commit (go-version->git-ref
+                         ,(cond
+                           (path-prefixed?
+                            `(string-append
+                              ,trimmed-path-suffix "/"
+                              ,@(if v-prefixed? '("v" version) '(version))))
+                           (v-prefixed? '(string-append "v" version))
+                           (else 'version))))))
           (file-name (git-file-name name version))
           (sha256
            (base32
-            ,(bytevector->nix-base32-string
-              (git-checkout-hash vcs-repo-url (go-version->git-ref version)
-                                 (hash-algorithm sha256))))))))
+            ,(bytevector->nix-base32-string checkout-hash))))))
     ((hg)
      `(origin
         (method hg-fetch)
@@ -614,6 +641,9 @@ (define* (go-module->guix-package module-path #:key
           (match:prefix (string-match "([\\./]v[0-9]+)?$" module-path)))
          (guix-name (go-module->guix-package-name module-path))
          (root-module-path (module-path->repository-root module-path))
+         (module-path-suffix  ; subdirectory inside the source repo
+          (substring module-path-sans-suffix
+                     (string-prefix-length root-module-path module-path-sans-suffix)))
          ;; The VCS type and URL are not included in goproxy information. For
          ;; this we need to fetch it from the official module page.
          (meta-data (fetch-module-meta-data root-module-path))
@@ -627,7 +657,7 @@ (define* (go-module->guix-package module-path #:key
         (name ,guix-name)
         (version ,(strip-v-prefix version*))
         (source
-         ,(vcs->origin vcs-type vcs-repo-url version*))
+         ,(vcs->origin vcs-type vcs-repo-url module-path-suffix version*))
         (build-system go-build-system)
         (arguments
          '(#:import-path ,module-path

base-commit: e499cb2c12d7f1c6d2f004364c9cc7bdb7e38cd5
-- 
2.40.1





Acknowledgement sent to Timo Wilken <guix@HIDDEN>:
New bug report received and forwarded. Copy sent to guix-patches@HIDDEN. Full text available.
Report forwarded to guix-patches@HIDDEN:
bug#63631; 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: Tue, 17 Oct 2023 08:45:02 UTC

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