Message ID | 1493305458-15309-1-git-send-email-george.redivo@datacom.ind.br |
---|---|
State | Superseded |
Headers | show |
Hi George, On 27-04-17 17:04, George Redivo wrote: > The created command shows, recursively, the reverse depends of a > package, > it means that the command shows not only the direct dependants (which is > done by 'show-rdepends'), but also all indirect dependents. Could you explain a bit more what the use case is you are trying to solve? > To do this it was necessary to create a new parameter '--flat-list', or > '-f', to graph-depends. > This parameter instructs the script to just print the name of package > instead of the .dot syntax. See below for a better alternative. > > Signed-off-by: George Redivo <george.redivo@datacom.ind.br> > --- > Makefile | 1 + > package/pkg-generic.mk | 10 ++++++++++ > support/scripts/graph-depends | 16 ++++++++++++---- > 3 files changed, 23 insertions(+), 4 deletions(-) > > diff --git a/Makefile b/Makefile > index 919d589..61943d8 100644 > --- a/Makefile > +++ b/Makefile > @@ -996,6 +996,7 @@ help: > @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>-show-rrdepends - List, recursivelly, packages which have <pkg> as a dependency' > @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies' > @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies' > @echo ' <pkg>-dirclean - Remove <pkg> build directory' > diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk > index 3b26e6b..c0f83b6 100644 > --- a/package/pkg-generic.mk > +++ b/package/pkg-generic.mk > @@ -353,6 +353,13 @@ define pkg-graph-depends > $$(GRAPHS_DIR)/$$(@).dot > endef > > +define pkg-rrdepends > + @$$(INSTALL) -d $$(GRAPHS_DIR) > + @cd "$$(CONFIG_DIR)"; \ > + $$(TOPDIR)/support/scripts/graph-depends $$(BR2_GRAPH_DEPS_OPTS) \ > + -p $(1) --reverse -f > +endef > + > ################################################################################ > # inner-generic-package -- generates the make targets needed to build a > # generic package > @@ -737,6 +744,9 @@ $(1)-show-depends: > $(1)-show-rdepends: > @echo $$($(2)_RDEPENDENCIES) > > +$(1)-show-rrdepends: > + $(call pkg-rrdepends,$(1)) It is better to use the approach like for show-build-order, i.e.: $(1)-show-rrdepends: $$(patsubst %,%-rrdepends,$$($(2)_FINAL_ALL_DEPENDENCIES)) @printf '%s' $$($(2)_RDEPENDENCIES) However, I would much prefer to rewrite graph-depends completely so it works in a single pass, and have just pkg-show-depends that works recursively like above. Then any filterling like depth or just a single package or reverting the arrows can be done by the graph-depends script itself. That would work a whole lot faster, and in addition would allow us to remove a lot of those annoying extra rules inside inner-generic-package (cfr. my rant recently). But that is of course a much bigger change, so for the time being I'm OK with adding this rrdepends. Regards, Arnout > + > $(1)-show-build-order: $$(patsubst %,%-show-build-order,$$($(2)_FINAL_ALL_DEPENDENCIES)) > $$(info $(1)) > > diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends > index b258c56..f6fec09 100755 > --- a/support/scripts/graph-depends > +++ b/support/scripts/graph-depends > @@ -69,6 +69,8 @@ parser.add_argument("--direct", dest="direct", action='store_true', default=True > help="Draw direct dependencies (the default)") > parser.add_argument("--reverse", dest="direct", action='store_false', > help="Draw reverse dependencies") > +parser.add_argument("--flat-list", '-f', dest="flat_list", action='store_true', default=False, > + help="Do not draw, just print a flat list output.") > args = parser.parse_args() > > check_only = args.check_only > @@ -361,7 +363,10 @@ def print_pkg_deps(depth, pkg): > if pkg in done_deps: > return > done_deps.append(pkg) > - print_attrs(pkg) > + if args.flat_list: > + outfile.write("%s\n" % (pkg)) > + else: > + print_attrs(pkg) > if pkg not in dict_deps: > return > for p in stop_list: > @@ -385,13 +390,16 @@ def print_pkg_deps(depth, pkg): > add = False > break > if add: > - outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir)) > + if not args.flat_list: > + outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir)) > print_pkg_deps(depth+1, d) > > # Start printing the graph data > -outfile.write("digraph G {\n") > +if not args.flat_list: > + outfile.write("digraph G {\n") > > done_deps = [] > print_pkg_deps(0, rootpkg) > > -outfile.write("}\n") > +if not args.flat_list: > + outfile.write("}\n") >
Hi Arnout, Sometimes I want to recompile all reverse-dependant packages, including indirect dependents. So if I have the list of these packages, it's pretty easy to recompile them. Using the approach you suggested some packages are repeatedly printed. Suppose the package A depends on packages B and C, and both B and C depends on package D. When I run show-rrdepends over D, I want to see "B C A", but with your proposed approach the output will be "B A C A" because It does not handle the already printed packages. However the graph-depends script handle this case and that's one of the reasons I implemented it in this script. George Redivo DATACOM Ethernet Switches Rua América, 1000 - Eldorado do Sul, RS Ramal: 3444 george.redivo@datacom.ind.br www.datacom.ind.br ----- Original Message ----- From: "Arnout Vandecappelle" <arnout@mind.be> To: "DATACOM" <george.redivo@datacom.ind.br>, buildroot@buildroot.org Cc: "Thomas Petazzoni" <thomas.petazzoni@free-electrons.com> Sent: Friday, April 28, 2017 6:25:04 PM Subject: Re: [Buildroot] [PATCH 1/1] Create 'make <pkt>-show-rrdepends' command Hi George, On 27-04-17 17:04, George Redivo wrote: > The created command shows, recursively, the reverse depends of a > package, > it means that the command shows not only the direct dependants (which is > done by 'show-rdepends'), but also all indirect dependents. Could you explain a bit more what the use case is you are trying to solve? > To do this it was necessary to create a new parameter '--flat-list', or > '-f', to graph-depends. > This parameter instructs the script to just print the name of package > instead of the .dot syntax. See below for a better alternative. > > Signed-off-by: George Redivo <george.redivo@datacom.ind.br> > --- > Makefile | 1 + > package/pkg-generic.mk | 10 ++++++++++ > support/scripts/graph-depends | 16 ++++++++++++---- > 3 files changed, 23 insertions(+), 4 deletions(-) > > diff --git a/Makefile b/Makefile > index 919d589..61943d8 100644 > --- a/Makefile > +++ b/Makefile > @@ -996,6 +996,7 @@ help: > @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>-show-rrdepends - List, recursivelly, packages which have <pkg> as a dependency' > @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies' > @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies' > @echo ' <pkg>-dirclean - Remove <pkg> build directory' > diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk > index 3b26e6b..c0f83b6 100644 > --- a/package/pkg-generic.mk > +++ b/package/pkg-generic.mk > @@ -353,6 +353,13 @@ define pkg-graph-depends > $$(GRAPHS_DIR)/$$(@).dot > endef > > +define pkg-rrdepends > + @$$(INSTALL) -d $$(GRAPHS_DIR) > + @cd "$$(CONFIG_DIR)"; \ > + $$(TOPDIR)/support/scripts/graph-depends $$(BR2_GRAPH_DEPS_OPTS) \ > + -p $(1) --reverse -f > +endef > + > ################################################################################ > # inner-generic-package -- generates the make targets needed to build a > # generic package > @@ -737,6 +744,9 @@ $(1)-show-depends: > $(1)-show-rdepends: > @echo $$($(2)_RDEPENDENCIES) > > +$(1)-show-rrdepends: > + $(call pkg-rrdepends,$(1)) It is better to use the approach like for show-build-order, i.e.: $(1)-show-rrdepends: $$(patsubst %,%-rrdepends,$$($(2)_FINAL_ALL_DEPENDENCIES)) @printf '%s' $$($(2)_RDEPENDENCIES) However, I would much prefer to rewrite graph-depends completely so it works in a single pass, and have just pkg-show-depends that works recursively like above. Then any filterling like depth or just a single package or reverting the arrows can be done by the graph-depends script itself. That would work a whole lot faster, and in addition would allow us to remove a lot of those annoying extra rules inside inner-generic-package (cfr. my rant recently). But that is of course a much bigger change, so for the time being I'm OK with adding this rrdepends. Regards, Arnout > + > $(1)-show-build-order: $$(patsubst %,%-show-build-order,$$($(2)_FINAL_ALL_DEPENDENCIES)) > $$(info $(1)) > > diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends > index b258c56..f6fec09 100755 > --- a/support/scripts/graph-depends > +++ b/support/scripts/graph-depends > @@ -69,6 +69,8 @@ parser.add_argument("--direct", dest="direct", action='store_true', default=True > help="Draw direct dependencies (the default)") > parser.add_argument("--reverse", dest="direct", action='store_false', > help="Draw reverse dependencies") > +parser.add_argument("--flat-list", '-f', dest="flat_list", action='store_true', default=False, > + help="Do not draw, just print a flat list output.") > args = parser.parse_args() > > check_only = args.check_only > @@ -361,7 +363,10 @@ def print_pkg_deps(depth, pkg): > if pkg in done_deps: > return > done_deps.append(pkg) > - print_attrs(pkg) > + if args.flat_list: > + outfile.write("%s\n" % (pkg)) > + else: > + print_attrs(pkg) > if pkg not in dict_deps: > return > for p in stop_list: > @@ -385,13 +390,16 @@ def print_pkg_deps(depth, pkg): > add = False > break > if add: > - outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir)) > + if not args.flat_list: > + outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir)) > print_pkg_deps(depth+1, d) > > # Start printing the graph data > -outfile.write("digraph G {\n") > +if not args.flat_list: > + outfile.write("digraph G {\n") > > done_deps = [] > print_pkg_deps(0, rootpkg) > > -outfile.write("}\n") > +if not args.flat_list: > + outfile.write("}\n") >
From: George Redivo <george.redivo@datacom.ind.br>
Hello,
Looks like this https://patchwork.ozlabs.org/patch/756075/ was accepted by
Arnout but was left behind. Could we have it applied, please?
---
Carlos Santos (Casantos) - DATACOM, P&D
Rua América, 1000 - Eldorado do Sul, RS, Brasil - 92990-000
casantos@datacom.ind.br +55 51 3933.3000 ext. 3627
http://www.datacom.ind.br
On 03-10-17 14:32, Carlos Santos wrote: > From: George Redivo <george.redivo@datacom.ind.br> > > Hello, > > Looks like this https://patchwork.ozlabs.org/patch/756075/ was accepted by > Arnout but was left behind. Could we have it applied, please? I didn't exactly "accept" this patch. I thought the implementation was acceptable, but I wasn't entirely sure the use case was important enough to warrant the additional complexity. If I understand the use case correctly, what you want is that you have changed something in package A, so you want to rebuild package A and all its recursive dependencies. For that, a recursive dirclean is probably more appropriate: $(1)-dirclean-recursive: $(1)-dirclean $$(patsubst %,%-dirclean-recursive,$$($(2)_FINAL_ALL_DEPENDENCIES)) Regards, Arnout
Hello all ----- Mensagem original ----- > De: "Arnout Vandecappelle" <arnout@mind.be> > Para: "Carlos Santos" <casantos@datacom.ind.br>, buildroot@buildroot.org > Cc: "George Redivo" <george.redivo@datacom.ind.br> > Enviadas: Quarta-feira, 4 de outubro de 2017 13:18:32 > Assunto: Re: [Buildroot] [PATCH] Create 'make <pkt>-show-rrdepends' command > On 03-10-17 14:32, Carlos Santos wrote: >> From: George Redivo <george.redivo@datacom.ind.br> >> >> Hello, >> >> Looks like this https://patchwork.ozlabs.org/patch/756075/ was accepted by >> Arnout but was left behind. Could we have it applied, please? > > I didn't exactly "accept" this patch. I thought the implementation was > acceptable, but I wasn't entirely sure the use case was important enough to > warrant the additional complexity. > > If I understand the use case correctly, what you want is that you have changed > something in package A, so you want to rebuild package A and all its recursive > dependencies. For that, a recursive dirclean is probably more appropriate: > > $(1)-dirclean-recursive: $(1)-dirclean $$(patsubst > %,%-dirclean-recursive,$$($(2)_FINAL_ALL_DEPENDENCIES)) > Not exactly the same i guess, i think this will rebuild package A and all its dependencies (we are going "down" on dependencies). The point of this script is to rebuild package A and all those who depends on it (we are going "up" on dependencies). Based on previous work done on the reverse-dependencies (make <pkg>-show-rdepends), this has been turned in recursive-reverse-dependencies.
On 05-10-17 13:36, Henrique Marks wrote: > Hello all > > ----- Mensagem original ----- >> De: "Arnout Vandecappelle" <arnout@mind.be> >> Para: "Carlos Santos" <casantos@datacom.ind.br>, buildroot@buildroot.org >> Cc: "George Redivo" <george.redivo@datacom.ind.br> >> Enviadas: Quarta-feira, 4 de outubro de 2017 13:18:32 >> Assunto: Re: [Buildroot] [PATCH] Create 'make <pkt>-show-rrdepends' command > >> On 03-10-17 14:32, Carlos Santos wrote: >>> From: George Redivo <george.redivo@datacom.ind.br> >>> >>> Hello, >>> >>> Looks like this https://patchwork.ozlabs.org/patch/756075/ was accepted by >>> Arnout but was left behind. Could we have it applied, please? >> >> I didn't exactly "accept" this patch. I thought the implementation was >> acceptable, but I wasn't entirely sure the use case was important enough to >> warrant the additional complexity. >> >> If I understand the use case correctly, what you want is that you have changed >> something in package A, so you want to rebuild package A and all its recursive >> dependencies. For that, a recursive dirclean is probably more appropriate: >> >> $(1)-dirclean-recursive: $(1)-dirclean $$(patsubst >> %,%-dirclean-recursive,$$($(2)_FINAL_ALL_DEPENDENCIES)) >> > > Not exactly the same i guess, i think this will rebuild package A and all its dependencies (we are going "down" on dependencies). > > The point of this script is to rebuild package A and all those who depends on it (we are going "up" on dependencies). > > Based on previous work done on the reverse-dependencies (make <pkg>-show-rdepends), this has been turned in recursive-reverse-dependencies. Ah right of course, I was getting confused by the double r (reverse-reverse, but of course it means recursive-reverse...). Regards, Arnout
diff --git a/Makefile b/Makefile index 919d589..61943d8 100644 --- a/Makefile +++ b/Makefile @@ -996,6 +996,7 @@ help: @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>-show-rrdepends - List, recursivelly, packages which have <pkg> as a dependency' @echo ' <pkg>-graph-depends - Generate a graph of <pkg>'\''s dependencies' @echo ' <pkg>-graph-rdepends - Generate a graph of <pkg>'\''s reverse dependencies' @echo ' <pkg>-dirclean - Remove <pkg> build directory' diff --git a/package/pkg-generic.mk b/package/pkg-generic.mk index 3b26e6b..c0f83b6 100644 --- a/package/pkg-generic.mk +++ b/package/pkg-generic.mk @@ -353,6 +353,13 @@ define pkg-graph-depends $$(GRAPHS_DIR)/$$(@).dot endef +define pkg-rrdepends + @$$(INSTALL) -d $$(GRAPHS_DIR) + @cd "$$(CONFIG_DIR)"; \ + $$(TOPDIR)/support/scripts/graph-depends $$(BR2_GRAPH_DEPS_OPTS) \ + -p $(1) --reverse -f +endef + ################################################################################ # inner-generic-package -- generates the make targets needed to build a # generic package @@ -737,6 +744,9 @@ $(1)-show-depends: $(1)-show-rdepends: @echo $$($(2)_RDEPENDENCIES) +$(1)-show-rrdepends: + $(call pkg-rrdepends,$(1)) + $(1)-show-build-order: $$(patsubst %,%-show-build-order,$$($(2)_FINAL_ALL_DEPENDENCIES)) $$(info $(1)) diff --git a/support/scripts/graph-depends b/support/scripts/graph-depends index b258c56..f6fec09 100755 --- a/support/scripts/graph-depends +++ b/support/scripts/graph-depends @@ -69,6 +69,8 @@ parser.add_argument("--direct", dest="direct", action='store_true', default=True help="Draw direct dependencies (the default)") parser.add_argument("--reverse", dest="direct", action='store_false', help="Draw reverse dependencies") +parser.add_argument("--flat-list", '-f', dest="flat_list", action='store_true', default=False, + help="Do not draw, just print a flat list output.") args = parser.parse_args() check_only = args.check_only @@ -361,7 +363,10 @@ def print_pkg_deps(depth, pkg): if pkg in done_deps: return done_deps.append(pkg) - print_attrs(pkg) + if args.flat_list: + outfile.write("%s\n" % (pkg)) + else: + print_attrs(pkg) if pkg not in dict_deps: return for p in stop_list: @@ -385,13 +390,16 @@ def print_pkg_deps(depth, pkg): add = False break if add: - outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir)) + if not args.flat_list: + outfile.write("%s -> %s [dir=%s]\n" % (pkg_node_name(pkg), pkg_node_name(d), arrow_dir)) print_pkg_deps(depth+1, d) # Start printing the graph data -outfile.write("digraph G {\n") +if not args.flat_list: + outfile.write("digraph G {\n") done_deps = [] print_pkg_deps(0, rootpkg) -outfile.write("}\n") +if not args.flat_list: + outfile.write("}\n")
The created command shows, recursively, the reverse depends of a package, it means that the command shows not only the direct dependants (which is done by 'show-rdepends'), but also all indirect dependents. To do this it was necessary to create a new parameter '--flat-list', or '-f', to graph-depends. This parameter instructs the script to just print the name of package instead of the .dot syntax. Signed-off-by: George Redivo <george.redivo@datacom.ind.br> --- Makefile | 1 + package/pkg-generic.mk | 10 ++++++++++ support/scripts/graph-depends | 16 ++++++++++++---- 3 files changed, 23 insertions(+), 4 deletions(-)