Skip to contentSkip to conversation

pkg-infra: allow dumping reverse dependencies of a package

PATCH New Yann E. MORIN 3 participants 8 messages Sep 25, 2016 – Oct 23, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pkg-infra: allow dumping reverse dependencies of a package

Finding the packages that select another one in a specific configuration is not very trivial:

- when optional, the dependency is not expressed in Kconfig

- looking at the .mk files is not very nice.

Introduce a way to dump reverse dependencies of packages, i.e. the list of packages that directly depend on that package. Like for direct dependencies, we limit the list to the first-order reverse dependencies.

Document it in the main help; use the opportunity to also docuemnt foo-show-depends.

---
 Makefile               | 2 ++
 package/pkg-generic.mk | 7 +++++++
 2 files changed, 9 insertions(+)
Makefile +2 -0
index 5e4daef..3039983 100644
@@ -943,6 +943,8 @@ 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-depends     - List packages on which <pkg> depends'
+	@echo '  <pkg>-show-rdepends    - List packages which have <pkg> as a dependency'
 	@echo '  <pkg>-graph-depends    - Generate a graph of <pkg>'\''s dependencies'
 	@echo '  <pkg>-dirclean         - Remove <pkg> build directory'
 	@echo '  <pkg>-reconfigure      - Restart the build from the configure step'
package/pkg-generic.mk +7 -0
index 68ead3d..779f294 100644
@@ -523,6 +523,10 @@ $(2)_FINAL_DEPENDENCIES = $$(sort $$($(2)_DEPENDENCIES))
 $(2)_FINAL_PATCH_DEPENDENCIES = $$(sort $$($(2)_PATCH_DEPENDENCIES))
 $(2)_FINAL_ALL_DEPENDENCIES = $$(sort $$($(2)_FINAL_DEPENDENCIES) $$($(2)_FINAL_PATCH_DEPENDENCIES))
 
+# Register package as a reverse-dependencies of all its dependencies
+$$(eval $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),\
+	$$(call UPPERCASE,$$(p))_RDEPENDENCIES += $(1)$$(sep)))
+
 $(2)_INSTALL_STAGING		?= NO
 $(2)_INSTALL_IMAGES		?= NO
 $(2)_INSTALL_TARGET		?= YES
@@ -698,6 +702,9 @@ $(1)-show-version:
 $(1)-show-depends:
 			@echo $$($(2)_FINAL_ALL_DEPENDENCIES)
 
+$(1)-show-rdepends:
+			@echo $$($(2)_RDEPENDENCIES)
+
 $(1)-graph-depends: graph-depends-requirements
 			@$$(INSTALL) -d $$(GRAPHS_DIR)
 			@cd "$$(CONFIG_DIR)"; \
Signature · 1 line
2.7.4
#1 lore raw

PATCH 1/1 pkg-infra: allow dumping reverse dependencies of a package

Quoted 6 lines · Yann E. MORIN

Finding the packages that select another one in a specific configuration is not very trivial:

- when optional, the dependency is not expressed in Kconfig

- looking at the .mk files is not very nice.

If I understand correctly, the idea is to answer the question "why is package
foo built?", right?

It would make sense to also add a foo-graph-rdepends, because often you'll want
the transitive dependencies as well and it's always nice to have it in a graph. But this patch is of course a prerequisite of that feature.

Quoted 6 lines

Introduce a way to dump reverse dependencies of packages, i.e. the list of packages that directly depend on that package. Like for direct dependencies, we limit the list to the first-order reverse dependencies.

Document it in the main help; use the opportunity to also docuemnt

document

Quoted 3 lines

foo-show-depends.

Quoted 44 lines
---
 Makefile               | 2 ++
 package/pkg-generic.mk | 7 +++++++
 2 files changed, 9 insertions(+)
Makefile +2 -0
index 5e4daef..3039983 100644
@@ -943,6 +943,8 @@ 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-depends     - List packages on which <pkg> depends'
+	@echo '  <pkg>-show-rdepends    - List packages which have <pkg> as a dependency'
 	@echo '  <pkg>-graph-depends    - Generate a graph of <pkg>'\''s dependencies'
 	@echo '  <pkg>-dirclean         - Remove <pkg> build directory'
 	@echo '  <pkg>-reconfigure      - Restart the build from the configure step'
package/pkg-generic.mk +7 -0
index 68ead3d..779f294 100644
@@ -523,6 +523,10 @@ $(2)_FINAL_DEPENDENCIES = $$(sort $$($(2)_DEPENDENCIES))
 $(2)_FINAL_PATCH_DEPENDENCIES = $$(sort $$($(2)_PATCH_DEPENDENCIES))
 $(2)_FINAL_ALL_DEPENDENCIES = $$(sort $$($(2)_FINAL_DEPENDENCIES) $$($(2)_FINAL_PATCH_DEPENDENCIES))
 
