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

  • Done
  • quality assurance status badge
Details
3 participants
  • Efraim Flashner
  • Maxim Cournoyer
  • Sharlatan Hellseher
Owner
unassigned
Submitted by
Efraim Flashner
Severity
normal
E
E
Efraim Flashner wrote on 16 Sep 17:38 +0200
(address . guix-patches@gnu.org)
aabe3fc30f0f3e237eda339e73c25d376175b283.1726501103.git.efraim@flashner.co.il
* 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(-)

Toggle diff (55 lines)
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
S
S
Sharlatan Hellseher wrote on 16 Sep 22:09 +0200
(address . 73299@debbugs.gnu.org)(name . Efraim Flashner)(address . efraim@flashner.co.il)
87jzfbbbsr.fsf@gmail.com
Hi Efraim,

Thank you for implementing it as a procedure! I've slightly modifed your
patch to have an optional list of other embed files or patterns which
will be copied. It started appearing more and more during updates where
project needs embed file(s) and Golang can't detect it location.

Changes in v2:
- implement #:embed-files key
- implement building match pattern based on it
- add documentation
- add missing copyright for Troy, who implemented #:test-flags key
- include 2 examples on how it solves for the case where go could not
find more files

I can apply it on go-team and clean up all TODOs.

The branch would need some review as it contains adjustments to importer
an build system. I do not want to push more changes for now and it would
be great to merge it to master after resolving all potential build
issues.


Efraim Flashner (1):
build/go: Replace symlinks with a copy of the file.

Sharlatan Hellseher (2):
gnu: go-github-com-prometheus-statsd-exporter: Remove redundant phase.
gnu: go-github-com-golang-protobuf: Remove redundant phase.

doc/guix.texi | 8 ++++++++
gnu/packages/golang-build.scm | 18 ------------------
gnu/packages/prometheus.scm | 24 +-----------------------
guix/build-system/go.scm | 6 ++++++
guix/build/go-build-system.scm | 30 ++++++++++++++++++++++++++++--
5 files changed, 43 insertions(+), 43 deletions(-)


