[Buildroot] [RFC PATCH v2] Handle _LICENSE_FILES with full path
Cyril Bur
cyrilbur at gmail.com
Thu Nov 25 12:48:44 UTC 2021
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.
When this happens, the legal-info process adds the build directory on
the front of the _LICENSE_FILES value resulting in a failed cp of the
file.
This patch adds 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 full path.
An 'offending' package .mk file could look something like this:
LIBFOO_VERSION = 1.0
LIBFOO_SOURCE = libfoo-$(LIBFOO_VERSION).tar.gz
LIBFOO_SITE = http://www.foosoftware.org/download
LIBFOO_LICENSE = GPL-3.0+
LIBFOO_LICENSE_FILES = $(LIBFOO_PKGDIR)/COPYING
[...]
$(eval $(generic-package))
Signed-off-by: Cyril Bur <cyrilbur at gmail.com>
---
Adding a licence file to buildroot is probably odd and a strange thing
to do, we're doing this internally (and I do hope I can push the package
soon) with https://github.com/BrianGladman/modes
V1->V2 Reworked commit message and added example as requested by Thomas
Petazzoni
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
More information about the buildroot
mailing list