public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Mike Frysinger (vapier)" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
Date: Mon, 25 Mar 2013 22:35:59 +0000 (UTC)	[thread overview]
Message-ID: <20130325223559.79A482171D@flycatcher.gentoo.org> (raw)

vapier      13/03/25 22:35:59

  Modified:             lddtree.py
  Log:
  lddtree.py: when using --root, stop copying files into the output using that path too
  
  similarly, have the files specified on the command line automatically prefix with the root path (controllable by --no-auto-root)

Revision  Changes    Path
1.25                 pax-utils/lddtree.py

file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.25&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.25&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.24&r2=1.25

Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- lddtree.py	24 Mar 2013 05:37:34 -0000	1.24
+++ lddtree.py	25 Mar 2013 22:35:59 -0000	1.25
@@ -3,7 +3,7 @@
 # Copyright 2012 Mike Frysinger <vapier@gentoo.org>
 # Use of this source code is governed by a BSD-style license (BSD-3)
 # pylint: disable=C0301
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.24 2013/03/24 05:37:34 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.25 2013/03/25 22:35:59 vapier Exp $
 
 """Read the ELF dependency tree and show it
 
@@ -319,7 +319,7 @@
 
 
 def _ShowVersion(_option, _opt, _value, _parser):
-  d = '$Id: lddtree.py,v 1.24 2013/03/24 05:37:34 vapier Exp $'.split()
+  d = '$Id: lddtree.py,v 1.25 2013/03/25 22:35:59 vapier Exp $'.split()
   print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
   sys.exit(0)
 
@@ -365,11 +365,16 @@
 
 def _ActionCopy(options, elf):
   """Copy the ELF and its dependencies to a destination tree"""
-  def _copy(src):
+  def _copy(src, striproot=True):
     if src is None:
       return
 
-    dst = options.dest + src
+    if striproot:
+      subdst = src[len(options.root) - 1:]
+    else:
+      subdst = src
+    dst = options.dest + subdst
+
     if os.path.exists(dst):
       # See if they're the same file.
       ostat = os.stat(src)
@@ -396,7 +401,7 @@
       os.unlink(dst)
     shutil.copy2(src, dst)
 
-  _copy(elf['path'])
+  _copy(elf['path'], striproot=options.auto_root)
   _copy(elf['interp'])
   for lib in elf['libs']:
     _copy(elf['libs'][lib]['path'])
@@ -405,14 +410,30 @@
 def main(argv):
   parser = optparse.OptionParser("""%prog [options] <ELFs>
 
-Display ELF dependencies as a tree""")
+Display ELF dependencies as a tree
+
+When using the --root option, all paths are implicitly prefixed by that.
+  e.g. lddtree -R /my/magic/root /bin/bash
+This will load up the ELF found at /my/magic/root/bin/bash and then resolve
+all libraries via that path.  If you wish to actually read /bin/bash (and
+so use the ROOT path as an alternative library tree), you can specify the
+--no-auto-root option.
+
+When pairing --root with --copy-to-tree, the ROOT path will be stripped.
+  e.g. lddtree -R /my/magic/root --copy-to-tree /foo /bin/bash
+You will see /foo/bin/bash and /foo/lib/libc.so.6 and not paths like
+/foo/my/magic/root/bin/bash.  If you want that, you'll have to manually
+add the ROOT path to the output path.""")
   parser.add_option('-a', '--all',
     action='store_true', default=False,
     help=('Show all duplicated dependencies'))
   parser.add_option('-R', '--root',
-    dest='root', default=os.environ.get('ROOT', ''), type='string',
+    default=os.environ.get('ROOT', ''), type='string',
     action='callback', callback=_NormalizePath,
     help=('Search for all files/dependencies in ROOT'))
