kumquat-buildroot/package/pkg-utils.mk
Yann E. MORIN 63eeb9a383 core/legal-info: use hash file from version sub-dir
When we have multiple versions for a package, and the licensing terms
depend on the version actually selected (e.g. like Qt5), storing the
hashes for those license files in the .hash file is broken: the infra
will ensure that all hashes for a file do match, which would not be the
case here.

We fix that by first looking for a hash file in the version sub-dir
first, and if that does not exist, then we use the main hash file.

Drop the useless intermediate variable 'ret'.

Update the documentation accordingly.

Reported-by: Joshua Henderson <joshua.henderson@microchip.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Joshua Henderson <joshua.henderson@microchip.com>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Cc: Luca Ceresoli <luca@lucaceresoli.net>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2017-07-29 22:34:41 +02:00

98 lines
3.2 KiB
Makefile

################################################################################
#
# This file contains various utility functions used by the package
# infrastructure, or by the packages themselves.
#
################################################################################
#
# Manipulation of .config files based on the Kconfig
# infrastructure. Used by the BusyBox package, the Linux kernel
# package, and more.
#
define KCONFIG_ENABLE_OPT # (option, file)
$(SED) "/\\<$(1)\\>/d" $(2)
echo '$(1)=y' >> $(2)
endef
define KCONFIG_SET_OPT # (option, value, file)
$(SED) "/\\<$(1)\\>/d" $(3)
echo '$(1)=$(2)' >> $(3)
endef
define KCONFIG_DISABLE_OPT # (option, file)
$(SED) "/\\<$(1)\\>/d" $(2)
echo '# $(1) is not set' >> $(2)
endef
# Helper functions to determine the name of a package and its
# directory from its makefile directory, using the $(MAKEFILE_LIST)
# variable provided by make. This is used by the *-package macros to
# automagically find where the package is located.
pkgdir = $(dir $(lastword $(MAKEFILE_LIST)))
pkgname = $(lastword $(subst /, ,$(pkgdir)))
# Define extractors for different archive suffixes
INFLATE.bz2 = $(BZCAT)
INFLATE.gz = $(ZCAT)
INFLATE.lz = $(LZCAT)
INFLATE.lzma = $(XZCAT)
INFLATE.tbz = $(BZCAT)
INFLATE.tbz2 = $(BZCAT)
INFLATE.tgz = $(ZCAT)
INFLATE.xz = $(XZCAT)
INFLATE.tar = cat
# suitable-extractor(filename): returns extractor based on suffix
suitable-extractor = $(INFLATE$(suffix $(1)))
# extractor-dependency(filename): returns extractor for 'filename' if the
# extractor is a dependency. If we build the extractor return nothing.
# $(firstword) is used here because the extractor can have arguments, like
# ZCAT="gzip -d -c", and to check for the dependency we only want 'gzip'.
extractor-dependency = $(firstword $(INFLATE$(filter-out \
$(EXTRACTOR_DEPENDENCY_PRECHECKED_EXTENSIONS),$(suffix $(1)))))
# check-deprecated-variable -- throw an error on deprecated variables
# example:
# $(eval $(call check-deprecated-variable,FOO_MAKE_OPT,FOO_MAKE_OPTS))
define check-deprecated-variable # (deprecated var, new var)
ifneq ($$(origin $(1)),undefined)
$$(error Package error: use $(2) instead of $(1). Please fix your .mk file)
endif
endef
#
# legal-info helper functions
#
LEGAL_INFO_SEPARATOR = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
define legal-warning # text
echo "WARNING: $(1)" >>$(LEGAL_WARNINGS)
endef
define legal-warning-pkg # pkg, text
echo "WARNING: $(1): $(2)" >>$(LEGAL_WARNINGS)
endef
define legal-warning-nosource # pkg, {local|override}
$(call legal-warning-pkg,$(1),sources not saved ($(2) packages not handled))
endef
define legal-manifest # pkg, version, license, license-files, source, url, {HOST|TARGET}
echo '"$(1)","$(2)","$(3)","$(4)","$(5)","$(6)"' >>$(LEGAL_MANIFEST_CSV_$(7))
endef
define legal-license-file # pkgname, pkgname-pkgver, pkgdir, filename, file-fullpath, {HOST|TARGET}
mkdir -p $(LICENSE_FILES_DIR_$(6))/$(2)/$(dir $(4)) && \
{ \
if [ -f $(3)/$($(PKG)_VERSION)/$(1).hash ]; then \
support/download/check-hash $(3)/$($(PKG)_VERSION)/$(1).hash $(5) $(4); \
else \
support/download/check-hash $(3)/$(1).hash $(5) $(4); \
fi; \
case $${?} in (0|3) ;; (*) exit 1;; esac; \
} && \
cp $(5) $(LICENSE_FILES_DIR_$(6))/$(2)/$(4)
endef