From patchwork Fri Aug 27 15:13:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Marius Bakke X-Patchwork-Id: 32335 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 609C227BBE3; Fri, 27 Aug 2021 16:16:42 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id D0D0327BBE1 for ; Fri, 27 Aug 2021 16:16:41 +0100 (BST) Received: from localhost ([::1]:41248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJday-0000Ws-Vp for patchwork@mira.cbaines.net; Fri, 27 Aug 2021 11:16:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:55432) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJdYQ-0006v2-RH for guix-patches@gnu.org; Fri, 27 Aug 2021 11:14:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41159) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mJdYQ-0007yQ-JX for guix-patches@gnu.org; Fri, 27 Aug 2021 11:14:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mJdYQ-00073o-Fm for guix-patches@gnu.org; Fri, 27 Aug 2021 11:14:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50227] [PATCH 1/3] build-system/go: Use a native-search-path for GOPATH. References: <20210827151052.12611-1-marius@gnu.org> In-Reply-To: <20210827151052.12611-1-marius@gnu.org> Resent-From: Marius Bakke Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 27 Aug 2021 15:14:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50227 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50227@debbugs.gnu.org Received: via spool by 50227-submit@debbugs.gnu.org id=B50227.163007722727092 (code B ref 50227); Fri, 27 Aug 2021 15:14:02 +0000 Received: (at 50227) by debbugs.gnu.org; 27 Aug 2021 15:13:47 +0000 Received: from localhost ([127.0.0.1]:52699 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdY6-00072i-Ms for submit@debbugs.gnu.org; Fri, 27 Aug 2021 11:13:47 -0400 Received: from eggs.gnu.org ([209.51.188.92]:39196) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mJdY1-00072P-Ay for 50227@debbugs.gnu.org; Fri, 27 Aug 2021 11:13:41 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:50744) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mJdXw-0007do-6N for 50227@debbugs.gnu.org; Fri, 27 Aug 2021 11:13:32 -0400 Received: from host-37-191-231-185.lynet.no ([37.191.231.185]:38002 helo=localhost) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mJdXv-00023J-Sh for 50227@debbugs.gnu.org; Fri, 27 Aug 2021 11:13:32 -0400 From: Marius Bakke Date: Fri, 27 Aug 2021 17:13:28 +0200 Message-Id: <20210827151330.13112-1-marius@gnu.org> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 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" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/golang.scm (go-1.14)[native-search-paths]: New field. * guix/build/go-build-system.scm (setup-go-environment): Make the working directory the first entry on GOPATH instead of creating a union. (unpack, install): Adjust accordingly. (go-package?, go-inputs): Remove variables. --- gnu/packages/golang.scm | 4 ++++ guix/build/go-build-system.scm | 37 ++++------------------------------ 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm index 72579d6bd2..3a5c6ddc3f 100644 --- a/gnu/packages/golang.scm +++ b/gnu/packages/golang.scm @@ -257,6 +257,10 @@ in the style of communicating sequential processes (@dfn{CSP}).") (sha256 (base32 "1crh90qkvhlx23hwsi4wxy3l3h8973lr18135y6h1nnzzwr3n3ps")))) + (native-search-paths + (list (search-path-specification + (variable "GOPATH") + (files '("src/.." "pkg/.."))))) (arguments (substitute-keyword-arguments (package-arguments go-1.4) ((#:system system) diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm index 227df820db..01dd8cd249 100644 --- a/guix/build/go-build-system.scm +++ b/guix/build/go-build-system.scm @@ -5,6 +5,7 @@ ;;; Copyright © 2020 Jack Hill ;;; Copyright © 2020 Jakub Kądziołka ;;; Copyright © 2020 Efraim Flashner +;;; Copyright © 2021 Marius Bakke ;;; ;;; This file is part of GNU Guix. ;;; @@ -88,7 +89,6 @@ ;; a tmpdir when creating the inputs union. ;; * Use Go modules [4] ;; * Re-use compiled packages [5] -;; * Avoid the go-inputs hack ;; * Stop needing remove-go-references (-trimpath ? ) ;; * Remove module packages, only offering the full Git repos? This is ;; more idiomatic, I think, because Go downloads Git repos, not modules. @@ -143,23 +143,12 @@ dependencies, so it should be self-contained." (setenv "GOCACHE" "/tmp/go-cache") ;; Using the current working directory as GOPATH makes it easier for packagers ;; who need to manipulate the unpacked source code. - (setenv "GOPATH" (getcwd)) + (setenv "GOPATH" (string-append (getcwd) ":" (getenv "GOPATH"))) ;; Go 1.13 uses go modules by default. The go build system does not ;; currently support modules, so turn modules off to continue using the old ;; GOPATH behavior. (setenv "GO111MODULE" "off") (setenv "GOBIN" (string-append (assoc-ref outputs "out") "/bin")) - (let ((tmpdir (tmpnam))) - (match (go-inputs inputs) - (((names . directories) ...) - (union-build tmpdir (filter directory-exists? directories) - #:create-all-directories? #t - #:log-port (%make-void-port "w")))) - ;; XXX A little dance because (guix build union) doesn't use mkdir-p. - (copy-recursively tmpdir - (string-append (getenv "GOPATH")) - #:keep-mtime? #t) - (delete-file-recursively tmpdir)) #t) (define* (unpack #:key source import-path unpack-path #:allow-other-keys) @@ -191,31 +180,13 @@ unpacking." (display "WARNING: The Go import path is unset.\n")) (when (string-null? unpack-path) (set! unpack-path import-path)) - (let ((dest (string-append (getenv "GOPATH") "/src/" unpack-path))) + (let ((dest (string-append (getcwd) "/src/" unpack-path))) (mkdir-p dest) (if (file-is-directory? source) (copy-recursively source dest #:keep-mtime? #t) (unpack-maybe-strip source dest))) #t) -(define (go-package? name) - (string-prefix? "go-" name)) - -(define (go-inputs inputs) - "Return the alist of INPUTS that are Go software." - ;; XXX This should not check the file name of the store item. Instead we - ;; should pass, from the host side, the list of inputs that are packages using - ;; the go-build-system. - (alist-delete "go" ; Exclude the Go compiler - (alist-delete "source" ; Exclude the source code of the package being built - (filter (match-lambda - ((label . directory) - (go-package? ((compose package-name->name+version - strip-store-file-name) - directory))) - (_ #f)) - inputs)))) - (define* (build #:key import-path build-flags #:allow-other-keys) "Build the package named by IMPORT-PATH." (with-throw-handler @@ -249,7 +220,7 @@ XXX We can't make use of compiled libraries (Go \"packages\")." (if (string-null? import-path) ((display "WARNING: The Go import path is unset.\n"))) (let* ((out (assoc-ref outputs "out")) - (source (string-append (getenv "GOPATH") "/src/" import-path)) + (source (string-append "src/" import-path)) (dest (string-append out "/src/" import-path))) (mkdir-p dest) (copy-recursively source dest #:keep-mtime? #t)))