diff mbox series

[4/8] package/pkg-golang: handle licensing terms for host-only packages

Message ID 243109e5e05b74bbf150d902a55625da4844564d.1698941362.git.yann.morin@orange.com
State Accepted
Headers show
Series [1/8] package/pkg-cargo: don't expand license info when empty | expand

Commit Message

Yann E. MORIN Nov. 2, 2023, 4:09 p.m. UTC
From: "Yann E. MORIN" <yann.morin@orange.com>

The licensing terms are inherited from the target variant to the host
variant: when the host _LICENSE is empty, then the value of the target
_LICENSE is used.

However, for the golang infra, we want to append a little blurb about
vendored depndencies. If the package is a host-only, then it would
inherit the target _LICENSE, i.e. the variable without the leading
HOST_. If that is defined, this is inherited in the generic-package part
of the infra, but in the golang infra, we saw an empty variable, and so
we would not add the vendoring blurb.

We can't move the condition appending that blurb, after we called into
the generic-package infra, otherwise in that case, we'd have the
opposite issue for packages that are both target and host packages,
where the blurb would be duplicated for host packages...

Instead, we workaround the issue by duplicating the heuristic to inherit
the target value, from the generic- into the golang-package infra.

Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
---
 package/pkg-golang.mk | 9 +++++++++
 1 file changed, 9 insertions(+)

Comments

Arnout Vandecappelle Nov. 4, 2023, 4:54 p.m. UTC | #1
On 02/11/2023 17:09, yann.morin@orange.com wrote:
> From: "Yann E. MORIN" <yann.morin@orange.com>
> 
> The licensing terms are inherited from the target variant to the host
> variant: when the host _LICENSE is empty, then the value of the target
> _LICENSE is used.
> 
> However, for the golang infra, we want to append a little blurb about
> vendored depndencies. If the package is a host-only, then it would
> inherit the target _LICENSE, i.e. the variable without the leading
> HOST_. If that is defined, this is inherited in the generic-package part
> of the infra, but in the golang infra, we saw an empty variable, and so
> we would not add the vendoring blurb.
> 
> We can't move the condition appending that blurb, after we called into
> the generic-package infra, otherwise in that case, we'd have the
> opposite issue for packages that are both target and host packages,
> where the blurb would be duplicated for host packages...
> 
> Instead, we workaround the issue by duplicating the heuristic to inherit
> the target value, from the generic- into the golang-package infra.
> 
> Signed-off-by: Yann E. MORIN <yann.morin@orange.com>
> ---
>   package/pkg-golang.mk | 9 +++++++++
>   1 file changed, 9 insertions(+)
> 
> diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
> index 1fa0b001e0..8e27602d41 100644
> --- a/package/pkg-golang.mk
> +++ b/package/pkg-golang.mk
> @@ -91,6 +91,15 @@ $(2)_DL_ENV += \
>   	GOPROXY=direct \
>   	$$($(2)_GO_ENV)
>   
> +# Because we append vendored info, we can't rely on the values being empty
> +# once we eventually get into the generic-package infra. So, we duplicate
> +# the heuristics here
> +ifndef $(2)_LICENSE
> +  ifdef $(3)_LICENSE
> +    $(2)_LICENSE = $$($(3)_LICENSE)
> +  endif
> +endif

  This isn't a very elegant solution, but I can't think of anything better.

  Applied the first 4 patches of this series to master, thanks.

  Regards,
  Arnout

> +
>   # Due to vendoring, it is pretty likely that not all licenses are
>   # listed in <pkg>_LICENSE. If the license is unset, it is "unknown"
>   # so adding unknowns to some unknown is still some other unkown,
diff mbox series

Patch

diff --git a/package/pkg-golang.mk b/package/pkg-golang.mk
index 1fa0b001e0..8e27602d41 100644
--- a/package/pkg-golang.mk
+++ b/package/pkg-golang.mk
@@ -91,6 +91,15 @@  $(2)_DL_ENV += \
 	GOPROXY=direct \
 	$$($(2)_GO_ENV)
 
+# Because we append vendored info, we can't rely on the values being empty
+# once we eventually get into the generic-package infra. So, we duplicate
+# the heuristics here
+ifndef $(2)_LICENSE
+  ifdef $(3)_LICENSE
+    $(2)_LICENSE = $$($(3)_LICENSE)
+  endif
+endif
+
 # Due to vendoring, it is pretty likely that not all licenses are
 # listed in <pkg>_LICENSE. If the license is unset, it is "unknown"
 # so adding unknowns to some unknown is still some other unkown,