From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id PT2UM4eJ42G7gQEAgWs5BA (envelope-from ) for ; Sun, 16 Jan 2022 03:57:11 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id QF4OMIeJ42EfDgEA9RJhRA (envelope-from ) for ; Sun, 16 Jan 2022 03:57:11 +0100 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 D7EB910B25 for ; Sun, 16 Jan 2022 03:57:10 +0100 (CET) Received: from localhost ([::1]:34086 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8vjC-0002c2-1E for larch@yhetil.org; Sat, 15 Jan 2022 21:57:10 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52554) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8vj4-0002bu-2D for bug-guix@gnu.org; Sat, 15 Jan 2022 21:57:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49373) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8vj3-00025d-PM for bug-guix@gnu.org; Sat, 15 Jan 2022 21:57:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8vj3-0007GK-Ls for bug-guix@gnu.org; Sat, 15 Jan 2022 21:57:01 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#52362: [PATCH v2] guix: import: go: Use correct tag for go module in subdirectory. References: In-Reply-To: Resent-From: Stephen Paul Weber Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Sun, 16 Jan 2022 02:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 52362 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 52362@debbugs.gnu.org Received: via spool by 52362-submit@debbugs.gnu.org id=B52362.164230180227884 (code B ref 52362); Sun, 16 Jan 2022 02:57:01 +0000 Received: (at 52362) by debbugs.gnu.org; 16 Jan 2022 02:56:42 +0000 Received: from localhost ([127.0.0.1]:42275 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8vij-0007Fe-Tc for submit@debbugs.gnu.org; Sat, 15 Jan 2022 21:56:42 -0500 Received: from singpolyma.net ([192.99.233.116]:45363) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8vii-0007FV-3I for 52362@debbugs.gnu.org; Sat, 15 Jan 2022 21:56:40 -0500 Received: by singpolyma.net (Postfix, from userid 1000) id D6C89486170A; Sun, 16 Jan 2022 02:56:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=singpolyma.net; s=iweb; t=1642301798; bh=LZ8UkRluAuqBnIAOet0pK2H0Lz4kf10mvwP9Sma2iuU=; h=From:To:Cc:Subject:Date:From; b=HL019qqmRC9qtZkcH0BfO8gzcF59cSHlEAtykTA9vk780NNGRiRqEAkdZMG5xxYoE 4qVLbkm9M0n6vojp0kw8SW3XDgi4uJzpOzrhgNRD+HPsmrLYbSF+aseYCMqMgHhD9j +GuqyAb/UmRfRdNFQSMxt5FE5E+ZtfbqrB08T0uY= From: Stephen Paul Weber Date: Sat, 15 Jan 2022 21:56:34 -0500 Message-Id: <20220116025634.43833-1-singpolyma@singpolyma.net> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Stephen Paul Weber Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: "bug-Guix" X-Migadu-Flow: FLOW_IN X-Migadu-Country: US ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1642301831; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: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=GBV6jrCtMGcNt2Psb24slILJG5jgudv6TuuFhL4IiL0=; b=e70VBpiJyscy7CIqONvOPEs3n6S7bS4U8dPG4Lu5kr31upxNt68kHWELXbNWhLFVstkMO/ Ggq3ummALzYBuZTyFZxB4NTMdvbcN4p6cyc1xinyZUsBUELvk53G9EZhJT4H3MF3zlG+Fb Y5YLQtWzy/MNFgADaNxizjTlZxtjthM7L89yXX77kDfAo94To6wpBsiSswSPB3933Z0I57 5BSH1O+78LEdGjSlVTLfX3+5Nn8JyysuKJ2BXufp64INuKc5GJqpnTaNSiip9avqo4lolk ru/6tiykkDCaqX9v7H1eq6xDmG9qhRGSn9tAl9ImkIH7LYytvBjY57eZ1zxqAg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642301831; a=rsa-sha256; cv=none; b=UZs0bgBMTCO3oied9y4ro3EBXfEK+aBBbP8bDMpAzT5+jTTne8TMahbUiFMEu0DKaoQKa3 TulW1ZScxX9BCm4gRIe77xWWs6hgk4D1HrO2wzr3ODIl7Xcvumsr67a9T8Tz4KOvF8xR1p k6RnvKrZjWOm+R9nLEPmoEDF8xUe/GcjK995ZRzxIQAzzBd3tXFE3pjH2XWpHrRQwEx7Wo Rbv4Gc84p1NzL7CrzL8ROlCKf/E7mXhQp7GT+WIZIUhefRw6GGjZXBKHqIvGduwZ6Inu0T MgtIqW4BMMxC1J5OAlcYoeVP+wqwio76MlGxs7yvCIpJb/oRYYUDiJmhPmQGUQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=singpolyma.net header.s=iweb header.b=HL019qqm; dmarc=fail reason="SPF not aligned (strict)" header.from=singpolyma.net (policy=none); 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" X-Migadu-Spam-Score: -0.52 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=singpolyma.net header.s=iweb header.b=HL019qqm; dmarc=fail reason="SPF not aligned (strict)" header.from=singpolyma.net (policy=none); 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" X-Migadu-Queue-Id: D7EB910B25 X-Spam-Score: -0.52 X-Migadu-Scanner: scn1.migadu.com X-TUID: YUVA5WTpWgA4 https://go.dev/ref/mod says a module in a subdirectory has a tag prefixed with the subdirectory. * guix/import/go.scm (version+subdirectory->tag-prefix): New variable. (vcs->origin): New argument module-path-subdirectory. --- guix/import/go.scm | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index d00c13475a..b6f8686c0d 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -521,28 +521,37 @@ tag." `(tag-or-commit . ,reference))))) (file-hash* checkout #:algorithm algorithm #:recursive? #true))) -(define (vcs->origin vcs-type vcs-repo-url version) +(define (version+subdirectory->tag-prefix subdirectory) + (if (string=? subdirectory "") + "" + (string-append (substring subdirectory 1) "/"))) + +(define (vcs->origin vcs-type vcs-repo-url module-path-subdirectory 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* ((plain-version? (string=? version (go-version->git-ref version))) + (v-prefixed? (string-prefix? "v" version)) + (tag-prefix (version+subdirectory->tag-prefix + module-path-subdirectory)) + (git-commit (if plain-version? + (string-append tag-prefix version) + (go-version->git-ref version)))) `(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) + (if (string=? module-path-subdirectory "") + '(string-append "v" version) + `(string-append ,tag-prefix "v" version)) '(go-version->git-ref 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) + (git-checkout-hash vcs-repo-url git-commit (hash-algorithm sha256)))))))) ((hg) `(origin @@ -618,9 +627,13 @@ When VERSION is unspecified, the latest version available is used." dependencies+versions (map car dependencies+versions))) (module-path-sans-suffix - (match:prefix (string-match "([\\./]v[0-9]+)?$" module-path))) + (if (string-prefix? "gopkg.in" module-path) + module-path + (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)) + (root-module-path (module-path->repository-root module-path-sans-suffix)) + (module-path-subdirectory + (substring module-path-sans-suffix (string-length root-module-path))) ;; 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)) @@ -634,7 +647,7 @@ When VERSION is unspecified, the latest version available is used." (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-subdirectory version*)) (build-system go-build-system) (arguments '(#:import-path ,module-path -- 2.30.2