* [bug#49615] [PATCH] gnu: go-1.16: Clean up installation location and logic.
@ 2021-07-18 3:53 Sarah Morgensen via Guix-patches via
2021-09-03 1:07 ` bug#49615: " Sarah Morgensen
0 siblings, 1 reply; 2+ messages in thread
From: Sarah Morgensen via Guix-patches via @ 2021-07-18 3:53 UTC (permalink / raw)
To: 49615
* 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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* bug#49615: [PATCH] gnu: go-1.16: Clean up installation location and logic.
2021-07-18 3:53 [bug#49615] [PATCH] gnu: go-1.16: Clean up installation location and logic Sarah Morgensen via Guix-patches via
@ 2021-09-03 1:07 ` Sarah Morgensen
0 siblings, 0 replies; 2+ messages in thread
From: Sarah Morgensen @ 2021-09-03 1:07 UTC (permalink / raw)
To: 49615-done
This will be superseded by a backport of the changes in #50348, if accepted.
--
Sarah
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-09-03 1:08 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-07-18 3:53 [bug#49615] [PATCH] gnu: go-1.16: Clean up installation location and logic Sarah Morgensen via Guix-patches via
2021-09-03 1:07 ` bug#49615: " Sarah Morgensen
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).