+# Register package as a reverse-dependencies of all its dependencies
+$$(eval $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),\
+	$$(call UPPERCASE,$$(p))_RDEPENDENCIES += $(1)$$(sep)))
+
 $(2)_INSTALL_STAGING		?= NO
 $(2)_INSTALL_IMAGES		?= NO
 $(2)_INSTALL_TARGET		?= YES
@@ -698,6 +702,9 @@ $(1)-show-version:
 $(1)-show-depends:
 			@echo $$($(2)_FINAL_ALL_DEPENDENCIES)
 
+$(1)-show-rdepends:
+			@echo $$($(2)_RDEPENDENCIES)
+
 $(1)-graph-depends: graph-depends-requirements
 			@$$(INSTALL) -d $$(GRAPHS_DIR)
 			@cd "$$(CONFIG_DIR)"; \
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#2 lore raw

PATCH 1/1 pkg-infra: allow dumping reverse dependencies of a package

On 2016-09-27 22:40 +0200, Arnout Vandecappelle spake thusly:

Quoted 12 lines · Yann E. MORIN
Quoted 6 lines

Finding the packages that select another one in a specific configuration is not very trivial:

- when optional, the dependency is not expressed in Kconfig

- looking at the .mk files is not very nice.

If I understand correctly, the idea is to answer the question "why is package
foo built?", right?

Right. In my use-case, that was "what do I need to disable so I can disable that broken package?".

Quoted 2 lines

It would make sense to also add a foo-graph-rdepends, because often you'll want
the transitive dependencies as well and it's always nice to have it in a graph.

Yup, planned. But not trivial...

Quoted 1 line

But this patch is of course a prerequisite of that feature.

And it proved already usefull in its own right. ;-)

Quoted 6 lines
Quoted 5 lines

Introduce a way to dump reverse dependencies of packages, i.e. the list of packages that directly depend on that package. Like for direct dependencies, we limit the list to the first-order reverse dependencies.

Document it in the main help; use the opportunity to also docuemnt

document

Boaf... One typo more, one typo less... I stopped countign a long time ago! ;-)

Quoted 5 lines
Quoted 3 lines

foo-show-depends.

Thanks!

Regards,
Yann E. MORIN.

Quoted 52 lines
Quoted 44 lines
---
 Makefile               | 2 ++
 package/pkg-generic.mk | 7 +++++++
 2 files changed, 9 insertions(+)
Makefile +2 -0
index 5e4daef..3039983 100644
@@ -943,6 +943,8 @@ 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-depends     - List packages on which <pkg> depends'
+	@echo '  <pkg>-show-rdepends    - List packages which have <pkg> as a dependency'
 	@echo '  <pkg>-graph-depends    - Generate a graph of <pkg>'\''s dependencies'
 	@echo '  <pkg>-dirclean         - Remove <pkg> build directory'
 	@echo '  <pkg>-reconfigure      - Restart the build from the configure step'
package/pkg-generic.mk +7 -0
index 68ead3d..779f294 100644
@@ -523,6 +523,10 @@ $(2)_FINAL_DEPENDENCIES = $$(sort $$($(2)_DEPENDENCIES))
 $(2)_FINAL_PATCH_DEPENDENCIES = $$(sort $$($(2)_PATCH_DEPENDENCIES))
 $(2)_FINAL_ALL_DEPENDENCIES = $$(sort $$($(2)_FINAL_DEPENDENCIES) $$($(2)_FINAL_PATCH_DEPENDENCIES))
 
+# Register package as a reverse-dependencies of all its dependencies
+$$(eval $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),\
+	$$(call UPPERCASE,$$(p))_RDEPENDENCIES += $(1)$$(sep)))
+
 $(2)_INSTALL_STAGING		?= NO
 $(2)_INSTALL_IMAGES		?= NO
 $(2)_INSTALL_TARGET		?= YES
@@ -698,6 +702,9 @@ $(1)-show-version:
 $(1)-show-depends:
 			@echo $$($(2)_FINAL_ALL_DEPENDENCIES)
 
+$(1)-show-rdepends:
+			@echo $$($(2)_RDEPENDENCIES)
+
 $(1)-graph-depends: graph-depends-requirements
 			@$$(INSTALL) -d $$(GRAPHS_DIR)
 			@cd "$$(CONFIG_DIR)"; \
Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 1/1 pkg-infra: allow dumping reverse dependencies of a package