base-commit: f5449685143be0805a8a9b54ddecee94e368c6e9
prerequisite-patch-id: bf5c64d8c918f491f55da888b016e6a3f71119fc
prerequisite-patch-id: 37d4fcd80049a0d2f23e4a2823be899ac9ba5a92
prerequisite-patch-id: df0368ad227844a04e5ee1c7f950629aa78261a4
prerequisite-patch-id: 7f84b54ceeed4e876b80c9719d01c4ac46107bc0
prerequisite-patch-id: 0296a60d5c71c1c0340dafc71805d73c1ecfd842
prerequisite-patch-id: 2d94a9caf8da756a9d7db97c05dd4bb389b8229e
prerequisite-patch-id: 492ab0bbf944adbaa9781a5c5e52244f2b8658fe
prerequisite-patch-id: 6f971b174a8ad69e9f3961ad9b85417e45623bb6
prerequisite-patch-id: dd63d8b78cd9683db737967abddd37bca9a6e857
prerequisite-patch-id: a32b4ef3062548909d14a0828e45df1394a3219b
prerequisite-patch-id: 011f3c12c5c5982faf524c28778fb903426feaa2
prerequisite-patch-id: c38e1756dccf87c74efe631f64a1c7f441d11641
prerequisite-patch-id: 00e7d1dc1e39e512a4e2e9714f080291425dcfc8
prerequisite-patch-id: 28134b8dffa9d27fca725ba9f85e167c1274034a
prerequisite-patch-id: 509868ff5c4a3a67b03d6a57e02a539e348284ee
prerequisite-patch-id: 7ca3232011da5c664f65ba802b6786cab561bbad
prerequisite-patch-id: 0ba03d80347c47d2c9f744d20bfd29912e40f318
prerequisite-patch-id: e3a8892e61c618e1d3920cf988d88554092dd8a8
prerequisite-patch-id: 6e9876b605b9ce55c6183614b1bfebcf26e59430
prerequisite-patch-id: b299291ef134206cfe8ad45c7a9a8010bb87f36a
prerequisite-patch-id: e7729b0615445695d3f875a835824d73e02402fa
prerequisite-patch-id: a684974f9b28cd9e77728a2701397ec43eb1b924
prerequisite-patch-id: 907c96345848d2412a52e3c819a2e7f23dadf2e8
prerequisite-patch-id: 743555a609ce940d60bef70239f3a343e7728538
prerequisite-patch-id: 02a0aecd4f35b17cf18fe2bbefb8351b002f0758
prerequisite-patch-id: 100395e419ab8f34297a225b09790ab164503819
prerequisite-patch-id: a643606e91d3d9e26c201ac548781c3dd681cfbf
prerequisite-patch-id: 6251c5780a23f465765c0fe99dff91c1b650bc4d
prerequisite-patch-id: a93ecc6c9fea0f862a25ae1905b15c6e3019de67
prerequisite-patch-id: 39a686620fec6dd9f0dc5dee02492391b40c5784
prerequisite-patch-id: bfb191d2c2e504d6f5d3aba89dac4c092b41b4c6
prerequisite-patch-id: ad344284c5c86bb7165e31e74613016ea88dd350
prerequisite-patch-id: ce8004b812d523cee9a164492958084660b862de
prerequisite-patch-id: 0a15c680f1915b9c393f37a940ef5250dd378a1d
prerequisite-patch-id: e7bfa7e3dcaf1e007fe55690e0a649b40bd02ff4
prerequisite-patch-id: 91b5c05f4ed9de44ca6eedb6955076a3c7721cdd
prerequisite-patch-id: 94b5b61881f77c643a0d974a8716aa38feba6f7f
prerequisite-patch-id: 12496373563bece7cbc951fda0f9544662f97746
prerequisite-patch-id: 94fd500b9a233a8b98592b68c01726d2c379debd
prerequisite-patch-id: 76f762b24e013aabe2da2d5f8d4705b4d93b4970
prerequisite-patch-id: e4a4048a05a33eb8014250c4750159f6f9aa9884
prerequisite-patch-id: bae47578a5b697a3a74af34bf8e32d42ff1467aa
prerequisite-patch-id: 5fb108815c9dedd829e7b124f0217eebe55d4858
prerequisite-patch-id: 149f495240146f7e24b611452db0e9013143056a
prerequisite-patch-id: 459e11365cd3a343570a908a22c0e2aba3a58f09
prerequisite-patch-id: 5c88c28af5317f5342448b30267c4423726167f2
prerequisite-patch-id: 4d0443def5d0bc8aab514e0df86f001dda19ba2b
prerequisite-patch-id: 9d1ad455f0cfdf22eade1c469a3c5b700603cad7
prerequisite-patch-id: 60c4b855690f700c6fc9edc6e0c61bd553fb20fb
prerequisite-patch-id: 8f3af07731497a073f5bc421a26bc9889bbb62ce
prerequisite-patch-id: b464542aee48a0ae9593185074cc7b66d75b36ed
prerequisite-patch-id: b838bdbeceeec178d52cf544b4c1c784b458ae7d
prerequisite-patch-id: 0f3961d4fea2f6b2d305e2ad500284c84b8d10dc
prerequisite-patch-id: 26f6a0af3443ca07e0c20e5913c334aca3c209d6
prerequisite-patch-id: 4cd07ca6b74c163c3c762a5e956447b47b580369
prerequisite-patch-id: 4d34cd2070170fdbd86c84a455526bd12d941964
prerequisite-patch-id: d5f5089cf771ba0b76bfe6805abfe631d07c29dc
prerequisite-patch-id: 9c13e9b901aa38db4cc150f227ddc9557ec5e511
prerequisite-patch-id: 9f5a14c05bb1a6dff24936d0f6702ca4993d775b
prerequisite-patch-id: 458f5f792f7a019572a33ab49fc11c12ecb42472
prerequisite-patch-id: d93592a3623b23e76eb4cb37661d029433257eec
prerequisite-patch-id: 068ca74f1ff9a38d4a3fedd6d91df582082e5ef4
prerequisite-patch-id: b940c60f2bf310201d566eab1b2e8a359a9bbaf4
prerequisite-patch-id: d628e14aeb629e70c99bd4c010a88a162ecbd5c0
prerequisite-patch-id: 5d6eddbbdfdd8fa4c8ea8d9621f0c2a23e130743
prerequisite-patch-id: 62332e6f9cefb59b437fe48f776221efa7281040
prerequisite-patch-id: 88bc78415d0c4b8a8323e20dcf511fa66af330c4
prerequisite-patch-id: fcbfc689c5711d222caa29c07053bf31eb4b91cd
prerequisite-patch-id: da204ba21e647383281cfaf2a6c70ee1fa58e5a5
prerequisite-patch-id: 63b677332671f61d07929b9095bd0a74f3efe60e
prerequisite-patch-id: 62d7b58ff66835200f5d83c3d4c0672b2633049a
prerequisite-patch-id: dcd16fdaa2af61501818a4ea4323ca5c91a1127b
prerequisite-patch-id: dc36b4bf9fd3ded6a39706107b265f93b80fe370
prerequisite-patch-id: 770a07cac55179ba07166ad048c97e86f4b13670
prerequisite-patch-id: 8d34c2ba148b861bec3a485a6543135698296886
prerequisite-patch-id: cc88568c0587fd723bdfa4c5358a5a9d6984457e
prerequisite-patch-id: 1f016e814fb174e06d6b33ec07b0f95471cabf19
prerequisite-patch-id: 2c69132dce6ba24fa402a2b1c379a5b5c387dd7b
prerequisite-patch-id: 2c5168b75d80a01bf0d6815f0055ff3ec30caa44
prerequisite-patch-id: e615055c1c3090731090aed42f05eb5d1fb6564a
prerequisite-patch-id: 4caa2472b4c06ae0c8011b049197bedad5f5228e
prerequisite-patch-id: 452f33dd740f65beb7e22e0ca81baef5457c82ab
prerequisite-patch-id: c74579d2771af9098e24557c10ab3e4140746b75
prerequisite-patch-id: 7e84e3d0892975c807f3773d07424237c9639483
prerequisite-patch-id: 712126549fa65ec1babbb8710314319d5875362d
prerequisite-patch-id: 43441e3a86f3c1711afcbf14df5ecd7a0b0343be
prerequisite-patch-id: cae4bd98106f640d76904270244b1bf1315bcb1d
prerequisite-patch-id: c9bf6829217ab6b460b522fb1252dcb6b39a71e3
prerequisite-patch-id: 59b16e880553456851031fde64db1060f36bb125
prerequisite-patch-id: 61cf441c09658a605c09e2afdfe6a0ed644153a5
prerequisite-patch-id: 20920fe50dbd3a4f8b28d8c08a18011efc020d0d
prerequisite-patch-id: 408b7758d3decd92387ff19446590f6339c948c7
prerequisite-patch-id: 7bcb962bbbfb07ae864e005276b7629f5dd2a2a5
prerequisite-patch-id: 53d89343a81a8ef4a47b9ec5c34a7795930f3221
prerequisite-patch-id: 50a2ff5650b9bbbb111333e72a3180c9220c93b1
prerequisite-patch-id: e5587d038c63f97f5821c7d64e64968f6d23f18b
prerequisite-patch-id: ebec5c6bcebd6ee0b34e02efb63e16e0c689e96e
prerequisite-patch-id: e58d6eb187ba7a726cfc8fcbc02c636c63eeb01f
prerequisite-patch-id: ff82775fa0be79e3ca23e91e15cf8b6d3934261a
prerequisite-patch-id: 6cffdf3b490683f50f1478b02d7ec50982b52443
prerequisite-patch-id: 9f76593f3984482bb0c191a3c1753a8bc74a1bb5
prerequisite-patch-id: 91dd68bc14f8c88f82515077f229f67a91c47c98
prerequisite-patch-id: 564f47441f415c0f6a31ba97c4993824868a4c51
prerequisite-patch-id: 0f8321acaae45c42001a03f64fbda7c7789da377
prerequisite-patch-id: 9f529cf0218c6d6241bd1702b4be370fc30a71fa
prerequisite-patch-id: 7bf436492ad84783eceb860aaada2f2820c205cc
prerequisite-patch-id: b2dd4888a77f0d7e5da5be8ad13561913e818c9f
prerequisite-patch-id: a18a8ee540d5ddd13367e0dc4a5a4608f9f87410
prerequisite-patch-id: a7de718aa40a43dffc015eea1c9aabe54ad853b4
prerequisite-patch-id: 3b7026bcb6dc9045ffcd88003ae80a969840b17b
prerequisite-patch-id: 827b7210126c3e4af59768f027e8d9f0d9d9b88b
prerequisite-patch-id: 1b04fe7abb2801551192579eaf449ec0575879a7
prerequisite-patch-id: 04c43ab1383ff99a18f125bd9494ce5e348d39c0
prerequisite-patch-id: 2ec07e430ae6410f1cbb515c7c94dfcbf48deb9d
prerequisite-patch-id: 19d90156bd1b798376c1b48e8d97cb2e10e052eb
prerequisite-patch-id: 83ad7de8b7d2987a67e2702d5b2a4e10dbfb8b88
prerequisite-patch-id: acb7e450a5c776f8aed85fee56ad4cd6eaa272ed
prerequisite-patch-id: 9efbb939415534e6ac18e0bb1a7e44fafa309e92
prerequisite-patch-id: c779017f15fc711a693fde48429b9410b6b0703b
prerequisite-patch-id: 6bae6f8cedbea090582ca108fa785f4ffa72194d
prerequisite-patch-id: 6d440be966ddb0c5ec25209e2add9eba9281e602
prerequisite-patch-id: 2f5fff666441ab39aa5a41ff04a2008a5910131d
prerequisite-patch-id: f3010317857ccda72dfd26c60517ecf2d7d68045
prerequisite-patch-id: 49c6204f732cb27ff947d27aedf919a76227396f
--
2.46.0
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEmEeB3micIcJkGAhndtcnv/Ys0rUFAmbokIQACgkQdtcnv/Ys
0rWncA/9F28gZhSV0QWBjBBjoJuWfq5DL5L1Oco4WFdFt4n1euaA6KOW1WDpv6ZR
Qmjz5CSrnjsAWyXAQNNw/M3Aymfo4xki1AHp2D1HkAURjVCjplhFLzvwE7AG2bMV
9n0LOblhxoO0jfFEYLBv3Io+27/eg6/VeQeD3s/3a3sYz0+pJgKvSkaHH6kTiTRN
gPHeob60Djg2wxsXMXUzg2/fMyHL1UBsS8FlU8NiV7Qe1/A8uhVLnzcj6hXuS83v
sWC7URK6FTpVNraUuqdgcHn1tbcdhcEoCyg9oXMedAUPYmOA4z+jsfmbRO3sFEkP
YfBt9QCYwaB/Hd6ypF2pbiiSN+P9EsxJTtu3wHSs9C37bAVU59MigWuMqBCOfGaK
ste4oVhV9B0sU3MovveF01YgTUL+NsZPIxhaIyh6mypaVdJpoQW3Zph8kxWEaKLR
UJ4xa2JDUYgkjJig9S1lfbPrdOSuLutZaWh2exF/8vKla4PSWDbd8kUJ+dShfpzP
lEIRrGfiHSDRuIGFW2frzZikoRm8hoqMOJMopo7RyHeHoE67vDlurmNLImcBIO+H
3qqjsGp7uZ8kaIwyDPoGz34xwoLxU2J+Yf12HzyjygF8SHbEBt1sTydj4d0xSgTQ
jiW3cOzXG9s2G3CI05aqQOyvvnHEqaBY0F10Kh38rF4qG1D1Dz0=
=PrFj
-----END PGP SIGNATURE-----

