summaryrefslogtreecommitdiffstats
path: root/package
diff options
context:
space:
mode:
authorLuca Ceresoli <luca@lucaceresoli.net>2012-05-17 19:33:00 +0200
committerThomas Petazzoni <thomas.petazzoni@free-electrons.com>2012-07-17 19:05:49 +0200
commit7e76f904d208e4ef0bf722583897d4044264f546 (patch)
tree42d13db7331256d045dfd44e7a847d2d3533589c /package
parent8d19377d24b2b1d6ded278559c16252ec320bef6 (diff)
downloadbuildroot-novena-7e76f904d208e4ef0bf722583897d4044264f546.tar.gz
buildroot-novena-7e76f904d208e4ef0bf722583897d4044264f546.zip
legal-info: infrastructure to collect legally-relevant material
This allows to automatically collect material that may be needed to comply with the license of packages that Buildroot prepares for the target device. The core of the implementation is made by the following parts: - in package/pkg-utils.mk some helper functions are defined for common actions such as generating a warning, producing info about a package etc; - in package/pkg-gentargets.mk, within the GENTARGETS framework, a new <PKG>-legal-info target produces all the info for a given package; - Makefile implements the top-level targets: - legal-info-prepare creates the output directory and produces legal info about Buildroot itself and the toolchain, which mostly means just warning the user that this is not implemented; - legal-info, the only target that is supposed to be used directly, depends on all of the above and finishes things by producing the README files from the various pieces. Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net> Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
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