GNU bug report logs - #49615
[PATCH] gnu: go-1.16: Clean up installation location and logic.

Previous Next

Package: guix-patches;

Reported by: Sarah Morgensen <iskarian <at> mgsn.dev>

Date: Sun, 18 Jul 2021 03:54:01 UTC

Severity: normal

Tags: patch

Done: Sarah Morgensen <iskarian <at> mgsn.dev>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 49615 in the body.
You can then email your comments to 49615 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#49615; Package guix-patches. (Sun, 18 Jul 2021 03:54:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Sarah Morgensen <iskarian <at> mgsn.dev>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Sun, 18 Jul 2021 03:54:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: guix-patches <at> gnu.org
Subject: [PATCH] gnu: go-1.16: Clean up installation location and logic.
Date: Sat, 17 Jul 2021 20:53:36 -0700
* gnu/packages/golang.scm (go-1.16)[arguments]<#:tests>: Fix formatting.
<#:strip-directories>: Avoid stripping standard library which breaks it.
<#:phases>{install}: Install to out/lib/go instead of out.
{build}: Use the new location.
{reset-cwd}: Chdir back to source root before install-license-files.
---
Hello Guix,

Currently the "out" output of Go looks like...

/gnu/store/...-go-1.16.5
|-> bin          [binaries]
|-> lib          [host-independent timezone data]
|-> misc         [various arch-independent resources]
|-> pkg          [compiled Go std library]
|-> src          [Go compiler and std library source]

...which means that after installing Go, all of those directories are polluting
~/.guix-profile. Unfortunately, Go does not have any standardized installation
process, and it expects all these directories to be siblings (yes, it needs its
own source to work). Its install instructions suggest installing everything in
/usr/local/go; Debian installs in /usr/lib/go-X.Y and /usr/share/go-X.Y, with
symlinks in /usr/lib/go-X.Y for anything in /usr/share/go-X.Y.

We could install source to e.g. /share/go (or even in its own output), but we
would still require a symlink like Debian so that Go sees it in its main tree.

(Tests (6MB) and docs (7MB) are currently installed in separate directories in
separate outputs, which makes them difficult to actually use.)

This patch is fairly conservative, and just moves everything to "/lib/go":

/gnu/store/...-go-1.16.5
|-> bin                  [symlinks to "lib/go/bin"]
|-> lib
    |-> go
        |-> bin          [binaries]
        |-> lib          [host-independent timezone data]
        |-> misc         [various arch-independent resources]
        |-> pkg          [compiled Go std library]
        |-> src          [Go compiler and std library source]

But if it were up to me, I'd chuck it all in "out" and symlink like
Debian. WDYT?

--
Sarah

 gnu/packages/golang.scm | 48 ++++++++++++++++++++++++++++++++++++++---
 1 file changed, 45 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/golang.scm b/gnu/packages/golang.scm
