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


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Efraim Flashner <efraim <at> flashner.co.il>
Subject: bug#73299: closed ([PATCH] build/go: Replace symlinks with a copy
 of the file.)
Date: Thu, 19 Sep 2024 13:29:02 +0000
[Message part 1 (text/plain, inline)]
Your bug report

#73299: [PATCH] build/go: Replace symlinks with a copy of the file.

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to 73299 <at> debbugs.gnu.org.

-- 
73299: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=73299
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Sharlatan Hellseher <sharlatanus <at> gmail.com>
To: 73299-done <at> debbugs.gnu.org
Subject: [PATCH] build/go: Replace symlinks with a copy of the file.
Date: Thu, 19 Sep 2024 14:26:49 +0100
[Message part 3 (text/plain, inline)]
Hi,

Pushed as:

- 272cdbb16d * go-team gnu: build/go: Apply default 'fix-embed-files phase.
- 870204639e * build/go: Replace symlinks with a copy of the file.

to go-team branch.

--
Oleg
[signature.asc (application/pgp-signature, inline)]
[Message part 5 (message/rfc822, inline)]
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.