From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id gJR+NQ4n4mFD/QAAgWs5BA (envelope-from ) for ; Sat, 15 Jan 2022 02:44:46 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id kG4jLg4n4mGVmgAAG6o9tA (envelope-from ) for ; Sat, 15 Jan 2022 02:44:46 +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 6DEBA24568 for ; Sat, 15 Jan 2022 02:44:46 +0100 (CET) Received: from localhost ([::1]:55862 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8Y7Y-0007n8-CB for larch@yhetil.org; Fri, 14 Jan 2022 20:44:45 -0500 Received: from eggs.gnu.org ([209.51.188.92]:41440) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8Y6u-0007lN-Sw for bug-guix@gnu.org; Fri, 14 Jan 2022 20:44:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:45743) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8Y6s-0007Hq-BA for bug-guix@gnu.org; Fri, 14 Jan 2022 20:44:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8Y6s-0000k5-AW for bug-guix@gnu.org; Fri, 14 Jan 2022 20:44:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#52362: [PATCH] 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: Sat, 15 Jan 2022 01:44:02 +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.16422110232801 (code B ref 52362); Sat, 15 Jan 2022 01:44:02 +0000 Received: (at 52362) by debbugs.gnu.org; 15 Jan 2022 01:43:43 +0000 Received: from localhost ([127.0.0.1]:38639 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8Y6Y-0000j6-K2 for submit@debbugs.gnu.org; Fri, 14 Jan 2022 20:43:42 -0500 Received: from singpolyma.net ([192.99.233.116]:39453) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8Y6V-0000iy-Ry for 52362@debbugs.gnu.org; Fri, 14 Jan 2022 20:43:41 -0500 Received: by singpolyma.net (Postfix, from userid 1000) id A2A024861709; Sat, 15 Jan 2022 01:43:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=singpolyma.net; s=iweb; t=1642211018; bh=syFT3xXKEcqHmstrcM0dD1epJk6NKVWS4g9VfDQc61o=; h=From:To:Cc:Subject:Date:From; b=ebBl/jQDvcA5SfIhGup1xBaSbAr9XuJAltGJqyxETUmx02Ig9lBY9GsGsbMknPVv3 +HjmUFDfMibtTfsL/BzYscekrJbsoei0ZPOdkLxy/BVM8Zxl+huxbtfIRUkDmTrqtE KmtM6kF5KBXCge03ySZrK13chkcv8TDL2x9ck1YY= From: Stephen Paul Weber Date: Fri, 14 Jan 2022 20:43:33 -0500 Message-Id: <20220115014333.26372-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=1642211086; 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=gh7tL2E8dqDc0GsOwso13LAYPxtxCMVnMzt6I58rte8=; b=MMSJBx4lNeR1pSgqN2FmoXapIzn4NXf5XLY4+wMeTZIDV3PNgYuKaOz58kIiBxZZatZrfS 5ZdFoMWaRdo/6qbXL7g9TvZaQmkuJJS2p3WxhX94QfRgVKpgvq3zG8tA5WTfLNkseO/pw9 a6r9VooCVYa+m25QXDJwPanSVL3CeUONAmqkx5VGLi870ZdHQO1mxogNFPVJLGLdI0g2H+ Ej4p9hoJ7Tfz0+BPcLnnf/+WWy2zvoDGyr3dWOOpA5/wvIOBeTbg6EUKejHys3cNpMF61F nrux7bBbZz6ja920lfTsMxDqt/zqokG5ZX9HcZr78lucIGbtTKJHe/mzy1LLGg== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642211086; a=rsa-sha256; cv=none; b=QXx+qeVjBQywa863v61XVwOFP/efwm+4ruGxCOlbeCvic/ZdXCUPFOdW89SbydHWLq61cH i+AdtryJzmKhsxehhZX0p29yHFaWjQ5SfiFNurvZhH/TAioMpHdjginFORvsC2ZTO8tTGW TjoOsW7QwIQwZPur+t5FLsJzNeUhVqbPGLAGPB0dA9BS81ccFvx370C1TskwhpF0f89jZQ Ex4zX/wCF4Kjym59OpzMTyeXou6dYmoCWNcmlVrX+KU2O8Hl/AgOVaOqpy/xJ4TII0z1DB xvw3aGUW12GBB6H+ZkDJnyQ8axEWDieXM1OKOJR5JqnNL8s230ZSlvP/JtMHOg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=singpolyma.net header.s=iweb header.b="ebBl/jQD"; 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: -1.03 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=singpolyma.net header.s=iweb header.b="ebBl/jQD"; 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: 6DEBA24568 X-Spam-Score: -1.03 X-Migadu-Scanner: scn0.migadu.com X-TUID: mNxHlghrLtTH 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-name): New variable. (vcs->origin): New argument module-path-subdirectory. --- guix/import/go.scm | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index d00c13475a..6fae1994b8 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -521,28 +521,30 @@ 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-name version subdirectory) + (if (string=? subdirectory "") + version + (string-append (substring subdirectory 1) "/" version))) + +(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 ((git-commit (if (string=? version (go-version->git-ref version)) + (version+subdirectory->tag-name + version module-path-subdirectory) + (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) - '(go-version->git-ref version))))) + (commit ,git-commit))) (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 @@ -621,6 +623,8 @@ When VERSION is unspecified, the latest version available is used." (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-subdirectory + (substring module-path (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 +638,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