2013-06-05 17:53:30 -06:00
|
|
|
################################################################################
|
2012-04-17 08:45:20 -06:00
|
|
|
#
|
|
|
|
# This file contains various utility functions used by the package
|
|
|
|
# infrastructure, or by the packages themselves.
|
|
|
|
#
|
2013-06-05 17:53:30 -06:00
|
|
|
################################################################################
|
2012-04-17 08:45:20 -06:00
|
|
|
|
|
|
|
#
|
|
|
|
# Manipulation of .config files based on the Kconfig
|
2014-05-31 01:55:35 -06:00
|
|
|
# infrastructure. Used by the BusyBox package, the Linux kernel
|
2012-04-17 08:45:20 -06:00
|
|
|
# package, and more.
|
|
|
|
#
|
|
|
|
|
2014-07-14 05:50:25 -06:00
|
|
|
define KCONFIG_ENABLE_OPT # (option, file)
|
2012-07-22 07:28:33 -06:00
|
|
|
$(SED) "/\\<$(1)\\>/d" $(2)
|
2014-07-14 05:50:26 -06:00
|
|
|
echo '$(1)=y' >> $(2)
|
2012-04-17 08:45:19 -06:00
|
|
|
endef
|
|
|
|
|
2014-07-14 05:50:25 -06:00
|
|
|
define KCONFIG_SET_OPT # (option, value, file)
|
2012-07-22 07:28:33 -06:00
|
|
|
$(SED) "/\\<$(1)\\>/d" $(3)
|
2014-07-14 05:50:26 -06:00
|
|
|
echo '$(1)=$(2)' >> $(3)
|
2012-04-17 08:45:19 -06:00
|
|
|
endef
|
|
|
|
|
2014-07-14 05:50:25 -06:00
|
|
|
define KCONFIG_DISABLE_OPT # (option, file)
|
2012-07-22 07:28:33 -06:00
|
|
|
$(SED) "/\\<$(1)\\>/d" $(2)
|
2014-07-14 05:50:26 -06:00
|
|
|
echo '# $(1) is not set' >> $(2)
|
2012-04-17 08:45:19 -06:00
|
|
|
endef
|
|
|
|
|
|
|
|
# Helper functions to determine the name of a package and its
|
|
|
|
# directory from its makefile directory, using the $(MAKEFILE_LIST)
|
2015-04-13 03:53:21 -06:00
|
|
|
# variable provided by make. This is used by the *-package macros to
|
2014-02-05 02:44:04 -07:00
|
|
|
# automagically find where the package is located.
|
.mk files: bulk aligment and whitespace cleanup of assignments
The Buildroot coding style defines one space around make assignments and
does not align the assignment symbols.
This patch does a bulk fix of offending packages. The package
infrastructures (or more in general assignments to calculated variable
names, like $(2)_FOO) are not touched.
Alignment of line continuation characters (\) is kept as-is.
The sed command used to do this replacement is:
find * -name "*.mk" | xargs sed -i \
-e 's#^\([A-Z0-9a-z_]\+\)\s*\([?:+]\?=\)\s*$#\1 \2#'
-e 's#^\([A-Z0-9a-z_]\+\)\s*\([?:+]\?=\)\s*\([^\\]\+\)$#\1 \2 \3#'
-e 's#^\([A-Z0-9a-z_]\+\)\s*\([?:+]\?=\)\s*\([^\\ \t]\+\s*\\\)\s*$#\1 \2 \3#'
-e 's#^\([A-Z0-9a-z_]\+\)\s*\([?:+]\?=\)\(\s*\\\)#\1 \2\3#'
Brief explanation of this command:
^\([A-Z0-9a-z_]\+\) a regular variable at the beginning of the line
\([?:+]\?=\) any assignment character =, :=, ?=, +=
\([^\\]\+\) any string not containing a line continuation
\([^\\ \t]\+\s*\\\) string, optional whitespace, followed by a
line continuation character
\(\s*\\\) optional whitespace, followed by a line
continuation character
Hence, the first subexpression handles empty assignments, the second
handles regular assignments, the third handles regular assignments with
line continuation, and the fourth empty assignments with line
continuation.
This expression was tested on following test text: (initial tab not
included)
FOO = spaces before
FOO = spaces before and after
FOO = tab before
FOO = tab and spaces before
FOO = tab after
FOO = tab and spaces after
FOO = spaces and tab after
FOO = \
FOO = bar \
FOO = bar space \
FOO = \
GENIMAGE_DEPENDENCIES = host-pkgconf libconfuse
FOO += spaces before
FOO ?= spaces before and after
FOO :=
FOO =
FOO =
FOO =
FOO =
$(MAKE1) CROSS_COMPILE=$(TARGET_CROSS) -C
AT91BOOTSTRAP3_DEFCONFIG = \
AXEL_DISABLE_I18N=--i18n=0
After this bulk change, following manual fixups were done:
- fix line continuation alignment in cegui06 and spice (the sed
expression leaves the number of whitespace between the value and line
continuation character intact, but the whitespace before that could have
changed, causing misalignment.
- qt5base was reverted, as this package uses extensive alignment which
actually makes the code more readable.
Finally, the end result was manually reviewed.
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Cc: Yann E. Morin <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2014-10-07 01:06:03 -06:00
|
|
|
pkgdir = $(dir $(lastword $(MAKEFILE_LIST)))
|
|
|
|
pkgname = $(lastword $(subst /, ,$(pkgdir)))
|
2012-04-17 08:45:19 -06:00
|
|
|
|
|
|
|
# Define extractors for different archive suffixes
|
|
|
|
INFLATE.bz2 = $(BZCAT)
|
|
|
|
INFLATE.gz = $(ZCAT)
|
2017-02-12 13:15:39 -07:00
|
|
|
INFLATE.lz = $(LZCAT)
|
2015-06-15 16:57:21 -06:00
|
|
|
INFLATE.lzma = $(XZCAT)
|
2012-04-17 08:45:19 -06:00
|
|
|
INFLATE.tbz = $(BZCAT)
|
|
|
|
INFLATE.tbz2 = $(BZCAT)
|
|
|
|
INFLATE.tgz = $(ZCAT)
|
|
|
|
INFLATE.xz = $(XZCAT)
|
|
|
|
INFLATE.tar = cat
|
2013-08-02 03:05:14 -06:00
|
|
|
# suitable-extractor(filename): returns extractor based on suffix
|
|
|
|
suitable-extractor = $(INFLATE$(suffix $(1)))
|
2012-04-17 08:45:19 -06:00
|
|
|
|
2017-02-12 13:15:38 -07:00
|
|
|
# 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)))))
|
|
|
|
|
2014-10-05 01:58:31 -06:00
|
|
|
# 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
|
|
|
|
|
2019-08-06 05:02:03 -06:00
|
|
|
# $(1): YES or NO
|
|
|
|
define yesno-to-bool
|
|
|
|
$(subst NO,false,$(subst YES,true,$(1)))
|
|
|
|
endef
|
|
|
|
|
core: introduce new global show-info
Users are increasingly trying to extract information about packages. For
example, they might need to get the list of URIs, or the dependencies of
a package.
Although we do have a bunch of rules to generate some of that, this is
done in ad-hoc way, with most of the output formats just ad-hoc, raw,
unformatted blurbs, mostly internal data dumped as-is.
Introduce a new rule, show-info, that provides a properly formatted
output of all the meta-information about packages: name, type, version,
licenses, dependencies...
We choose to use JSON as the output format, because it is pretty
versatile, has parsers in virtually all languages, has tools to parse
from the shell (jq). It also closely matches Python data structure,
which makes it easy to use with our own internal tools as well. Finally,
JSON being a key-value store, allows for easy expanding the output
without requiring existing consumers to be updated; new, unknown keys
are simply ignored by those (as long as they are true JSON parsers).
The complex part of this change was the conditional output of parts of
the data: virtual packages have no source, version, license or
downloads, unlike non-virtual packages. Same goes for filesystems. We
use a wrapper macro, show-info, that de-multiplexes unto either the
package-related- or filesystem-related macros, and for packages, we also
use a detailed macro for non-virtual packages.
It is non-trivial to properly output correct JSON blurbs, especially
when trying to output an array of objects, like so, where the last item
shall not be followed by a comma: [ { ... }, { ... } ]
So, we use a trick (as sugegsted by Arnout), to $(subst) any pair of
",}" or ", }" or ",]" or ", ]" with only the respective closing symbol,
"}" or "]".
The whole stuff is $(strip)ed to make it a somewhat-minified JSON blurb
that fits on a single line with all spaces squashed (but still with
spaces, as it is not possible to differentiate spaces between JSON
elements from spaces inside JSON strings).
Reported-by: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2019-04-15 13:47:31 -06:00
|
|
|
# json-info -- return package or filesystem metadata formatted as an entry
|
|
|
|
# of a JSON dictionnary
|
|
|
|
# $(1): upper-case package or filesystem name
|
|
|
|
define json-info
|
|
|
|
"$($(1)_NAME)": {
|
|
|
|
"type": "$($(1)_TYPE)",
|
|
|
|
$(if $(filter rootfs,$($(1)_TYPE)), \
|
|
|
|
$(call _json-info-fs,$(1)), \
|
|
|
|
$(call _json-info-pkg,$(1)), \
|
|
|
|
)
|
|
|
|
}
|
|
|
|
endef
|
|
|
|
|
|
|
|
# _json-info-pkg, _json-info-pkg-details, _json-info-fs: private helpers
|
|
|
|
# for json-info, above
|
|
|
|
define _json-info-pkg
|
|
|
|
$(if $($(1)_IS_VIRTUAL), \
|
|
|
|
"virtual": true$(comma),
|
|
|
|
"virtual": false$(comma)
|
|
|
|
$(call _json-info-pkg-details,$(1)) \
|
|
|
|
)
|
|
|
|
"dependencies": [
|
|
|
|
$(call make-comma-list,$(sort $($(1)_FINAL_ALL_DEPENDENCIES)))
|
|
|
|
],
|
|
|
|
"reverse_dependencies": [
|
|
|
|
$(call make-comma-list,$(sort $($(1)_RDEPENDENCIES)))
|
|
|
|
]
|
|
|
|
endef
|
|
|
|
|
|
|
|
define _json-info-pkg-details
|
|
|
|
"version": "$($(1)_DL_VERSION)",
|
|
|
|
"licenses": "$($(1)_LICENSE)",
|
2019-08-03 08:04:33 -06:00
|
|
|
"dl_dir": "$($(1)_DL_SUBDIR)",
|
2019-08-06 05:02:03 -06:00
|
|
|
"install_target": $(call yesno-to-bool,$($(1)_INSTALL_TARGET)),
|
|
|
|
"install_staging": $(call yesno-to-bool,$($(1)_INSTALL_STAGING)),
|
|
|
|
"install_images": $(call yesno-to-bool,$($(1)_INSTALL_IMAGES)),
|
core: introduce new global show-info
Users are increasingly trying to extract information about packages. For
example, they might need to get the list of URIs, or the dependencies of
a package.
Although we do have a bunch of rules to generate some of that, this is
done in ad-hoc way, with most of the output formats just ad-hoc, raw,
unformatted blurbs, mostly internal data dumped as-is.
Introduce a new rule, show-info, that provides a properly formatted
output of all the meta-information about packages: name, type, version,
licenses, dependencies...
We choose to use JSON as the output format, because it is pretty
versatile, has parsers in virtually all languages, has tools to parse
from the shell (jq). It also closely matches Python data structure,
which makes it easy to use with our own internal tools as well. Finally,
JSON being a key-value store, allows for easy expanding the output
without requiring existing consumers to be updated; new, unknown keys
are simply ignored by those (as long as they are true JSON parsers).
The complex part of this change was the conditional output of parts of
the data: virtual packages have no source, version, license or
downloads, unlike non-virtual packages. Same goes for filesystems. We
use a wrapper macro, show-info, that de-multiplexes unto either the
package-related- or filesystem-related macros, and for packages, we also
use a detailed macro for non-virtual packages.
It is non-trivial to properly output correct JSON blurbs, especially
when trying to output an array of objects, like so, where the last item
shall not be followed by a comma: [ { ... }, { ... } ]
So, we use a trick (as sugegsted by Arnout), to $(subst) any pair of
",}" or ", }" or ",]" or ", ]" with only the respective closing symbol,
"}" or "]".
The whole stuff is $(strip)ed to make it a somewhat-minified JSON blurb
that fits on a single line with all spaces squashed (but still with
spaces, as it is not possible to differentiate spaces between JSON
elements from spaces inside JSON strings).
Reported-by: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2019-04-15 13:47:31 -06:00
|
|
|
"downloads": [
|
|
|
|
$(foreach dl,$(sort $($(1)_ALL_DOWNLOADS)),
|
|
|
|
{
|
|
|
|
"source": "$(notdir $(dl))",
|
|
|
|
"uris": [
|
|
|
|
$(call make-comma-list,
|
|
|
|
$(subst \|,|,
|
|
|
|
$(call DOWNLOAD_URIS,$(dl),$(1))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
]
|
|
|
|
},
|
|
|
|
)
|
|
|
|
],
|
|
|
|
endef
|
|
|
|
|
|
|
|
define _json-info-fs
|
|
|
|
"dependencies": [
|
|
|
|
$(call make-comma-list,$(sort $($(1)_DEPENDENCIES)))
|
|
|
|
]
|
|
|
|
endef
|
|
|
|
|
|
|
|
# clean-json -- cleanup pseudo-json into clean json:
|
|
|
|
# - remove commas before closing ] and }
|
|
|
|
# - minify with $(strip)
|
|
|
|
clean-json = $(strip \
|
|
|
|
$(subst $(comma)},}, $(subst $(comma)$(space)},$(space)}, \
|
|
|
|
$(subst $(comma)],], $(subst $(comma)$(space)],$(space)], \
|
|
|
|
$(strip $(1)) \
|
|
|
|
)))) \
|
|
|
|
)
|
|
|
|
|
2012-05-17 11:33:00 -06:00
|
|
|
#
|
|
|
|
# legal-info helper functions
|
|
|
|
#
|
.mk files: bulk aligment and whitespace cleanup of assignments
The Buildroot coding style defines one space around make assignments and
does not align the assignment symbols.
This patch does a bulk fix of offending packages. The package
infrastructures (or more in general assignments to calculated variable
names, like $(2)_FOO) are not touched.
Alignment of line continuation characters (\) is kept as-is.
The sed command used to do this replacement is:
find * -name "*.mk" | xargs sed -i \
-e 's#^\([A-Z0-9a-z_]\+\)\s*\([?:+]\?=\)\s*$#\1 \2#'
-e 's#^\([A-Z0-9a-z_]\+\)\s*\([?:+]\?=\)\s*\([^\\]\+\)$#\1 \2 \3#'
-e 's#^\([A-Z0-9a-z_]\+\)\s*\([?:+]\?=\)\s*\([^\\ \t]\+\s*\\\)\s*$#\1 \2 \3#'
-e 's#^\([A-Z0-9a-z_]\+\)\s*\([?:+]\?=\)\(\s*\\\)#\1 \2\3#'
Brief explanation of this command:
^\([A-Z0-9a-z_]\+\) a regular variable at the beginning of the line
\([?:+]\?=\) any assignment character =, :=, ?=, +=
\([^\\]\+\) any string not containing a line continuation
\([^\\ \t]\+\s*\\\) string, optional whitespace, followed by a
line continuation character
\(\s*\\\) optional whitespace, followed by a line
continuation character
Hence, the first subexpression handles empty assignments, the second
handles regular assignments, the third handles regular assignments with
line continuation, and the fourth empty assignments with line
continuation.
This expression was tested on following test text: (initial tab not
included)
FOO = spaces before
FOO = spaces before and after
FOO = tab before
FOO = tab and spaces before
FOO = tab after
FOO = tab and spaces after
FOO = spaces and tab after
FOO = \
FOO = bar \
FOO = bar space \
FOO = \
GENIMAGE_DEPENDENCIES = host-pkgconf libconfuse
FOO += spaces before
FOO ?= spaces before and after
FOO :=
FOO =
FOO =
FOO =
FOO =
$(MAKE1) CROSS_COMPILE=$(TARGET_CROSS) -C
AT91BOOTSTRAP3_DEFCONFIG = \
AXEL_DISABLE_I18N=--i18n=0
After this bulk change, following manual fixups were done:
- fix line continuation alignment in cegui06 and spice (the sed
expression leaves the number of whitespace between the value and line
continuation character intact, but the whitespace before that could have
changed, causing misalignment.
- qt5base was reverted, as this package uses extensive alignment which
actually makes the code more readable.
Finally, the end result was manually reviewed.
Signed-off-by: Thomas De Schampheleire <thomas.de.schampheleire@gmail.com>
Cc: Yann E. Morin <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
2014-10-07 01:06:03 -06:00
|
|
|
LEGAL_INFO_SEPARATOR = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
|
2013-11-12 01:48:00 -07:00
|
|
|
|
|
|
|
define legal-warning # text
|
|
|
|
echo "WARNING: $(1)" >>$(LEGAL_WARNINGS)
|
|
|
|
endef
|
|
|
|
|
|
|
|
define legal-warning-pkg # pkg, text
|
|
|
|
echo "WARNING: $(1): $(2)" >>$(LEGAL_WARNINGS)
|
|
|
|
endef
|
|
|
|
|
2014-06-22 06:41:15 -06:00
|
|
|
define legal-warning-nosource # pkg, {local|override}
|
|
|
|
$(call legal-warning-pkg,$(1),sources not saved ($(2) packages not handled))
|
2012-05-17 11:33:00 -06:00
|
|
|
endef
|
2013-11-12 01:48:00 -07:00
|
|
|
|
2018-10-21 05:59:24 -06:00
|
|
|
define legal-manifest # {HOST|TARGET}, pkg, version, license, license-files, source, url, dependencies
|
|
|
|
echo '"$(2)","$(3)","$(4)","$(5)","$(6)","$(7)","$(8)"' >>$(LEGAL_MANIFEST_CSV_$(1))
|
2013-11-12 01:48:00 -07:00
|
|
|
endef
|
|
|
|
|
2018-10-14 06:25:41 -06:00
|
|
|
define legal-license-file # pkgname, pkgname-pkgver, pkg-hashfile, filename, file-fullpath, {HOST|TARGET}
|
2017-06-25 16:03:39 -06:00
|
|
|
mkdir -p $(LICENSE_FILES_DIR_$(6))/$(2)/$(dir $(4)) && \
|
2017-06-25 16:03:40 -06:00
|
|
|
{ \
|
2018-10-14 06:25:41 -06:00
|
|
|
support/download/check-hash $(3) $(5) $(4); \
|
2017-07-16 11:22:39 -06:00
|
|
|
case $${?} in (0|3) ;; (*) exit 1;; esac; \
|
2017-06-25 16:03:40 -06:00
|
|
|
} && \
|
2017-06-25 16:03:39 -06:00
|
|
|
cp $(5) $(LICENSE_FILES_DIR_$(6))/$(2)/$(4)
|
2012-05-17 11:33:00 -06:00
|
|
|
endef
|
2018-10-21 05:59:24 -06:00
|
|
|
|
|
|
|
non-virtual-deps = $(foreach p,$(1),$(if $($(call UPPERCASE,$(p))_IS_VIRTUAL),,$(p)))
|
|
|
|
|
|
|
|
# Returns the list of recursive dependencies and their licensing terms
|
|
|
|
# for the package specified in parameter (in lowercase). If that
|
|
|
|
# package is a target package, remove host packages from the list.
|
|
|
|
legal-deps = \
|
|
|
|
$(foreach p,\
|
|
|
|
$(filter-out $(if $(1:host-%=),host-%),\
|
|
|
|
$(call non-virtual-deps,\
|
|
|
|
$($(call UPPERCASE,$(1))_FINAL_RECURSIVE_DEPENDENCIES))),$(p) [$($(call UPPERCASE,$(p))_LICENSE)])
|