From: George Redivo <george.redivo@datacom.ind.br>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH 1/1] Create 'make <pkt>-show-rrdepends' command
Date: Mon, 15 May 2017 14:54:46 -0300 (BRT) [thread overview]
Message-ID: <1198207156.22919142.1494870886087.JavaMail.zimbra@datacom.ind.br> (raw)
In-Reply-To: <47ecd969-0c92-0ddd-e647-50bbb7fe5c6e@mind.be>
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 at datacom.ind.br
www.datacom.ind.br
----- Original Message -----
From: "Arnout Vandecappelle" <arnout@mind.be>
To: "DATACOM" <george.redivo@datacom.ind.br>, buildroot at 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")
>
--
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
next prev parent reply other threads:[~2017-05-15 17:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-27 15:04 [Buildroot] [PATCH 1/1] Create 'make <pkt>-show-rrdepends' command George Redivo
2017-04-28 21:25 ` Arnout Vandecappelle
2017-05-15 17:54 ` George Redivo [this message]
2017-10-03 12:32 ` [Buildroot] [PATCH] " Carlos Santos
2017-10-04 16:18 ` Arnout Vandecappelle
2017-10-05 11:36 ` Henrique Marks
2017-10-05 17:52 ` Arnout Vandecappelle
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1198207156.22919142.1494870886087.JavaMail.zimbra@datacom.ind.br \
--to=george.redivo@datacom.ind.br \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox