From: "Mike Frysinger" <vapier@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/pax-utils:master commit in: /
Date: Mon, 13 Jul 2015 09:14:57 +0000 (UTC) [thread overview]
Message-ID: <1433394247.b9e102a371169f2aec0b9945c6450b9576a95012.vapier@gentoo> (raw)
commit: b9e102a371169f2aec0b9945c6450b9576a95012
Author: Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 4 05:04:07 2015 +0000
Commit: Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Jun 4 05:04:07 2015 +0000
URL: https://gitweb.gentoo.org/proj/pax-utils.git/commit/?id=b9e102a3
lddtree.py: convert to arparse
lddtree.py | 184 ++++++++++++++++++++++++++++++-------------------------------
1 file changed, 91 insertions(+), 93 deletions(-)
diff --git a/lddtree.py b/lddtree.py
index c284182..645cfd1 100755
--- a/lddtree.py
+++ b/lddtree.py
@@ -9,13 +9,42 @@
This does not work like `ldd` in that we do not execute/load code (only read
files on disk), and we should the ELFs as a tree rather than a flat list.
+
+Paths may be globs that lddtree will take care of expanding.
+Useful when you want to glob a path under the ROOT path.
+
+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.
+
+The --bindir and --libdir flags are used to normalize the output subdirs
+when used with --copy-to-tree.
+ e.g. lddtree --copy-to-tree /foo /bin/bash /usr/sbin/lspci /usr/bin/lsof
+This will mirror the input paths in the output. So you will end up with
+/foo/bin/bash and /foo/usr/sbin/lspci and /foo/usr/bin/lsof. Similarly,
+the libraries needed will be scattered among /foo/lib/ and /foo/usr/lib/
+and perhaps other paths (like /foo/lib64/ and /usr/lib/gcc/...). You can
+collapse all that down into nice directory structure.
+ e.g. lddtree --copy-to-tree /foo /bin/bash /usr/sbin/lspci /usr/bin/lsof \\
+ --bindir /bin --libdir /lib
+This will place bash, lspci, and lsof into /foo/bin/. All the libraries
+they need will be placed into /foo/lib/ only.
"""
from __future__ import print_function
+import argparse
import glob
import errno
-import optparse
import os
import shutil
import sys
@@ -451,13 +480,9 @@ def ParseELF(path, root='/', prefix='', ldpaths={'conf':[], 'env':[], 'interp':[
return ret
-def _NormalizePath(option, _opt, value, parser):
- setattr(parser.values, option.dest, normpath(value))
-
-
-def _ShowVersion(_option, _opt, _value, _parser):
- print('lddtree by Mike Frysinger <vapier@gentoo.org>')
- sys.exit(0)
+class _NormalizePathAction(argparse.Action):
+ def __call__(self, parser, namespace, values, option_string=None):
+ setattr(namespace, self.dest, normpath(values))
def _ActionShow(options, elf):
@@ -590,91 +615,64 @@ def _ActionCopy(options, elf):
def main(argv):
- parser = optparse.OptionParser("""%prog [options] <ELFs>
-
-Display ELF dependencies as a tree
-
-<ELFs> can be globs that lddtree will take care of expanding.
-Useful when you want to glob a path under the ROOT path.
-
-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.
-
-The --bindir and --libdir flags are used to normalize the output subdirs
-when used with --copy-to-tree.
- e.g. lddtree --copy-to-tree /foo /bin/bash /usr/sbin/lspci /usr/bin/lsof
-This will mirror the input paths in the output. So you will end up with
-/foo/bin/bash and /foo/usr/sbin/lspci and /foo/usr/bin/lsof. Similarly,
-the libraries needed will be scattered among /foo/lib/ and /foo/usr/lib/
-and perhaps other paths (like /foo/lib64/ and /usr/lib/gcc/...). You can
-collapse all that down into nice directory structure.
- e.g. lddtree --copy-to-tree /foo /bin/bash /usr/sbin/lspci /usr/bin/lsof \\
- --bindir /bin --libdir /lib
-This will place bash, lspci, and lsof into /foo/bin/. All the libraries
-they need will be placed into /foo/lib/ only.""")
- parser.add_option('-a', '--all',
- action='store_true', default=False,
- help='Show all duplicated dependencies')
- parser.add_option('-R', '--root',
- default=os.environ.get('ROOT', ''), type='string',
- action='callback', callback=_NormalizePath,
- help='Search for all files/dependencies in ROOT')
- parser.add_option('-P', '--prefix',
- default=os.environ.get(
- 'EPREFIX', '@GENTOO_PORTAGE_EPREFIX@'), type='string',
- action='callback', callback=_NormalizePath,
- help='Specify EPREFIX for binaries (for Gentoo Prefix)')
- 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('-l', '--list',
- action='store_true', default=False,
- help='Display output in a simple list (easy for copying)')
- parser.add_option('-x', '--debug',
- action='store_true', default=False,
- help='Run with debugging')
- parser.add_option('-v', '--verbose',
- action='store_true', default=False,
- help='Be verbose')
- parser.add_option('--skip-non-elfs',
- action='store_true', default=False,
- help='Skip plain (non-ELF) files instead of warning')
- parser.add_option('-V', '--version',
- action='callback', callback=_ShowVersion,
- help='Show version information')
-
- group = optparse.OptionGroup(parser, 'Copying options')
- group.add_option('--copy-to-tree',
- dest='dest', default=None, type='string',
- action='callback', callback=_NormalizePath,
- help='Copy all files to the specified tree')
- group.add_option('--bindir',
- default=None, type='string',
- action='callback', callback=_NormalizePath,
- help='Dir to store all ELFs specified on the command line')
- group.add_option('--libdir',
- default=None, type='string',
- action='callback', callback=_NormalizePath,
- help='Dir to store all ELF libs')
- group.add_option('--generate-wrappers',
- action='store_true', default=False,
- help='Wrap executable ELFs with scripts for local ldso')
- group.add_option('--copy-non-elfs',
- action='store_true', default=False,
- help='Copy over plain (non-ELF) files instead of warn+ignore')
- parser.add_option_group(group)
-
- (options, paths) = parser.parse_args(argv)
+ parser = argparse.ArgumentParser(
+ description=__doc__,
+ formatter_class=argparse.RawDescriptionHelpFormatter)
+ parser.add_argument('-a', '--all',
+ action='store_true', default=False,
+ help='Show all duplicated dependencies')
+ parser.add_argument('-R', '--root',
+ default=os.environ.get('ROOT', ''), type=str,
+ action=_NormalizePathAction,
+ help='Search for all files/dependencies in ROOT')
+ parser.add_argument('-P', '--prefix',
+ default=os.environ.get(
+ 'EPREFIX', '@GENTOO_PORTAGE_EPREFIX@'), type=str,
+ action=_NormalizePathAction,
+ help='Specify EPREFIX for binaries (for Gentoo Prefix)')
+ parser.add_argument('--no-auto-root',
+ dest='auto_root', action='store_false', default=True,
+ help='Do not automatically prefix input ELFs with ROOT')
+ parser.add_argument('-l', '--list',
+ action='store_true', default=False,
+ help='Display output in a simple list (easy for copying)')
+ parser.add_argument('-x', '--debug',
+ action='store_true', default=False,
+ help='Run with debugging')
+ parser.add_argument('-v', '--verbose',
+ action='store_true', default=False,
+ help='Be verbose')
+ parser.add_argument('--skip-non-elfs',
+ action='store_true', default=False,
+ help='Skip plain (non-ELF) files instead of warning')
+ parser.add_argument('-V', '--version',
+ action='version',
+ version='lddtree by Mike Frysinger <vapier@gentoo.org>',
+ help='Show version information')
+ parser.add_argument('path', nargs='+')
+
+ group = parser.add_argument_group('Copying options')
+ group.add_argument('--copy-to-tree',
+ dest='dest', default=None, type=str,
+ action=_NormalizePathAction,
+ help='Copy all files to the specified tree')
+ group.add_argument('--bindir',
+ default=None, type=str,
+ action=_NormalizePathAction,
+ help='Dir to store all ELFs specified on the command line')
+ group.add_argument('--libdir',
+ default=None, type=str,
+ action=_NormalizePathAction,
+ help='Dir to store all ELF libs')
+ group.add_argument('--generate-wrappers',
+ action='store_true', default=False,
+ help='Wrap executable ELFs with scripts for local ldso')
+ group.add_argument('--copy-non-elfs',
+ action='store_true', default=False,
+ help='Copy over plain (non-ELF) files instead of warn+ignore')
+
+ options = parser.parse_args(argv)
+ paths = options.path
if options.root != '/':
options.root += '/'
next reply other threads:[~2015-07-13 9:15 UTC|newest]
Thread overview: 253+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-13 9:14 Mike Frysinger [this message]
-- strict thread matches above, loose matches on Subject: below --
2024-09-22 4:33 [gentoo-commits] proj/pax-utils:master commit in: / Sam James
2024-09-22 4:30 Sam James
2024-08-09 10:06 Sam James
2024-08-09 10:06 Sam James
2024-08-09 10:06 Sam James
2024-08-09 10:06 Sam James
2024-08-09 10:06 Sam James
2024-08-09 10:06 Sam James
2024-08-09 10:02 Sam James
2024-07-22 21:07 Mike Gilbert
2024-07-22 20:08 Mike Gilbert
2024-01-25 6:52 Mike Frysinger
2024-01-25 5:57 Mike Frysinger
2024-01-25 5:57 Mike Frysinger
2024-01-25 5:36 Mike Frysinger
2024-01-25 5:21 Mike Frysinger
2024-01-25 5:06 Mike Frysinger
2024-01-25 5:06 Mike Frysinger
2024-01-25 4:44 Mike Frysinger
2024-01-25 2:53 Mike Frysinger
2024-01-25 2:53 Mike Frysinger
2024-01-25 2:53 Mike Frysinger
2024-01-25 2:14 Mike Frysinger
2024-01-24 22:53 Mike Frysinger
2024-01-24 22:15 Mike Frysinger
2024-01-24 15:44 Mike Frysinger
2024-01-16 5:13 Mike Frysinger
2024-01-16 5:13 Mike Frysinger
2024-01-10 8:05 Mike Frysinger
2024-01-10 8:02 Mike Frysinger
2024-01-10 8:02 Mike Frysinger
2024-01-10 7:58 Mike Frysinger
2024-01-02 18:03 Mike Frysinger
2024-01-02 18:03 Mike Frysinger
2024-01-02 18:03 Mike Frysinger
2024-01-02 18:03 Mike Frysinger
2024-01-02 16:28 Mike Frysinger
2024-01-01 15:43 Mike Frysinger
2024-01-01 15:43 Mike Frysinger
2023-12-22 5:31 Mike Frysinger
2023-12-22 5:31 Mike Frysinger
2023-12-22 5:31 Mike Frysinger
2023-12-22 2:31 Mike Frysinger
2023-12-22 2:31 Mike Frysinger
2023-12-22 2:31 Mike Frysinger
2023-12-14 21:28 Mike Frysinger
2023-12-14 21:28 Mike Frysinger
2023-12-14 19:57 Mike Frysinger
2023-11-23 13:31 Sam James
2023-02-13 5:26 Sam James
2023-02-13 5:26 Sam James
2023-01-29 5:56 Sam James
2023-01-29 5:56 Sam James
2023-01-29 5:56 Sam James
2023-01-29 3:41 Sam James
2023-01-29 3:36 Sam James
2023-01-29 3:36 Sam James
2023-01-26 21:46 Sam James
2023-01-06 7:15 Sam James
2022-09-28 7:42 Mike Frysinger
2022-09-28 7:42 Mike Frysinger
2022-09-28 7:42 Mike Frysinger
2022-09-28 7:42 Mike Frysinger
2022-09-28 7:42 Mike Frysinger
2022-09-28 7:42 Mike Frysinger
2022-09-28 7:42 Mike Frysinger
2022-09-21 8:28 Mike Frysinger
2022-09-21 8:26 Mike Frysinger
2022-09-21 8:20 Mike Frysinger
2022-07-31 4:56 Sam James
2022-07-12 6:33 Sam James
2022-07-12 6:33 Sam James
2022-04-25 1:20 WANG Xuerui
2022-03-24 15:42 Sam James
2022-03-09 8:01 Mike Frysinger
2022-02-07 7:18 Fabian Groffen
2022-01-23 2:47 Mike Frysinger
2021-12-24 1:45 Sam James
2021-12-17 5:19 Mike Frysinger
2021-10-17 5:15 Mike Frysinger
2021-10-05 1:05 Mike Frysinger
2021-10-04 22:05 Mike Frysinger
2021-09-20 4:51 Sam James
2021-07-22 21:31 Sergei Trofimovich
2021-07-22 21:16 Sergei Trofimovich
2021-07-02 22:04 Sergei Trofimovich
2021-06-10 7:07 Sergei Trofimovich
2021-06-10 7:02 Sergei Trofimovich
2021-04-19 4:58 Mike Frysinger
2021-04-18 18:29 Mike Frysinger
2021-04-17 5:39 Mike Frysinger
2021-04-17 5:39 Mike Frysinger
2021-04-17 0:38 Mike Frysinger
2021-04-16 19:26 Mike Frysinger
2021-04-16 19:26 Mike Frysinger
2021-04-16 19:26 Mike Frysinger
2021-04-16 19:03 Mike Frysinger
2021-04-16 19:03 Mike Frysinger
2021-04-16 15:08 Mike Frysinger
2021-04-16 15:08 Mike Frysinger
2021-04-16 15:08 Mike Frysinger
2021-04-16 3:41 Mike Frysinger
2021-04-16 3:39 Mike Frysinger
2021-04-16 3:39 Mike Frysinger
2021-04-16 1:56 Mike Frysinger
2021-04-16 1:56 Mike Frysinger
2021-04-16 0:48 Mike Frysinger
2021-04-16 0:48 Mike Frysinger
2021-02-26 11:51 Sergei Trofimovich
2021-02-04 18:51 Sergei Trofimovich
2021-02-03 20:41 Sergei Trofimovich
2021-02-03 20:17 Sergei Trofimovich
2021-02-03 19:46 Sergei Trofimovich
2021-01-01 14:08 Fabian Groffen
2021-01-01 14:08 Fabian Groffen
2020-12-20 19:53 Sergei Trofimovich
2020-10-05 17:46 Sergei Trofimovich
2020-08-14 22:17 Sergei Trofimovich
2020-04-13 10:41 Sergei Trofimovich
2020-04-06 18:00 Sergei Trofimovich
2020-03-26 19:27 Mike Frysinger
2020-03-26 17:09 Mike Frysinger
2020-03-26 17:09 Mike Frysinger
2020-03-19 0:00 Sergei Trofimovich
2020-03-18 23:39 Sergei Trofimovich
2020-02-16 10:57 Sergei Trofimovich
2020-02-16 10:50 Sergei Trofimovich
2020-02-16 10:48 Sergei Trofimovich
2020-02-16 10:17 Sergei Trofimovich
2019-01-14 22:53 Sergei Trofimovich
2018-11-19 22:20 Sergei Trofimovich
2018-06-07 14:09 Mike Frysinger
2018-06-07 14:09 Mike Frysinger
2018-06-07 14:09 Mike Frysinger
2018-06-07 14:09 Mike Frysinger
2018-06-07 14:09 Mike Frysinger
2018-06-07 14:09 Mike Frysinger
2018-06-07 14:09 Mike Frysinger
2018-06-07 14:09 Mike Frysinger
2018-06-07 14:09 Mike Frysinger
2018-06-07 4:44 Mike Frysinger
2018-06-07 4:44 Mike Frysinger
2018-06-07 4:44 Mike Frysinger
2018-02-24 10:16 Sergei Trofimovich
2017-09-18 9:27 Fabian Groffen
2017-09-18 9:27 Fabian Groffen
2017-09-18 7:06 Fabian Groffen
2017-03-14 7:19 Mike Frysinger
2017-02-16 21:24 Mike Frysinger
2017-02-16 21:24 Mike Frysinger
2017-02-16 21:24 Mike Frysinger
2017-02-11 7:06 Mike Frysinger
2017-02-01 23:08 Mike Frysinger
2017-02-01 23:08 Mike Frysinger
2017-02-01 23:08 Mike Frysinger
2017-01-24 20:39 Mike Frysinger
2017-01-24 20:39 Mike Frysinger
2017-01-24 6:50 Mike Frysinger
2017-01-24 6:50 Mike Frysinger
2017-01-24 6:50 Mike Frysinger
2017-01-24 6:50 Mike Frysinger
2017-01-22 17:59 Mike Frysinger
2017-01-22 17:59 Mike Frysinger
2017-01-22 17:59 Mike Frysinger
2017-01-22 17:59 Mike Frysinger
2017-01-22 17:59 Mike Frysinger
2017-01-22 17:59 Mike Frysinger
2017-01-22 17:59 Mike Frysinger
2017-01-22 17:59 Mike Frysinger
2017-01-22 17:59 Mike Frysinger
2016-11-27 3:43 Mike Frysinger
2016-11-15 4:02 Mike Frysinger
2016-11-15 4:02 Mike Frysinger
2016-11-14 14:57 Mike Frysinger
2016-11-12 7:15 Mike Frysinger
2016-11-12 7:15 Mike Frysinger
2016-11-12 7:15 Mike Frysinger
2016-11-12 7:15 Mike Frysinger
2016-11-12 7:15 Mike Frysinger
2016-11-12 7:15 Mike Frysinger
2016-11-08 20:47 Mike Gilbert
2016-06-20 17:46 Mike Frysinger
2016-06-20 4:03 Mike Frysinger
2016-06-20 4:03 Mike Frysinger
2016-06-20 3:22 Mike Frysinger
2016-06-20 3:22 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-06-20 3:08 Mike Frysinger
2016-05-31 22:27 Mike Frysinger
2016-03-03 21:15 Mike Frysinger
2016-02-10 19:41 Mike Frysinger
2016-02-10 18:54 Mike Frysinger
2016-01-28 22:42 Mike Frysinger
2016-01-03 22:23 Mike Frysinger
2016-01-03 22:23 Mike Frysinger
2016-01-03 22:01 Mike Frysinger
2016-01-02 15:26 Mike Frysinger
2016-01-02 3:52 Mike Frysinger
2015-12-19 19:41 Mike Frysinger
2015-12-17 3:24 Mike Frysinger
2015-12-17 3:24 Mike Frysinger
2015-12-17 3:24 Mike Frysinger
2015-12-17 3:24 Mike Frysinger
2015-12-12 22:45 Mike Frysinger
2015-12-12 22:45 Mike Frysinger
2015-12-12 22:45 Mike Frysinger
2015-12-12 22:45 Mike Frysinger
2015-12-12 22:45 Mike Frysinger
2015-12-12 22:45 Mike Frysinger
2015-11-26 8:43 Mike Frysinger
2015-10-26 4:35 Mike Frysinger
2015-10-08 20:31 Mike Frysinger
2015-09-19 6:27 Mike Frysinger
2015-09-19 6:27 Mike Frysinger
2015-09-12 4:17 Mike Frysinger
2015-08-28 0:33 Mike Frysinger
2015-08-26 6:29 Mike Frysinger
2015-08-24 21:22 Mike Frysinger
2015-08-24 21:22 Mike Frysinger
2015-08-24 21:22 Mike Frysinger
2015-08-20 14:39 Mike Frysinger
2015-08-20 14:39 Mike Frysinger
2015-08-20 14:39 Mike Frysinger
2015-08-20 14:33 Mike Frysinger
2015-08-20 14:33 Mike Frysinger
2015-08-20 13:32 Mike Frysinger
2015-08-18 15:56 Mike Frysinger
2015-08-18 15:35 Mike Frysinger
2015-08-18 15:35 Mike Frysinger
2015-08-18 14:39 Mike Frysinger
2015-08-18 14:38 Mike Frysinger
2015-07-13 9:14 Mike Frysinger
2015-07-13 9:14 Mike Frysinger
2015-05-24 3:22 Mike Frysinger
2015-03-29 20:07 Mike Frysinger
2015-03-29 20:07 Mike Frysinger
2015-03-29 20:07 Mike Frysinger
2015-03-10 5:31 Mike Frysinger
2015-03-10 5:31 Mike Frysinger
2015-03-10 4:19 Mike Frysinger
2015-03-10 3:36 Mike Frysinger
2015-03-06 11:52 Mike Frysinger
2015-03-04 22:35 Mike Frysinger
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=1433394247.b9e102a371169f2aec0b9945c6450b9576a95012.vapier@gentoo \
--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