unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Sarah Morgensen via Guix-patches via <guix-patches@gnu.org>
To: 49615@debbugs.gnu.org
Subject: [bug#49615] [PATCH] gnu: go-1.16: Clean up installation location and logic.
Date: Sat, 17 Jul 2021 20:53:36 -0700	[thread overview]
Message-ID: <1e0ee9395729f43db61b2e582d1718f536ed0c45.1626580143.git.iskarian@mgsn.dev> (raw)

* 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	other threads:[~2021-07-18  3:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-18  3:53 Sarah Morgensen via Guix-patches via [this message]
2021-09-03  1:07 ` bug#49615: [PATCH] gnu: go-1.16: Clean up installation location and logic Sarah Morgensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1e0ee9395729f43db61b2e582d1718f536ed0c45.1626580143.git.iskarian@mgsn.dev \
    --to=guix-patches@gnu.org \
    --cc=49615@debbugs.gnu.org \
    --cc=iskarian@mgsn.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).