From: Bruce Ashfield <bruce.ashfield@gmail.com>
To: stefan.herbrechtsmeier-oss@weidmueller.com
Cc: openembedded-core@lists.openembedded.org,
Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
Subject: Re: [OE-core] [RFC PATCH 18/30] classes: add vendor class for go
Date: Tue, 11 Feb 2025 17:59:55 -0500 [thread overview]
Message-ID: <Z6vWayPuHfEIrzEF@gmail.com> (raw)
In-Reply-To: <20250211150034.18696-18-stefan.herbrechtsmeier-oss@weidmueller.com>
In message: [OE-core] [RFC PATCH 18/30] classes: add vendor class for go
on 11/02/2025 Stefan Herbrechtsmeier via lists.openembedded.org wrote:
> From: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
>
> Add a vendor class for go to resolve the dependency SRC_URIs from a
> go.sum file and run populate the go mod vendor folder.
>
> Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> ---
>
> meta/classes-recipe/vendor_go.bbclass | 59 +++++++++++++++++++++++++++
> 1 file changed, 59 insertions(+)
> create mode 100644 meta/classes-recipe/vendor_go.bbclass
>
> diff --git a/meta/classes-recipe/vendor_go.bbclass b/meta/classes-recipe/vendor_go.bbclass
> new file mode 100644
> index 0000000000..dc5f8d1d8d
> --- /dev/null
> +++ b/meta/classes-recipe/vendor_go.bbclass
> @@ -0,0 +1,59 @@
> +# Copyright (C) 2025 Weidmueller Interface GmbH & Co. KG
> +# Stefan Herbrechtsmeier <stefan.herbrechtsmeier@weidmueller.com>
> +#
> +# SPDX-License-Identifier: MIT
> +#
> +
> +# The directory of the go.mod file relative to the root directory, per default
> +# assume there's a file directly in the root directory
> +GO_SRC_DIR ?= ""
> +
> +# The path to the go.mod file
> +GO_MANIFEST_DIR ?= "${GO_SRC_PATH}/go.mod"
> +
> +# The path to go.sum file
> +GO_LOCK_DIR ?= "${@os.path.join(os.path.dirname(d.getVar('GO_MANIFEST_DIR')), 'go.sum')}"
> +
> +# The URL of the go proxy
> +GO_PROXY ?= "https://proxy.golang.org"
> +
> +GO_SRC_PATH = "${S}/${GO_SRC_DIR}"
> +GO_SRC_SUBDIR = "${@os.path.relpath(d.getVar('CARGO_SRC_PATH'), d.getVar('WORKDIR'))}"
> +GO_SRC_URI_FILE = "${VENDOR_DIR}/go-source-uris.txt"
> +SRC_URI_FILES:append = " ${GO_SRC_URI_FILE}"
> +
> +inherit go-mod vendor
> +
> +GO_INSTALL_PREFIX = "."
> +GO_SRC_PATH = "${S}"
> +GO_SRCURI_DESTSUFFIX = ""
> +
> +GOMODCACHE = "invalid"
> +GO_MOD_CACHE_DIR = "go/pkg/mod"
> +GO_WORKPATH = "${GO_SRC_PATH}"
> +GO_MOD_RECRDEPTASK = ""
> +
> +GOBUILDFLAGS:append = " -mod=vendor"
> +
> +python vendor_go_do_vendor_resolve() {
> + import oe.vendor
> + import oe.vendor.go
> +
> + lock_file_dir = d.getVar("GO_LOCK_DIR")
> + lock_file_subdir = get_early_source_dir(d, lock_file_dir)
> + proxy = d.getVar("GO_PROXY")
> + cache_subdir = d.getVar("GO_MOD_CACHE_DIR")
> + src_uris = oe.vendor.go.resolve_src_uris(lock_file_subdir, proxy, cache_subdir)
> + with open(d.getVar("GO_SRC_URI_FILE"), "w") as f:
> + oe.vendor.dump(f, src_uris)
> +}
> +
> +run_go_mod_vendor() {
> + cd ${GO_SRC_PATH}
> + export GOMODCACHE="${UNPACKDIR}/${GO_MOD_CACHE_DIR}"
> + ${GO} mod vendor
What happens if a module isn't in the unpackdir ? I assume it goes
to the go infrastructure and fetches the module ? Or is it
impossible for one to not be in the cache (i.e. is it
always fully pre-poulated via the vendor_go_do_vendor_resolve ?)
It is unclear to me how the vendor'd modules get into an archive
that can be saved for future reproducible builds (can you point
me at that glue?).
Bruce
> +}
> +do_unpack[postfuncs] += "run_go_mod_vendor"
> +do_unpack[depends] += "${@oe.utils.build_depends_string(d.getVar('DEPENDS_GOLANG'), 'do_populate_sysroot')}"
> +
> +EXPORT_FUNCTIONS do_vendor_resolve
> --
> 2.39.5
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#211143): https://lists.openembedded.org/g/openembedded-core/message/211143
> Mute This Topic: https://lists.openembedded.org/mt/111123541/1050810
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [bruce.ashfield@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
next prev parent reply other threads:[~2025-02-11 23:00 UTC|newest]
Thread overview: 73+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 15:00 [RFC PATCH 00/30] Add vendor support for go, npm and rust Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 01/30] classes: create-spdx-2.2: use expanded FetchData for downloaded packages Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 02/30] lib: spdx30_tasks: use expanded FetchData for download files Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 03/30] classes: create-spdx-2.2: use name and version for download dependencies Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 04/30] lib: bb: fetch2: add support to unpack .crate files Stefan Herbrechtsmeier
2025-02-11 21:22 ` [OE-core] " Richard Purdie
2025-02-11 15:00 ` [RFC PATCH 05/30] lib: oe: add vendor module Stefan Herbrechtsmeier
2025-02-11 21:31 ` [OE-core] " Richard Purdie
2025-02-12 9:27 ` Stefan Herbrechtsmeier
2025-02-12 9:38 ` Richard Purdie
2025-02-12 12:21 ` Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 06/30] lib: oe: vendor: add cargo support Stefan Herbrechtsmeier
2025-02-12 10:32 ` [OE-core] " Alexander Kanavin
2025-02-12 12:45 ` Frédéric Martinsons
2025-02-12 16:29 ` Stefan Herbrechtsmeier
2025-02-12 17:48 ` Frédéric Martinsons
2025-02-13 8:53 ` Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 07/30] lib: oe: vendor: add go support Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 08/30] lib: oe: vendor: add npm support Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 09/30] oeqa: oelib: add vendor tests Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 10/30] conf: bitbake: add SRC_URI_FILES variable Stefan Herbrechtsmeier
2025-02-11 16:22 ` [bitbake-devel] " Peter Kjellerstedt
2025-02-12 8:55 ` Stefan Herbrechtsmeier
2025-02-12 9:49 ` [OE-core] " Alexander Kanavin
[not found] ` <18236D0FFBD06B89.28278@lists.openembedded.org>
2025-02-12 10:42 ` Alexander Kanavin
2025-02-11 19:06 ` Peter Kjellerstedt
2025-02-11 15:00 ` [RFC PATCH 11/30] classes: go: make source directory configurable Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 12/30] classes: go-mod: make class customizable Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 13/30] classes: add nodejs-arch class Stefan Herbrechtsmeier
2025-02-12 10:37 ` [OE-core] " Alexander Kanavin
2025-02-11 15:00 ` [RFC PATCH 14/30] classes: base: add get_src_uris and unpack_src_uris functions Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 15/30] classes: add early fetch, unpack and patch support Stefan Herbrechtsmeier
2025-02-11 22:27 ` [OE-core] " Richard Purdie
2025-02-12 12:21 ` Stefan Herbrechtsmeier
2025-02-11 22:32 ` Bruce Ashfield
2025-02-12 12:42 ` Stefan Herbrechtsmeier
2025-02-12 13:55 ` Bruce Ashfield
2025-02-12 14:40 ` Stefan Herbrechtsmeier
2025-02-12 11:08 ` Alexander Kanavin
2025-02-12 16:23 ` Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 16/30] classes: add vendor class Stefan Herbrechtsmeier
2025-02-11 19:17 ` [OE-core] " Peter Kjellerstedt
2025-02-11 15:00 ` [RFC PATCH 17/30] classes: add vendor class for cargo Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 18/30] classes: add vendor class for go Stefan Herbrechtsmeier
2025-02-11 22:59 ` Bruce Ashfield [this message]
2025-02-12 15:23 ` [OE-core] " Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 19/30] classes: add vendor class for npm Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 20/30] classes: add vendor_npm_build class Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 21/30] python3-bcrypt: mirgrate to vendor cargo class Stefan Herbrechtsmeier
2025-02-11 21:46 ` [OE-core] " Richard Purdie
2025-02-12 14:36 ` Stefan Herbrechtsmeier
2025-02-12 15:06 ` Richard Purdie
2025-02-12 17:27 ` Stefan Herbrechtsmeier
2025-02-12 15:07 ` Bruce Ashfield
2025-02-12 17:24 ` Stefan Herbrechtsmeier
2025-02-12 17:45 ` Bruce Ashfield
2025-02-12 17:52 ` Richard Purdie
2025-02-13 12:45 ` Stefan Herbrechtsmeier
2025-02-13 17:07 ` Bruce Ashfield
2025-02-11 15:00 ` [RFC PATCH 22/30] python3-cryptography: " Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 23/30] python3-maturin: " Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 24/30] python3-rpds-py: " Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 25/30] librsvg: " Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 26/30] librsvg: update dependecies to fix RUSTSEC-2024-0421 Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 27/30] [DO NOT MERGE] recipes: add crucible go demo Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 28/30] [DO NOT MERGE] recipes: add node-red npm demo Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 29/30] [DO NOT MERGE] recipes: add nucleoidai " Stefan Herbrechtsmeier
2025-02-11 15:00 ` [RFC PATCH 30/30] [DO NOT MERGE] classes: spdx: use version 2.2 Stefan Herbrechtsmeier
2025-02-11 23:14 ` [bitbake-devel] [RFC PATCH 00/30] Add vendor support for go, npm and rust Bruce Ashfield
2025-02-12 8:41 ` Stefan Herbrechtsmeier
2025-02-12 14:11 ` Bruce Ashfield
2025-02-13 8:36 ` Stefan Herbrechtsmeier
2025-02-13 17:01 ` Bruce Ashfield
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z6vWayPuHfEIrzEF@gmail.com \
--to=bruce.ashfield@gmail.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=stefan.herbrechtsmeier-oss@weidmueller.com \
--cc=stefan.herbrechtsmeier@weidmueller.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox