br2-external: make version of external trees available

For various reasons, like debugging or compliance, it is important to
identify what br2-external trees versions were used for a specific
build.

Add a Kconfig option that contains the version as computed by
support/scripts/setlocalversion; this will appear in the .config file
(but not in defconfig files, which is what we want).

Also generate that variable on the .mk side, so that it gets properly
exported in the environment, for post-build of post-iamge scripts to use
as they see fit (like, ensuring there is no dirtyness when in a CI for
example).

Reported-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
This commit is contained in:
Yann E. MORIN 2023-02-11 11:52:45 +01:00
parent 8a2b772e8c
commit 9ae089e2e9

View File

@ -66,7 +66,7 @@ do_validate() {
do_validate_one() {
local br2_ext="${1}"
local br2_name br2_desc n d
local br2_name br2_desc br2_ver n d
if [ ! -d "${br2_ext}" ]; then
error "'%s': no such file or directory\n" "${br2_ext}"
@ -104,8 +104,10 @@ do_validate_one() {
# Register this br2-external tree, use an absolute canonical path
br2_ext="$( cd "${br2_ext}"; pwd )"
br2_ver="$( support/scripts/setlocalversion "${br2_ext}" )"
BR2_EXT_NAMES+=( "${br2_name}" )
eval BR2_EXT_PATHS_${br2_name}="\"\${br2_ext}\""
eval BR2_EXT_VERS_${br2_name}="\"\${br2_ver}\""
eval BR2_EXT_DESCS_${br2_name}="\"\${br2_desc:-\${br2_name}}\""
}
@ -113,7 +115,7 @@ do_validate_one() {
# for the br2-external tree
do_mk() {
local outputdir="${1}"
local br2_name br2_desc br2_ext
local br2_name br2_desc br2_ext br2_ver
{
printf '#\n# Automatically generated file; DO NOT EDIT.\n#\n'
@ -139,12 +141,14 @@ do_mk() {
for br2_name in "${BR2_EXT_NAMES[@]}"; do
eval br2_desc="\"\${BR2_EXT_DESCS_${br2_name}}\""
eval br2_ext="\"\${BR2_EXT_PATHS_${br2_name}}\""
eval br2_ver="\"\${BR2_EXT_VERS_${br2_name}}\""
printf '\n'
printf 'BR2_EXTERNAL_NAMES += %s\n' "${br2_name}"
printf 'BR2_EXTERNAL_DIRS += %s\n' "${br2_ext}"
printf 'BR2_EXTERNAL_MKS += %s/external.mk\n' "${br2_ext}"
printf 'export BR2_EXTERNAL_%s_PATH = %s\n' "${br2_name}" "${br2_ext}"
printf 'export BR2_EXTERNAL_%s_DESC = %s\n' "${br2_name}" "${br2_desc}"
printf 'export BR2_EXTERNAL_%s_VERSION = %s\n' "${br2_name}" "${br2_ver}"
done
} >"${outputdir}/.br2-external.mk"
}
@ -152,7 +156,7 @@ do_mk() {
# Generate the kconfig snippets for the br2-external tree.
do_kconfig() {
local outputdir="${1}"
local br2_name br2_desc br2_ext br2
local br2_name br2_desc br2_ext br2_ver br2
local -a items
items=(
@ -192,11 +196,15 @@ do_kconfig() {
for br2_name in "${BR2_EXT_NAMES[@]}"; do
eval br2_desc="\"\${BR2_EXT_DESCS_${br2_name}}\""
eval br2_ext="\"\${BR2_EXT_PATHS_${br2_name}}\""
eval br2_ver="\"\${BR2_EXT_VERS_${br2_name}}\""
{
printf 'config BR2_EXTERNAL_%s_PATH\n' "${br2_name}"
printf '\tstring\n'
printf '\tdefault "%s"\n' "${br2_ext}"
printf 'config BR2_EXTERNAL_%s_VERSION\n' "${br2_name}"
printf '\tstring\n'
printf '\tdefault "%s"\n' "${br2_ver}"
printf '\n'
} >>"${outputdir}/.br2-external.in.paths"