GNU bug report logs - #73299
[PATCH] build/go: Replace symlinks with a copy of the file.

Previous Next

Package: guix-patches;

Reported by: Efraim Flashner <efraim <at> flashner.co.il>

Date: Mon, 16 Sep 2024 15:41:02 UTC

Severity: normal

Tags: patch

Done: Sharlatan Hellseher <sharlatanus <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


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

From: Efraim Flashner <efraim <at> flashner.co.il>
To: guix-patches <at> gnu.org
Cc: Sharlatan Hellseher <sharlatanus <at> gmail.com>,
 Efraim Flashner <efraim <at> flashner.co.il>
Subject: [PATCH] build/go: Replace symlinks with a copy of the file.
Date: Mon, 16 Sep 2024 18:38:46 +0300
* 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 <at> 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 <at> gmail.com>
 ;;; Copyright © 2020 Jack Hill <jackhill <at> jackhill.us>
 ;;; Copyright © 2020 Jakub Kądziołka <kuba <at> kadziolka.net>
-;;; Copyright © 2020, 2021, 2023 Efraim Flashner <efraim <at> flashner.co.il>
+;;; Copyright © 2020, 2021, 2023, 2024 Efraim Flashner <efraim <at> flashner.co.il>
 ;;; Copyright © 2021 Sarah Morgensen <iskarian <at> mgsn.dev>
 ;;; Copyright © 2024 Ekaitz Zarraga <ekaitz <at> elenq.tech>
 ;;; Copyright © 2024 Picnoir <picnoir <at> alternativebit.fr>
+;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus <at> 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 <at> 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





This bug report was last modified 236 days ago.

Previous Next


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