Quoted 11 lines · Yann E. MORIN

On 2016-09-27 22:40 +0200, Arnout Vandecappelle spake thusly:

Quoted 10 lines
Quoted 10 lines · Yann E. MORIN
Quoted 6 lines
Quoted 6 lines

Finding the packages that select another one in a specific configuration is not very trivial:

- when optional, the dependency is not expressed in Kconfig

- looking at the .mk files is not very nice.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

If I understand correctly, the idea is to answer the question "why is package
foo built?", right?

Right. In my use-case, that was "what do I need to disable so I can disable that broken package?".

Quoted 2 lines
Quoted 2 lines

It would make sense to also add a foo-graph-rdepends, because often you'll want
the transitive dependencies as well and it's always nice to have it in a graph.

Yup, planned. But not trivial...

No? Isn't it just calling foo-show-rdepends from graph-depends?

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

But this patch is of course a prerequisite of that feature.

And it proved already usefull in its own right. ;-)

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

Introduce a way to dump reverse dependencies of packages, i.e. the list of packages that directly depend on that package. Like for direct dependencies, we limit the list to the first-order reverse dependencies.

Document it in the main help; use the opportunity to also docuemnt

document

Boaf... One typo more, one typo less... I stopped countign a long time ago! ;-)

countign, really? :-P

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#4 lore raw

PATCH 1/1 pkg-infra: allow dumping reverse dependencies of a package

Arnout, All,

On 2016-09-28 00:02 +0200, Arnout Vandecappelle spake thusly:

Quoted 14 lines · Yann E. MORIN
Quoted 13 lines

On 2016-09-27 22:40 +0200, Arnout Vandecappelle spake thusly:

Quoted 12 lines
Quoted 12 lines · Yann E. MORIN
Quoted 6 lines
Quoted 6 lines

Finding the packages that select another one in a specific configuration is not very trivial:

- when optional, the dependency is not expressed in Kconfig

- looking at the .mk files is not very nice.

If I understand correctly, the idea is to answer the question "why is package
foo built?", right?

Quoted 8 lines
Quoted 6 lines

Right. In my use-case, that was "what do I need to disable so I can disable that broken package?".

Quoted 2 lines
Quoted 2 lines

It would make sense to also add a foo-graph-rdepends, because often you'll want
the transitive dependencies as well and it's always nice to have it in a graph.

Yup, planned. But not trivial...

No? Isn't it just calling foo-show-rdepends from graph-depends?

It would seem it would be that easy, but not really.

I don;t recall the details, but one thing is that we can't easily do an rdepends graph for 'all' in the current state: we'd need to be able to extract all packages that have no dependencies (i.e. leaf packages) so that we could construct the 'all' node for rdepends.

Hmm.. Or do we have to? We could construct that list... Lemme think...

Of course, we could limit the feature to just graphing the rdeps of a single package. That would not be overly complex, as you said.

But I was trying to mimick graph-depends into graph-rdepends, so they would be symetrical...

Well, anyway, it's not at the top of my TODO list... ;-)

Regards,
Yann E. MORIN.

Quoted 25 lines
Quoted 11 lines
Quoted 1 line
Quoted 1 line

But this patch is of course a prerequisite of that feature.

And it proved already usefull in its own right. ;-)

Quoted 6 lines
Quoted 6 lines
Quoted 5 lines
Quoted 5 lines

Introduce a way to dump reverse dependencies of packages, i.e. the list of packages that directly depend on that package. Like for direct dependencies, we limit the list to the first-order reverse dependencies.

Document it in the main help; use the opportunity to also docuemnt

document

Boaf... One typo more, one typo less... I stopped countign a long time ago! ;-)

countign, really? :-P

Regards,
Arnout

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#5 lore raw

PATCH 1/1 pkg-infra: allow dumping reverse dependencies of a package

Quoted 24 lines · Yann E. MORIN

Arnout, All,

On 2016-09-28 00:02 +0200, Arnout Vandecappelle spake thusly:

Quoted 21 lines
Quoted 21 lines · Yann E. MORIN
Quoted 19 lines
Quoted 19 lines

On 2016-09-27 22:40 +0200, Arnout Vandecappelle spake thusly:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines · Yann E. MORIN
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

Finding the packages that select another one in a specific configuration
is not very trivial:

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

- when optional, the dependency is not expressed in Kconfig

- looking at the .mk files is not very nice.

If I understand correctly, the idea is to answer the question "why is package
foo built?", right?

Right. In my use-case, that was "what do I need to disable so I can disable that broken package?".

Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines

