Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/pkg-golang: enable pkg specific go env also for download step
@ 2022-12-04 14:06 Patrick Gerber via buildroot
  2022-12-04 14:06 ` [Buildroot] [PATCH 2/2] package/mender-artifact: remove unnecessary GO_ENV Patrick Gerber via buildroot
  2022-12-04 17:35 ` [Buildroot] [PATCH 1/2] package/pkg-golang: enable pkg specific go env also for download step Yann E. MORIN
  0 siblings, 2 replies; 4+ messages in thread
From: Patrick Gerber via buildroot @ 2022-12-04 14:06 UTC (permalink / raw)
  To: buildroot, yann.morin.1998; +Cc: Patrick Gerber

Currently package secific go env is used only during package build step.

Go vendering is done during the download step and it's sometimes required
to specify package secific go env also for this step.

For example, when importing custom go modules who are hosted on a private
host, it’s required to set GOPRIVATE to avoid public sum checking.

Signed-off-by: Patrick Gerber <pge@ik.me>
---
 package/pkg-golang.mk | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
index 0b3dc3d32f..cdc67b32c0 100644
--- a/package/pkg-golang.mk
+++ b/package/pkg-golang.mk
@@ -87,7 +87,8 @@ $(2)_POST_PATCH_HOOKS += $(2)_GEN_GOMOD
 $(2)_DOWNLOAD_POST_PROCESS = go
 $(2)_DL_ENV += \
 	$$(HOST_GO_COMMON_ENV) \
-	GOPROXY=direct
+	GOPROXY=direct \
+	$$($(2)_GO_ENV)
 
 # Due to vendoring, it is pretty likely that not all licenses are
 # listed in <pkg>_LICENSE.
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH 2/2] package/mender-artifact: remove unnecessary GO_ENV
  2022-12-04 14:06 [Buildroot] [PATCH 1/2] package/pkg-golang: enable pkg specific go env also for download step Patrick Gerber via buildroot
@ 2022-12-04 14:06 ` Patrick Gerber via buildroot
  2022-12-04 17:36   ` Yann E. MORIN
  2022-12-04 17:35 ` [Buildroot] [PATCH 1/2] package/pkg-golang: enable pkg specific go env also for download step Yann E. MORIN
  1 sibling, 1 reply; 4+ messages in thread
From: Patrick Gerber via buildroot @ 2022-12-04 14:06 UTC (permalink / raw)
  To: buildroot, yann.morin.1998; +Cc: Patrick Gerber

All go packages are built with:
GOFLAGS="-mod=vendor"
(see HOST_GO_COMMON_ENV in go/go.mk)

Signed-off-by: Patrick Gerber <pge@ik.me>
---
 package/mender-artifact/mender-artifact.mk | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/package/mender-artifact/mender-artifact.mk b/package/mender-artifact/mender-artifact.mk
index 1031166f34..6ade624a23 100644
--- a/package/mender-artifact/mender-artifact.mk
+++ b/package/mender-artifact/mender-artifact.mk
@@ -86,14 +86,6 @@ HOST_MENDER_ARTIFACT_LICENSE_FILES = \
 
 HOST_MENDER_ARTIFACT_DEPENDENCIES = host-xz
 
-# By default, go will attempt to download needed modules before building, which
-# is not desirable. This behavior also causes permission issues when cleaning,
-# as go downloads modules as read-only by default. Because mender-artifact
-# includes the modules in the vendor directory, mod=vendor prevents the package
-# from downloading the go modules during the build process and prevents
-# permission issues when cleaning.
-HOST_MENDER_ARTIFACT_GO_ENV = GOFLAGS="-mod=vendor"
-
 HOST_MENDER_ARTIFACT_LDFLAGS = -X github.com/mendersoftware/mender-artifact/cli.Version=$(HOST_MENDER_ARTIFACT_VERSION)
 
 HOST_MENDER_ARTIFACT_BIN_NAME = mender-artifact
-- 
2.25.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH 1/2] package/pkg-golang: enable pkg specific go env also for download step
  2022-12-04 14:06 [Buildroot] [PATCH 1/2] package/pkg-golang: enable pkg specific go env also for download step Patrick Gerber via buildroot
  2022-12-04 14:06 ` [Buildroot] [PATCH 2/2] package/mender-artifact: remove unnecessary GO_ENV Patrick Gerber via buildroot
