From patchwork Fri Nov 15 21:11:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?J=C3=B8rgen_Kvalsvik?= X-Patchwork-Id: 70425 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 904EA27BBEA; Fri, 15 Nov 2024 21:12:37 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_VALIDITY_CERTIFIED,RCVD_IN_VALIDITY_RPBL,RCVD_IN_VALIDITY_SAFE, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id E331027BBE2 for ; Fri, 15 Nov 2024 21:12:36 +0000 (GMT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tC3bp-0002Dy-0R; Fri, 15 Nov 2024 16:12:05 -0500 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 1tC3bn-0002Df-Ae for guix-patches@gnu.org; Fri, 15 Nov 2024 16:12:03 -0500 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 1tC3bn-00069Q-1z for guix-patches@gnu.org; Fri, 15 Nov 2024 16:12:03 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debbugs.gnu.org; s=debbugs-gnu-org; h=MIME-Version:References:In-Reply-To:Date:From:To:Subject; bh=YaH4k+uq5KG+RAgyIBwT+Nc4HUwgRX/GbVCcqH+6cO4=; b=NwQgVFZU+t/XSccXu04oJC1Qj5uiJTqyxRFsXHdEJuQxzTQtau8W0Y1snEGf3+D7LqyPKPfiAieZRmzmgMDUBsbkWqj2tENaU/OntvA3MF6WI0SqE7B9CEScL6XC+CL51heI8TvqRsSK5wqEd2LzB8jWwGL+R8wZqxRBLzbofVCpYnoQudR0OB+kR7hecXBp5tVDR14YOjfLKb2orEjfbzaqyNpQXZVOg5ikFxXcHJZBUyccusTxK/q3Xq1yzy6/2GNt9O/2y6ekGt5cWe8R6kVW2kYASZhzaPqwZXHFld2k62DnnDsbBSIGZFM3H3z5IbqcFAArigXkKg7+Y5AgNA==; Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1tC3bm-0000G7-S2 for guix-patches@gnu.org; Fri, 15 Nov 2024 16:12:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#74371] [PATCH 3/4] guix: Add module aware 'guix import go' Resent-From: =?utf-8?q?J=C3=B8rgen?= Kvalsvik Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 15 Nov 2024 21:12:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 74371 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 74371@debbugs.gnu.org Cc: =?utf-8?q?J=C3=B8rgen?= Kvalsvik X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.1731705104912 (code B ref -1); Fri, 15 Nov 2024 21:12:02 +0000 Received: (at submit) by debbugs.gnu.org; 15 Nov 2024 21:11:44 +0000 Received: from localhost ([127.0.0.1]:51074 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tC3bS-0000EP-O3 for submit@debbugs.gnu.org; Fri, 15 Nov 2024 16:11:43 -0500 Received: from lists.gnu.org ([209.51.188.17]:48698) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1tC3bQ-0000Du-7I for submit@debbugs.gnu.org; Fri, 15 Nov 2024 16:11:40 -0500 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 1tC3bN-0002Bq-Sr for guix-patches@gnu.org; Fri, 15 Nov 2024 16:11:37 -0500 Received: from mx.kolabnow.com ([212.103.80.155]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tC3bD-00066X-V5 for guix-patches@gnu.org; Fri, 15 Nov 2024 16:11:32 -0500 Received: from localhost (unknown [127.0.0.1]) by mx.kolabnow.com (Postfix) with ESMTP id 4F5653069A98 for ; Fri, 15 Nov 2024 22:11:19 +0100 (CET) Authentication-Results: ext-mx-out013.mykolab.com (amavis); dkim=pass (2048-bit key) reason="pass (just generated, assumed good)" header.d=kolabnow.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:date:subject:subject:from:from:received :received:received; s=dkim20240523; t=1731705075; x=1733519476; bh=YaH4k+uq5KG+RAgyIBwT+Nc4HUwgRX/GbVCcqH+6cO4=; b=nwUM5Gb+Q3O2 OFgQNulbdmbi5Kt7KXG3Tftna1cLWmx7AN0+AujHRKl+qmMH9wZG3Lv3rK2JPqAy jn2FMLYK1EdZUEDlDQve2rDGD4Y9co4lgRlu+T/61oCnoIZeob7mPG45yFLiE/8g Y1tWiJPJ2AQwHKUjZ6LMAozTwy2cOA12OSj1bPvlFfh2yla4DvZQLPk8/WkdRgMt MD4aAKe2bgsr7QV+yHiVvh85Z5YNSoAHp2z+A84T54rYGVAbpJOEqEjKgGxKFSxE EVrHv7BWTM8DhbK5/V57hz1jMNB7LWp4V9ZALpIiZ1tPK3VgBVV4BYeVPsSfJvvf 0GNnZbxIHA== X-Virus-Scanned: amavis at mykolab.com Received: from mx.kolabnow.com ([127.0.0.1]) by localhost (ext-mx-out013.mykolab.com [127.0.0.1]) (amavis, port 10024) with ESMTP id MNYmo643scnZ for ; Fri, 15 Nov 2024 22:11:15 +0100 (CET) Received: from int-mx009.mykolab.com (unknown [10.9.13.9]) by mx.kolabnow.com (Postfix) with ESMTPS id BD0103069A9C for ; Fri, 15 Nov 2024 22:11:15 +0100 (CET) Received: from ext-subm010.mykolab.com (unknown [10.9.6.10]) by int-mx009.mykolab.com (Postfix) with ESMTPS id 762582097185 for ; Fri, 15 Nov 2024 22:11:15 +0100 (CET) From: =?utf-8?q?J=C3=B8rgen?= Kvalsvik Date: Fri, 15 Nov 2024 22:11:05 +0100 Message-Id: <20241115211106.2759121-4-j@lambda.is> In-Reply-To: <20241115211106.2759121-1-j@lambda.is> References: <20241115211106.2759121-1-j@lambda.is> MIME-Version: 1.0 Received-SPF: pass client-ip=212.103.80.155; envelope-from=j@lambda.is; helo=mx.kolabnow.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_FILL_THIS_FORM_SHORT=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches Emit module aware package go packages. It does not compute the hash of the full module yet, and only supports git, but goes a long way towards making it easy to package new go programs using the module-aware build system. * guix/import/go.scm (go-module->guix-package): Add go.mod awareness * guix/scripts/import/go.scm (show-help): Document -m, --mod (%options): Accept them. Change-Id: I4efd7260d69276279940e21698ecc7eb57232a67 --- guix/import/go.scm | 88 ++++++++++++++++++++++++-------------- guix/scripts/import/go.scm | 6 +++ 2 files changed, 61 insertions(+), 33 deletions(-) diff --git a/guix/import/go.scm b/guix/import/go.scm index dd9298808d..967aa54d58 100644 --- a/guix/import/go.scm +++ b/guix/import/go.scm @@ -615,6 +615,7 @@ (define (validate-version version available-versions module-path) (define* (go-module->guix-package module-path #:key (goproxy "https://proxy.golang.org") version + go-mod? pin-versions? #:allow-other-keys) "Return the package S-expression corresponding to MODULE-PATH at VERSION, a Go package. @@ -641,43 +642,62 @@ (define* (go-module->guix-package module-path #:key (meta-data (fetch-module-meta-data root-module-path)) (vcs-type (module-meta-vcs meta-data)) (vcs-repo-url (module-meta-data-repo-url meta-data goproxy)) + (home-page (format #f "https://~a" root-module-path)) (synopsis (go-package-synopsis module-path)) - (description (go-package-description module-path)) - (licenses (go-package-licenses module-path))) - (values - `(package - (name ,guix-name) - (version ,(strip-v-prefix version*)) - (source - ,(vcs->origin vcs-type vcs-repo-url version*)) - (build-system go-build-system) - (arguments - (list ,@(if (version>? min-go-version (package-version (go-package))) - `(#:go ,(string->number min-go-version)) - '()) - #:import-path ,module-path - ,@(if (string=? module-path-sans-suffix root-module-path) - '() - `(#:unpack-path ,root-module-path)))) - ,@(maybe-propagated-inputs - (map (match-lambda - ((name version) - (go-module->guix-package-name name (strip-v-prefix version))) - (name - (go-module->guix-package-name name))) - dependencies)) - (home-page ,(format #f "https://~a" root-module-path)) - (synopsis ,synopsis) - (description ,(and=> description beautify-description)) - (license ,(match (list->licenses licenses) + (description (and=> (go-package-description module-path) beautify-description)) + (licenses (go-package-licenses module-path)) + (license (match (list->licenses licenses) (() #f) ;unknown license - ((license) ;a single license - license) + ((license) license) ;a single license ((license ...) ;a list of licenses `(list ,@license))))) - (if pin-versions? - dependencies+versions - dependencies)))) + (if go-mod? + (values + `(package + (name ,guix-name) + (version ,(strip-v-prefix version*)) + (source + (origin + (method go-mod-fetch) + (uri (go-mod-reference + (source ,(vcs->origin vcs-type vcs-repo-url version*)))) + (sha256 + (base32 + ;; FIXME: fetch & compute checksum + "0000000000000000000000000000000000000000000000000000")))) + (build-system go-mod-build-system) + (home-page ,home-page) + (synopsis ,synopsis) + (description ,description) + (license ,license))) + (values + `(package + (name ,guix-name) + (version ,(strip-v-prefix version*)) + (source ,(vcs->origin vcs-type vcs-repo-url version*)) + (build-system go-build-system) + (arguments + (list ,@(if (version>? min-go-version (package-version (go-package))) + `(#:go ,(string->number min-go-version)) + '()) + #:import-path ,module-path + ,@(if (string=? module-path-sans-suffix root-module-path) + '() + `(#:unpack-path ,root-module-path)))) + ,@(maybe-propagated-inputs + (map (match-lambda + ((name version) + (go-module->guix-package-name name (strip-v-prefix version))) + (name + (go-module->guix-package-name name))) + dependencies)) + (home-page ,home-page) + (synopsis ,synopsis) + (description ,description) + (license ,license) + (if pin-versions? + dependencies+versions + dependencies)))))) (define go-module->guix-package* (lambda args @@ -699,6 +719,7 @@ (define go-module->guix-package* (define* (go-module-recursive-import package-name #:key (goproxy "https://proxy.golang.org") version + go-mod? pin-versions?) (recursive-import @@ -709,6 +730,7 @@ (define* (go-module-recursive-import package-name (receive (package-sexp dependencies) (go-module->guix-package* name #:goproxy goproxy #:version version + #:go-mod? go-mod? #:pin-versions? pin-versions?) (values package-sexp dependencies)))) #:guix-name go-module->guix-package-name diff --git a/guix/scripts/import/go.scm b/guix/scripts/import/go.scm index b90c6ac72f..a12c3a9b2f 100644 --- a/guix/scripts/import/go.scm +++ b/guix/scripts/import/go.scm @@ -50,6 +50,8 @@ (define (show-help) (display (G_ " -h, --help display this help and exit")) (display (G_ " + -m, --mod generate go-module based packages")) + (display (G_ " -r, --recursive generate package expressions for all Go modules that are not yet in Guix")) (display (G_ " @@ -65,6 +67,9 @@ (define %options (lambda args (show-help) (exit 0))) + (option '(#\m "mod") #f #f + (lambda (opt name arg result) + (alist-cons 'go-mod? #t result))) (option '(#\r "recursive") #f #f (lambda (opt name arg result) (alist-cons 'recursive #t result))) @@ -106,6 +111,7 @@ (define (parse-options) (let ((arguments (list name #:goproxy (assoc-ref opts 'goproxy) #:version version + #:go-mod? (assoc-ref opts 'go-mod?) #:pin-versions? (assoc-ref opts 'pin-versions?)))) (if (assoc-ref opts 'recursive)