It would make sense to also add a foo-graph-rdepends, because often you'll want
the transitive dependencies as well and it's always nice to have it in a graph.

Yup, planned. But not trivial...

Quoted 7 lines
Quoted 1 line
Quoted 1 line

No? Isn't it just calling foo-show-rdepends from graph-depends?

It would seem it would be that easy, but not really.

I don;t recall the details, but one thing is that we can't easily do an rdepends graph for 'all' in the current state: we'd need to be able to extract all packages that have no dependencies (i.e. leaf packages) so that we could construct the 'all' node for rdepends.

graph-rdepends would be exactly the same as graph-depends. Only
foo-graph-rdepends is relevant.

Regards,
Arnout

Quoted 10 lines

Hmm.. Or do we have to? We could construct that list... Lemme think...

Of course, we could limit the feature to just graphing the rdeps of a single package. That would not be overly complex, as you said.

But I was trying to mimick graph-depends into graph-rdepends, so they would be symetrical...

Well, anyway, it's not at the top of my TODO list... ;-)

Signature · 6 lines
Arnout Vandecappelle                          arnout at mind be
Senior Embedded Software Architect            +32-16-286500
Essensium/Mind                                http://www.mind.be
G.Geenslaan 9, 3001 Leuven, Belgium           BE 872 984 063 RPR Leuven
LinkedIn profile: http://www.linkedin.com/in/arnoutvandecappelle
GPG fingerprint:  7493 020B C7E3 8618 8DEC 222C 82EB F404 F9AC 0DDF
#6 lore raw

PATCH 1/1 pkg-infra: allow dumping reverse dependencies of a package

In reply to Yann E. MORIN

Hello,

Quoted 7 lines · Yann E. MORIN

Finding the packages that select another one in a specific configuration is not very trivial:

- when optional, the dependency is not expressed in Kconfig

- looking at the .mk files is not very nice.

Quoted 8 lines

Introduce a way to dump reverse dependencies of packages, i.e. the list of packages that directly depend on that package. Like for direct dependencies, we limit the list to the first-order reverse dependencies.

Document it in the main help; use the opportunity to also docuemnt foo-show-depends.

I was about to apply this patch, but after testing it, I'm a little bit skeptical.

The current <foo>-show-depends only shows the dependencies according to the current configuration. So, if a package A has:

A_DEPENDENCIES = B

ifeq ($(BR2_PACKAGE_C),y)
A_DEPENDENCNIES += C
endif

and BR2_PACKAGE_C is not enabled, then "make A-show-depends" will only show "B" but not C.

However, make <foo>-show-rdepends shows all possible reverse dependencies, even the ones that are not enabled in the current configuration. So let's say you have packages A, B, C and D.

a.mk:
A_DEPENDENCIES = D

b.mk:
B_DEPENDENCIES = D

c.mk:
ifeq ($(BR2_PACKAGE_C_SUPPORT_FOR_D),y)
C_DEPENDENCIES += D
endif

with:

BR2_PACKAGE_A=y
# BR2_PACKAGE_B is not set
# BR2_PACKAGE_C is not set
BR2_PACKAGE_D=y

Then, doing:

make D-show-rdepends

will list both A and B, even if:

1/ B is not enabled in the current configuration

2/ C could potentially be a reverse dependency of A

So in the end, I find the semantic of this "show-rdepends" a bit weird. It shows reverse dependencies, some according to the current configuration, some not.

It feels a bit weird :/

Best regards,

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
#7 lore raw

PATCH 1/1 pkg-infra: allow dumping reverse dependencies of a package

Thomas, All,

On 2016-10-23 15:23 +0200, Thomas Petazzoni spake thusly:

Quoted 12 lines · Yann E. MORIN
Quoted 11 lines

Finding the packages that select another one in a specific configuration is not very trivial:

- when optional, the dependency is not expressed in Kconfig

- looking at the .mk files is not very nice.

Introduce a way to dump reverse dependencies of packages, i.e. the list of packages that directly depend on that package. Like for direct dependencies, we limit the list to the first-order reverse dependencies.

Quoted 7 lines
Quoted 4 lines

Document it in the main help; use the opportunity to also docuemnt foo-show-depends.

I was about to apply this patch, but after testing it, I'm a little bit skeptical.

[--SNIP--]

Quoted 3 lines

So in the end, I find the semantic of this "show-rdepends" a bit weird. It shows reverse dependencies, some according to the current configuration, some not.

Right, good catch.

I've fixed it here now to take this into account. It should now match the behaviour of -show-depends.

I'll spin it soon.

Thanks! :-)

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'