1
Fork 0
mirror of https://https.git.savannah.gnu.org/git/guix.git/ synced 2025-07-14 11:00:36 +02:00

gnu: build/go: Apply default 'fix-embed-files phase.

These changes remove redundant phases where files, requiring to be embed
during build or check phases, are copied to the build directory as
proposed in <https://issues.guix.gnu.org/73299>.

* gnu/packages/backup.scm (restic-rest-server) [arguments]: <#:phases>:
Remove 'fix-embed-files phase.
* gnu/packages/configuration-management.scm (chezmoi): Likewise.
* gnu/packages/packages/golang-build.scm (go-github-com-golang-protobuf): Likewise.
* gnu/packages/golang-web.scm (go-github-com-go-openapi-loads,
go-github-com-go-openapi-runtime, go-github-com-golang-groupcache): Likewise.
* gnu/packages/golang-xyz.scm (go-github-com-dgraph-io-badger): Likewise.
* gnu/packages/golang.scm (go-github-com-ssgelm-cookiejarparser): Likewise.
* gnu/packages/ipfs.scm (go-github-com-ipfs-go-ds-badger,
go-github-com-libp2p-go-libp2p, kubo): Likewise.
* gnu/packages/irc.scm (soju): Likewise.
* gnu/packages/networking.scm (nebula): Likewise.
* gnu/packages/prometheus.scm (go-github-com-nbrownus-go-metrics-prometheus,
go-github-com-prometheus-client-golang, go-github-com-prometheus-common,
go-github-com-prometheus-common-sigv4, go-github-com-prometheus-exporter-toolkit,
go-github-com-prometheus-statsd-exporter): Likewise
* gnu/packages/version-control.scm (git-lfs): Likewise.
* gnu/packages/web.scm (miniflux): Likewise.

* gnu/packages/golang-crypto.scm (go-filippo-io-age): [arguments]:
<#:phases>: Remove 'copy-input-to-vendor-direcotyr and
'remove-vendor-directory phases.
* gnu/packages/golang-web.scm (go-github-com-go-openapi-analysis,
go-github-com-go-openapi-analysis, go-github-com-go-openapi-validate): Likewise.
* gnu/packages/golang.scm (go-github-com-charmbracelet-glamour): Likewise.
* gnu/packages/textutils.scm (vale): Likewise.

Change-Id: Ic2ec01c8caf86f3ae69d7a1812c1e0b78a549e91
This commit is contained in:
Sharlatan Hellseher 2024-09-19 14:00:56 +01:00
parent 922d017081
commit 9ff0a39943
No known key found for this signature in database
GPG key ID: 76D727BFF62CD2B5
14 changed files with 31 additions and 593 deletions

View file

@ -1596,6 +1596,7 @@ language.")
(build-system go-build-system)
(arguments
(list
#:embed-files #~(list "jsonschema-draft-04\\.json" "schema\\.json")
#:import-path "github.com/go-openapi/analysis"
#:phases
#~(modify-phases %standard-phases
@ -1606,35 +1607,11 @@ language.")
;; Tests requiring network access.
(("TestFlatten_RemoteAbsolute")
"OffTestFlatten_RemoteAbsolute")))))
;; FIXME: pattern schemas/*.json: cannot embed irregular file
;; schemas/jsonschema-draft-04.json
;;
;; This happens due to Golang can't determine the valid directory of
;; the module which is sourced during setup environment phase, but
;; easy resolved after coping to expected directory "vendor" within
;; 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 'copy-input-to-vendor-directory
(lambda* (#:key import-path #:allow-other-keys)
(with-directory-excursion (string-append "src/" import-path)
(mkdir "vendor")
(copy-recursively
(string-append
#$(this-package-input "go-github-com-go-openapi-spec")
"/src/github.com")
"vendor/github.com"))))
(replace 'check
(lambda* (#:key tests? import-path #:allow-other-keys)
(when tests?
(with-directory-excursion (string-append "src/" import-path)
(invoke "go" "test" "-v" "./...")))))
(add-before 'install 'remove-vendor-directory
(lambda* (#:key import-path #:allow-other-keys)
(with-directory-excursion (string-append "src/" import-path)
(delete-file-recursively "vendor")))))))
(invoke "go" "test" "-v" "./..."))))))))
(native-inputs
(list go-github-com-stretchr-testify))
(propagated-inputs
@ -1749,28 +1726,8 @@ prototyped in @url{https://github.com/xeipuuv/gojsonreference}.")
(build-system go-build-system)
(arguments
(list
#:import-path "github.com/go-openapi/loads"
#: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"
"^(jsonschema-draft-04|schema)\\.json$")))))))
#:embed-files #~(list "jsonschema-draft-04\\.json" "schema\\.json")
#:import-path "github.com/go-openapi/loads"))
(native-inputs
(list go-github-com-stretchr-testify))
(propagated-inputs
@ -1802,27 +1759,8 @@ Supports JSON and YAML documents.")
(build-system go-build-system)
(arguments
(list
#:import-path "github.com/go-openapi/runtime"
#: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" "\\.json$")))))))
#:embed-files #~(list "jsonschema-draft-04\\.json" "schema\\.json")
#:import-path "github.com/go-openapi/runtime"))
(native-inputs
(list go-github-com-stretchr-testify))
(propagated-inputs
@ -1957,6 +1895,7 @@ projects.")
(build-system go-build-system)
(arguments
(list
#:embed-files #~(list "jsonschema-draft-04\\.json" "schema\\.json")
#:import-path "github.com/go-openapi/validate"
#:phases
#~(modify-phases %standard-phases
@ -1967,41 +1906,7 @@ projects.")
(for-each delete-file
(list "benchmark_test.go"
"example_validator_test.go"
"doc_test.go")))))
;; FIXME: pattern schemas/*.json: cannot embed irregular file
;; schemas/jsonschema-draft-04.json
;;
;; This happens due to Golang can't determine the valid directory of
;; the module which is sourced during setup environment phase, but
;; easy resolved after coping to expected directory "vendor" within
;; 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 'copy-input-to-vendor-directory
(lambda* (#:key import-path #:allow-other-keys)
(with-directory-excursion (string-append "src/" import-path)
(mkdir "vendor")
(copy-recursively
(string-append
#$(this-package-input "go-github-com-go-openapi-loads")
"/src/github.com")
"vendor/github.com")
(copy-recursively
(string-append
#$(this-package-input "go-github-com-go-openapi-spec")
"/src/github.com")
"vendor/github.com")
(copy-recursively
(string-append
#$(this-package-input "go-github-com-go-openapi-analysis")
"/src/github.com")
"vendor/github.com"))))
(add-before 'install 'remove-vendor-directory
(lambda* (#:key import-path #:allow-other-keys)
(with-directory-excursion (string-append "src/" import-path)
(delete-file-recursively "vendor")))))))
"doc_test.go"))))))))
(native-inputs
(list go-github-com-stretchr-testify))
(propagated-inputs
@ -2169,27 +2074,7 @@ from CloudFlare's github.com/cloudflare/cfssl/revoke.")
(build-system go-build-system)
(arguments
(list
#:import-path "github.com/golang/groupcache"
#: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)$")))))))
#:import-path "github.com/golang/groupcache"))
(propagated-inputs
(list go-github-com-golang-protobuf))
(home-page "https://github.com/golang/groupcache")