all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#73299] [PATCH] build/go: Replace symlinks with a copy of the file.
@ 2024-09-16 15:38 Efraim Flashner
  2024-09-16 20:09 ` Sharlatan Hellseher
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: Efraim Flashner @ 2024-09-16 15:38 UTC (permalink / raw)
  To: 73299
  Cc: Sharlatan Hellseher, Efraim Flashner, Katherine Cox-Buday,
	Sharlatan Hellseher

* guix/build/go-build-system.scm (fix-embed-files): New procedure.
(%standard-phases): Add 'fix-embed-files after 'unpack.

Co-authored-by: Sharlatan Hellseher <sharlatanus@gmail.com>
Change-Id: I27bc46fa1a3f4675ff73b6cba4ef5c3d177c22b1
---

I saw this pattern coming up a couple of times in the go-team branch so
I figured I could factor it out, as the comment said. I figure later we
can adjust it to match other symlinked files.

 guix/build/go-build-system.scm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
index 3f0f5700a1e..c953976b485 100644
--- a/guix/build/go-build-system.scm
+++ b/guix/build/go-build-system.scm
@@ -4,10 +4,11 @@
 ;;; Copyright © 2019 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2020 Jack Hill <jackhill@jackhill.us>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba@kadziolka.net>
-;;; Copyright © 2020, 2021, 2023 Efraim Flashner <efraim@flashner.co.il>
+;;; Copyright © 2020, 2021, 2023, 2024 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
 ;;; Copyright © 2024 Ekaitz Zarraga <ekaitz@elenq.tech>
 ;;; Copyright © 2024 Picnoir <picnoir@alternativebit.fr>
+;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -201,6 +202,23 @@ (define* (setup-go-environment #:key inputs outputs goos goarch #:allow-other-ke
     (delete-file-recursively tmpdir))
   #t)
 
+(define* (fix-embed-files #:rest args)
+  "Golang can't determine the valid directory of the module of embed file
+which is symlinked during setup environment phase, but easy resolved after
+coping file from the store to the build directory of the current package."
+;; see details in Golang source:
+;;
+;; - URL: <https://github.com/golang/go/blob/>
+;; - commit: 82c14346d89ec0eeca114f9ca0e88516b2cda454
+;; - file: src/cmd/go/internal/load/pkg.go#L2059
+  (for-each (lambda (file)
+              (when (eq? (stat:type (lstat file))
+                         'symlink)
+                (let ((file-store-path (readlink file)))
+                  (delete-file file)
+                  (copy-recursively file-store-path file))))
+            (find-files "src" ".*(editions_defaults.binpb)$")))
+
 (define* (unpack #:key source import-path unpack-path #:allow-other-keys)
   "Relative to $GOPATH, unpack SOURCE in UNPACK-PATH, or IMPORT-PATH when
 UNPACK-PATH is unset.  If the SOURCE archive has a single top level directory,
@@ -321,6 +339,7 @@ (define %standard-phases
     (delete 'patch-generated-file-shebangs)
     (add-before 'unpack 'setup-go-environment setup-go-environment)
     (replace 'unpack unpack)
+    (add-after 'unpack 'fix-embed-files fix-embed-files)
     (replace 'build build)
     (replace 'check check)
     (replace 'install install)

base-commit: 0091fa2cc2ac2104d7945b585e4eaec908ca742f
-- 
Efraim Flashner   <efraim@flashner.co.il>   רנשלפ םירפא
GPG key = A28B F40C 3E55 1372 662D  14F7 41AA E7DC CA3D 8351
Confidentiality cannot be guaranteed on emails sent or received unencrypted





^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-09-27  6:58 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-16 15:38 [bug#73299] [PATCH] build/go: Replace symlinks with a copy of the file Efraim Flashner
2024-09-16 20:09 ` Sharlatan Hellseher
2024-09-19 13:26 ` bug#73299: " Sharlatan Hellseher
2024-09-26 13:33 ` [bug#73299] " Sharlatan Hellseher
2024-09-26 13:56   ` Maxim Cournoyer
2024-09-26 19:09 ` Sharlatan Hellseher
2024-09-27  6:57   ` Maxim Cournoyer

Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.