index f38f307392..77df7bfbf4 100644
--- a/gnu/packages/golang.scm
+++ b/gnu/packages/golang.scm
@@ -1405,7 +1405,8 @@ in the style of communicating sequential processes (@dfn{CSP}).")
          "19a93p217h5xi2sgh34qzv24pkd4df0sw4fc5z6k47lspjp3vx2l"))))
     (arguments
      (substitute-keyword-arguments (package-arguments go-1.14)
-       ((#:tests? _) #t)
+       ((#:tests? _ #t) #t)
+       ((#:strip-directories _ '()) ''("lib/go/pkg/tool" "lib/go/bin"))
        ((#:phases phases)
         `(modify-phases ,phases
            (add-after 'unpack 'remove-unused-sourcecode-generators
@@ -1523,7 +1524,7 @@ in the style of communicating sequential processes (@dfn{CSP}).")
                  (setenv "GO_LDSO" loader)
                  (setenv "GOOS" "linux")
                  (setenv "GOROOT" (dirname (getcwd)))
-                 (setenv "GOROOT_FINAL" output)
+                 (setenv "GOROOT_FINAL" (string-append output "/lib/go"))
                  (setenv "GOCACHE" "/tmp/go-cache")
                  (invoke "sh" "make.bash" "--no-banner"))))
            (replace 'check
@@ -1537,7 +1538,48 @@ in the style of communicating sequential processes (@dfn{CSP}).")
              (lambda _
                ;; Rewrite references to perl input in test scripts
                (substitute* "net/http/cgi/testdata/test.cgi"
-                 (("^#!.*") "#!/usr/bin/env perl\n"))))))))
+                 (("^#!.*") "#!/usr/bin/env perl\n"))))
+           (replace 'install
+             ;; TODO: Most of this could be factorized with Go 1.4.
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (tests (assoc-ref outputs "tests"))
+                      (out-lib (string-append out "/lib/go"))
+                      (tests-share (string-append tests "/share/go"))
+                      (docs (string-append (assoc-ref outputs "doc")
+                                          "/share/doc/go-"
+                                          ,(package-version this-package))))
+                 ;; Prevent installation of the build cache, which contains
+                 ;; store references to most of the tools used to build Go and
+                 ;; would unnecessarily increase the size of Go's closure if it
+                 ;; was installed.
+                 (delete-file-recursively "../pkg/obj")
+
+                 (install-file "../VERSION" out-lib)
+                 (copy-recursively "../pkg" (string-append out-lib "/pkg"))
+                 (copy-recursively "../src" (string-append out-lib "/src"))
+                 (copy-recursively "../bin" (string-append out-lib "/bin"))
+                 (copy-recursively "../lib" (string-append out-lib "/lib"))
+                 (copy-recursively "../misc" (string-append out-lib "/misc"))
+
+                 (mkdir-p (string-append out "/bin"))
+                 (with-directory-excursion (string-append out "/bin")
+                   (symlink "../lib/go/bin/go"    "go")
+                   (symlink "../lib/go/bin/gofmt" "gofmt"))
+
+                 (mkdir-p tests-share)
+                 (copy-recursively "../test" (string-append tests-share "/test"))
+                 (copy-recursively "../api" (string-append tests-share "/api"))
+
+                 (for-each
+                  (lambda (file) (install-file (string-append "../" file) docs))
+                  ;; Note the slightly different file names compared to 1.4.
+                  '("AUTHORS" "CONTRIBUTING.md" "CONTRIBUTORS" "PATENTS"
+                    "README.md" "SECURITY.md" "favicon.ico" "robots.txt"))
+                 (copy-recursively "../doc" (string-append docs "/doc")))))
+           (add-before 'install-license-files 'reset-cwd
+             (lambda _
+               (chdir "..")))))))
     (native-inputs
      `(("go-fix-script-tests.patch" ,(search-patch "go-fix-script-tests.patch"))
        ,@(if (not (member (%current-system) (package-supported-systems go-1.4)))

base-commit: 9cb35c02164d929fcb8929e7f454df215df8cf25
-- 
2.31.1





Reply sent to Sarah Morgensen <iskarian <at> mgsn.dev>:
You have taken responsibility. (Fri, 03 Sep 2021 01:08:02 GMT) Full text and rfc822 format available.

Notification sent to Sarah Morgensen <iskarian <at> mgsn.dev>:
bug acknowledged by developer. (Fri, 03 Sep 2021 01:08:02 GMT) Full text and rfc822 format available.

Message #10 received at 49615-done <at> debbugs.gnu.org (full text, mbox):

From: Sarah Morgensen <iskarian <at> mgsn.dev>
To: 49615-done <at> debbugs.gnu.org
Subject: Re: [bug#49615] [PATCH] gnu: go-1.16: Clean up installation
 location and logic.
Date: Thu, 02 Sep 2021 18:07:29 -0700
This will be superseded by a backport of the changes in #50348, if accepted.

--
Sarah




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 01 Oct 2021 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 207 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.