All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [RFC PATCH] Handle _LICENSE_FILES with full path
@ 2021-11-24 15:18 Cyril Bur
  2021-11-24 19:41 ` Thomas Petazzoni
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Bur @ 2021-11-24 15:18 UTC (permalink / raw)
  To: buildroot; +Cc: Luca Ceresoli, Thomas Petazzoni

legal-info currently assumes that a packages _LICENSE_FILES will be a
path or a filename relative to the source of the package.

There is nothing preventing _LICENSE_FILES from containing a full path,
probably using _PKGDIR within the package .mk file. When this happens,
the legal-info process simply adds the build directory on the front of
the _LICENSE_FILES resulting in a failed cp of the file.

This patch simply performs a check to see if the _LICENSE_FILES path
with the build directory prepended exists (as is the case for all
packages currently) and uses that. Otherwise it will assume that
the _LICENSE_FILES file is a fullpath and attempt to use that.

Signed-off-by: Cyril Bur <cyrilbur@gmail.com>
---
This might well be one of those "don't do that" cases and just force
these unique packages to just have some kind of post extract hook to
put the file in the build directory.

Having said that, I don't think the fix is particularly invasive.

 package/pkg-generic.mk | 2 +-
 package/pkg-utils.mk   | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk
index ded5176428..e6d9f457e4 100644
--- a/package/pkg-generic.mk
+++ b/package/pkg-generic.mk
@@ -1139,7 +1139,7 @@ ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
 ifeq ($$(call qstrip,$$($(2)_LICENSE_FILES)),)
 	$(Q)$$(call legal-warning-pkg,$$($(2)_BASENAME_RAW),cannot save license ($(2)_LICENSE_FILES not defined))
 else
-	$(Q)$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$($(2)_RAWNAME),$$($(2)_BASENAME_RAW),$$($(2)_HASH_FILE),$$(F),$$($(2)_DIR)/$$(F),$$(call UPPERCASE,$(4)))$$(sep))
+	$(Q)$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$($(2)_RAWNAME),$$($(2)_BASENAME_RAW),$$($(2)_HASH_FILE),$$(F),$$(call prefix-if-needed,$$($(2)_DIR),$$(F)),$$(call UPPERCASE,$(4)))$$(sep))
 endif # license files
 
 ifeq ($$($(2)_SITE_METHOD),local)
diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index ae3c7f9da9..0c287a0f50 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -207,6 +207,10 @@ endif
 #
 LEGAL_INFO_SEPARATOR = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
 
+define prefix-if-needed # builddir, filename
+	$(if $(wildcard $(1)/$(2)),$(1)/$(2),$(2))
+endef
+
 define legal-warning # text
 	echo "WARNING: $(1)" >>$(LEGAL_WARNINGS)
 endef
-- 
2.34.0

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

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

* Re: [Buildroot] [RFC PATCH] Handle _LICENSE_FILES with full path
  2021-11-24 15:18 [Buildroot] [RFC PATCH] Handle _LICENSE_FILES with full path Cyril Bur
@ 2021-11-24 19:41 ` Thomas Petazzoni
  2021-11-25 12:25   ` Cyril Bur
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni @ 2021-11-24 19:41 UTC (permalink / raw)
  To: Cyril Bur; +Cc: Luca Ceresoli, buildroot

Hello Cyril,

On Wed, 24 Nov 2021 15:18:27 +0000
Cyril Bur <cyrilbur@gmail.com> wrote:

> legal-info currently assumes that a packages _LICENSE_FILES will be a
> path or a filename relative to the source of the package.
> 
> There is nothing preventing _LICENSE_FILES from containing a full path,
> probably using _PKGDIR within the package .mk file. When this happens,
> the legal-info process simply adds the build directory on the front of
> the _LICENSE_FILES resulting in a failed cp of the file.
> 
> This patch simply performs a check to see if the _LICENSE_FILES path
> with the build directory prepended exists (as is the case for all
> packages currently) and uses that. Otherwise it will assume that
> the _LICENSE_FILES file is a fullpath and attempt to use that.
> 
> Signed-off-by: Cyril Bur <cyrilbur@gmail.com>

Could you clarify the use case with a specific example ?

Thanks!

Thoimas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

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

* Re: [Buildroot] [RFC PATCH] Handle _LICENSE_FILES with full path
  2021-11-24 19:41 ` Thomas Petazzoni
@ 2021-11-25 12:25   ` Cyril Bur
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Bur @ 2021-11-25 12:25 UTC (permalink / raw)
  To: Thomas Petazzoni; +Cc: Luca Ceresoli, buildroot

On Wed, 24 Nov 2021 20:41:27 +0100
Thomas Petazzoni <thomas.petazzoni@bootlin.com> wrote:

> Hello Cyril,
> 
> On Wed, 24 Nov 2021 15:18:27 +0000
> Cyril Bur <cyrilbur@gmail.com> wrote:
> 
> > legal-info currently assumes that a packages _LICENSE_FILES will be
> > a path or a filename relative to the source of the package.
> > 
> > There is nothing preventing _LICENSE_FILES from containing a full
> > path, probably using _PKGDIR within the package .mk file. When this
> > happens, the legal-info process simply adds the build directory on
> > the front of the _LICENSE_FILES resulting in a failed cp of the
> > file.
> > 
> > This patch simply performs a check to see if the _LICENSE_FILES path
> > with the build directory prepended exists (as is the case for all
> > packages currently) and uses that. Otherwise it will assume that
> > the _LICENSE_FILES file is a fullpath and attempt to use that.
> > 
> > Signed-off-by: Cyril Bur <cyrilbur@gmail.com>  
> 
> Could you clarify the use case with a specific example ?
> 

Hi Thomas,

Having reread that commit message it seems i'm out of practice (was
never very good to begin with). I'll send another and include a
concrete example.

Cyril

> Thanks!
> 
> Thoimas

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

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

end of thread, other threads:[~2021-11-25 12:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-24 15:18 [Buildroot] [RFC PATCH] Handle _LICENSE_FILES with full path Cyril Bur
2021-11-24 19:41 ` Thomas Petazzoni
2021-11-25 12:25   ` Cyril Bur

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.