Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Robert Yang <liezhi.yang@windriver.com>
To: Chen Qi <Qi.Chen@windriver.com>,
	<openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH 1/1] oe-depends-dot: print dependency chains for '--why' option
Date: Tue, 8 May 2018 10:22:45 +0800	[thread overview]
Message-ID: <83120d79-16cb-b071-e481-ec221f2fcdf5@windriver.com> (raw)
In-Reply-To: <6d90dfb28dcf9eb98af81c0277d03547772fe1b7.1525745853.git.Qi.Chen@windriver.com>



On 05/08/2018 10:19 AM, Chen Qi wrote:
> When using '--why' option, we currently only list elements.
> It's better to print out dependency chains. This patch adds
> such abitility.
> 
> e.g.
>    $ oe-depends-dot -k util-linux -w recipe-depends.dot
>    Because: packagegroup-core-boot systemd-compat-units systemd shadow core-image-minimal dbus e2fsprogs
>    core-image-minimal -> packagegroup-core-boot -> systemd-compat-units -> systemd -> dbus -> shadow -> util-linux
>    core-image-minimal -> packagegroup-core-boot -> systemd-compat-units -> systemd -> dbus -> e2fsprogs -> util-linux

Looks great to me.

// Robert

> 
> Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
> ---
>   scripts/oe-depends-dot | 46 ++++++++++++++++++++++++++++++++++++++++++++++
>   1 file changed, 46 insertions(+)
> 
> diff --git a/scripts/oe-depends-dot b/scripts/oe-depends-dot
> index 5cec23b..6c7e9d3 100755
> --- a/scripts/oe-depends-dot
> +++ b/scripts/oe-depends-dot
> @@ -47,6 +47,51 @@ class Dot(object):
>           if len(sys.argv) != 3 and len(sys.argv) < 5:
>               print('ERROR: Not enough args, see --help for usage')
>   
> +    @staticmethod
> +    def insert_dep_chain(chain, rdeps, alldeps):
> +        """
> +        insert elements to chain from rdeps, according to alldeps
> +        """
> +        # chain should at least contain one element
> +        if len(chain) == 0:
> +            raise
> +
> +        inserted_elements = []
> +        for rdep in rdeps:
> +            if rdep in chain:
> +                continue
> +            else:
> +                for i in range(0, len(chain)-1):
> +                    if chain[i] in alldeps[rdep] and rdep in alldeps[chain[i+1]]:
> +                        chain.insert(i+1, rdep)
> +                        inserted_elements.append(rdep)
> +                        break
> +                if chain[-1] in alldeps[rdep] and rdep not in chain:
> +                    chain.append(rdep)
> +                    inserted_elements.append(rdep)
> +        return inserted_elements
> +
> +    @staticmethod
> +    def print_dep_chains(key, rdeps, alldeps):
> +        rlist = rdeps.copy()
> +        chain = []
> +        removed_rdeps = [] # hold rdeps removed from rlist
> +
> +        chain.append(key)
> +        while (len(rlist) != 0):
> +            # insert chain from rlist
> +            inserted_elements = Dot.insert_dep_chain(chain, rlist, alldeps)
> +            if not inserted_elements:
> +                if chain[-1] in rlist:
> +                    rlist.remove(chain[-1])
> +                    removed_rdeps.append(chain[-1])
> +                chain.pop()
> +                continue
> +            else:
> +                # insert chain from removed_rdeps
> +                Dot.insert_dep_chain(chain, removed_rdeps, alldeps)
> +                print(' -> '.join(list(reversed(chain))))
> +
>       def main(self):
>           #print(self.args.dotfile[0])
>           # The format is {key: depends}
> @@ -109,6 +154,7 @@ class Dot(object):
>                   if self.args.key in v and not k in reverse_deps:
>                       reverse_deps.append(k)
>               print('Because: %s' % ' '.join(reverse_deps))
> +            Dot.print_dep_chains(self.args.key, reverse_deps, depends)
>   
>   if __name__ == "__main__":
>       try:
> 


      reply	other threads:[~2018-05-08  2:23 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-08  2:19 [PATCH 0/1] oe-depends-dot: print dependency chains for '--why' option Chen Qi
2018-05-08  2:19 ` [PATCH 1/1] " Chen Qi
2018-05-08  2:22   ` Robert Yang [this message]

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=83120d79-16cb-b071-e481-ec221f2fcdf5@windriver.com \
    --to=liezhi.yang@windriver.com \
    --cc=Qi.Chen@windriver.com \
    --cc=openembedded-core@lists.openembedded.org \
    /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