summaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
Diffstat (limited to 'package')
-rw-r--r--package/pkg-gentargets.mk61
-rw-r--r--package/pkg-utils.mk25
2 files changed, 86 insertions, 0 deletions
diff --git a/package/pkg-gentargets.mk b/package/pkg-gentargets.mk
index 5da9cdc70..51053359a 100644
--- a/package/pkg-gentargets.mk
+++ b/package/pkg-gentargets.mk
@@ -180,6 +180,7 @@ define GENTARGETS_INNER
$(2)_TYPE = $(5)
$(2)_NAME = $(1)
+$(2)_RAWNAME = $(patsubst host-%,%,$(1))
# Keep the package version that may contain forward slashes in the _DL_VERSION
# variable, then replace all forward slashes ('/') by underscores ('_') to
@@ -245,6 +246,20 @@ $(2)_OVERRIDE_SRCDIR = $($(2)_SITE)
endif
endif
+ifndef $(2)_LICENSE
+ ifdef $(3)_LICENSE
+ $(2)_LICENSE = $($(3)_LICENSE)
+ endif
+endif
+
+ifndef $(2)_LICENSE_FILES
+ ifdef $(3)_LICENSE_FILES
+ $(2)_LICENSE_FILES = $($(3)_LICENSE_FILES)
+ endif
+endif
+
+$(2)_LICENSE ?= unknown
+
$(2)_DEPENDENCIES ?= $(filter-out $(1),$(patsubst host-host-%,host-%,$(addprefix host-,$($(3)_DEPENDENCIES))))
$(2)_INSTALL_STAGING ?= NO
@@ -412,6 +427,52 @@ else
$(2)_KCONFIG_VAR = BR2_PACKAGE_$(2)
endif
+# legal-info: declare dependencies and set values used later for the manifest
+ifneq ($$($(2)_LICENSE),PROPRIETARY)
+ifneq ($$($(2)_SITE_METHOD),local)
+ifneq ($$($(2)_SITE_METHOD),override)
+# Packages that have a tarball need it downloaded and extracted beforehand
+$(1)-legal-info: $(1)-extract $(REDIST_SOURCES_DIR)
+$(2)_MANIFEST_TARBALL = $$($(2)_SOURCE)
+ifneq ($$($(2)_LICENSE_FILES),)
+$(2)_MANIFEST_LICENSE_FILES = $$($(2)_LICENSE_FILES)
+endif
+endif
+endif
+endif
+# defaults for packages without tarball or license files
+$(2)_MANIFEST_TARBALL ?= not saved
+$(2)_MANIFEST_LICENSE_FILES ?= not saved
+
+# legal-info: produce legally relevant info.
+$(1)-legal-info:
+# Packages without a source are assumed to be part of Buildroot, skip them.
+ifneq ($(call qstrip,$$($(2)_SOURCE)),)
+ifeq ($$($(2)_LICENSE),PROPRIETARY)
+# Proprietary packages: nothing to save
+else ifeq ($$($(2)_SITE_METHOD),local)
+# Packages without a tarball: don't save and warn
+ @$(call legal-warning-pkg-savednothing,$$($(2)_RAWNAME),local)
+else ifeq ($$($(2)_SITE_METHOD),override)
+ @$(call legal-warning-pkg-savednothing,$$($(2)_RAWNAME),override)
+else
+# Other packages
+# Save license files if defined
+ifeq ($(call qstrip,$$($(2)_LICENSE_FILES)),)
+ @$(call legal-license-nofiles,$$($(2)_RAWNAME))
+ @$(call legal-warning-pkg,$$($(2)_RAWNAME),cannot save license ($(2)_LICENSE_FILES not defined))
+else
+ @for F in $$($(2)_LICENSE_FILES); do \
+ $(call legal-license-file,$$($(2)_RAWNAME),$$$${F},$$($(2)_DIR)/$$$${F}); \
+ done
+endif
+# Copy the source tarball (just hardlink if possible)
+ @cp -l $(DL_DIR)/$$($(2)_SOURCE) $(REDIST_SOURCES_DIR) 2>/dev/null || \
+ cp $(DL_DIR)/$$($(2)_SOURCE) $(REDIST_SOURCES_DIR)
+endif
+ @$(call legal-manifest,$$($(2)_RAWNAME),$$($(2)_VERSION),$$($(2)_LICENSE),$$($(2)_MANIFEST_LICENSE_FILES),$$($(2)_MANIFEST_TARBALL))
+endif # ifneq ($(call qstrip,$$($(2)_SOURCE)),)
+
# add package to the general list of targets if requested by the buildroot
# configuration
ifeq ($$($$($(2)_KCONFIG_VAR)),y)
diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index 0c55a9d71..35abb17ce 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -92,3 +92,28 @@ define sep
endef
+
+#
+# legal-info helper functions
+#
+LEGAL_INFO_SEPARATOR="::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
+legal-warning=echo "WARNING: $(1)" >>$(LEGAL_WARNINGS)
+legal-warning-pkg=echo "WARNING: $(1): $(2)" >>$(LEGAL_WARNINGS)
+define legal-warning-pkg-savednothing # pkg, {local|override}
+ $(call legal-warning-pkg,$(1),sources and license files not saved ($(2) packages not handled))
+endef
+legal-manifest=echo "$(1),$(2),$(3),$(4),$(5)" >>$(LEGAL_MANIFEST_CSV)
+define legal-license-header
+ echo -e "$(LEGAL_INFO_SEPARATOR)\n\t$(1):" \
+ "$(2)\n$(LEGAL_INFO_SEPARATOR)\n\n" >>$(LEGAL_LICENSES_TXT)
+endef
+define legal-license-nofiles
+ $(call legal-license-header,$(1),unknown license file(s))
+endef
+define legal-license-file # pkg, filename, file-fullpath
+ $(call legal-license-header,$(1),$(2) file) && \
+ cat $(3) >>$(LEGAL_LICENSES_TXT) && \
+ echo >>$(LEGAL_LICENSES_TXT) && \
+ mkdir -p $(LICENSE_FILES_DIR)/$(1)/ && \
+ cp $(3) $(LICENSE_FILES_DIR)/$(1)/
+endef