diff mbox series

[v4,1/2] package/pkg-utils.mk: include external tree info in show-info output

Message ID 20250830131036.1295970-2-fiona.klute@gmx.de
State Handled Elsewhere
Headers show
Series Add external tree information to CycloneDX SBOM | expand

Commit Message

Fiona Klute Aug. 30, 2025, 1:10 p.m. UTC
From: "Fiona Klute (WIWA)" <fiona.klute@gmx.de>

This allows identifying packages from external trees, and the external
tree version allows identifying the precise version of the packaging
code independent of the package version. If needed, the location of
the external tree can be derived from package_dir and further
information loaded from there.

Signed-off-by: Fiona Klute (WIWA) <fiona.klute@gmx.de>
---
Changes v3 -> v4:
* Add an "external" mapping with external tree name and version to
  show-info output for packages from external trees (this patch).

 package/pkg-utils.mk | 12 ++++++++++++
 1 file changed, 12 insertions(+)
diff mbox series

Patch

diff --git a/package/pkg-utils.mk b/package/pkg-utils.mk
index 288a202230..4c9861e946 100644
--- a/package/pkg-utils.mk
+++ b/package/pkg-utils.mk
@@ -111,6 +111,17 @@  define json-info
 	}
 endef
 
+define json-external
+	$(foreach name,$(BR2_EXTERNAL_NAMES),\
+		$(if $(findstring $(BR2_EXTERNAL_$(name)_PATH),$(1)),\
+			"external": {\
+				"name": $(call mk-json-str,$(strip $(name)))$(comma)\
+				"version": $(call mk-json-str,$(strip $(BR2_EXTERNAL_$(name)_VERSION)))\
+			}$(comma)\
+		)\
+	)
+endef
+
 # _json-info-pkg, _json-info-pkg-details, _json-info-fs: private helpers
 # for json-info, above
 define _json-info-pkg
@@ -121,6 +132,7 @@  define _json-info-pkg
 		$(call _json-info-pkg-details,$(1)) \
 	)
 	"package_dir": $(call mk-json-str,$(patsubst $(CURDIR)/%,%,$($(1)_PKGDIR))),
+	$(call json-external,$(patsubst $(CURDIR)/%,%,$($(1)_PKGDIR)))
 	"stamp_dir": $(call mk-json-str,$(patsubst $(CONFIG_DIR)/%,%,$($(1)_DIR))),
 	"source_dir": $(call mk-json-str,$(patsubst $(CONFIG_DIR)/%,%,$($(1)_DIR))),
 	"build_dir": $(call mk-json-str,$(patsubst $(CONFIG_DIR)/%,%,$($(1)_BUILDDIR))),