core: add per-package and per-filesystem show-info
authorYann E. MORIN <yann.morin.1998@free.fr>
Mon, 15 Apr 2019 19:47:32 +0000 (21:47 +0200)
committerArnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Mon, 15 Apr 2019 21:47:22 +0000 (23:47 +0200)
Sometimes, it is need to quickly get the metadata of a subset of
packages, without resorting to a full-blown JSON query.

Introduce a new per-package (and per-filesystem) foo-show-info rule,
that otputs a per-entity valid JSON blob.

Note that calling it for multiple packages and.or filesystems at once
will not generate a valid JSON blob, as there would be no separator
between the JSON elements:

    $ make {foo,bar}-show-info
    { "foo": { foo stuff } }
    { "bar": { bar stuff } }

However, jq is able to absorb this, with its slurping ability, which
generates an array (ellipsed and manualy reformated for readability):

    $ make {foo,bar}-show-info |jq -s . -
    [
      { "foo": { foo stuff } },
      { "bar": { bar stuff } }
    ]

Signed-off-by: "Yann E. MORIN" <yann.morin.1998@free.fr>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Cc: Thomas De Schampheleire <patrickdepinguin@gmail.com>
Cc: Arnout Vandecappelle <arnout@mind.be>
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
Makefile
fs/common.mk
package/pkg-generic.mk

index 0f5331ec7edd76400c17033489b9ce1e324e28bc..522c0b0606cd2b50d8aa45e0e5d1f3fea7856124 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1111,6 +1111,7 @@ help:
        @echo '  <pkg>-depends          - Build <pkg>'\''s dependencies'
        @echo '  <pkg>-configure        - Build <pkg> up to the configure step'
        @echo '  <pkg>-build            - Build <pkg> up to the build step'
+       @echo '  <pkg>-show-info        - generate info about <pkg>, as a JSON blurb'
        @echo '  <pkg>-show-depends     - List packages on which <pkg> depends'
        @echo '  <pkg>-show-rdepends    - List packages which have <pkg> as a dependency'
        @echo '  <pkg>-show-recursive-depends'
index f7989eac573ac12d82bba5da20ba9b0fa8c7f29b..6dd1774726c0cf2ab8d0b0aed5587941a92fb07f 100644 (file)
@@ -87,6 +87,11 @@ endif
 rootfs-common-show-depends:
        @echo $(ROOTFS_COMMON_DEPENDENCIES)
 
+.PHONY: rootfs-common-show-info
+rootfs-common-show-info:
+       @:
+       $(info $(call clean-json,{ $(call json-info,ROOTFS_COMMON) }))
+
 # Since this function will be called from within an $(eval ...)
 # all variable references except the arguments must be $$-quoted.
 define inner-rootfs
@@ -184,9 +189,13 @@ endif
 rootfs-$(1)-show-depends:
        @echo $$(ROOTFS_$(2)_DEPENDENCIES)
 
+rootfs-$(1)-show-info:
+       @:
+       $$(info $$(call clean-json,{ $$(call json-info,ROOTFS_$(2)) }))
+
 rootfs-$(1): $$(BINARIES_DIR)/$$(ROOTFS_$(2)_FINAL_IMAGE_NAME)
 
-.PHONY: rootfs-$(1) rootfs-$(1)-show-depends
+.PHONY: rootfs-$(1) rootfs-$(1)-show-depends rootfs-$(1)-show-info
 
 ifeq ($$(BR2_TARGET_ROOTFS_$(2)),y)
 TARGETS_ROOTFS += rootfs-$(1)
index 8ff8cff12d848f7686ae880bdfdcba3149784a8d..67782138b494f56846365a23d60f19a4bb6db43f 100644 (file)
@@ -867,6 +867,10 @@ $(1)-show-dependency-tree: $$(patsubst %,%-show-dependency-tree,$$($(2)_FINAL_AL
        $$(info $(1): $(4) $$(if $$($(2)_IS_VIRTUAL),virtual,$$($(2)_DL_VERSION)))
        $$(info $(1) -> $$($(2)_FINAL_ALL_DEPENDENCIES))
 
+$(1)-show-info:
+       @:
+       $$(info $$(call clean-json,{ $$(call json-info,$(2)) }))
+
 $(1)-graph-depends: graph-depends-requirements
        $(call pkg-graph-depends,$(1),--direct)
 
@@ -1099,6 +1103,7 @@ DL_TOOLS_DEPENDENCIES += $$(call extractor-dependency,$$($(2)_SOURCE))
        $(1)-rsync \
        $(1)-show-dependency-tree \
        $(1)-show-depends \
+       $(1)-show-info \
        $(1)-show-version \
        $(1)-source