S
S
Sharlatan Hellseher wrote on 16 Sep 22:10 +0200
[PATCH v2 2/3] gnu: go-github-com-prometheus-statsd-exporter: Remove redundant phase.
(address . 73299@debbugs.gnu.org)(name . Sharlatan Hellseher)(address . sharlatanus@gmail.com)
c4069e80755c59a57a47c6069d0f15d176cb4644.1726516329.git.sharlatanus@gmail.com
* gnu/packages/prometheus.scm (go-github-com-prometheus-statsd-exporter)
[arguments]: <#:phases>: Remove 'fix-embed-files and relay on standard
one.

Change-Id: I1bc965c65bcd40fcaef7d0ace9943a01ef08bdd3
---
gnu/packages/prometheus.scm | 24 +-----------------------
1 file changed, 1 insertion(+), 23 deletions(-)

Toggle diff (37 lines)
diff --git a/gnu/packages/prometheus.scm b/gnu/packages/prometheus.scm
index fe2fa18e95..a81932f62b 100644
--- a/gnu/packages/prometheus.scm
+++ b/gnu/packages/prometheus.scm
@@ -572,29 +572,7 @@ (define-public go-github-com-prometheus-statsd-exporter
(arguments
(list
#:import-path "github.com/prometheus/statsd_exporter"
- #:phases
- #~(modify-phases %standard-phases
- ;; TODO: Implement it in go-build-system.
- ;;
- ;; This happens due to 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
- (add-before 'build 'fix-embed-files
- (lambda _
- (for-each (lambda (file)
- (let ((file-store-path (readlink file)))
- (delete-file file)
- (copy-recursively file-store-path file)))
- (find-files "src" (string-append
- ".*(editions_defaults.binpb"
- "|landing_page.css"
- "|landing_page.html)$"))))))))
+ #:embed-files #~(list "landing_page.css" "landing_page.html")))
(native-inputs
(list go-github-com-stvp-go-udp-testing))
(propagated-inputs
--
2.46.0
S
S
Sharlatan Hellseher wrote on 16 Sep 22:10 +0200
[PATCH v2 1/3] build/go: Replace symlinks with a copy of the file.
(address . 73299@debbugs.gnu.org)
870204639eb63370aae42e86364899d333064749.1726516329.git.sharlatanus@gmail.com
From: Efraim Flashner <efraim@flashner.co.il>

* guix/build/go-build-system.scm (fix-embed-files): New procedure.
(%standard-phases): Add 'fix-embed-files after 'unpack.
* guix/build-system/go.scm (#:embed-files): New key parameter.
* doc/guix.texi: (go-build-system): Document a new key.

Co-authored-by: Sharlatan Hellseher <sharlatanus@gmail.com>
Change-Id: I27bc46fa1a3f4675ff73b6cba4ef5c3d177c22b1
---
doc/guix.texi | 8 ++++++++
guix/build-system/go.scm | 6 ++++++
guix/build/go-build-system.scm | 30 ++++++++++++++++++++++++++++--
3 files changed, 42 insertions(+), 2 deletions(-)

Toggle diff (139 lines)
diff --git a/doc/guix.texi b/doc/guix.texi
index 4abe258af0..e780bde6cf 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -130,6 +130,9 @@
Copyright @copyright{} 2024 Dariqq@*
Copyright @copyright{} 2024 Denis 'GNUtoo' Carikli@*
Copyright @copyright{} 2024 Fabio Natali@*
+Copyright @copyright{} 2024 Troy Figiel@*
+Copyright @copyright{} 2024 Sharlatan Hellseher@*
+
Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
@@ -9580,6 +9583,11 @@ Build Systems
@code{#:test-flags} parameter, default is @code{'()}. See @code{go help
test} and @code{go help testflag} for more details.
+The key @code{#:embed-files}, default is @code{'()}, provides a list of
+future embedded files or regexps matching files. They will be copied to
+build directory after @code{unpack} phase. See
+@url{https://pkg.go.dev/embed} for more details.
+
@end defvar
@defvar glib-or-gtk-build-system
diff --git a/guix/build-system/go.scm b/guix/build-system/go.scm
index e6e8b84e48..97581a14c6 100644
--- a/guix/build-system/go.scm
+++ b/guix/build-system/go.scm
@@ -6,6 +6,8 @@
;;; Copyright © 2021, 2023 Efraim Flashner <efraim@flashner.co.il>
;;; Copyright © 2021 Sarah Morgensen <iskarian@mgsn.dev>
;;; Copyright © 2024 Christina O'Donnell <cdo@mutix.org>
+;;; Copyright © 2024 Troy Figiel <troy@troyfigiel.com>
+;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -197,6 +199,7 @@ (define* (go-build name inputs
(outputs '("out"))
(search-paths '())
(install-source? #t)
+ (embed-files ''())
(import-path "")
(unpack-path "")
(build-flags ''())
@@ -226,6 +229,7 @@ (define* (go-build name inputs
#:substitutable? #$substitutable?
#:goarch #$goarch
#:goos #$goos
+ #:embed-files #$embed-files
#:search-paths '#$(sexp->gexp
(map search-path-specification->sexp
search-paths))
@@ -264,6 +268,7 @@ (define* (go-cross-build name
(system (%current-system))
(goarch (first (go-target target)))
(goos (last (go-target target)))
+ (embed-files ''())
(guile #f)
(imported-modules %go-build-system-modules)
(modules '((guix build go-build-system)
@@ -297,6 +302,7 @@ (define* (go-cross-build name
#:target #$target
#:goarch #$goarch
#:goos #$goos
+ #:embed-files #$embed-files
#:inputs %build-target-inputs
#:native-inputs %build-host-inputs
#:search-paths '#$(map search-path-specification->sexp
diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
index 3f0f5700a1..14cb5ae687 100644
--- a/guix/build/go-build-system.scm
+++ b/guix/build/go-build-system.scm
@@ -4,10 +4,12 @@
;;; 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 Troy Figiel <troy@troyfigiel.com>
+;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus@gmail.com>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -28,8 +30,9 @@ (define-module (guix build go-build-system)
#:use-module ((guix build gnu-build-system) #:prefix gnu:)
#:use-module (guix build union)
#:use-module (guix build utils)
- #:use-module (ice-9 match)
+ #:use-module (ice-9 format)
#:use-module (ice-9 ftw)
+ #:use-module (ice-9 match)
#:use-module (srfi srfi-1)
#:use-module (rnrs io ports)
#:use-module (rnrs bytevectors)
@@ -201,6 +204,28 @@ (define* (setup-go-environment #:key inputs outputs goos goarch #:allow-other-ke
(delete-file-recursively tmpdir))
#t)
+(define* (fix-embed-files #:key embed-files #:allow-other-keys)
+ "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. Take
+a list of files or regexps matching files from EMBED-FILES paramter, failover
+to 'editions_defaults.binpb' which is a part of <github.com/golang/protobuf>."
+ ;; see details in Golang source:
+ ;;
+ ;; - URL: <https://github.com/golang/go/blob/>
+ ;; - commit: 82c14346d89ec0eeca114f9ca0e88516b2cda454
+ ;; - file: src/cmd/go/internal/load/pkg.go#L2059
+ (let ((embed-files (format #f "^(~{~a|~}~a)$"
+ embed-files
+ "editions_defaults.binpb")))
+ (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" embed-files))))
+
(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 +346,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)
--
2.46.0
S
S
Sharlatan Hellseher wrote on 16 Sep 22:10 +0200
[PATCH v2 3/3] gnu: go-github-com-golang-protobuf: Remove redundant phase.
(address . 73299@debbugs.gnu.org)(name . Sharlatan Hellseher)(address . sharlatanus@gmail.com)
e5fe2c958f1bdadddd3458949c3a973bf064a9ae.1726516329.git.sharlatanus@gmail.com
* gnu/packages/packages/golang-build.scm (go-github-com-golang-protobuf)
[arguments]: <#:phases>: Remove 'fix-embed-files and relay on standard
one.

Change-Id: Ife4d86e8072588d562364534a66d41ff01851361
---
gnu/packages/golang-build.scm | 18 ------------------
1 file changed, 18 deletions(-)

Toggle diff (31 lines)
diff --git a/gnu/packages/golang-build.scm b/gnu/packages/golang-build.scm
index 8fdd652b63..7049acf8c2 100644
--- a/gnu/packages/golang-build.scm
+++ b/gnu/packages/golang-build.scm
@@ -103,24 +103,6 @@ (define-public go-github-com-golang-protobuf
#:import-path "github.com/golang/protobuf"
#:phases
#~(modify-phases %standard-phases
- ;; TODO: Implement it in go-build-system.
- ;;
- ;; This happens due to 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
- (add-after 'unpack 'fix-embed-files
- (lambda _
- (for-each (lambda (file)
- (let ((file-store-path (readlink file)))
- (delete-file file)
- (copy-recursively file-store-path file)))
- (find-files "src" ".*(editions_defaults.binpb)$"))))
;; XXX: Workaround for go-build-system's lack of Go modules
;; support.
(delete 'build)
--
2.46.0
S
S
Sharlatan Hellseher wrote on 19 Sep 15:26 +0200
[PATCH] build/go: Replace symlinks with a copy of the file.
(address . 73299-done@debbugs.gnu.org)
87zfo34vvq.fsf@gmail.com
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
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEmEeB3micIcJkGAhndtcnv/Ys0rUFAmbsJpkACgkQdtcnv/Ys
0rXjhQ/6ApGIMsW5xIE1A/VOGx5G37ZlRv7+QiCwrHzcUGZEMf8zz3rhJpSMDNXv
oZOe+d8lOyLbTMDSkHw/gmJTuGqh7T4qum7i2zTKZEC9ng7vkNlihx2ongyDf1dw
5/ccaFn54fHMBee8N4tregtjKWUyjFgASqnU6dlQD5I8qayin36m4KTUxThGG62U
JDyRocA5vBDhC+6MxZArX52nrFoSVRluVZ58XAfFKVm8eov6OTAc9Y4bWsispeIG
VZ94jkqu1+N6rf0FVt5Ybt9AwDjaTbcfsmazDeoUtQKOfnl9cyeVrOWyW0Q3viwM
1X4PufpPrlE5pKlYwnXx8whbOYqfV7gvqSh4fRFvofZwleJsdNFL9yFwcw6i7jOw
5n3EMqfRjjSSRcQc/ptSOkskNcbTwvzPVQJFJf9gcLOMrOCNvA23FA2OmCsfUY6N
6qHkTVcyWiIABC0Fl3TpaIUkjgVqpmwGSesfAVbsf9i1hF1SRSXujzu9VKn3pU/i
1Y3v642S3+UJHoCy2zACwbrRS/4gIZbiSDyLwqLJKjreHUFI+ueSvY9ATXFp0snz
p7daQga5w0wAEl8qhOUR1BZ/s3CIrN1TQDxfCDAqLmY2xR8jM+ymJMjtoHj48swP
ZCPQpk4H414daqs6pFIwF2Ol10wYFyxkNfB6lPV/V56XVzE3dPU=
=Bkf/
-----END PGP SIGNATURE-----

Closed
M
M
Maxim Cournoyer wrote on 26 Sep 15:22 +0200
Re: [bug#73299] [PATCH v2 1/3] build/go: Replace symlinks with a copy of the file.
(name . Sharlatan Hellseher)(address . sharlatanus@gmail.com)
8734lmft2o.fsf@gmail.com
Hi Sharlatan,

Some small nitpicks below:

Sharlatan Hellseher <sharlatanus@gmail.com> writes:

Toggle quote (25 lines)
> From: Efraim Flashner <efraim@flashner.co.il>
>
> * guix/build/go-build-system.scm (fix-embed-files): New procedure.
> (%standard-phases): Add 'fix-embed-files after 'unpack.
> * guix/build-system/go.scm (#:embed-files): New key parameter.
> * doc/guix.texi: (go-build-system): Document a new key.
>
> Co-authored-by: Sharlatan Hellseher <sharlatanus@gmail.com>
> Change-Id: I27bc46fa1a3f4675ff73b6cba4ef5c3d177c22b1
> ---
> doc/guix.texi | 8 ++++++++
> guix/build-system/go.scm | 6 ++++++
> guix/build/go-build-system.scm | 30 ++++++++++++++++++++++++++++--
> 3 files changed, 42 insertions(+), 2 deletions(-)
>
> diff --git a/doc/guix.texi b/doc/guix.texi
> index 4abe258af0..e780bde6cf 100644
> --- a/doc/guix.texi
> +++ b/doc/guix.texi
> @@ -130,6 +130,9 @@
> Copyright @copyright{} 2024 Dariqq@*
> Copyright @copyright{} 2024 Denis 'GNUtoo' Carikli@*
> Copyright @copyright{} 2024 Fabio Natali@*
> +Copyright @copyright{} 2024 Troy Figiel@*

Is this accurate? Should another Co-authored-by: git trailer be added
for them?

[...]

[...]

Toggle quote (35 lines)
> diff --git a/guix/build/go-build-system.scm b/guix/build/go-build-system.scm
> index 3f0f5700a1..14cb5ae687 100644
> --- a/guix/build/go-build-system.scm
> +++ b/guix/build/go-build-system.scm
> @@ -4,10 +4,12 @@
> ;;; 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 Troy Figiel <troy@troyfigiel.com>
> +;;; Copyright © 2024 Sharlatan Hellseher <sharlatanus@gmail.com>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -28,8 +30,9 @@ (define-module (guix build go-build-system)
> #:use-module ((guix build gnu-build-system) #:prefix gnu:)
> #:use-module (guix build union)
> #:use-module (guix build utils)
> - #:use-module (ice-9 match)
> + #:use-module (ice-9 format)
> #:use-module (ice-9 ftw)
> + #:use-module (ice-9 match)
> #:use-module (srfi srfi-1)
> #:use-module (rnrs io ports)
> #:use-module (rnrs bytevectors)
> @@ -201,6 +204,28 @@ (define* (setup-go-environment #:key inputs outputs goos goarch #:allow-other-ke
> (delete-file-recursively tmpdir))
> #t)
>
> +(define* (fix-embed-files #:key embed-files #:allow-other-keys)
> + "Golang can't determine the valid directory of the module of embed file
^ *an* embed file
or
embed fileS

I typically prefer 'cannot' vs can't and likewise for 'do not' vs
doesn't, etc., which I feel reads more "formal".

Toggle quote (2 lines)
> +which is symlinked during setup environment phase, but easy resolved after

easy resolved -> easily resolved

Toggle quote (2 lines)
> +coping file from the store to the build directory of the current package. Take

coping file -> copying the file; missing double space before 'Take'.

Toggle quote (2 lines)
> +a list of files or regexps matching files from EMBED-FILES paramter, failover

paramter -> parameter

Toggle quote (4 lines)
> +to 'editions_defaults.binpb' which is a part of <github.com/golang/protobuf>."

> + ;; see details in Golang source:

Please use fully punctuated sentences for standalone comments; e.g. :
"For the details, consult the Golang source:"

Toggle quote (5 lines)
> + ;;
> + ;; - URL: <https://github.com/golang/go/blob/>
> + ;; - commit: 82c14346d89ec0eeca114f9ca0e88516b2cda454
> + ;; - file: src/cmd/go/internal/load/pkg.go#L2059

You could use github's raw URL for the file, which doesn't require any
javascript to be viewed.

That's it! Thank you for working on improving Go on Guix.

--
Maxim
S
S
Sharlatan Hellseher wrote on 26 Sep 15:33 +0200
[PATCH] build/go: Replace symlinks with a copy of the file.
(address . 73299@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87ed56o7z1.fsf@gmail.com
Hi Maxim,

Thanks for a feedback!

I currently polishing go-team branch (rebasing, adjusting failed builds,
etc.)
Is it ok to apply your suggestions, modify the commit and rebase the
branch once again or it would be ok to apply adjustment commit on top
of it?

Thanks,
--
Oleg
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEmEeB3micIcJkGAhndtcnv/Ys0rUFAmb1YqIACgkQdtcnv/Ys
0rX1mw//a6RkKio5PLHHJ/BnuThcAg5I6Upj56cXT1+abY+HAc9JR4seRkWlJcgy
YcnuYGniW7OQFUx8521TZ+8+Y1M+7Vne+izzoMKUEvSEAFAPHDVUrPieKCtqzTIv
Q3eFli51dyK1/w2zwjKPNC8y1+nTTYPvxz5QJPu7Oc4OJQUmn7smntcOk3nz89YC
0d+10r94IraICDeOTxNPglW29cy12zmksT5WC9fYjIZ4qKcAfCqRNxMbsRGhyVsS
EV2pMEmW/6MgD4dxUp5i6Ib+OB4PfCF4o4d8NJnYdZOtL7v3nBXHviTYB0r/opyT
3EJacadN/D/qWsb6QC2HmuUGJS77qbJn/d/h5e4n8FJLsnBE0pIndi/b3hv/qgnu
EJYLNB1EkGxsVw04WEgoPMJilMSaYkNqO6ik9XBKVwE+DMk6S2bMq1NgpbKwE6w9
4h304a15kFA1+qyFFICAedz6SdWLmLVt+nETGYzNpCmoZeYhLcfGEScFEHS3BeNT
2AkfbUyvOWRzB2s1+wZL2llLlhQjicaIhygmLgGyOklXRNjv2UuYdyc2t+LSM8aa
KpW8fN3pigFJbU4rSgjFnFa9Oz02kPVnPDX27yzoY50kH2AWigQ+oUB+W7uRomK2
CcrZw+O+0t7mf/W/ah6xkt140AMFX+dlskPuLfsgirJZqxGkE6o=
=eeoM
-----END PGP SIGNATURE-----

M
M
Maxim Cournoyer wrote on 26 Sep 15:56 +0200
(name . Sharlatan Hellseher)(address . sharlatanus@gmail.com)(address . 73299@debbugs.gnu.org)
87jzeyecwp.fsf@gmail.com
Hi Sharlatan,

Sharlatan Hellseher <sharlatanus@gmail.com> writes:

Toggle quote (9 lines)
> Hi Maxim,
>
> Thanks for a feedback!
>
> I currently polishing go-team branch (rebasing, adjusting failed builds,
> etc.)
> Is it ok to apply your suggestions, modify the commit and rebase the
> branch once again or it would be ok to apply adjustment commit on top

I think it'd be safer to have a fixup commit; unless you are sure nobody
cherry-picked some commits from the branch to master or elsewhere (which
would then appear duplicated once the go-team branch gets merged into
that same branch).

--
Thanks,
Maxim
S
S
Sharlatan Hellseher wrote on 26 Sep 21:09 +0200
[PATCH] build/go: Replace symlinks with a copy of the file.
(address . 73299@debbugs.gnu.org)(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)
87bk0ansem.fsf@gmail.com
-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEmEeB3micIcJkGAhndtcnv/Ys0rUFAmb1sXEACgkQdtcnv/Ys
0rXIaw/+MtaG+U/jr4ppoF/joJ9QRYJvz+/eXjeLQlElkBPheejR1vY9XQssf78J
8LW4RE/W8cdiI/8i9AhUiC78NGUVga94EDavfJiZVkdqEnFg+RK6TAux9pwco5C/
ujxtKuJRs7wDJTijpvlNi9ihcrPnHHhMfNC1gQ28pvy4ysT5mHt3nhqmZLcHvzaG
Iu8YO9yRZvUk6/ybltEf82WLoPvvyNdJ77cnRjKxVDeKU0H3tjJZ7ARI+INISMUn
vi07hfMRSPXJtIO25W5MWl90zW5IikD9cjTZIhMoAiGSu+Wma18268/3U6H8uwrj
OxFQ2pIl4+Kvr0C1I3YMQSgFIDAtafwLeLCJ1EX2mVI89iCTFLNlOMM2cNmm+N63
GMTD+3LR7Xh6QZrszWa9ATaRIrwaSz+knmLu73dV/RAofhPW/dv0JJKcaTaGyy7f
DW8eiOTRD5P0XxfLiG7mlX8PqYcqKpYrIciMiz2xyYSs9awVGmvl7tZXVaUbwXZ7
fYmSvhSQrn1vK68tYxVaEM+MS2gTEnhYQ7V7TkVeo7gnF+TRwGZNy6BfTPs2JuJB
OFGNwCttnoIh3jS69mHOs7DG2d+xwSL/Rj8YHEXmi46kM3XrNzJR4okQ1YkK607X
l3ZRIMS97DLLKa9wuTPo2G58+pzt7A4h/JoFPzfrZ2lo0SO0KQg=
=cn39
-----END PGP SIGNATURE-----

M
M
Maxim Cournoyer wrote on 27 Sep 08:57 +0200
(name . Sharlatan Hellseher)(address . sharlatanus@gmail.com)(address . 73299@debbugs.gnu.org)
874j61eg8s.fsf@gmail.com
Hi,

Sharlatan Hellseher <sharlatanus@gmail.com> writes:

Toggle quote (4 lines)
> Hi,
>
> Pushed to go-team as https://git.savannah.gnu.org/cgit/guix.git/commit/?h=go-team&id=ad39aa197af0833523b6c43ecc798790e0f9c060

Thank you for taking the effort to address my (small) comments!

--
Maxim
?
Your comment

This issue is archived.

To comment on this conversation send an email to 73299@debbugs.gnu.org

To respond to this issue using the mumi CLI, first switch to it
mumi current 73299
Then, you may apply the latest patchset in this issue (with sign off)
mumi am -- -s
Or, compose a reply to this issue
mumi compose
Or, send patches to this issue
mumi send-email *.patch