@ 2022-12-04 17:35 ` Yann E. MORIN
  1 sibling, 0 replies; 4+ messages in thread
From: Yann E. MORIN @ 2022-12-04 17:35 UTC (permalink / raw)
  To: Patrick Gerber; +Cc: buildroot

Patrick, All,

Thanks for this respin. :-)

On 2022-12-04 15:06 +0100, Patrick Gerber spake thusly:
> Currently package secific go env is used only during package build step.
> 
> Go vendering is done during the download step and it's sometimes required
> to specify package secific go env also for this step.
> 
> For example, when importing custom go modules who are hosted on a private
> host, it’s required to set GOPRIVATE to avoid public sum checking.
> 
> Signed-off-by: Patrick Gerber <pge@ik.me>
> ---
>  package/pkg-golang.mk | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
> index 0b3dc3d32f..cdc67b32c0 100644
> --- a/package/pkg-golang.mk
> +++ b/package/pkg-golang.mk
> @@ -87,7 +87,8 @@ $(2)_POST_PATCH_HOOKS += $(2)_GEN_GOMOD
>  $(2)_DOWNLOAD_POST_PROCESS = go
>  $(2)_DL_ENV += \
>  	$$(HOST_GO_COMMON_ENV) \
> -	GOPROXY=direct
> +	GOPROXY=direct \
> +	$$($(2)_GO_ENV)

As you can see, the pkg-golang infra extends $(2)_DL_ENV, so you can
already achieve what you want by adding the following to your package:
    FOO_DL_ENV = GOPRIVATE=blablabla

or even:
    FOO_GO_ENV = GOPRIVATE=blablabla
    FOO_DL_ENV = $(FOO_GO_ENV)

Also, what was probably not very clear in my previous review, is the
concern whether we can have some package that set FOO_GO_ENV to
something that would break the download step.

So I had a look at the official documentation for generic environment
variables that apply to the go command [0]; I could not spot a generic
variable that would obviously have an impact on downloads, unless also
listed as those that just apply to the go-mod command [1].

It thus looks like the correct behaviour to use the build environment
variables during hte download. Still, I was not sure this was material
for the master branch, so I applied to next. Thanks!

[0] https://pkg.go.dev/cmd/go#hdr-Environment_variables
[1] https://go.dev/ref/mod#environment-variables

Regards,
Yann E. MORIN.

>  # Due to vendoring, it is pretty likely that not all licenses are
>  # listed in <pkg>_LICENSE.
> -- 
> 2.25.1
> 

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH 2/2] package/mender-artifact: remove unnecessary GO_ENV
  2022-12-04 14:06 ` [Buildroot] [PATCH 2/2] package/mender-artifact: remove unnecessary GO_ENV Patrick Gerber via buildroot
@ 2022-12-04 17:36   ` Yann E. MORIN
  0 siblings, 0 replies; 4+ messages in thread
From: Yann E. MORIN @ 2022-12-04 17:36 UTC (permalink / raw)
  To: Patrick Gerber; +Cc: buildroot

Patrick, All,

On 2022-12-04 15:06 +0100, Patrick Gerber via buildroot spake thusly:
> All go packages are built with:
> GOFLAGS="-mod=vendor"
> (see HOST_GO_COMMON_ENV in go/go.mk)
> 
> Signed-off-by: Patrick Gerber <pge@ik.me>

I slightly extended the commit log to explain why mender-artifacts had
that settings to begin with and applied to next, thanks.

Regards,
Yann E. MORIN.

> ---
>  package/mender-artifact/mender-artifact.mk | 8 --------
>  1 file changed, 8 deletions(-)
> 
> diff --git a/package/mender-artifact/mender-artifact.mk b/package/mender-artifact/mender-artifact.mk
> index 1031166f34..6ade624a23 100644
> --- a/package/mender-artifact/mender-artifact.mk
> +++ b/package/mender-artifact/mender-artifact.mk
> @@ -86,14 +86,6 @@ HOST_MENDER_ARTIFACT_LICENSE_FILES = \
>  
>  HOST_MENDER_ARTIFACT_DEPENDENCIES = host-xz
>  
> -# By default, go will attempt to download needed modules before building, which
> -# is not desirable. This behavior also causes permission issues when cleaning,
> -# as go downloads modules as read-only by default. Because mender-artifact
> -# includes the modules in the vendor directory, mod=vendor prevents the package
> -# from downloading the go modules during the build process and prevents
> -# permission issues when cleaning.
> -HOST_MENDER_ARTIFACT_GO_ENV = GOFLAGS="-mod=vendor"
> -
>  HOST_MENDER_ARTIFACT_LDFLAGS = -X github.com/mendersoftware/mender-artifact/cli.Version=$(HOST_MENDER_ARTIFACT_VERSION)
>  
>  HOST_MENDER_ARTIFACT_BIN_NAME = mender-artifact
> -- 
> 2.25.1
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-12-04 17:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-04 14:06 [Buildroot] [PATCH 1/2] package/pkg-golang: enable pkg specific go env also for download step Patrick Gerber via buildroot
2022-12-04 14:06 ` [Buildroot] [PATCH 2/2] package/mender-artifact: remove unnecessary GO_ENV Patrick Gerber via buildroot
2022-12-04 17:36   ` Yann E. MORIN
2022-12-04 17:35 ` [Buildroot] [PATCH 1/2] package/pkg-golang: enable pkg specific go env also for download step Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox