From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp10.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id qHb9MwOS42F2GAAAgWs5BA (envelope-from ) for ; Sun, 16 Jan 2022 04:33:23 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp10.migadu.com with LMTPS id UDtcLAOS42F+bQAAG6o9tA (envelope-from ) for ; Sun, 16 Jan 2022 04:33:23 +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 7023F37557 for ; Sun, 16 Jan 2022 04:33:23 +0100 (CET) Received: from localhost ([::1]:52146 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n8wID-00086I-44 for larch@yhetil.org; Sat, 15 Jan 2022 22:33:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56910) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n8wHu-000866-Vm for bug-guix@gnu.org; Sat, 15 Jan 2022 22:33:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:49384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1n8wHu-0003IL-8b for bug-guix@gnu.org; Sat, 15 Jan 2022 22:33:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1n8wHu-0008Cc-63 for bug-guix@gnu.org; Sat, 15 Jan 2022 22:33:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#52362: [PATCH v3] 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 03:33: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.164230393231460 (code B ref 52362); Sun, 16 Jan 2022 03:33:02 +0000 Received: (at 52362) by debbugs.gnu.org; 16 Jan 2022 03:32:12 +0000 Received: from localhost ([127.0.0.1]:42287 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8wH6-0008BM-9Y for submit@debbugs.gnu.org; Sat, 15 Jan 2022 22:32:12 -0500 Received: from singpolyma.net ([192.99.233.116]:50637) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1n8wH4-0008BE-H2 for 52362@debbugs.gnu.org; Sat, 15 Jan 2022 22:32:11 -0500 Received: by singpolyma.net (Postfix, from userid 1000) id 73017486170A; Sun, 16 Jan 2022 03:32:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=singpolyma.net; s=iweb; t=1642303929; bh=FSkLx1fN8s/nFB4UKO75BwD6oI/9agxrC6NEW+nRyR4=; h=From:To:Cc:Subject:Date:From; b=F04+O8qZH/IZz+sD9qh0cEHLfeG0h2kQKPl4zsGvjXcKF+OwA7MqckGcqYSX9CsJZ rbCInlmGA0WKvGS7dieEl8VngCV8/pOyCEtKc5xu6XZ81XTGy2IQAKUFx4t7/NbdSh yVOteN9jCd+r4nQvCAKJPNZckf97Yfh9hL3dXKVs= From: Stephen Paul Weber Date: Sat, 15 Jan 2022 22:32:08 -0500 Message-Id: <20220116033208.54370-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=1642304003; 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=TuBqobnbjcGPSQaZ5EEuVx64zjD+C5rNDfx2kJvWSTY=; b=lj2t2kB19riptMX3sts2SHghl9sLkw8iPKBJfDIzvXyCwbrNaHjhpIGk6Esl51uYhPDwJT YdVOQSaSUOiiISKoil+6MtUTOc7czNczgDjUXKTJcaCEGJ2hsnxDk5a6kOwD+62cSZkLyF /JWbbpmamgjymQ7Ow9hVCS5clbmYVr6g7h13dSadN6S8wxXgTyY9gIgBDAl9dM0BgEsiQt 7xVTqKcNJy+271YpkJ3+4WkSl79kvdvFgueiLOWwv2RKQ44ws2YjiLVDP4Cj2XUSt6AbM6 C+1T4akT9g/JLd7aRRmssf6y2D+Y5u9XsaIrV+0mP7kX7DCzJeY187PA07rV5A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1642304003; a=rsa-sha256; cv=none; b=DaUn1wJFhYu1qBJ2gIE1L9zgOl0Z9Lketugii9Ta89VvRIny6jAQ+UyabYgvuw0+Eq7jLD +zzZ5BuGppf0r3uJ61Oc0nsWNOuvMFGz0Y7dkEiiaQGsmPVK/k8dsz5ruAId8IAugw/hqu Ud0UVM9HZkfcMAsKEgG8GgBhLVK1MRY3o0mRt9G/XIc5cTkCZWJT/ZjthgTP8KszacAV8j QBkT10L1ks+jONpvYnGvYcD5PxXSD8IocN6dVewvUUzFFstmSEeoYqwgI932T+68TJtOOF sZwEmkYszti1wfHFkD97aldM0OVmuAWYFtOUIDS61/hjkIZKsGQjwAf1RjrtGg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=singpolyma.net header.s=iweb header.b=F04+O8qZ; 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=F04+O8qZ; 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: 7023F37557 X-Spam-Score: -0.52 X-Migadu-Scanner: scn1.migadu.com X-TUID: qLmmUZ0vnpJE 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 | 36 +++++++++++++++++++++++++----------- 1 file changed, 25 insertions(+), 11 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index d00c13475a..f2ea9dbbae 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,12 +627,17 @@ 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)) ;; 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)) + (module-path-subdirectory + (substring module-path-sans-suffix + (string-length (module-meta-import-prefix meta-data)))) (vcs-type (module-meta-vcs meta-data)) (vcs-repo-url (module-meta-data-repo-url meta-data goproxy)) (synopsis (go-package-synopsis module-path)) @@ -634,7 +648,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