diff mbox series

bitbake: forward proxy env variables if network access is enabled

Message ID 20250725111347.1812105-1-alexander.merkle@lauterbach.com
State New
Headers show
Series bitbake: forward proxy env variables if network access is enabled | expand

Commit Message

Alexander Merkle July 25, 2025, 11:13 a.m. UTC
For steps that set `network` manually e.g. `do_compile[network] = "1"`
the proxy environment variables should be forwarded. Otherwise the step
may not have full access when corporate proxies are used.
There seem to be various examples around that use e.g. the go.bbclass
which downloads modules while the `do_compile` step.

Signed-off-by: Alexander Merkle <alexander.merkle@lauterbach.com>
---
 bitbake/bin/bitbake-worker | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Alexander Kanavin July 26, 2025, 10:24 p.m. UTC | #1
I don't quite understand. How does do_fetch work then, without having
to do this export_proxies call? It also relies on do_compile[network]
= "1".

Alex

On Fri, 25 Jul 2025 at 13:14, Alexander Merkle via
lists.openembedded.org
<alexander.merkle=lauterbach.com@lists.openembedded.org> wrote:
>
> For steps that set `network` manually e.g. `do_compile[network] = "1"`
> the proxy environment variables should be forwarded. Otherwise the step
> may not have full access when corporate proxies are used.
> There seem to be various examples around that use e.g. the go.bbclass
> which downloads modules while the `do_compile` step.
>
> Signed-off-by: Alexander Merkle <alexander.merkle@lauterbach.com>
> ---
>  bitbake/bin/bitbake-worker | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
> index d2b146a6a9..4012a1a1fb 100755
> --- a/bitbake/bin/bitbake-worker
> +++ b/bitbake/bin/bitbake-worker
> @@ -292,6 +292,10 @@ def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
>                  exports = bb.data.exported_vars(the_data)
>
>                  bb.utils.empty_environment()
> +
> +                if bb.utils.to_boolean(the_data.getVarFlag(taskname, 'network')):
> +                    bb.utils.export_proxies(the_data)
> +
>                  for e, v in exports:
>                      os.environ[e] = v
>
> --
> 2.39.5
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#17809): https://lists.openembedded.org/g/bitbake-devel/message/17809
> Mute This Topic: https://lists.openembedded.org/mt/114335899/1686489
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
Alexander Kanavin July 26, 2025, 10:28 p.m. UTC | #2
On Sun, 27 Jul 2025 at 00:24, Alexander Kanavin via
lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org>
wrote:
>
> I don't quite understand. How does do_fetch work then, without having
> to do this export_proxies call? It also relies on do_compile[network]
> = "1".

Specifically, there's do_fetch[network] = "1" in
meta/classes-global/base.bbclass.

Alex
Alexander Merkle July 28, 2025, 5:30 a.m. UTC | #3
As far as I understood the `fetch2` library sets up it's own 
environment,compare [1].

[1] 
https://git.yoctoproject.org/poky/tree/bitbake/lib/bb/fetch2/__init__.py#n873

On 27.07.2025 00:29, Alexander Kanavin via lists.openembedded.org wrote:
> On Sun, 27 Jul 2025 at 00:24, Alexander Kanavin via
> lists.openembedded.org <alex.kanavin=gmail.com@lists.openembedded.org>
> wrote:
>> I don't quite understand. How does do_fetch work then, without having
>> to do this export_proxies call? It also relies on do_compile[network]
>> = "1".
> Specifically, there's do_fetch[network] = "1" in
> meta/classes-global/base.bbclass.
>
> Alex
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#17811): https://lists.openembedded.org/g/bitbake-devel/message/17811
> Mute This Topic: https://lists.openembedded.org/mt/114335899/9941510
> Group Owner: bitbake-devel+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [alexander.merkle@lauterbach.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker
index d2b146a6a9..4012a1a1fb 100755
--- a/bitbake/bin/bitbake-worker
+++ b/bitbake/bin/bitbake-worker
@@ -292,6 +292,10 @@  def fork_off_task(cfg, data, databuilder, workerdata, extraconfigdata, runtask):
                 exports = bb.data.exported_vars(the_data)
 
                 bb.utils.empty_environment()
+
+                if bb.utils.to_boolean(the_data.getVarFlag(taskname, 'network')):
+                    bb.utils.export_proxies(the_data)
+
                 for e, v in exports:
                     os.environ[e] = v