+  parser.add_option('--no-auto-root',
+    dest='auto_root', action='store_false', default=True,
+    help=('Do not automatically prefix input ELFs with ROOT'))
   parser.add_option('--copy-to-tree',
     dest='dest', default=None, type='string',
     action='callback', callback=_NormalizePath,
@@ -449,6 +470,8 @@
   # Process all the files specified.
   ret = 0
   for path in paths:
+    if options.auto_root:
+      path = options.root + path.lstrip('/')
     try:
       elf = ParseELF(path, options.root, ldpaths)
     except (exceptions.ELFError, IOError) as e:





             reply	other threads:[~2013-03-25 22:36 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-25 22:35 Mike Frysinger (vapier) [this message]
  -- strict thread matches above, loose matches on Subject: below --
2014-11-20  1:22 [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py Mike Frysinger (vapier)
2014-11-20  1:17 Mike Frysinger (vapier)
2014-11-20  1:13 Mike Frysinger (vapier)
2014-08-01  2:20 Mike Frysinger (vapier)
2014-08-01  1:39 Mike Frysinger (vapier)
2014-07-30 14:35 Mike Frysinger (vapier)
2014-07-30  8:22 Mike Frysinger (vapier)
2014-07-30  4:34 Mike Frysinger (vapier)
2014-07-30  4:28 Mike Frysinger (vapier)
2014-07-30  4:16 Mike Frysinger (vapier)
2014-07-30  4:07 Mike Frysinger (vapier)
2014-07-30  4:06 Mike Frysinger (vapier)
2014-03-20  8:25 Mike Frysinger (vapier)
2014-03-20  8:18 Mike Frysinger (vapier)
2013-04-23  2:16 Mike Frysinger (vapier)
2013-04-22 22:02 Mike Frysinger (vapier)
2013-04-22 18:31 Mike Frysinger (vapier)
2013-04-05 22:26 Mike Frysinger (vapier)
2013-04-03  4:51 Mike Frysinger (vapier)
2013-03-28 17:14 Mike Frysinger (vapier)
2013-03-28  1:17 Mike Frysinger (vapier)
2013-03-28  0:58 Mike Frysinger (vapier)
2013-03-27  3:22 Mike Frysinger (vapier)
2013-03-27  3:20 Mike Frysinger (vapier)
2013-03-27  3:20 Mike Frysinger (vapier)
2013-03-27  3:07 Mike Frysinger (vapier)
2013-03-26  5:22 Mike Frysinger (vapier)
2013-03-26  5:03 Mike Frysinger (vapier)
2013-03-26  4:50 Mike Frysinger (vapier)
2013-03-24  5:37 Mike Frysinger (vapier)
2013-03-24  5:27 Mike Frysinger (vapier)
2013-03-23  7:28 Mike Frysinger (vapier)
2013-03-21 22:55 Mike Frysinger (vapier)
2013-03-21  3:04 Mike Frysinger (vapier)
2013-03-21  3:03 Mike Frysinger (vapier)
2013-01-05 20:39 Mike Frysinger (vapier)
2012-12-14  4:22 Mike Frysinger (vapier)
2012-11-26 20:06 Mike Frysinger (vapier)
2012-11-24 19:44 Mike Frysinger (vapier)
2012-11-24 17:01 Mike Frysinger (vapier)
2012-11-24 16:54 Mike Frysinger (vapier)
2012-11-17  0:11 Mike Frysinger (vapier)
2012-11-16 23:53 Mike Frysinger (vapier)
2012-11-15 20:39 Mike Frysinger (vapier)
2012-11-15 20:28 Mike Frysinger (vapier)
2012-11-15 20:26 Mike Frysinger (vapier)
2012-11-15 19:33 Mike Frysinger (vapier)
2012-11-13  5:10 Mike Frysinger (vapier)
2012-11-13  2:33 Mike Frysinger (vapier)
2012-11-12 23:08 Mike Frysinger (vapier)

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=20130325223559.79A482171D@flycatcher.gentoo.org \
    --to=vapier@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.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