* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-07-30 4:06 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-07-30 4:06 UTC (permalink / raw
To: gentoo-commits
vapier 14/07/30 04:06:56
Modified: lddtree.py
Log:
lddtree.py: update copyright
Revision Changes Path
1.45 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.45&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.45&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.44&r2=1.45
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -r1.44 -r1.45
--- lddtree.py 20 Mar 2014 08:25:45 -0000 1.44
+++ lddtree.py 30 Jul 2014 04:06:56 -0000 1.45
@@ -1,9 +1,10 @@
#!/usr/bin/python
-# Copyright 2012-2013 Gentoo Foundation
-# Copyright 2012-2013 Mike Frysinger <vapier@gentoo.org>
+# Copyright 2012-2014 Gentoo Foundation
+# Copyright 2012-2014 Mike Frysinger <vapier@gentoo.org>
+# Copyright 2012-2014 The Chromium OS Authors
# 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.44 2014/03/20 08:25:45 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.45 2014/07/30 04:06:56 vapier Exp $
# TODO: Handle symlinks.
@@ -385,7 +386,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.44 2014/03/20 08:25:45 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.45 2014/07/30 04:06:56 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-11-20 1:22 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-11-20 1:22 UTC (permalink / raw
To: gentoo-commits
vapier 14/11/20 01:22:36
Modified: lddtree.py
Log:
lddtree.py: if we could not find the lib for copying, issue a warning and skip the path
Revision Changes Path
1.56 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.56&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.56&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.55&r2=1.56
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.55
retrieving revision 1.56
diff -u -r1.55 -r1.56
--- lddtree.py 20 Nov 2014 01:17:23 -0000 1.55
+++ lddtree.py 20 Nov 2014 01:22:36 -0000 1.56
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.55 2014/11/20 01:17:23 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.56 2014/11/20 01:22:36 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -447,7 +447,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.55 2014/11/20 01:17:23 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.56 2014/11/20 01:22:36 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -557,6 +557,9 @@
for lib in elf['libs']:
libdata = elf['libs'][lib]
path = libdata['realpath']
+ if path is None:
+ warn('could not locate library: %s' % lib)
+ continue
if not options.libdir:
libpaths.add(_StripRoot(os.path.dirname(path)))
_copy(path, libdata['path'], outdir=options.libdir)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-11-20 1:17 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-11-20 1:17 UTC (permalink / raw
To: gentoo-commits
vapier 14/11/20 01:17:23
Modified: lddtree.py
Log:
lddtree.py: plumb down --debug into ParseLdSoConf
Revision Changes Path
1.55 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.55&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.55&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.54&r2=1.55
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -r1.54 -r1.55
--- lddtree.py 20 Nov 2014 01:13:19 -0000 1.54
+++ lddtree.py 20 Nov 2014 01:17:23 -0000 1.55
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.54 2014/11/20 01:13:19 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.55 2014/11/20 01:17:23 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -174,7 +174,7 @@
return dedupe(ldpaths)
-def ParseLdSoConf(ldso_conf, root='/', _first=True):
+def ParseLdSoConf(ldso_conf, root='/', debug=False, _first=True):
"""Load all the paths from a given ldso config file
This should handle comments, whitespace, and "include" statements.
@@ -182,6 +182,7 @@
Args:
ldso_conf: The file to scan
root: The path to prepend to all paths found
+ debug: Enable debug output
_first: Recursive use only; is this the first ELF ?
Returns:
@@ -189,7 +190,9 @@
"""
paths = []
+ dbg_pfx = '' if _first else ' '
try:
+ dbg(debug, '%sParseLdSoConf(%s)' % (dbg_pfx, ldso_conf))
with open(ldso_conf) as f:
for line in f.readlines():
line = line.split('#', 1)[0].strip()
@@ -201,8 +204,9 @@
line = root + line.lstrip('/')
else:
line = os.path.dirname(ldso_conf) + '/' + line
+ dbg(debug, '%s glob: %s' % (dbg_pfx, line))
for path in glob.glob(line):
- paths += ParseLdSoConf(path, root=root, _first=False)
+ paths += ParseLdSoConf(path, root=root, debug=debug, _first=False)
else:
paths += [normpath(root + line)]
except IOError as e:
@@ -217,7 +221,7 @@
return paths
-def LoadLdpaths(root='/', prefix=''):
+def LoadLdpaths(root='/', prefix='', debug=False):
"""Load linker paths from common locations
This parses the ld.so.conf and LD_LIBRARY_PATH env var.
@@ -225,6 +229,7 @@
Args:
root: The root tree to prepend to paths
prefix: The path under |root| to search
+ debug: Enable debug output
Returns:
dict containing library paths to search
@@ -247,7 +252,8 @@
ldpaths['env'] = ParseLdPaths(env_ldpath, path='')
# Load up /etc/ld.so.conf.
- ldpaths['conf'] = ParseLdSoConf(root + prefix + '/etc/ld.so.conf', root=root)
+ ldpaths['conf'] = ParseLdSoConf(root + prefix + '/etc/ld.so.conf', root=root,
+ debug=debug)
return ldpaths
@@ -441,7 +447,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.54 2014/11/20 01:13:19 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.55 2014/11/20 01:17:23 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -678,7 +684,7 @@
if not paths:
err('missing ELF files to scan')
- ldpaths = LoadLdpaths(options.root, options.prefix)
+ ldpaths = LoadLdpaths(options.root, options.prefix, debug=options.debug)
dbg(options.debug, 'ldpaths[conf] =', ldpaths['conf'])
dbg(options.debug, 'ldpaths[env] =', ldpaths['env'])
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-11-20 1:13 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-11-20 1:13 UTC (permalink / raw
To: gentoo-commits
vapier 14/11/20 01:13:19
Modified: lddtree.py
Log:
lddtree.py: adjust style to fix pylint warnings
Revision Changes Path
1.54 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.54&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.54&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.53&r2=1.54
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -r1.53 -r1.54
--- lddtree.py 1 Aug 2014 02:20:20 -0000 1.53
+++ lddtree.py 20 Nov 2014 01:13:19 -0000 1.54
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.53 2014/08/01 02:20:20 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.54 2014/11/20 01:13:19 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -118,10 +118,10 @@
interp_dir, interp_name = os.path.split(interp)
libpaths = dedupe([interp_dir] + list(libpaths))
replacements = {
- 'interp': os.path.join(os.path.relpath(interp_dir, basedir),
- interp_name),
- 'libpaths': ':'.join(['${basedir}/' + os.path.relpath(p, basedir)
- for p in libpaths]),
+ 'interp': os.path.join(os.path.relpath(interp_dir, basedir),
+ interp_name),
+ 'libpaths': ':'.join(['${basedir}/' + os.path.relpath(p, basedir)
+ for p in libpaths]),
}
wrapper = """#!/bin/sh
if ! base=$(realpath "$0" 2>/dev/null); then
@@ -230,9 +230,9 @@
dict containing library paths to search
"""
ldpaths = {
- 'conf': [],
- 'env': [],
- 'interp': [],
+ 'conf': [],
+ 'env': [],
+ 'interp': [],
}
# Load up $LD_LIBRARY_PATH.
@@ -267,12 +267,12 @@
"""
osabis = frozenset([e.header['e_ident']['EI_OSABI'] for e in (elf1, elf2)])
compat_sets = (
- frozenset('ELFOSABI_%s' % x for x in ('NONE', 'SYSV', 'GNU', 'LINUX',)),
+ frozenset('ELFOSABI_%s' % x for x in ('NONE', 'SYSV', 'GNU', 'LINUX',)),
)
return ((len(osabis) == 1 or any(osabis.issubset(x) for x in compat_sets)) and
- elf1.elfclass == elf2.elfclass and
- elf1.little_endian == elf2.little_endian and
- elf1.header['e_machine'] == elf2.header['e_machine'])
+ elf1.elfclass == elf2.elfclass and
+ elf1.little_endian == elf2.little_endian and
+ elf1.header['e_machine'] == elf2.header['e_machine'])
def FindLib(elf, lib, ldpaths, root='/', debug=False):
@@ -344,13 +344,13 @@
_all_libs = {}
ldpaths = ldpaths.copy()
ret = {
- 'interp': None,
- 'path': path if display is None else display,
- 'realpath': path,
- 'needed': [],
- 'rpath': [],
- 'runpath': [],
- 'libs': _all_libs,
+ 'interp': None,
+ 'path': path if display is None else display,
+ 'realpath': path,
+ 'needed': [],
+ 'rpath': [],
+ 'runpath': [],
+ 'libs': _all_libs,
}
dbg(debug, 'ParseELF(%s)' % path)
@@ -368,14 +368,14 @@
dbg(debug, ' interp =', interp)
ret['interp'] = normpath(root + interp)
ret['libs'][os.path.basename(interp)] = {
- 'path': ret['interp'],
- 'realpath': readlink(ret['interp'], root, prefixed=True),
- 'needed': [],
+ 'path': ret['interp'],
+ 'realpath': readlink(ret['interp'], root, prefixed=True),
+ 'needed': [],
}
# XXX: Should read it and scan for /lib paths.
ldpaths['interp'] = [
- normpath(root + os.path.dirname(interp)),
- normpath(root + prefix + '/usr' + os.path.dirname(interp).lstrip(prefix)),
+ normpath(root + os.path.dirname(interp)),
+ normpath(root + prefix + '/usr' + os.path.dirname(interp).lstrip(prefix)),
]
dbg(debug, ' ldpaths[interp] =', ldpaths['interp'])
break
@@ -422,9 +422,9 @@
all_ldpaths = rpaths + ldpaths['rpath'] + ldpaths['env'] + runpaths + ldpaths['runpath'] + ldpaths['conf'] + ldpaths['interp']
realpath, fullpath = FindLib(elf, lib, all_ldpaths, root, debug=debug)
_all_libs[lib] = {
- 'realpath': realpath,
- 'path': fullpath,
- 'needed': [],
+ 'realpath': realpath,
+ 'path': fullpath,
+ 'needed': [],
}
if fullpath:
lret = ParseELF(realpath, root, prefix, ldpaths, display=fullpath,
@@ -441,7 +441,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.53 2014/08/01 02:20:20 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.54 2014/11/20 01:13:19 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -606,54 +606,55 @@
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')
+ 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')
+ 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)')
+ 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')
+ 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)')
+ 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')
+ action='store_true', default=False,
+ help='Run with debugging')
parser.add_option('-v', '--verbose',
- action='store_true', default=False,
- help='Be 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')
+ 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')
+ 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')
+ 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')
+ 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')
+ 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')
+ 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')
+ 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)
@@ -721,12 +722,12 @@
if options.dest is not None and options.copy_non_elfs:
if os.path.exists(p):
elf = {
- 'interp': None,
- 'libs': [],
- 'runpath': [],
- 'rpath': [],
- 'path': p,
- 'realpath': realpath,
+ 'interp': None,
+ 'libs': [],
+ 'runpath': [],
+ 'rpath': [],
+ 'path': p,
+ 'realpath': realpath,
}
_ActionCopy(options, elf)
continue
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-08-01 2:20 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-08-01 2:20 UTC (permalink / raw
To: gentoo-commits
vapier 14/08/01 02:20:20
Modified: lddtree.py
Log:
lddtree.py: when parsing libs, make sure to pass down the realpath too
Revision Changes Path
1.53 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.53&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.53&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.52&r2=1.53
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -r1.52 -r1.53
--- lddtree.py 1 Aug 2014 01:39:33 -0000 1.52
+++ lddtree.py 1 Aug 2014 02:20:20 -0000 1.53
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.52 2014/08/01 01:39:33 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.53 2014/08/01 02:20:20 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -427,8 +427,8 @@
'needed': [],
}
if fullpath:
- lret = ParseELF(fullpath, root, prefix, ldpaths, debug=debug,
- _first=False, _all_libs=_all_libs)
+ lret = ParseELF(realpath, root, prefix, ldpaths, display=fullpath,
+ debug=debug, _first=False, _all_libs=_all_libs)
_all_libs[lib]['needed'] = lret['needed']
del elf
@@ -441,7 +441,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.52 2014/08/01 01:39:33 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.53 2014/08/01 02:20:20 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-08-01 1:39 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-08-01 1:39 UTC (permalink / raw
To: gentoo-commits
vapier 14/08/01 01:39:33
Modified: lddtree.py
Log:
lddtree.py: drop TODO since we should handle symlinks now
Revision Changes Path
1.52 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.52&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.52&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.51&r2=1.52
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.51
retrieving revision 1.52
diff -u -r1.51 -r1.52
--- lddtree.py 30 Jul 2014 14:35:38 -0000 1.51
+++ lddtree.py 1 Aug 2014 01:39:33 -0000 1.52
@@ -4,9 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.51 2014/07/30 14:35:38 vapier Exp $
-
-# TODO: Handle symlinks.
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.52 2014/08/01 01:39:33 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -443,7 +441,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.51 2014/07/30 14:35:38 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.52 2014/08/01 01:39:33 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-07-30 14:35 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-07-30 14:35 UTC (permalink / raw
To: gentoo-commits
vapier 14/07/30 14:35:39
Modified: lddtree.py
Log:
lddtree.py: save the original path as well as the full path for symlinks
SONAMEs are usually symlinks, so we need to manually dereference them to get to the right file, but we want to save the original name so we can copy them to the right place
Revision Changes Path
1.51 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.51&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.51&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.50&r2=1.51
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -r1.50 -r1.51
--- lddtree.py 30 Jul 2014 08:22:07 -0000 1.50
+++ lddtree.py 30 Jul 2014 14:35:38 -0000 1.51
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.50 2014/07/30 08:22:07 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.51 2014/07/30 14:35:38 vapier Exp $
# TODO: Handle symlinks.
@@ -63,6 +63,10 @@
def readlink(path, root, prefixed=False):
"""Like os.readlink(), but relative to a |root|
+ This does not currently handle the pathological case:
+ /lib/foo.so -> ../../../../../../../foo.so
+ This relies on the .. entries in / to point to itself.
+
Args:
path: The symlink to read
root: The path to use for resolving absolute symlinks
@@ -81,7 +85,7 @@
while os.path.islink(root + path):
path = os.path.join(os.path.dirname(path), os.readlink(root + path))
- return (root + path) if prefixed else path
+ return normpath((root + path) if prefixed else path)
def makedirs(path):
@@ -284,7 +288,7 @@
debug: Enable debug output
Returns:
- the full path to the desired library
+ Tuple of the full path to the desired library and the real path to it
"""
dbg(debug, ' FindLib(%s)' % lib)
@@ -293,17 +297,16 @@
target = readlink(path, root, prefixed=True)
if path != target:
dbg(debug, ' checking: %s -> %s' % (path, target))
- path = target
else:
dbg(debug, ' checking:', path)
- if os.path.exists(path):
- with open(path, 'rb') as f:
+ if os.path.exists(target):
+ with open(target, 'rb') as f:
libelf = ELFFile(f)
if CompatibleELFs(elf, libelf):
- return path
+ return (target, path)
- return None
+ return (None, None)
def ParseELF(path, root='/', prefix='', ldpaths={'conf':[], 'env':[], 'interp':[]},
@@ -345,6 +348,7 @@
ret = {
'interp': None,
'path': path if display is None else display,
+ 'realpath': path,
'needed': [],
'rpath': [],
'runpath': [],
@@ -367,6 +371,7 @@
ret['interp'] = normpath(root + interp)
ret['libs'][os.path.basename(interp)] = {
'path': ret['interp'],
+ 'realpath': readlink(ret['interp'], root, prefixed=True),
'needed': [],
}
# XXX: Should read it and scan for /lib paths.
@@ -417,8 +422,9 @@
continue
if all_ldpaths is None:
all_ldpaths = rpaths + ldpaths['rpath'] + ldpaths['env'] + runpaths + ldpaths['runpath'] + ldpaths['conf'] + ldpaths['interp']
- fullpath = FindLib(elf, lib, all_ldpaths, root, debug=debug)
+ realpath, fullpath = FindLib(elf, lib, all_ldpaths, root, debug=debug)
_all_libs[lib] = {
+ 'realpath': realpath,
'path': fullpath,
'needed': [],
}
@@ -437,7 +443,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.50 2014/07/30 08:22:07 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.51 2014/07/30 14:35:38 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -486,8 +492,9 @@
def _StripRoot(path):
return path[len(options.root) - 1:]
- def _copy(src, striproot=True, wrapit=False, libpaths=(), outdir=None):
- if src is None:
+ def _copy(realsrc, src, striproot=True, wrapit=False, libpaths=(),
+ outdir=None):
+ if realsrc is None:
return
if wrapit:
@@ -506,7 +513,7 @@
try:
# See if they're the same file.
nstat = os.stat(dst + ('.elf' if wrapit else ''))
- ostat = os.stat(src)
+ ostat = os.stat(realsrc)
for field in ('mode', 'mtime', 'size'):
if getattr(ostat, 'st_' + field) != \
getattr(nstat, 'st_' + field):
@@ -522,10 +529,10 @@
makedirs(os.path.dirname(dst))
try:
- shutil.copy2(src, dst)
+ shutil.copy2(realsrc, dst)
except IOError:
os.unlink(dst)
- shutil.copy2(src, dst)
+ shutil.copy2(realsrc, dst)
if wrapit:
if options.verbose:
@@ -544,10 +551,11 @@
# for known libs that get loaded (e.g. curl will dlopen(libresolv)).
libpaths = set()
for lib in elf['libs']:
- path = elf['libs'][lib]['path']
+ libdata = elf['libs'][lib]
+ path = libdata['realpath']
if not options.libdir:
libpaths.add(_StripRoot(os.path.dirname(path)))
- _copy(path, outdir=options.libdir)
+ _copy(path, libdata['path'], outdir=options.libdir)
if not options.libdir:
libpaths = list(libpaths)
@@ -558,8 +566,10 @@
else:
libpaths.add(options.libdir)
- _copy(elf['interp'], outdir=options.libdir)
- _copy(elf['path'], striproot=options.auto_root,
+ # We don't bother to copy this as ParseElf adds the interp to the 'libs',
+ # so it was already copied in the libs loop above.
+ #_copy(elf['interp'], outdir=options.libdir)
+ _copy(elf['realpath'], elf['path'], striproot=options.auto_root,
wrapit=options.generate_wrappers, libpaths=libpaths,
outdir=options.bindir)
@@ -718,6 +728,7 @@
'runpath': [],
'rpath': [],
'path': p,
+ 'realpath': realpath,
}
_ActionCopy(options, elf)
continue
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-07-30 8:22 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-07-30 8:22 UTC (permalink / raw
To: gentoo-commits
vapier 14/07/30 08:22:07
Modified: lddtree.py
Log:
lddtree: do symlink resolution on args on the command line
This is needed when given a path which itself is an absolute symlink. If we deref it as-is, we end up poking into / instead of $ROOT.
Revision Changes Path
1.50 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.50&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.50&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.49&r2=1.50
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.49
retrieving revision 1.50
diff -u -r1.49 -r1.50
--- lddtree.py 30 Jul 2014 04:34:09 -0000 1.49
+++ lddtree.py 30 Jul 2014 08:22:07 -0000 1.50
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.49 2014/07/30 04:34:09 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.50 2014/07/30 08:22:07 vapier Exp $
# TODO: Handle symlinks.
@@ -307,7 +307,7 @@
def ParseELF(path, root='/', prefix='', ldpaths={'conf':[], 'env':[], 'interp':[]},
- debug=False, _first=True, _all_libs={}):
+ display=None, debug=False, _first=True, _all_libs={}):
"""Parse the ELF dependency tree of the specified file
Args:
@@ -317,6 +317,7 @@
prefix: The path under |root| to search
ldpaths: dict containing library paths to search; should have the keys:
conf, env, interp
+ display: The path to show rather than |path|
debug: Enable debug output
_first: Recursive use only; is this the first ELF ?
_all_libs: Recursive use only; dict of all libs we've seen
@@ -343,7 +344,7 @@
ldpaths = ldpaths.copy()
ret = {
'interp': None,
- 'path': path,
+ 'path': path if display is None else display,
'needed': [],
'rpath': [],
'runpath': [],
@@ -422,7 +423,8 @@
'needed': [],
}
if fullpath:
- lret = ParseELF(fullpath, root, prefix, ldpaths, debug, False, _all_libs)
+ lret = ParseELF(fullpath, root, prefix, ldpaths, debug=debug,
+ _first=False, _all_libs=_all_libs)
_all_libs[lib]['needed'] = lret['needed']
del elf
@@ -435,7 +437,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.49 2014/07/30 04:34:09 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.50 2014/07/30 08:22:07 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -684,10 +686,26 @@
matched = False
for p in glob.iglob(path):
+ # Once we've processed the globs, resolve the symlink. This way you can
+ # operate on a path that is an absolute symlink itself. e.g.:
+ # $ ln -sf /bin/bash $PWD/root/bin/sh
+ # $ lddtree --root $PWD/root /bin/sh
+ # First we'd turn /bin/sh into $PWD/root/bin/sh, then we want to resolve
+ # the symlink to $PWD/root/bin/bash rather than a plain /bin/bash.
+ dbg(options.debug, ' globbed =', p)
+ if not path.startswith('/'):
+ realpath = os.path.realpath(path)
+ elif options.auto_root:
+ realpath = readlink(p, options.root, prefixed=True)
+ else:
+ realpath = path
+ if path != realpath:
+ dbg(options.debug, ' resolved =', realpath)
+
matched = True
try:
- elf = ParseELF(p, options.root, options.prefix, ldpaths,
- debug=options.debug)
+ elf = ParseELF(realpath, options.root, options.prefix, ldpaths,
+ display=p, debug=options.debug)
except exceptions.ELFError as e:
if options.skip_non_elfs:
continue
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-07-30 4:34 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-07-30 4:34 UTC (permalink / raw
To: gentoo-commits
vapier 14/07/30 04:34:09
Modified: lddtree.py
Log:
lddtree.py: when searching for libs, make sure we resolve symlinks inside the root before checking if they exist
Revision Changes Path
1.49 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.49&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.49&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.48&r2=1.49
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -r1.48 -r1.49
--- lddtree.py 30 Jul 2014 04:28:41 -0000 1.48
+++ lddtree.py 30 Jul 2014 04:34:09 -0000 1.49
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.48 2014/07/30 04:28:41 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.49 2014/07/30 04:34:09 vapier Exp $
# TODO: Handle symlinks.
@@ -60,6 +60,30 @@
return os.path.normpath(path).replace('//', '/')
+def readlink(path, root, prefixed=False):
+ """Like os.readlink(), but relative to a |root|
+
+ Args:
+ path: The symlink to read
+ root: The path to use for resolving absolute symlinks
+ prefixed: When False, the |path| must not have |root| prefixed to it, nor
+ will the return value have |root| prefixed. When True, |path|
+ must have |root| prefixed, and the return value will have |root|
+ added.
+
+ Returns:
+ A fully resolved symlink path
+ """
+ root = root.rstrip('/')
+ if prefixed:
+ path = path[len(root):]
+
+ while os.path.islink(root + path):
+ path = os.path.join(os.path.dirname(path), os.readlink(root + path))
+
+ return (root + path) if prefixed else path
+
+
def makedirs(path):
"""Like os.makedirs(), but ignore EEXIST errors"""
try:
@@ -249,27 +273,36 @@
elf1.header['e_machine'] == elf2.header['e_machine'])
-def FindLib(elf, lib, ldpaths, debug=False):
+def FindLib(elf, lib, ldpaths, root='/', debug=False):
"""Try to locate a |lib| that is compatible to |elf| in the given |ldpaths|
Args:
elf: The elf which the library should be compatible with (ELF wise)
lib: The library (basename) to search for
ldpaths: A list of paths to search
+ root: The root path to resolve symlinks
debug: Enable debug output
Returns:
the full path to the desired library
"""
dbg(debug, ' FindLib(%s)' % lib)
+
for ldpath in ldpaths:
path = os.path.join(ldpath, lib)
- dbg(debug, ' checking:', path)
+ target = readlink(path, root, prefixed=True)
+ if path != target:
+ dbg(debug, ' checking: %s -> %s' % (path, target))
+ path = target
+ else:
+ dbg(debug, ' checking:', path)
+
if os.path.exists(path):
with open(path, 'rb') as f:
libelf = ELFFile(f)
if CompatibleELFs(elf, libelf):
return path
+
return None
@@ -383,7 +416,7 @@
continue
if all_ldpaths is None:
all_ldpaths = rpaths + ldpaths['rpath'] + ldpaths['env'] + runpaths + ldpaths['runpath'] + ldpaths['conf'] + ldpaths['interp']
- fullpath = FindLib(elf, lib, all_ldpaths, debug=debug)
+ fullpath = FindLib(elf, lib, all_ldpaths, root, debug=debug)
_all_libs[lib] = {
'path': fullpath,
'needed': [],
@@ -402,7 +435,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.48 2014/07/30 04:28:41 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.49 2014/07/30 04:34:09 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-07-30 4:28 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-07-30 4:28 UTC (permalink / raw
To: gentoo-commits
vapier 14/07/30 04:28:41
Modified: lddtree.py
Log:
lddtree.py: update ParseELF arg list after previous commit
Revision Changes Path
1.48 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.48&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.48&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.47&r2=1.48
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- lddtree.py 30 Jul 2014 04:16:25 -0000 1.47
+++ lddtree.py 30 Jul 2014 04:28:41 -0000 1.48
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.47 2014/07/30 04:16:25 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.48 2014/07/30 04:28:41 vapier Exp $
# TODO: Handle symlinks.
@@ -389,7 +389,7 @@
'needed': [],
}
if fullpath:
- lret = ParseELF(fullpath, root, prefix, ldpaths, False, _all_libs)
+ lret = ParseELF(fullpath, root, prefix, ldpaths, debug, False, _all_libs)
_all_libs[lib]['needed'] = lret['needed']
del elf
@@ -402,7 +402,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.47 2014/07/30 04:16:25 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.48 2014/07/30 04:28:41 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-07-30 4:16 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-07-30 4:16 UTC (permalink / raw
To: gentoo-commits
vapier 14/07/30 04:16:25
Modified: lddtree.py
Log:
lddtree.py: rework debug handling and add a bit more throughout the processing
Revision Changes Path
1.47 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.47&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.47&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.46&r2=1.47
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -r1.46 -r1.47
--- lddtree.py 30 Jul 2014 04:07:43 -0000 1.46
+++ lddtree.py 30 Jul 2014 04:16:25 -0000 1.47
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.46 2014/07/30 04:07:43 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.47 2014/07/30 04:16:25 vapier Exp $
# TODO: Handle symlinks.
@@ -38,6 +38,12 @@
sys.exit(status)
+def dbg(debug, *args, **kwargs):
+ """Pass |args| and |kwargs| to print() when |debug| is True"""
+ if debug:
+ print(*args, **kwargs)
+
+
def bstr(buf):
"""Decode the byte string into a string"""
return buf.decode('utf-8')
@@ -243,19 +249,22 @@
elf1.header['e_machine'] == elf2.header['e_machine'])
-def FindLib(elf, lib, ldpaths):
+def FindLib(elf, lib, ldpaths, debug=False):
"""Try to locate a |lib| that is compatible to |elf| in the given |ldpaths|
Args:
- elf: the elf which the library should be compatible with (ELF wise)
- lib: the library (basename) to search for
- ldpaths: a list of paths to search
+ elf: The elf which the library should be compatible with (ELF wise)
+ lib: The library (basename) to search for
+ ldpaths: A list of paths to search
+ debug: Enable debug output
Returns:
the full path to the desired library
"""
+ dbg(debug, ' FindLib(%s)' % lib)
for ldpath in ldpaths:
path = os.path.join(ldpath, lib)
+ dbg(debug, ' checking:', path)
if os.path.exists(path):
with open(path, 'rb') as f:
libelf = ELFFile(f)
@@ -265,7 +274,7 @@
def ParseELF(path, root='/', prefix='', ldpaths={'conf':[], 'env':[], 'interp':[]},
- _first=True, _all_libs={}):
+ debug=False, _first=True, _all_libs={}):
"""Parse the ELF dependency tree of the specified file
Args:
@@ -275,6 +284,7 @@
prefix: The path under |root| to search
ldpaths: dict containing library paths to search; should have the keys:
conf, env, interp
+ debug: Enable debug output
_first: Recursive use only; is this the first ELF ?
_all_libs: Recursive use only; dict of all libs we've seen
@@ -307,6 +317,8 @@
'libs': _all_libs,
}
+ dbg(debug, 'ParseELF(%s)' % path)
+
with open(path, 'rb') as f:
elf = ELFFile(f)
@@ -317,6 +329,7 @@
continue
interp = bstr(segment.get_interp_name())
+ dbg(debug, ' interp =', interp)
ret['interp'] = normpath(root + interp)
ret['libs'][os.path.basename(interp)] = {
'path': ret['interp'],
@@ -327,6 +340,7 @@
normpath(root + os.path.dirname(interp)),
normpath(root + prefix + '/usr' + os.path.dirname(interp).lstrip(prefix)),
]
+ dbg(debug, ' ldpaths[interp] =', ldpaths['interp'])
break
# Parse the ELF's dynamic tags.
@@ -356,6 +370,8 @@
# used at runtime to locate things.
ldpaths['rpath'] = rpaths
ldpaths['runpath'] = runpaths
+ dbg(debug, ' ldpaths[rpath] =', rpaths)
+ dbg(debug, ' ldpaths[runpath] =', runpaths)
ret['rpath'] = rpaths
ret['runpath'] = runpaths
ret['needed'] = libs
@@ -367,7 +383,7 @@
continue
if all_ldpaths is None:
all_ldpaths = rpaths + ldpaths['rpath'] + ldpaths['env'] + runpaths + ldpaths['runpath'] + ldpaths['conf'] + ldpaths['interp']
- fullpath = FindLib(elf, lib, all_ldpaths)
+ fullpath = FindLib(elf, lib, all_ldpaths, debug=debug)
_all_libs[lib] = {
'path': fullpath,
'needed': [],
@@ -386,7 +402,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.46 2014/07/30 04:07:43 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.47 2014/07/30 04:16:25 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -612,32 +628,33 @@
if options.skip_non_elfs and options.copy_non_elfs:
parser.error('pick one handler for non-ELFs: skip or copy')
- if options.debug:
- print('root =', options.root)
- if options.dest:
- print('dest =', options.dest)
+ dbg(options.debug, 'root =', options.root)
+ if options.dest:
+ dbg(options.debug, 'dest =', options.dest)
if not paths:
err('missing ELF files to scan')
ldpaths = LoadLdpaths(options.root, options.prefix)
- if options.debug:
- print('ldpaths[conf] =', ldpaths['conf'])
- print('ldpaths[env] =', ldpaths['env'])
+ dbg(options.debug, 'ldpaths[conf] =', ldpaths['conf'])
+ dbg(options.debug, 'ldpaths[env] =', ldpaths['env'])
# Process all the files specified.
ret = 0
for path in paths:
+ dbg(options.debug, 'argv[x] =', path)
# Only auto-prefix the path if the ELF is absolute.
# If it's a relative path, the user most likely wants
# the local path.
if options.auto_root and path.startswith('/'):
path = options.root + path.lstrip('/')
+ dbg(options.debug, ' +auto-root =', path)
matched = False
for p in glob.iglob(path):
matched = True
try:
- elf = ParseELF(p, options.root, options.prefix, ldpaths)
+ elf = ParseELF(p, options.root, options.prefix, ldpaths,
+ debug=options.debug)
except exceptions.ELFError as e:
if options.skip_non_elfs:
continue
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-07-30 4:07 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-07-30 4:07 UTC (permalink / raw
To: gentoo-commits
vapier 14/07/30 04:07:43
Modified: lddtree.py
Log:
lddtree.py: use basename of argv[0] for warnings as it looks nicer
Revision Changes Path
1.46 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.46&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.46&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.45&r2=1.46
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.45
retrieving revision 1.46
diff -u -r1.45 -r1.46
--- lddtree.py 30 Jul 2014 04:06:56 -0000 1.45
+++ lddtree.py 30 Jul 2014 04:07:43 -0000 1.46
@@ -4,7 +4,7 @@
# Copyright 2012-2014 The Chromium OS Authors
# 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.45 2014/07/30 04:06:56 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.46 2014/07/30 04:07:43 vapier Exp $
# TODO: Handle symlinks.
@@ -29,7 +29,7 @@
def warn(msg, prefix='warning'):
"""Write |msg| to stderr with a |prefix| before it"""
- print('%s: %s: %s' % (sys.argv[0], prefix, msg), file=sys.stderr)
+ print('%s: %s: %s' % (os.path.basename(sys.argv[0]), prefix, msg), file=sys.stderr)
def err(msg, status=1):
@@ -386,7 +386,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.45 2014/07/30 04:06:56 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.46 2014/07/30 04:07:43 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-03-20 8:25 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-03-20 8:25 UTC (permalink / raw
To: gentoo-commits
vapier 14/03/20 08:25:45
Modified: lddtree.py
Log:
lddtree.py: initial prefix support by Benda Xu #488460
Revision Changes Path
1.44 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.44&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.44&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.43&r2=1.44
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -r1.43 -r1.44
--- lddtree.py 20 Mar 2014 08:18:06 -0000 1.43
+++ lddtree.py 20 Mar 2014 08:25:45 -0000 1.44
@@ -3,7 +3,7 @@
# Copyright 2012-2013 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.43 2014/03/20 08:18:06 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.44 2014/03/20 08:25:45 vapier Exp $
# TODO: Handle symlinks.
@@ -184,13 +184,14 @@
return paths
-def LoadLdpaths(root='/'):
+def LoadLdpaths(root='/', prefix=''):
"""Load linker paths from common locations
This parses the ld.so.conf and LD_LIBRARY_PATH env var.
Args:
root: The root tree to prepend to paths
+ prefix: The path under |root| to search
Returns:
dict containing library paths to search
@@ -213,7 +214,7 @@
ldpaths['env'] = ParseLdPaths(env_ldpath, path='')
# Load up /etc/ld.so.conf.
- ldpaths['conf'] = ParseLdSoConf(root + 'etc/ld.so.conf', root=root)
+ ldpaths['conf'] = ParseLdSoConf(root + prefix + '/etc/ld.so.conf', root=root)
return ldpaths
@@ -262,7 +263,7 @@
return None
-def ParseELF(path, root='/', ldpaths={'conf':[], 'env':[], 'interp':[]},
+def ParseELF(path, root='/', prefix='', ldpaths={'conf':[], 'env':[], 'interp':[]},
_first=True, _all_libs={}):
"""Parse the ELF dependency tree of the specified file
@@ -270,6 +271,7 @@
path: The ELF to scan
root: The root tree to prepend to paths; this applies to interp and rpaths
only as |path| and |ldpaths| are expected to be prefixed already
+ prefix: The path under |root| to search
ldpaths: dict containing library paths to search; should have the keys:
conf, env, interp
_first: Recursive use only; is this the first ELF ?
@@ -322,7 +324,7 @@
# XXX: Should read it and scan for /lib paths.
ldpaths['interp'] = [
normpath(root + os.path.dirname(interp)),
- normpath(root + '/usr' + os.path.dirname(interp)),
+ normpath(root + prefix + '/usr' + os.path.dirname(interp).lstrip(prefix)),
]
break
@@ -370,7 +372,7 @@
'needed': [],
}
if fullpath:
- lret = ParseELF(fullpath, root, ldpaths, False, _all_libs)
+ lret = ParseELF(fullpath, root, prefix, ldpaths, False, _all_libs)
_all_libs[lib]['needed'] = lret['needed']
del elf
@@ -383,7 +385,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.43 2014/03/20 08:18:06 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.44 2014/03/20 08:25:45 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -550,6 +552,10 @@
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')
@@ -594,6 +600,8 @@
if options.root != '/':
options.root += '/'
+ if options.prefix == '@''GENTOO_PORTAGE_EPREFIX''@':
+ options.prefix = ''
if options.bindir and options.bindir[0] != '/':
parser.error('--bindir accepts absolute paths only')
@@ -610,7 +618,7 @@
if not paths:
err('missing ELF files to scan')
- ldpaths = LoadLdpaths(options.root)
+ ldpaths = LoadLdpaths(options.root, options.prefix)
if options.debug:
print('ldpaths[conf] =', ldpaths['conf'])
print('ldpaths[env] =', ldpaths['env'])
@@ -628,7 +636,7 @@
for p in glob.iglob(path):
matched = True
try:
- elf = ParseELF(p, options.root, ldpaths)
+ elf = ParseELF(p, options.root, options.prefix, ldpaths)
except exceptions.ELFError as e:
if options.skip_non_elfs:
continue
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2014-03-20 8:18 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2014-03-20 8:18 UTC (permalink / raw
To: gentoo-commits
vapier 14/03/20 08:18:07
Modified: lddtree.py
Log:
lddtree.py: fix style
Revision Changes Path
1.43 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.43&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.43&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.42&r2=1.43
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -r1.42 -r1.43
--- lddtree.py 23 Apr 2013 02:16:59 -0000 1.42
+++ lddtree.py 20 Mar 2014 08:18:06 -0000 1.43
@@ -3,7 +3,7 @@
# Copyright 2012-2013 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.42 2013/04/23 02:16:59 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.43 2014/03/20 08:18:06 vapier Exp $
# TODO: Handle symlinks.
@@ -121,9 +121,10 @@
- (TODO) $LIB and friends
Args:
- str_ldpath: A colon-delimited string of paths
+ str_ldpaths: A colon-delimited string of paths
root: The path to prepend to all paths found
path: The object actively being parsed (used for $ORIGIN)
+
Returns:
list of processed paths
"""
@@ -149,6 +150,7 @@
ldso_conf: The file to scan
root: The path to prepend to all paths found
_first: Recursive use only; is this the first ELF ?
+
Returns:
list of paths found
"""
@@ -189,6 +191,7 @@
Args:
root: The root tree to prepend to paths
+
Returns:
dict containing library paths to search
"""
@@ -224,6 +227,7 @@
Args:
elf1: an ELFFile object
elf2: an ELFFile object
+
Returns:
True if compatible, False otherwise
"""
@@ -244,6 +248,7 @@
elf: the elf which the library should be compatible with (ELF wise)
lib: the library (basename) to search for
ldpaths: a list of paths to search
+
Returns:
the full path to the desired library
"""
@@ -269,6 +274,7 @@
conf, env, interp
_first: Recursive use only; is this the first ELF ?
_all_libs: Recursive use only; dict of all libs we've seen
+
Returns:
a dict containing information about all the ELFs; e.g.
{
@@ -377,7 +383,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.42 2013/04/23 02:16:59 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.43 2014/03/20 08:18:06 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-04-23 2:16 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-23 2:16 UTC (permalink / raw
To: gentoo-commits
vapier 13/04/23 02:16:59
Modified: lddtree.py
Log:
lddtree.py: add docstring for path in ParseLdPaths
Revision Changes Path
1.42 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.42&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.42&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.41&r2=1.42
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.41
retrieving revision 1.42
diff -u -r1.41 -r1.42
--- lddtree.py 22 Apr 2013 22:02:43 -0000 1.41
+++ lddtree.py 23 Apr 2013 02:16:59 -0000 1.42
@@ -3,7 +3,7 @@
# Copyright 2012-2013 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.41 2013/04/22 22:02:43 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.42 2013/04/23 02:16:59 vapier Exp $
# TODO: Handle symlinks.
@@ -123,6 +123,7 @@
Args:
str_ldpath: A colon-delimited string of paths
root: The path to prepend to all paths found
+ path: The object actively being parsed (used for $ORIGIN)
Returns:
list of processed paths
"""
@@ -376,7 +377,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.41 2013/04/22 22:02:43 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.42 2013/04/23 02:16:59 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-04-22 22:02 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-22 22:02 UTC (permalink / raw
To: gentoo-commits
vapier 13/04/22 22:02:43
Modified: lddtree.py
Log:
lddtree.py: add --skip-non-elfs option so you can batch commands like `lddtree -l <blah>` while filtering out non elfs easily
Revision Changes Path
1.41 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.41&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.41&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.40&r2=1.41
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -r1.40 -r1.41
--- lddtree.py 22 Apr 2013 18:31:10 -0000 1.40
+++ lddtree.py 22 Apr 2013 22:02:43 -0000 1.41
@@ -3,7 +3,7 @@
# Copyright 2012-2013 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.40 2013/04/22 18:31:10 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.41 2013/04/22 22:02:43 vapier Exp $
# TODO: Handle symlinks.
@@ -376,7 +376,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.40 2013/04/22 18:31:10 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.41 2013/04/22 22:02:43 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -555,6 +555,9 @@
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')
@@ -590,6 +593,9 @@
if options.libdir and options.libdir[0] != '/':
parser.error('--libdir accepts absolute paths only')
+ if options.skip_non_elfs and options.copy_non_elfs:
+ parser.error('pick one handler for non-ELFs: skip or copy')
+
if options.debug:
print('root =', options.root)
if options.dest:
@@ -616,7 +622,9 @@
matched = True
try:
elf = ParseELF(p, options.root, ldpaths)
- except (exceptions.ELFError, IOError) as e:
+ except exceptions.ELFError as e:
+ if options.skip_non_elfs:
+ continue
# XXX: Ugly. Should unify with _Action* somehow.
if options.dest is not None and options.copy_non_elfs:
if os.path.exists(p):
@@ -632,6 +640,10 @@
ret = 1
warn('%s: %s' % (p, e))
continue
+ except IOError as e:
+ ret = 1
+ warn('%s: %s' % (p, e))
+ continue
if options.dest is None:
_ActionShow(options, elf)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-04-22 18:31 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-22 18:31 UTC (permalink / raw
To: gentoo-commits
vapier 13/04/22 18:31:10
Modified: lddtree.py
Log:
lddtree.py: fix $ORIGIN handling when using --root so the root does not get double prefixed
Revision Changes Path
1.40 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.40&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.40&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.39&r2=1.40
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- lddtree.py 7 Apr 2013 19:20:09 -0000 1.39
+++ lddtree.py 22 Apr 2013 18:31:10 -0000 1.40
@@ -3,7 +3,7 @@
# Copyright 2012-2013 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.39 2013/04/07 19:20:09 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.40 2013/04/22 18:31:10 vapier Exp $
# TODO: Handle symlinks.
@@ -131,9 +131,11 @@
if ldpath == '':
# The ldso treats "" paths as $PWD.
ldpath = os.getcwd()
- else:
+ elif '$ORIGIN' in ldpath:
ldpath = ldpath.replace('$ORIGIN', os.path.dirname(path))
- ldpaths.append(normpath(root + ldpath))
+ else:
+ ldpath = root + ldpath
+ ldpaths.append(normpath(ldpath))
return dedupe(ldpaths)
@@ -374,7 +376,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.39 2013/04/07 19:20:09 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.40 2013/04/22 18:31:10 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-04-05 22:26 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-05 22:26 UTC (permalink / raw
To: gentoo-commits
vapier 13/04/05 22:26:53
Modified: lddtree.py
Log:
lddtree.py: only auto-prefix paths w/ROOT if the path is absolute
people probably do not expect `lddtree -R /foo ./bash` to look at /foo/bash
Revision Changes Path
1.38 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.38&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.38&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.37&r2=1.38
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -r1.37 -r1.38
--- lddtree.py 5 Apr 2013 22:04:41 -0000 1.37
+++ lddtree.py 5 Apr 2013 22:26:53 -0000 1.38
@@ -3,7 +3,7 @@
# Copyright 2012-2013 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.37 2013/04/05 22:04:41 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.38 2013/04/05 22:26:53 vapier Exp $
# TODO: Handle symlinks.
@@ -374,7 +374,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.37 2013/04/05 22:04:41 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.38 2013/04/05 22:26:53 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -603,7 +603,10 @@
# Process all the files specified.
ret = 0
for path in paths:
- if options.auto_root:
+ # Only auto-prefix the path if the ELF is absolute.
+ # If it's a relative path, the user most likely wants
+ # the local path.
+ if options.auto_root and path.startswith('/'):
path = options.root + path.lstrip('/')
matched = False
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-04-03 4:51 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-04-03 4:51 UTC (permalink / raw
To: gentoo-commits
vapier 13/04/03 04:51:22
Modified: lddtree.py
Log:
lddtree.py: use option groups for --copy-to-tree flags
Revision Changes Path
1.36 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.36&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.36&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.35&r2=1.36
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -r1.35 -r1.36
--- lddtree.py 28 Mar 2013 17:14:10 -0000 1.35
+++ lddtree.py 3 Apr 2013 04:51:22 -0000 1.36
@@ -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.35 2013/03/28 17:14:10 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.36 2013/04/03 04:51:22 vapier Exp $
# TODO: Handle symlinks.
@@ -374,7 +374,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.35 2013/03/28 17:14:10 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.36 2013/04/03 04:51:22 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -544,36 +544,40 @@
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',
+ 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('-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')
- parser.add_option('--bindir',
+ group.add_option('--bindir',
default=None, type='string',
action='callback', callback=_NormalizePath,
help='Dir to store all ELFs specified on the command line')
- parser.add_option('--libdir',
+ group.add_option('--libdir',
default=None, type='string',
action='callback', callback=_NormalizePath,
help='Dir to store all ELF libs')
- parser.add_option('--generate-wrappers',
+ group.add_option('--generate-wrappers',
action='store_true', default=False,
help='Wrap executable ELFs with scripts for local ldso')
- parser.add_option('--copy-non-elfs',
+ 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('-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('-V', '--version',
- action='callback', callback=_ShowVersion,
- help='Show version information')
+ parser.add_option_group(group)
+
(options, paths) = parser.parse_args(argv)
if options.root != '/':
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-28 17:14 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-28 17:14 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/28 17:14:11
Modified: lddtree.py
Log:
lddtree.py: drop superfluous () around help strings
Revision Changes Path
1.35 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.35&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.35&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.34&r2=1.35
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- lddtree.py 28 Mar 2013 01:17:14 -0000 1.34
+++ lddtree.py 28 Mar 2013 17:14:10 -0000 1.35
@@ -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.34 2013/03/28 01:17:14 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.35 2013/03/28 17:14:10 vapier Exp $
# TODO: Handle symlinks.
@@ -374,7 +374,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.34 2013/03/28 01:17:14 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.35 2013/03/28 17:14:10 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -536,44 +536,44 @@
they need will be placed into /foo/lib/ only.""")
parser.add_option('-a', '--all',
action='store_true', default=False,
- help=('Show all duplicated dependencies'))
+ 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'))
+ 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'))
+ 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,
- help=('Copy all files to the specified tree'))
+ help='Copy all files to the specified tree')
parser.add_option('--bindir',
default=None, type='string',
action='callback', callback=_NormalizePath,
- help=('Dir to store all ELFs specified on the command line'))
+ help='Dir to store all ELFs specified on the command line')
parser.add_option('--libdir',
default=None, type='string',
action='callback', callback=_NormalizePath,
- help=('Dir to store all ELF libs'))
+ help='Dir to store all ELF libs')
parser.add_option('--generate-wrappers',
action='store_true', default=False,
- help=('Wrap executable ELFs with scripts for local ldso'))
+ help='Wrap executable ELFs with scripts for local ldso')
parser.add_option('--copy-non-elfs',
action='store_true', default=False,
- help=('Copy over plain (non-ELF) files instead of warn+ignore'))
+ help='Copy over plain (non-ELF) files instead of warn+ignore')
parser.add_option('-l', '--list',
action='store_true', default=False,
- help=('Display output in a simple list (easy for copying)'))
+ help='Display output in a simple list (easy for copying)')
parser.add_option('-x', '--debug',
action='store_true', default=False,
- help=('Run with debugging'))
+ help='Run with debugging')
parser.add_option('-v', '--verbose',
action='store_true', default=False,
- help=('Be verbose'))
+ help='Be verbose')
parser.add_option('-V', '--version',
action='callback', callback=_ShowVersion,
- help=('Show version information'))
+ help='Show version information')
(options, paths) = parser.parse_args(argv)
if options.root != '/':
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-28 1:17 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-28 1:17 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/28 01:17:14
Modified: lddtree.py
Log:
lddtree.py: handle the case where `realpath` is not available (like small initramfs)
Revision Changes Path
1.34 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.34&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.34&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.33&r2=1.34
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -r1.33 -r1.34
--- lddtree.py 28 Mar 2013 00:58:20 -0000 1.33
+++ lddtree.py 28 Mar 2013 01:17:14 -0000 1.34
@@ -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.33 2013/03/28 00:58:20 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.34 2013/03/28 01:17:14 vapier Exp $
# TODO: Handle symlinks.
@@ -91,7 +91,12 @@
for p in libpaths]),
}
wrapper = """#!/bin/sh
-base=$(realpath "$0")
+if ! base=$(realpath "$0" 2>/dev/null); then
+ case $0 in
+ /*) base=$0;;
+ *) base=${PWD:-`pwd`}/$0;;
+ esac
+fi
basedir=${base%%/*}
exec \
"${basedir}/%(interp)s" \
@@ -369,7 +374,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.33 2013/03/28 00:58:20 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.34 2013/03/28 01:17:14 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-28 0:58 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-28 0:58 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/28 00:58:20
Modified: lddtree.py
Log:
lddtree.py: add documentation/checks on --bindir/--libdir flags
Revision Changes Path
1.33 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.33&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.33&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.32&r2=1.33
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -r1.32 -r1.33
--- lddtree.py 27 Mar 2013 03:22:00 -0000 1.32
+++ lddtree.py 28 Mar 2013 00:58:20 -0000 1.33
@@ -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.32 2013/03/27 03:22:00 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.33 2013/03/28 00:58:20 vapier Exp $
# TODO: Handle symlinks.
@@ -369,7 +369,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.32 2013/03/27 03:22:00 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.33 2013/03/28 00:58:20 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -515,7 +515,20 @@
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.""")
+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'))
@@ -543,7 +556,7 @@
help=('Wrap executable ELFs with scripts for local ldso'))
parser.add_option('--copy-non-elfs',
action='store_true', default=False,
- help=('Copy over plain (non-ELF) files rather than warn+ignore'))
+ help=('Copy over plain (non-ELF) files instead of warn+ignore'))
parser.add_option('-l', '--list',
action='store_true', default=False,
help=('Display output in a simple list (easy for copying)'))
@@ -561,6 +574,11 @@
if options.root != '/':
options.root += '/'
+ if options.bindir and options.bindir[0] != '/':
+ parser.error('--bindir accepts absolute paths only')
+ if options.libdir and options.libdir[0] != '/':
+ parser.error('--libdir accepts absolute paths only')
+
if options.debug:
print('root =', options.root)
if options.dest:
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-27 3:22 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-27 3:22 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/27 03:22:00
Modified: lddtree.py
Log:
lddtree.py: use 0o for octal prefix for python3 compat
Revision Changes Path
1.32 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.32&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.32&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.31&r2=1.32
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -r1.31 -r1.32
--- lddtree.py 27 Mar 2013 03:20:52 -0000 1.31
+++ lddtree.py 27 Mar 2013 03:22:00 -0000 1.32
@@ -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.31 2013/03/27 03:20:52 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.32 2013/03/27 03:22:00 vapier Exp $
# TODO: Handle symlinks.
@@ -104,7 +104,7 @@
os.rename(wrappath, wrappath + '.elf')
with open(wrappath, 'w') as f:
f.write(wrapper % replacements)
- os.chmod(wrappath, 0755)
+ os.chmod(wrappath, 0o0755)
def ParseLdPaths(str_ldpaths, root='', path=None):
@@ -369,7 +369,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.31 2013/03/27 03:20:52 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.32 2013/03/27 03:22:00 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-27 3:20 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-27 3:20 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/27 03:20:52
Modified: lddtree.py
Log:
lddtree.py: add --copy-non-elfs to simplify copying of lots of files
Revision Changes Path
1.31 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.31&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.31&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.30&r2=1.31
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -r1.30 -r1.31
--- lddtree.py 27 Mar 2013 03:20:04 -0000 1.30
+++ lddtree.py 27 Mar 2013 03:20:52 -0000 1.31
@@ -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.30 2013/03/27 03:20:04 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.31 2013/03/27 03:20:52 vapier Exp $
# TODO: Handle symlinks.
@@ -369,7 +369,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.30 2013/03/27 03:20:04 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.31 2013/03/27 03:20:52 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -541,6 +541,9 @@
parser.add_option('--generate-wrappers',
action='store_true', default=False,
help=('Wrap executable ELFs with scripts for local ldso'))
+ parser.add_option('--copy-non-elfs',
+ action='store_true', default=False,
+ help=('Copy over plain (non-ELF) files rather than warn+ignore'))
parser.add_option('-l', '--list',
action='store_true', default=False,
help=('Display output in a simple list (easy for copying)'))
@@ -582,6 +585,18 @@
try:
elf = ParseELF(p, options.root, ldpaths)
except (exceptions.ELFError, IOError) as e:
+ # XXX: Ugly. Should unify with _Action* somehow.
+ if options.dest is not None and options.copy_non_elfs:
+ if os.path.exists(p):
+ elf = {
+ 'interp': None,
+ 'libs': [],
+ 'runpath': [],
+ 'rpath': [],
+ 'path': p,
+ }
+ _ActionCopy(options, elf)
+ continue
ret = 1
warn('%s: %s' % (p, e))
continue
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-27 3:20 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-27 3:20 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/27 03:20:04
Modified: lddtree.py
Log:
lddtree.py: use glob.iglob, and warn when no paths were matched
Revision Changes Path
1.30 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.30&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.30&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.29&r2=1.30
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- lddtree.py 27 Mar 2013 03:07:46 -0000 1.29
+++ lddtree.py 27 Mar 2013 03:20:04 -0000 1.30
@@ -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.29 2013/03/27 03:07:46 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.30 2013/03/27 03:20:04 vapier Exp $
# TODO: Handle symlinks.
@@ -369,7 +369,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.29 2013/03/27 03:07:46 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.30 2013/03/27 03:20:04 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -575,17 +575,26 @@
for path in paths:
if options.auto_root:
path = options.root + path.lstrip('/')
- for p in glob.glob(path):
+
+ matched = False
+ for p in glob.iglob(path):
+ matched = True
try:
elf = ParseELF(p, options.root, ldpaths)
except (exceptions.ELFError, IOError) as e:
ret = 1
warn('%s: %s' % (p, e))
continue
+
if options.dest is None:
_ActionShow(options, elf)
else:
_ActionCopy(options, elf)
+
+ if not matched:
+ ret = 1
+ warn('%s: did not match any paths' % (path,))
+
return ret
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-27 3:07 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-27 3:07 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/27 03:07:46
Modified: lddtree.py
Log:
lddtree.py: support globs on the command line
Revision Changes Path
1.29 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.29&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.29&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.28&r2=1.29
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -r1.28 -r1.29
--- lddtree.py 26 Mar 2013 05:22:28 -0000 1.28
+++ lddtree.py 27 Mar 2013 03:07:46 -0000 1.29
@@ -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.28 2013/03/26 05:22:28 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.29 2013/03/27 03:07:46 vapier Exp $
# TODO: Handle symlinks.
@@ -369,7 +369,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.28 2013/03/26 05:22:28 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.29 2013/03/27 03:07:46 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -501,6 +501,9 @@
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
@@ -572,16 +575,17 @@
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:
- ret = 1
- warn('%s: %s' % (path, e))
- continue
- if options.dest is None:
- _ActionShow(options, elf)
- else:
- _ActionCopy(options, elf)
+ for p in glob.glob(path):
+ try:
+ elf = ParseELF(p, options.root, ldpaths)
+ except (exceptions.ELFError, IOError) as e:
+ ret = 1
+ warn('%s: %s' % (p, e))
+ continue
+ if options.dest is None:
+ _ActionShow(options, elf)
+ else:
+ _ActionCopy(options, elf)
return ret
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-26 5:22 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-26 5:22 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/26 05:22:28
Modified: lddtree.py
Log:
lddtree.py: add --bindir/--libdir options to support collapsing the outputs down to single paths
Revision Changes Path
1.28 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.28&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.28&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.27&r2=1.28
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -r1.27 -r1.28
--- lddtree.py 26 Mar 2013 05:03:42 -0000 1.27
+++ lddtree.py 26 Mar 2013 05:22:28 -0000 1.28
@@ -3,7 +3,9 @@
# 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.27 2013/03/26 05:03:42 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.28 2013/03/26 05:22:28 vapier Exp $
+
+# TODO: Handle symlinks.
"""Read the ELF dependency tree and show it
@@ -367,7 +369,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.27 2013/03/26 05:03:42 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.28 2013/03/26 05:22:28 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -416,7 +418,7 @@
def _StripRoot(path):
return path[len(options.root) - 1:]
- def _copy(src, striproot=True, wrapit=False, libpaths=()):
+ def _copy(src, striproot=True, wrapit=False, libpaths=(), outdir=None):
if src is None:
return
@@ -427,7 +429,10 @@
striproot = _StripRoot if striproot else lambda x: x
- subdst = striproot(src)
+ if outdir:
+ subdst = os.path.join(outdir, os.path.basename(src))
+ else:
+ subdst = striproot(src)
dst = options.dest + subdst
try:
@@ -458,8 +463,11 @@
if options.verbose:
print('generate wrapper %s' % (dst,))
- GenerateLdsoWrapper(options.dest, subdst, _StripRoot(elf['interp']),
- libpaths)
+ if options.libdir:
+ interp = os.path.join(options.libdir, os.path.basename(elf['interp']))
+ else:
+ interp = _StripRoot(elf['interp'])
+ GenerateLdsoWrapper(options.dest, subdst, interp, libpaths)
# XXX: We should automatically import libgcc_s.so whenever libpthread.so
# is copied over (since we know it can be dlopen-ed by NPTL at runtime).
@@ -469,18 +477,23 @@
libpaths = set()
for lib in elf['libs']:
path = elf['libs'][lib]['path']
- libpaths.add(_StripRoot(os.path.dirname(path)))
- _copy(path)
-
- libpaths = list(libpaths)
- if elf['runpath']:
- libpaths = elf['runpath'] + libpaths
+ if not options.libdir:
+ libpaths.add(_StripRoot(os.path.dirname(path)))
+ _copy(path, outdir=options.libdir)
+
+ if not options.libdir:
+ libpaths = list(libpaths)
+ if elf['runpath']:
+ libpaths = elf['runpath'] + libpaths
+ else:
+ libpaths = elf['rpath'] + libpaths
else:
- libpaths = elf['rpath'] + libpaths
+ libpaths.add(options.libdir)
- _copy(elf['interp'])
+ _copy(elf['interp'], outdir=options.libdir)
_copy(elf['path'], striproot=options.auto_root,
- wrapit=options.generate_wrappers, libpaths=libpaths)
+ wrapit=options.generate_wrappers, libpaths=libpaths,
+ outdir=options.bindir)
def main(argv):
@@ -514,6 +527,14 @@
dest='dest', default=None, type='string',
action='callback', callback=_NormalizePath,
help=('Copy all files to the specified tree'))
+ parser.add_option('--bindir',
+ default=None, type='string',
+ action='callback', callback=_NormalizePath,
+ help=('Dir to store all ELFs specified on the command line'))
+ parser.add_option('--libdir',
+ default=None, type='string',
+ action='callback', callback=_NormalizePath,
+ help=('Dir to store all ELF libs'))
parser.add_option('--generate-wrappers',
action='store_true', default=False,
help=('Wrap executable ELFs with scripts for local ldso'))
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-26 5:03 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-26 5:03 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/26 05:03:42
Modified: lddtree.py
Log:
lddtree.py: do not try and wrap static ELFs
Revision Changes Path
1.27 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.27&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.27&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.26&r2=1.27
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- lddtree.py 26 Mar 2013 04:50:47 -0000 1.26
+++ lddtree.py 26 Mar 2013 05:03:42 -0000 1.27
@@ -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.26 2013/03/26 04:50:47 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.27 2013/03/26 05:03:42 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -367,7 +367,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.26 2013/03/26 04:50:47 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.27 2013/03/26 05:03:42 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -420,6 +420,11 @@
if src is None:
return
+ if wrapit:
+ # Static ELFs don't need to be wrapped.
+ if not elf['interp']:
+ wrapit = False
+
striproot = _StripRoot if striproot else lambda x: x
subdst = striproot(src)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-26 4:50 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-26 4:50 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/26 04:50:47
Modified: lddtree.py
Log:
lddtree.py: add a --generate-wrappers option for automatically wrapping executable ELFs with shell scripts
this is useful because it will run the local ldso with the right paths so only the local libraries (glibc included) get used. compare this to LD_LIBRARY_PATH hacks where the system ldso still gets run, but tries to load libs from the local dirs leading to random misbehavior at runtime (or even crash at load).
Revision Changes Path
1.26 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.26&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.26&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.25&r2=1.26
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- lddtree.py 25 Mar 2013 22:35:59 -0000 1.25
+++ lddtree.py 26 Mar 2013 04:50:47 -0000 1.26
@@ -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.25 2013/03/25 22:35:59 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.26 2013/03/26 04:50:47 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -51,12 +51,60 @@
return os.path.normpath(path).replace('//', '/')
+def makedirs(path):
+ """Like os.makedirs(), but ignore EEXIST errors"""
+ try:
+ os.makedirs(path)
+ except OSError as e:
+ if e.errno != os.errno.EEXIST:
+ raise
+
+
def dedupe(items):
"""Remove all duplicates from |items| (keeping order)"""
seen = {}
return [seen.setdefault(x, x) for x in items if x not in seen]
+def GenerateLdsoWrapper(root, path, interp, libpaths=()):
+ """Generate a shell script wrapper which uses local ldso to run the ELF
+
+ Since we cannot rely on the host glibc (or other libraries), we need to
+ execute the local packaged ldso directly and tell it where to find our
+ copies of libraries.
+
+ Args:
+ root: The root tree to generate scripts inside of
+ path: The full path (inside |root|) to the program to wrap
+ interp: The ldso interpreter that we need to execute
+ libpaths: Extra lib paths to search for libraries
+ """
+ basedir = os.path.dirname(path)
+ interp_dir, interp_name = os.path.split(interp)
+ libpaths = dedupe([interp_dir] + list(libpaths))
+ replacements = {
+ 'interp': os.path.join(os.path.relpath(interp_dir, basedir),
+ interp_name),
+ 'libpaths': ':'.join(['${basedir}/' + os.path.relpath(p, basedir)
+ for p in libpaths]),
+ }
+ wrapper = """#!/bin/sh
+base=$(realpath "$0")
+basedir=${base%%/*}
+exec \
+ "${basedir}/%(interp)s" \
+ --library-path "%(libpaths)s" \
+ --inhibit-rpath '' \
+ "${base}.elf" \
+ "$@"
+"""
+ wrappath = root + path
+ os.rename(wrappath, wrappath + '.elf')
+ with open(wrappath, 'w') as f:
+ f.write(wrapper % replacements)
+ os.chmod(wrappath, 0755)
+
+
def ParseLdPaths(str_ldpaths, root='', path=None):
"""Parse the colon-delimited list of paths and apply ldso rules to each
@@ -319,7 +367,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.25 2013/03/25 22:35:59 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.26 2013/03/26 04:50:47 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -365,46 +413,69 @@
def _ActionCopy(options, elf):
"""Copy the ELF and its dependencies to a destination tree"""
- def _copy(src, striproot=True):
+ def _StripRoot(path):
+ return path[len(options.root) - 1:]
+
+ def _copy(src, striproot=True, wrapit=False, libpaths=()):
if src is None:
return
- if striproot:
- subdst = src[len(options.root) - 1:]
- else:
- subdst = src
+ striproot = _StripRoot if striproot else lambda x: x
+
+ subdst = striproot(src)
dst = options.dest + subdst
- if os.path.exists(dst):
+ try:
# See if they're the same file.
+ nstat = os.stat(dst + ('.elf' if wrapit else ''))
ostat = os.stat(src)
- nstat = os.stat(dst)
for field in ('mode', 'mtime', 'size'):
if getattr(ostat, 'st_' + field) != \
getattr(nstat, 'st_' + field):
break
else:
return
+ except OSError as e:
+ if e.errno != errno.ENOENT:
+ raise
if options.verbose:
print('%s -> %s' % (src, dst))
- try:
- os.makedirs(os.path.dirname(dst))
- except OSError as e:
- if e.errno != os.errno.EEXIST:
- raise
+ makedirs(os.path.dirname(dst))
try:
shutil.copy2(src, dst)
- return
except IOError:
os.unlink(dst)
- shutil.copy2(src, dst)
+ shutil.copy2(src, dst)
- _copy(elf['path'], striproot=options.auto_root)
- _copy(elf['interp'])
+ if wrapit:
+ if options.verbose:
+ print('generate wrapper %s' % (dst,))
+
+ GenerateLdsoWrapper(options.dest, subdst, _StripRoot(elf['interp']),
+ libpaths)
+
+ # XXX: We should automatically import libgcc_s.so whenever libpthread.so
+ # is copied over (since we know it can be dlopen-ed by NPTL at runtime).
+ # Similarly, we should provide an option for automatically copying over
+ # the libnsl.so and libnss_*.so libraries, as well as an open ended list
+ # for known libs that get loaded (e.g. curl will dlopen(libresolv)).
+ libpaths = set()
for lib in elf['libs']:
- _copy(elf['libs'][lib]['path'])
+ path = elf['libs'][lib]['path']
+ libpaths.add(_StripRoot(os.path.dirname(path)))
+ _copy(path)
+
+ libpaths = list(libpaths)
+ if elf['runpath']:
+ libpaths = elf['runpath'] + libpaths
+ else:
+ libpaths = elf['rpath'] + libpaths
+
+ _copy(elf['interp'])
+ _copy(elf['path'], striproot=options.auto_root,
+ wrapit=options.generate_wrappers, libpaths=libpaths)
def main(argv):
@@ -438,6 +509,9 @@
dest='dest', default=None, type='string',
action='callback', callback=_NormalizePath,
help=('Copy all files to the specified tree'))
+ parser.add_option('--generate-wrappers',
+ action='store_true', default=False,
+ help=('Wrap executable ELFs with scripts for local ldso'))
parser.add_option('-l', '--list',
action='store_true', default=False,
help=('Display output in a simple list (easy for copying)'))
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-25 22:35 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-25 22:35 UTC (permalink / raw
To: gentoo-commits
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:
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-24 5:37 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-24 5:37 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/24 05:37:34
Modified: lddtree.py
Log:
lddtree.py: fix help text w/--root option
Revision Changes Path
1.24 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.24&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.24&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.23&r2=1.24
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- lddtree.py 24 Mar 2013 05:27:49 -0000 1.23
+++ lddtree.py 24 Mar 2013 05:37:34 -0000 1.24
@@ -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.23 2013/03/24 05:27:49 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.24 2013/03/24 05:37:34 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.23 2013/03/24 05:27:49 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.24 2013/03/24 05:37:34 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -412,7 +412,7 @@
parser.add_option('-R', '--root',
dest='root', default=os.environ.get('ROOT', ''), type='string',
action='callback', callback=_NormalizePath,
- help=('Show all duplicated dependencies'))
+ help=('Search for all files/dependencies in ROOT'))
parser.add_option('--copy-to-tree',
dest='dest', default=None, type='string',
action='callback', callback=_NormalizePath,
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-24 5:27 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-24 5:27 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/24 05:27:49
Modified: lddtree.py
Log:
lddtree.py: have main() process all args given it rather than worrying about argv[0] being passed in
Revision Changes Path
1.23 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.23&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.23&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.22&r2=1.23
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- lddtree.py 23 Mar 2013 07:28:58 -0000 1.22
+++ lddtree.py 24 Mar 2013 05:27:49 -0000 1.23
@@ -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.22 2013/03/23 07:28:58 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.23 2013/03/24 05:27:49 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.22 2013/03/23 07:28:58 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.23 2013/03/24 05:27:49 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
@@ -431,8 +431,6 @@
help=('Show version information'))
(options, paths) = parser.parse_args(argv)
- # Throw away argv[0].
- paths.pop(0)
if options.root != '/':
options.root += '/'
@@ -465,4 +463,4 @@
if __name__ == '__main__':
- sys.exit(main(sys.argv))
+ sys.exit(main(sys.argv[1:]))
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-23 7:28 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-23 7:28 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/23 07:28:58
Modified: lddtree.py
Log:
lddtree.py: convert from tabs to two space indents to keep pylint happy, and to make ChromiumOS style so i stop getting it wrong when moving between code bases
Revision Changes Path
1.22 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.22&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.22&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.21&r2=1.22
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -r1.21 -r1.22
--- lddtree.py 21 Mar 2013 22:55:15 -0000 1.21
+++ lddtree.py 23 Mar 2013 07:28:58 -0000 1.22
@@ -2,7 +2,8 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Use of this source code is governed by a BSD-style license (BSD-3)
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.21 2013/03/21 22:55:15 vapier Exp $
+# pylint: disable=C0301
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.22 2013/03/23 07:28:58 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -24,444 +25,444 @@
def warn(msg, prefix='warning'):
- """Write |msg| to stderr with a |prefix| before it"""
- print('%s: %s: %s' % (sys.argv[0], prefix, msg), file=sys.stderr)
+ """Write |msg| to stderr with a |prefix| before it"""
+ print('%s: %s: %s' % (sys.argv[0], prefix, msg), file=sys.stderr)
def err(msg, status=1):
- """Write |msg| to stderr and exit with |status|"""
- warn(msg, prefix='error')
- sys.exit(status)
+ """Write |msg| to stderr and exit with |status|"""
+ warn(msg, prefix='error')
+ sys.exit(status)
def bstr(buf):
- """Decode the byte string into a string"""
- return buf.decode('utf-8')
+ """Decode the byte string into a string"""
+ return buf.decode('utf-8')
def normpath(path):
- """Normalize a path
+ """Normalize a path
- Python's os.path.normpath() doesn't handle some cases:
- // -> //
- //..// -> //
- //..//..// -> ///
- """
- return os.path.normpath(path).replace('//', '/')
+ Python's os.path.normpath() doesn't handle some cases:
+ // -> //
+ //..// -> //
+ //..//..// -> ///
+ """
+ return os.path.normpath(path).replace('//', '/')
def dedupe(items):
- """Remove all duplicates from |items| (keeping order)"""
- seen = {}
- return [seen.setdefault(x, x) for x in items if x not in seen]
+ """Remove all duplicates from |items| (keeping order)"""
+ seen = {}
+ return [seen.setdefault(x, x) for x in items if x not in seen]
def ParseLdPaths(str_ldpaths, root='', path=None):
- """Parse the colon-delimited list of paths and apply ldso rules to each
+ """Parse the colon-delimited list of paths and apply ldso rules to each
- Note the special handling as dictated by the ldso:
- - Empty paths are equivalent to $PWD
- - $ORIGIN is expanded to the path of the given file
- - (TODO) $LIB and friends
-
- Args:
- str_ldpath: A colon-delimited string of paths
- root: The path to prepend to all paths found
- Returns:
- list of processed paths
- """
- ldpaths = []
- for ldpath in str_ldpaths.split(':'):
- if ldpath == '':
- # The ldso treats "" paths as $PWD.
- ldpath = os.getcwd()
- else:
- ldpath = ldpath.replace('$ORIGIN', os.path.dirname(path))
- ldpaths.append(normpath(root + ldpath))
- return dedupe(ldpaths)
+ Note the special handling as dictated by the ldso:
+ - Empty paths are equivalent to $PWD
+ - $ORIGIN is expanded to the path of the given file
+ - (TODO) $LIB and friends
+
+ Args:
+ str_ldpath: A colon-delimited string of paths
+ root: The path to prepend to all paths found
+ Returns:
+ list of processed paths
+ """
+ ldpaths = []
+ for ldpath in str_ldpaths.split(':'):
+ if ldpath == '':
+ # The ldso treats "" paths as $PWD.
+ ldpath = os.getcwd()
+ else:
+ ldpath = ldpath.replace('$ORIGIN', os.path.dirname(path))
+ ldpaths.append(normpath(root + ldpath))
+ return dedupe(ldpaths)
def ParseLdSoConf(ldso_conf, root='/', _first=True):
- """Load all the paths from a given ldso config file
+ """Load all the paths from a given ldso config file
- This should handle comments, whitespace, and "include" statements.
+ This should handle comments, whitespace, and "include" statements.
- Args:
- ldso_conf: The file to scan
- root: The path to prepend to all paths found
- _first: Recursive use only; is this the first ELF ?
- Returns:
- list of paths found
- """
- paths = []
-
- try:
- with open(ldso_conf) as f:
- for line in f.readlines():
- line = line.split('#', 1)[0].strip()
- if not line:
- continue
- if line.startswith('include '):
- line = line[8:]
- if line[0] == '/':
- line = root + line.lstrip('/')
- else:
- line = os.path.dirname(ldso_conf) + '/' + line
- for path in glob.glob(line):
- paths += ParseLdSoConf(path, root=root, _first=False)
- else:
- paths += [normpath(root + line)]
- except IOError as e:
- if e.errno != errno.ENOENT:
- warn(e)
-
- if _first:
- # XXX: Load paths from ldso itself.
- # Remove duplicate entries to speed things up.
- paths = dedupe(paths)
+ Args:
+ ldso_conf: The file to scan
+ root: The path to prepend to all paths found
+ _first: Recursive use only; is this the first ELF ?
+ Returns:
+ list of paths found
+ """
+ paths = []
+
+ try:
+ with open(ldso_conf) as f:
+ for line in f.readlines():
+ line = line.split('#', 1)[0].strip()
+ if not line:
+ continue
+ if line.startswith('include '):
+ line = line[8:]
+ if line[0] == '/':
+ line = root + line.lstrip('/')
+ else:
+ line = os.path.dirname(ldso_conf) + '/' + line
+ for path in glob.glob(line):
+ paths += ParseLdSoConf(path, root=root, _first=False)
+ else:
+ paths += [normpath(root + line)]
+ except IOError as e:
+ if e.errno != errno.ENOENT:
+ warn(e)
+
+ if _first:
+ # XXX: Load paths from ldso itself.
+ # Remove duplicate entries to speed things up.
+ paths = dedupe(paths)
- return paths
+ return paths
def LoadLdpaths(root='/'):
- """Load linker paths from common locations
+ """Load linker paths from common locations
- This parses the ld.so.conf and LD_LIBRARY_PATH env var.
+ This parses the ld.so.conf and LD_LIBRARY_PATH env var.
- Args:
- root: The root tree to prepend to paths
- Returns:
- dict containing library paths to search
- """
- ldpaths = {
- 'conf': [],
- 'env': [],
- 'interp': [],
- }
-
- # Load up $LD_LIBRARY_PATH.
- ldpaths['env'] = []
- env_ldpath = os.environ.get('LD_LIBRARY_PATH')
- if not env_ldpath is None:
- if root != '/':
- warn('ignoring LD_LIBRARY_PATH due to ROOT usage')
- else:
- # XXX: If this contains $ORIGIN, we probably have to parse this
- # on a per-ELF basis so it can get turned into the right thing.
- ldpaths['env'] = ParseLdPaths(env_ldpath, path='')
+ Args:
+ root: The root tree to prepend to paths
+ Returns:
+ dict containing library paths to search
+ """
+ ldpaths = {
+ 'conf': [],
+ 'env': [],
+ 'interp': [],
+ }
+
+ # Load up $LD_LIBRARY_PATH.
+ ldpaths['env'] = []
+ env_ldpath = os.environ.get('LD_LIBRARY_PATH')
+ if not env_ldpath is None:
+ if root != '/':
+ warn('ignoring LD_LIBRARY_PATH due to ROOT usage')
+ else:
+ # XXX: If this contains $ORIGIN, we probably have to parse this
+ # on a per-ELF basis so it can get turned into the right thing.
+ ldpaths['env'] = ParseLdPaths(env_ldpath, path='')
- # Load up /etc/ld.so.conf.
- ldpaths['conf'] = ParseLdSoConf(root + 'etc/ld.so.conf', root=root)
+ # Load up /etc/ld.so.conf.
+ ldpaths['conf'] = ParseLdSoConf(root + 'etc/ld.so.conf', root=root)
- return ldpaths
+ return ldpaths
def CompatibleELFs(elf1, elf2):
- """See if two ELFs are compatible
+ """See if two ELFs are compatible
- This compares the aspects of the ELF to see if they're compatible:
- bit size, endianness, machine type, and operating system.
+ This compares the aspects of the ELF to see if they're compatible:
+ bit size, endianness, machine type, and operating system.
- Args:
- elf1: an ELFFile object
- elf2: an ELFFile object
- Returns:
- True if compatible, False otherwise
- """
- osabis = frozenset([e.header['e_ident']['EI_OSABI'] for e in (elf1, elf2)])
- compat_sets = (
- frozenset(['ELFOSABI_NONE', 'ELFOSABI_SYSV', 'ELFOSABI_LINUX']),
- )
- return ((len(osabis) == 1 or any(osabis.issubset(x) for x in compat_sets)) and
- elf1.elfclass == elf2.elfclass and
- elf1.little_endian == elf2.little_endian and
- elf1.header['e_machine'] == elf2.header['e_machine'])
+ Args:
+ elf1: an ELFFile object
+ elf2: an ELFFile object
+ Returns:
+ True if compatible, False otherwise
+ """
+ osabis = frozenset([e.header['e_ident']['EI_OSABI'] for e in (elf1, elf2)])
+ compat_sets = (
+ frozenset(['ELFOSABI_NONE', 'ELFOSABI_SYSV', 'ELFOSABI_LINUX']),
+ )
+ return ((len(osabis) == 1 or any(osabis.issubset(x) for x in compat_sets)) and
+ elf1.elfclass == elf2.elfclass and
+ elf1.little_endian == elf2.little_endian and
+ elf1.header['e_machine'] == elf2.header['e_machine'])
def FindLib(elf, lib, ldpaths):
- """Try to locate a |lib| that is compatible to |elf| in the given |ldpaths|
+ """Try to locate a |lib| that is compatible to |elf| in the given |ldpaths|
- Args:
- elf: the elf which the library should be compatible with (ELF wise)
- lib: the library (basename) to search for
- ldpaths: a list of paths to search
- Returns:
- the full path to the desired library
- """
- for ldpath in ldpaths:
- path = os.path.join(ldpath, lib)
- if os.path.exists(path):
- with open(path, 'rb') as f:
- libelf = ELFFile(f)
- if CompatibleELFs(elf, libelf):
- return path
- return None
+ Args:
+ elf: the elf which the library should be compatible with (ELF wise)
+ lib: the library (basename) to search for
+ ldpaths: a list of paths to search
+ Returns:
+ the full path to the desired library
+ """
+ for ldpath in ldpaths:
+ path = os.path.join(ldpath, lib)
+ if os.path.exists(path):
+ with open(path, 'rb') as f:
+ libelf = ELFFile(f)
+ if CompatibleELFs(elf, libelf):
+ return path
+ return None
def ParseELF(path, root='/', ldpaths={'conf':[], 'env':[], 'interp':[]},
_first=True, _all_libs={}):
- """Parse the ELF dependency tree of the specified file
+ """Parse the ELF dependency tree of the specified file
- Args:
- path: The ELF to scan
- root: The root tree to prepend to paths; this applies to interp and rpaths
- only as |path| and |ldpaths| are expected to be prefixed already
- ldpaths: dict containing library paths to search; should have the keys:
- conf, env, interp
- _first: Recursive use only; is this the first ELF ?
- _all_libs: Recursive use only; dict of all libs we've seen
- Returns:
- a dict containing information about all the ELFs; e.g.
- {
- 'interp': '/lib64/ld-linux.so.2',
- 'needed': ['libc.so.6', 'libcurl.so.4',],
- 'libs': {
- 'libc.so.6': {
- 'path': '/lib64/libc.so.6',
- 'needed': [],
- },
- 'libcurl.so.4': {
- 'path': '/usr/lib64/libcurl.so.4',
- 'needed': ['libc.so.6', 'librt.so.1',],
- },
- },
- }
- """
- if _first:
- _all_libs = {}
- ldpaths = ldpaths.copy()
- ret = {
- 'interp': None,
- 'path': path,
- 'needed': [],
- 'rpath': [],
- 'runpath': [],
- 'libs': _all_libs,
- }
-
- with open(path, 'rb') as f:
- elf = ELFFile(f)
-
- # If this is the first ELF, extract the interpreter.
- if _first:
- for segment in elf.iter_segments():
- if segment.header.p_type != 'PT_INTERP':
- continue
-
- interp = bstr(segment.get_interp_name())
- ret['interp'] = normpath(root + interp)
- ret['libs'][os.path.basename(interp)] = {
- 'path': ret['interp'],
- 'needed': [],
- }
- # XXX: Should read it and scan for /lib paths.
- ldpaths['interp'] = [
- normpath(root + os.path.dirname(interp)),
- normpath(root + '/usr' + os.path.dirname(interp)),
- ]
- break
-
- # Parse the ELF's dynamic tags.
- libs = []
- rpaths = []
- runpaths = []
- for segment in elf.iter_segments():
- if segment.header.p_type != 'PT_DYNAMIC':
- continue
-
- for t in segment.iter_tags():
- if t.entry.d_tag == 'DT_RPATH':
- rpaths = ParseLdPaths(bstr(t.rpath), root=root, path=path)
- elif t.entry.d_tag == 'DT_RUNPATH':
- runpaths = ParseLdPaths(bstr(t.runpath), root=root, path=path)
- elif t.entry.d_tag == 'DT_NEEDED':
- libs.append(bstr(t.needed))
- if runpaths:
- # If both RPATH and RUNPATH are set, only the latter is used.
- rpaths = []
-
- # XXX: We assume there is only one PT_DYNAMIC. This is
- # probably fine since the runtime ldso does the same.
- break
- if _first:
- # Propagate the rpaths used by the main ELF since those will be
- # used at runtime to locate things.
- ldpaths['rpath'] = rpaths
- ldpaths['runpath'] = runpaths
- ret['rpath'] = rpaths
- ret['runpath'] = runpaths
- ret['needed'] = libs
-
- # Search for the libs this ELF uses.
- all_ldpaths = None
- for lib in libs:
- if lib in _all_libs:
- continue
- if all_ldpaths is None:
- all_ldpaths = rpaths + ldpaths['rpath'] + ldpaths['env'] + runpaths + ldpaths['runpath'] + ldpaths['conf'] + ldpaths['interp']
- fullpath = FindLib(elf, lib, all_ldpaths)
- _all_libs[lib] = {
- 'path': fullpath,
- 'needed': [],
- }
- if fullpath:
- lret = ParseELF(fullpath, root, ldpaths, False, _all_libs)
- _all_libs[lib]['needed'] = lret['needed']
+ Args:
+ path: The ELF to scan
+ root: The root tree to prepend to paths; this applies to interp and rpaths
+ only as |path| and |ldpaths| are expected to be prefixed already
+ ldpaths: dict containing library paths to search; should have the keys:
+ conf, env, interp
+ _first: Recursive use only; is this the first ELF ?
+ _all_libs: Recursive use only; dict of all libs we've seen
+ Returns:
+ a dict containing information about all the ELFs; e.g.
+ {
+ 'interp': '/lib64/ld-linux.so.2',
+ 'needed': ['libc.so.6', 'libcurl.so.4',],
+ 'libs': {
+ 'libc.so.6': {
+ 'path': '/lib64/libc.so.6',
+ 'needed': [],
+ },
+ 'libcurl.so.4': {
+ 'path': '/usr/lib64/libcurl.so.4',
+ 'needed': ['libc.so.6', 'librt.so.1',],
+ },
+ },
+ }
+ """
+ if _first:
+ _all_libs = {}
+ ldpaths = ldpaths.copy()
+ ret = {
+ 'interp': None,
+ 'path': path,
+ 'needed': [],
+ 'rpath': [],
+ 'runpath': [],
+ 'libs': _all_libs,
+ }
+
+ with open(path, 'rb') as f:
+ elf = ELFFile(f)
+
+ # If this is the first ELF, extract the interpreter.
+ if _first:
+ for segment in elf.iter_segments():
+ if segment.header.p_type != 'PT_INTERP':
+ continue
+
+ interp = bstr(segment.get_interp_name())
+ ret['interp'] = normpath(root + interp)
+ ret['libs'][os.path.basename(interp)] = {
+ 'path': ret['interp'],
+ 'needed': [],
+ }
+ # XXX: Should read it and scan for /lib paths.
+ ldpaths['interp'] = [
+ normpath(root + os.path.dirname(interp)),
+ normpath(root + '/usr' + os.path.dirname(interp)),
+ ]
+ break
+
+ # Parse the ELF's dynamic tags.
+ libs = []
+ rpaths = []
+ runpaths = []
+ for segment in elf.iter_segments():
+ if segment.header.p_type != 'PT_DYNAMIC':
+ continue
+
+ for t in segment.iter_tags():
+ if t.entry.d_tag == 'DT_RPATH':
+ rpaths = ParseLdPaths(bstr(t.rpath), root=root, path=path)
+ elif t.entry.d_tag == 'DT_RUNPATH':
+ runpaths = ParseLdPaths(bstr(t.runpath), root=root, path=path)
+ elif t.entry.d_tag == 'DT_NEEDED':
+ libs.append(bstr(t.needed))
+ if runpaths:
+ # If both RPATH and RUNPATH are set, only the latter is used.
+ rpaths = []
+
+ # XXX: We assume there is only one PT_DYNAMIC. This is
+ # probably fine since the runtime ldso does the same.
+ break
+ if _first:
+ # Propagate the rpaths used by the main ELF since those will be
+ # used at runtime to locate things.
+ ldpaths['rpath'] = rpaths
+ ldpaths['runpath'] = runpaths
+ ret['rpath'] = rpaths
+ ret['runpath'] = runpaths
+ ret['needed'] = libs
+
+ # Search for the libs this ELF uses.
+ all_ldpaths = None
+ for lib in libs:
+ if lib in _all_libs:
+ continue
+ if all_ldpaths is None:
+ all_ldpaths = rpaths + ldpaths['rpath'] + ldpaths['env'] + runpaths + ldpaths['runpath'] + ldpaths['conf'] + ldpaths['interp']
+ fullpath = FindLib(elf, lib, all_ldpaths)
+ _all_libs[lib] = {
+ 'path': fullpath,
+ 'needed': [],
+ }
+ if fullpath:
+ lret = ParseELF(fullpath, root, ldpaths, False, _all_libs)
+ _all_libs[lib]['needed'] = lret['needed']
- del elf
+ del elf
- return ret
+ return ret
def _NormalizePath(option, _opt, value, parser):
- setattr(parser.values, option.dest, normpath(value))
+ setattr(parser.values, option.dest, normpath(value))
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.21 2013/03/21 22:55:15 vapier Exp $'.split()
- print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
- sys.exit(0)
+ d = '$Id: lddtree.py,v 1.22 2013/03/23 07:28:58 vapier Exp $'.split()
+ print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
+ sys.exit(0)
def _ActionShow(options, elf):
- """Show the dependency tree for this ELF"""
- def _show(lib, depth):
- chain_libs.append(lib)
- fullpath = elf['libs'][lib]['path']
- if options.list:
- print(fullpath or lib)
- else:
- print('%s%s => %s' % (' ' * depth, lib, fullpath))
-
- new_libs = []
- for lib in elf['libs'][lib]['needed']:
- if lib in chain_libs:
- if not options.list:
- print('%s%s => !!! circular loop !!!' % (' ' * depth, lib))
- continue
- if options.all or not lib in shown_libs:
- shown_libs.add(lib)
- new_libs.append(lib)
-
- for lib in new_libs:
- _show(lib, depth + 1)
- chain_libs.pop()
-
- shown_libs = set(elf['needed'])
- chain_libs = []
- interp = elf['interp']
- if interp:
- shown_libs.add(os.path.basename(interp))
- if options.list:
- print(elf['path'])
- if not interp is None:
- print(interp)
- else:
- print('%s (interpreter => %s)' % (elf['path'], interp))
- for lib in elf['needed']:
- _show(lib, 1)
+ """Show the dependency tree for this ELF"""
+ def _show(lib, depth):
+ chain_libs.append(lib)
+ fullpath = elf['libs'][lib]['path']
+ if options.list:
+ print(fullpath or lib)
+ else:
+ print('%s%s => %s' % (' ' * depth, lib, fullpath))
+
+ new_libs = []
+ for lib in elf['libs'][lib]['needed']:
+ if lib in chain_libs:
+ if not options.list:
+ print('%s%s => !!! circular loop !!!' % (' ' * depth, lib))
+ continue
+ if options.all or not lib in shown_libs:
+ shown_libs.add(lib)
+ new_libs.append(lib)
+
+ for lib in new_libs:
+ _show(lib, depth + 1)
+ chain_libs.pop()
+
+ shown_libs = set(elf['needed'])
+ chain_libs = []
+ interp = elf['interp']
+ if interp:
+ shown_libs.add(os.path.basename(interp))
+ if options.list:
+ print(elf['path'])
+ if not interp is None:
+ print(interp)
+ else:
+ print('%s (interpreter => %s)' % (elf['path'], interp))
+ for lib in elf['needed']:
+ _show(lib, 1)
def _ActionCopy(options, elf):
- """Copy the ELF and its dependencies to a destination tree"""
- def _copy(src):
- if src is None:
- return
-
- dst = options.dest + src
- if os.path.exists(dst):
- # See if they're the same file.
- ostat = os.stat(src)
- nstat = os.stat(dst)
- for field in ('mode', 'mtime', 'size'):
- if getattr(ostat, 'st_' + field) != \
- getattr(nstat, 'st_' + field):
- break
- else:
- return
-
- if options.verbose:
- print('%s -> %s' % (src, dst))
-
- try:
- os.makedirs(os.path.dirname(dst))
- except OSError as e:
- if e.errno != os.errno.EEXIST:
- raise
- try:
- shutil.copy2(src, dst)
- return
- except IOError:
- os.unlink(dst)
- shutil.copy2(src, dst)
-
- _copy(elf['path'])
- _copy(elf['interp'])
- for lib in elf['libs']:
- _copy(elf['libs'][lib]['path'])
+ """Copy the ELF and its dependencies to a destination tree"""
+ def _copy(src):
+ if src is None:
+ return
+
+ dst = options.dest + src
+ if os.path.exists(dst):
+ # See if they're the same file.
+ ostat = os.stat(src)
+ nstat = os.stat(dst)
+ for field in ('mode', 'mtime', 'size'):
+ if getattr(ostat, 'st_' + field) != \
+ getattr(nstat, 'st_' + field):
+ break
+ else:
+ return
+
+ if options.verbose:
+ print('%s -> %s' % (src, dst))
+
+ try:
+ os.makedirs(os.path.dirname(dst))
+ except OSError as e:
+ if e.errno != os.errno.EEXIST:
+ raise
+ try:
+ shutil.copy2(src, dst)
+ return
+ except IOError:
+ os.unlink(dst)
+ shutil.copy2(src, dst)
+
+ _copy(elf['path'])
+ _copy(elf['interp'])
+ for lib in elf['libs']:
+ _copy(elf['libs'][lib]['path'])
def main(argv):
- parser = optparse.OptionParser("""%prog [options] <ELFs>
+ parser = optparse.OptionParser("""%prog [options] <ELFs>
Display ELF dependencies as a tree""")
- 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',
- action='callback', callback=_NormalizePath,
- help=('Show all duplicated dependencies'))
- parser.add_option('--copy-to-tree',
- dest='dest', default=None, type='string',
- action='callback', callback=_NormalizePath,
- help=('Copy all files to the specified tree'))
- 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('-V', '--version',
- action='callback', callback=_ShowVersion,
- help=('Show version information'))
- (options, paths) = parser.parse_args(argv)
-
- # Throw away argv[0].
- paths.pop(0)
- if options.root != '/':
- options.root += '/'
-
- if options.debug:
- print('root =', options.root)
- if options.dest:
- print('dest =', options.dest)
- if not paths:
- err('missing ELF files to scan')
-
- ldpaths = LoadLdpaths(options.root)
- if options.debug:
- print('ldpaths[conf] =', ldpaths['conf'])
- print('ldpaths[env] =', ldpaths['env'])
-
- # Process all the files specified.
- ret = 0
- for path in paths:
- try:
- elf = ParseELF(path, options.root, ldpaths)
- except (exceptions.ELFError, IOError) as e:
- ret = 1
- warn('%s: %s' % (path, e))
- continue
- if options.dest is None:
- _ActionShow(options, elf)
- else:
- _ActionCopy(options, elf)
- return ret
+ 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',
+ action='callback', callback=_NormalizePath,
+ help=('Show all duplicated dependencies'))
+ parser.add_option('--copy-to-tree',
+ dest='dest', default=None, type='string',
+ action='callback', callback=_NormalizePath,
+ help=('Copy all files to the specified tree'))
+ 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('-V', '--version',
+ action='callback', callback=_ShowVersion,
+ help=('Show version information'))
+ (options, paths) = parser.parse_args(argv)
+
+ # Throw away argv[0].
+ paths.pop(0)
+ if options.root != '/':
+ options.root += '/'
+
+ if options.debug:
+ print('root =', options.root)
+ if options.dest:
+ print('dest =', options.dest)
+ if not paths:
+ err('missing ELF files to scan')
+
+ ldpaths = LoadLdpaths(options.root)
+ if options.debug:
+ print('ldpaths[conf] =', ldpaths['conf'])
+ print('ldpaths[env] =', ldpaths['env'])
+
+ # Process all the files specified.
+ ret = 0
+ for path in paths:
+ try:
+ elf = ParseELF(path, options.root, ldpaths)
+ except (exceptions.ELFError, IOError) as e:
+ ret = 1
+ warn('%s: %s' % (path, e))
+ continue
+ if options.dest is None:
+ _ActionShow(options, elf)
+ else:
+ _ActionCopy(options, elf)
+ return ret
if __name__ == '__main__':
- sys.exit(main(sys.argv))
+ sys.exit(main(sys.argv))
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-21 22:55 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-21 22:55 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/21 22:55:15
Modified: lddtree.py
Log:
lddtree.py: relicense to BSD-3 to make Debian licensecheck.pl stfu
Revision Changes Path
1.21 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.21&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.21&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.20&r2=1.21
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- lddtree.py 21 Mar 2013 03:04:58 -0000 1.20
+++ lddtree.py 21 Mar 2013 22:55:15 -0000 1.21
@@ -1,8 +1,8 @@
#!/usr/bin/python
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.20 2013/03/21 03:04:58 vapier Exp $
+# Use of this source code is governed by a BSD-style license (BSD-3)
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.21 2013/03/21 22:55:15 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -318,7 +318,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- d = '$Id: lddtree.py,v 1.20 2013/03/21 03:04:58 vapier Exp $'.split()
+ d = '$Id: lddtree.py,v 1.21 2013/03/21 22:55:15 vapier Exp $'.split()
print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-21 3:04 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-21 3:04 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/21 03:04:58
Modified: lddtree.py
Log:
lddtree.py: fix a few random pylint warnings
Revision Changes Path
1.20 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.20&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.20&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.19&r2=1.20
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- lddtree.py 21 Mar 2013 03:03:32 -0000 1.19
+++ lddtree.py 21 Mar 2013 03:04:58 -0000 1.20
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.19 2013/03/21 03:03:32 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.20 2013/03/21 03:04:58 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -50,10 +50,10 @@
return os.path.normpath(path).replace('//', '/')
-def dedupe(input):
- """Remove all duplicates from input (keeping order)"""
+def dedupe(items):
+ """Remove all duplicates from |items| (keeping order)"""
seen = {}
- return [seen.setdefault(x, x) for x in input if x not in seen]
+ return [seen.setdefault(x, x) for x in items if x not in seen]
def ParseLdPaths(str_ldpaths, root='', path=None):
@@ -318,8 +318,8 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.19 2013/03/21 03:03:32 vapier Exp $'.split()
- print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
+ d = '$Id: lddtree.py,v 1.20 2013/03/21 03:04:58 vapier Exp $'.split()
+ print('%s-%s %s %s' % (d[1].split('.')[0], d[2], d[3], d[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-03-21 3:03 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-03-21 3:03 UTC (permalink / raw
To: gentoo-commits
vapier 13/03/21 03:03:32
Modified: lddtree.py
Log:
lddtree.py: get it working under python-3 #452178
Revision Changes Path
1.19 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.19&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.19&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.18&r2=1.19
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- lddtree.py 5 Jan 2013 20:39:56 -0000 1.18
+++ lddtree.py 21 Mar 2013 03:03:32 -0000 1.19
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.18 2013/01/05 20:39:56 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.19 2013/03/21 03:03:32 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -34,6 +34,11 @@
sys.exit(status)
+def bstr(buf):
+ """Decode the byte string into a string"""
+ return buf.decode('utf-8')
+
+
def normpath(path):
"""Normalize a path
@@ -186,7 +191,7 @@
for ldpath in ldpaths:
path = os.path.join(ldpath, lib)
if os.path.exists(path):
- with open(path) as f:
+ with open(path, 'rb') as f:
libelf = ELFFile(f)
if CompatibleELFs(elf, libelf):
return path
@@ -234,7 +239,7 @@
'libs': _all_libs,
}
- with open(path) as f:
+ with open(path, 'rb') as f:
elf = ELFFile(f)
# If this is the first ELF, extract the interpreter.
@@ -243,7 +248,7 @@
if segment.header.p_type != 'PT_INTERP':
continue
- interp = segment.get_interp_name()
+ interp = bstr(segment.get_interp_name())
ret['interp'] = normpath(root + interp)
ret['libs'][os.path.basename(interp)] = {
'path': ret['interp'],
@@ -266,11 +271,11 @@
for t in segment.iter_tags():
if t.entry.d_tag == 'DT_RPATH':
- rpaths = ParseLdPaths(t.rpath, root=root, path=path)
+ rpaths = ParseLdPaths(bstr(t.rpath), root=root, path=path)
elif t.entry.d_tag == 'DT_RUNPATH':
- runpaths = ParseLdPaths(t.runpath, root=root, path=path)
+ runpaths = ParseLdPaths(bstr(t.runpath), root=root, path=path)
elif t.entry.d_tag == 'DT_NEEDED':
- libs.append(t.needed)
+ libs.append(bstr(t.needed))
if runpaths:
# If both RPATH and RUNPATH are set, only the latter is used.
rpaths = []
@@ -313,7 +318,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.18 2013/01/05 20:39:56 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.19 2013/03/21 03:03:32 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2013-01-05 20:39 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2013-01-05 20:39 UTC (permalink / raw
To: gentoo-commits
vapier 13/01/05 20:39:56
Modified: lddtree.py
Log:
lddtree.py: leverage the rpaths from the main executable to better locate libs that get used
Revision Changes Path
1.18 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.18&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.18&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.17&r2=1.18
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- lddtree.py 14 Dec 2012 04:22:52 -0000 1.17
+++ lddtree.py 5 Jan 2013 20:39:56 -0000 1.18
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.17 2012/12/14 04:22:52 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.18 2013/01/05 20:39:56 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -224,10 +224,13 @@
"""
if _first:
_all_libs = {}
+ ldpaths = ldpaths.copy()
ret = {
'interp': None,
'path': path,
'needed': [],
+ 'rpath': [],
+ 'runpath': [],
'libs': _all_libs,
}
@@ -272,7 +275,16 @@
# If both RPATH and RUNPATH are set, only the latter is used.
rpaths = []
+ # XXX: We assume there is only one PT_DYNAMIC. This is
+ # probably fine since the runtime ldso does the same.
break
+ if _first:
+ # Propagate the rpaths used by the main ELF since those will be
+ # used at runtime to locate things.
+ ldpaths['rpath'] = rpaths
+ ldpaths['runpath'] = runpaths
+ ret['rpath'] = rpaths
+ ret['runpath'] = runpaths
ret['needed'] = libs
# Search for the libs this ELF uses.
@@ -281,7 +293,7 @@
if lib in _all_libs:
continue
if all_ldpaths is None:
- all_ldpaths = rpaths + ldpaths['env'] + runpaths + ldpaths['conf'] + ldpaths['interp']
+ all_ldpaths = rpaths + ldpaths['rpath'] + ldpaths['env'] + runpaths + ldpaths['runpath'] + ldpaths['conf'] + ldpaths['interp']
fullpath = FindLib(elf, lib, all_ldpaths)
_all_libs[lib] = {
'path': fullpath,
@@ -301,7 +313,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.17 2012/12/14 04:22:52 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.18 2013/01/05 20:39:56 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-12-14 4:22 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-12-14 4:22 UTC (permalink / raw
To: gentoo-commits
vapier 12/12/14 04:22:52
Modified: lddtree.py
Log:
lddtree.py: fix typo found by pyflakes
Revision Changes Path
1.17 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.17&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.17&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.16&r2=1.17
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -r1.16 -r1.17
--- lddtree.py 26 Nov 2012 20:06:54 -0000 1.16
+++ lddtree.py 14 Dec 2012 04:22:52 -0000 1.17
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.16 2012/11/26 20:06:54 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.17 2012/12/14 04:22:52 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -270,7 +270,7 @@
libs.append(t.needed)
if runpaths:
# If both RPATH and RUNPATH are set, only the latter is used.
- rpath = []
+ rpaths = []
break
ret['needed'] = libs
@@ -301,7 +301,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.16 2012/11/26 20:06:54 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.17 2012/12/14 04:22:52 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-26 20:06 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-26 20:06 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/26 20:06:54
Modified: lddtree.py
Log:
lddtree.py: even simpler CompatibleELFs by David James
Revision Changes Path
1.16 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.16&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.16&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.15&r2=1.16
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- lddtree.py 24 Nov 2012 19:44:03 -0000 1.15
+++ lddtree.py 26 Nov 2012 20:06:54 -0000 1.16
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.15 2012/11/24 19:44:03 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.16 2012/11/26 20:06:54 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -163,23 +163,14 @@
Returns:
True if compatible, False otherwise
"""
- osabi1 = elf1.header['e_ident']['EI_OSABI']
- osabi2 = elf2.header['e_ident']['EI_OSABI']
- if elf1.elfclass != elf2.elfclass or \
- elf1.little_endian != elf2.little_endian or \
- elf1.header['e_machine'] != elf2.header['e_machine']:
- return False
- elif osabi1 != osabi2:
- compat_sets = (
- frozenset(['ELFOSABI_NONE', 'ELFOSABI_SYSV', 'ELFOSABI_LINUX']),
- )
- osabis = frozenset([osabi1, osabi2])
- for cs in compat_sets:
- if osabis.issubset(cs):
- return True
- return False
- else:
- return True
+ osabis = frozenset([e.header['e_ident']['EI_OSABI'] for e in (elf1, elf2)])
+ compat_sets = (
+ frozenset(['ELFOSABI_NONE', 'ELFOSABI_SYSV', 'ELFOSABI_LINUX']),
+ )
+ return ((len(osabis) == 1 or any(osabis.issubset(x) for x in compat_sets)) and
+ elf1.elfclass == elf2.elfclass and
+ elf1.little_endian == elf2.little_endian and
+ elf1.header['e_machine'] == elf2.header['e_machine'])
def FindLib(elf, lib, ldpaths):
@@ -310,7 +301,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.15 2012/11/24 19:44:03 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.16 2012/11/26 20:06:54 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-24 19:44 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-24 19:44 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/24 19:44:03
Modified: lddtree.py
Log:
lddtree.py: simplify osabi compat logic a bit with suggestion from David James
Revision Changes Path
1.15 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.15&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.15&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.14&r2=1.15
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- lddtree.py 24 Nov 2012 17:01:48 -0000 1.14
+++ lddtree.py 24 Nov 2012 19:44:03 -0000 1.15
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.14 2012/11/24 17:01:48 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.15 2012/11/24 19:44:03 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -173,10 +173,9 @@
compat_sets = (
frozenset(['ELFOSABI_NONE', 'ELFOSABI_SYSV', 'ELFOSABI_LINUX']),
)
+ osabis = frozenset([osabi1, osabi2])
for cs in compat_sets:
- cs1 = cs | set([osabi1])
- cs2 = cs | set([osabi2])
- if cs1 == cs2:
+ if osabis.issubset(cs):
return True
return False
else:
@@ -311,7 +310,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.14 2012/11/24 17:01:48 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.15 2012/11/24 19:44:03 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-24 17:01 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-24 17:01 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/24 17:01:48
Modified: lddtree.py
Log:
lddtree.py: simplify ldpath uniqification with algo by David James
Revision Changes Path
1.14 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.14&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.14&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.13&r2=1.14
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- lddtree.py 24 Nov 2012 16:54:32 -0000 1.13
+++ lddtree.py 24 Nov 2012 17:01:48 -0000 1.14
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.13 2012/11/24 16:54:32 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.14 2012/11/24 17:01:48 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -45,6 +45,12 @@
return os.path.normpath(path).replace('//', '/')
+def dedupe(input):
+ """Remove all duplicates from input (keeping order)"""
+ seen = {}
+ return [seen.setdefault(x, x) for x in input if x not in seen]
+
+
def ParseLdPaths(str_ldpaths, root='', path=None):
"""Parse the colon-delimited list of paths and apply ldso rules to each
@@ -66,10 +72,8 @@
ldpath = os.getcwd()
else:
ldpath = ldpath.replace('$ORIGIN', os.path.dirname(path))
- ldpath = normpath(root + ldpath)
- if not ldpath in ldpaths:
- ldpaths.append(ldpath)
- return ldpaths
+ ldpaths.append(normpath(root + ldpath))
+ return dedupe(ldpaths)
def ParseLdSoConf(ldso_conf, root='/', _first=True):
@@ -107,13 +111,9 @@
warn(e)
if _first:
- # Remove duplicate entries to speed things up.
# XXX: Load paths from ldso itself.
- new_paths = []
- for path in paths:
- if not path in new_paths:
- new_paths.append(path)
- paths = new_paths
+ # Remove duplicate entries to speed things up.
+ paths = dedupe(paths)
return paths
@@ -311,7 +311,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.13 2012/11/24 16:54:32 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.14 2012/11/24 17:01:48 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-24 16:54 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-24 16:54 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/24 16:54:32
Modified: lddtree.py
Log:
lddtree.py: handle $ORIGIN in the middle of paths as pointed out by David James
Revision Changes Path
1.13 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.13&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.13&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.12&r2=1.13
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- lddtree.py 17 Nov 2012 00:11:39 -0000 1.12
+++ lddtree.py 24 Nov 2012 16:54:32 -0000 1.13
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.12 2012/11/17 00:11:39 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.13 2012/11/24 16:54:32 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -64,8 +64,8 @@
if ldpath == '':
# The ldso treats "" paths as $PWD.
ldpath = os.getcwd()
- elif ldpath == '$ORIGIN':
- ldpath = os.path.dirname(path)
+ else:
+ ldpath = ldpath.replace('$ORIGIN', os.path.dirname(path))
ldpath = normpath(root + ldpath)
if not ldpath in ldpaths:
ldpaths.append(ldpath)
@@ -141,7 +141,9 @@
if root != '/':
warn('ignoring LD_LIBRARY_PATH due to ROOT usage')
else:
- ldpaths['env'] = ParseLdPaths(env_ldpath)
+ # XXX: If this contains $ORIGIN, we probably have to parse this
+ # on a per-ELF basis so it can get turned into the right thing.
+ ldpaths['env'] = ParseLdPaths(env_ldpath, path='')
# Load up /etc/ld.so.conf.
ldpaths['conf'] = ParseLdSoConf(root + 'etc/ld.so.conf', root=root)
@@ -309,7 +311,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.12 2012/11/17 00:11:39 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.13 2012/11/24 16:54:32 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-17 0:11 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-17 0:11 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/17 00:11:39
Modified: lddtree.py
Log:
lddtree.py: fix indentation in previous commit
Revision Changes Path
1.12 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.12&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.12&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.11&r2=1.12
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -r1.11 -r1.12
--- lddtree.py 16 Nov 2012 23:53:30 -0000 1.11
+++ lddtree.py 17 Nov 2012 00:11:39 -0000 1.12
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.11 2012/11/16 23:53:30 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.12 2012/11/17 00:11:39 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -230,8 +230,8 @@
},
}
"""
- if _first:
- _all_libs = {}
+ if _first:
+ _all_libs = {}
ret = {
'interp': None,
'path': path,
@@ -309,7 +309,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.11 2012/11/16 23:53:30 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.12 2012/11/17 00:11:39 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-16 23:53 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-16 23:53 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/16 23:53:30
Modified: lddtree.py
Log:
lddtree.py: clear _all_libs state at initial state to avoid recursive state messing up other runs
Revision Changes Path
1.11 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.11&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.11&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.10&r2=1.11
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- lddtree.py 15 Nov 2012 20:39:20 -0000 1.10
+++ lddtree.py 16 Nov 2012 23:53:30 -0000 1.11
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.10 2012/11/15 20:39:20 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.11 2012/11/16 23:53:30 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -230,6 +230,8 @@
},
}
"""
+ if _first:
+ _all_libs = {}
ret = {
'interp': None,
'path': path,
@@ -307,7 +309,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.10 2012/11/15 20:39:20 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.11 2012/11/16 23:53:30 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-15 20:39 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-15 20:39 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/15 20:39:20
Modified: lddtree.py
Log:
lddtree.py: warn if opening ld.so.conf fails (ignoring missing files)
Revision Changes Path
1.10 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.10&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.10&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.9&r2=1.10
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- lddtree.py 15 Nov 2012 20:35:04 -0000 1.9
+++ lddtree.py 15 Nov 2012 20:39:20 -0000 1.10
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.9 2012/11/15 20:35:04 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.10 2012/11/15 20:39:20 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -13,6 +13,7 @@
from __future__ import print_function
import glob
+import errno
import optparse
import os
import shutil
@@ -101,8 +102,9 @@
paths += ParseLdSoConf(path, root=root, _first=False)
else:
paths += [normpath(root + line)]
- except IOError:
- pass
+ except IOError as e:
+ if e.errno != errno.ENOENT:
+ warn(e)
if _first:
# Remove duplicate entries to speed things up.
@@ -305,7 +307,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.9 2012/11/15 20:35:04 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.10 2012/11/15 20:39:20 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-15 20:28 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-15 20:28 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/15 20:28:56
Modified: lddtree.py
Log:
lddtree.py: add root to displayed interp path
Revision Changes Path
1.8 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.8&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.8&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.7&r2=1.8
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- lddtree.py 15 Nov 2012 20:26:27 -0000 1.7
+++ lddtree.py 15 Nov 2012 20:28:55 -0000 1.8
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.7 2012/11/15 20:26:27 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.8 2012/11/15 20:28:55 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -242,9 +242,10 @@
if segment.header.p_type != 'PT_INTERP':
continue
- ret['interp'] = interp = segment.get_interp_name()
+ interp = segment.get_interp_name()
+ ret['interp'] = normpath(root + interp)
ret['libs'][os.path.basename(interp)] = {
- 'path': normpath(root + interp),
+ 'path': ret['interp'],
'needed': [],
}
# XXX: Should read it and scan for /lib paths.
@@ -302,7 +303,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.7 2012/11/15 20:26:27 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.8 2012/11/15 20:28:55 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-15 20:26 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-15 20:26 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/15 20:26:27
Modified: lddtree.py
Log:
lddtree.py: avoid shadowing global "file"
Revision Changes Path
1.7 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.7&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.7&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.6&r2=1.7
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- lddtree.py 15 Nov 2012 19:33:08 -0000 1.6
+++ lddtree.py 15 Nov 2012 20:26:27 -0000 1.7
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.6 2012/11/15 19:33:08 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.7 2012/11/15 20:26:27 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -95,8 +95,8 @@
line = root + line.lstrip('/')
else:
line = os.path.dirname(ldso_conf) + '/' + line
- for file in glob.glob(line):
- paths += ParseLdSoConf(file, root=root, _first=False)
+ for path in glob.glob(line):
+ paths += ParseLdSoConf(path, root=root, _first=False)
else:
paths += [normpath(root + line)]
except IOError:
@@ -197,14 +197,14 @@
return None
-def ParseELF(file, root='/', ldpaths={'conf':[], 'env':[], 'interp':[]},
+def ParseELF(path, root='/', ldpaths={'conf':[], 'env':[], 'interp':[]},
_first=True, _all_libs={}):
"""Parse the ELF dependency tree of the specified file
Args:
- file: The ELF to scan
+ path: The ELF to scan
root: The root tree to prepend to paths; this applies to interp and rpaths
- only as |file| and |ldpaths| are expected to be prefixed already
+ only as |path| and |ldpaths| are expected to be prefixed already
ldpaths: dict containing library paths to search; should have the keys:
conf, env, interp
_first: Recursive use only; is this the first ELF ?
@@ -224,16 +224,16 @@
'needed': ['libc.so.6', 'librt.so.1',],
},
},
- }
+ }
"""
ret = {
'interp': None,
- 'path': file,
+ 'path': path,
'needed': [],
'libs': _all_libs,
}
- with open(file) as f:
+ with open(path) as f:
elf = ELFFile(f)
# If this is the first ELF, extract the interpreter.
@@ -302,7 +302,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.6 2012/11/15 19:33:08 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.7 2012/11/15 20:26:27 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
@@ -348,15 +348,15 @@
def _ActionCopy(options, elf):
"""Copy the ELF and its dependencies to a destination tree"""
- def _copy(file):
- if file is None:
+ def _copy(src):
+ if src is None:
return
- dest = options.dest + file
- if os.path.exists(dest):
+ dst = options.dest + src
+ if os.path.exists(dst):
# See if they're the same file.
- ostat = os.stat(file)
- nstat = os.stat(dest)
+ ostat = os.stat(src)
+ nstat = os.stat(dst)
for field in ('mode', 'mtime', 'size'):
if getattr(ostat, 'st_' + field) != \
getattr(nstat, 'st_' + field):
@@ -365,19 +365,19 @@
return
if options.verbose:
- print('%s -> %s' % (file, dest))
+ print('%s -> %s' % (src, dst))
try:
- os.makedirs(os.path.dirname(dest))
+ os.makedirs(os.path.dirname(dst))
except OSError as e:
if e.errno != os.errno.EEXIST:
raise
try:
- shutil.copy2(file, dest)
+ shutil.copy2(src, dst)
return
except IOError:
- os.unlink(dest)
- shutil.copy2(file, dest)
+ os.unlink(dst)
+ shutil.copy2(src, dst)
_copy(elf['path'])
_copy(elf['interp'])
@@ -412,9 +412,10 @@
parser.add_option('-V', '--version',
action='callback', callback=_ShowVersion,
help=('Show version information'))
- (options, files) = parser.parse_args(argv)
+ (options, paths) = parser.parse_args(argv)
- files.pop(0)
+ # Throw away argv[0].
+ paths.pop(0)
if options.root != '/':
options.root += '/'
@@ -422,7 +423,7 @@
print('root =', options.root)
if options.dest:
print('dest =', options.dest)
- if not files:
+ if not paths:
err('missing ELF files to scan')
ldpaths = LoadLdpaths(options.root)
@@ -432,12 +433,12 @@
# Process all the files specified.
ret = 0
- for file in files:
+ for path in paths:
try:
- elf = ParseELF(file, options.root, ldpaths)
+ elf = ParseELF(path, options.root, ldpaths)
except (exceptions.ELFError, IOError) as e:
ret = 1
- warn('%s: %s' % (file, e))
+ warn('%s: %s' % (path, e))
continue
if options.dest is None:
_ActionShow(options, elf)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-15 19:33 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-15 19:33 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/15 19:33:08
Modified: lddtree.py
Log:
lddtree.py: break ldpath setup out so other modules can use it, fix set handling in CompatibleELFs, and add some more documentation
Revision Changes Path
1.6 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.6&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.6&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.5&r2=1.6
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- lddtree.py 13 Nov 2012 05:10:37 -0000 1.5
+++ lddtree.py 15 Nov 2012 19:33:08 -0000 1.6
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.5 2012/11/13 05:10:37 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.6 2012/11/15 19:33:08 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -50,7 +50,7 @@
Note the special handling as dictated by the ldso:
- Empty paths are equivalent to $PWD
- (TODO) $ORIGIN is expanded to the path of the given file
- - (TODO)
+ - (TODO) $LIB and friends
Args:
str_ldpath: A colon-delimited string of paths
@@ -114,6 +114,37 @@
return paths
+def LoadLdpaths(root='/'):
+ """Load linker paths from common locations
+
+ This parses the ld.so.conf and LD_LIBRARY_PATH env var.
+
+ Args:
+ root: The root tree to prepend to paths
+ Returns:
+ dict containing library paths to search
+ """
+ ldpaths = {
+ 'conf': [],
+ 'env': [],
+ 'interp': [],
+ }
+
+ # Load up $LD_LIBRARY_PATH.
+ ldpaths['env'] = []
+ env_ldpath = os.environ.get('LD_LIBRARY_PATH')
+ if not env_ldpath is None:
+ if root != '/':
+ warn('ignoring LD_LIBRARY_PATH due to ROOT usage')
+ else:
+ ldpaths['env'] = ParseLdPaths(env_ldpath)
+
+ # Load up /etc/ld.so.conf.
+ ldpaths['conf'] = ParseLdSoConf(root + 'etc/ld.so.conf', root=root)
+
+ return ldpaths
+
+
def CompatibleELFs(elf1, elf2):
"""See if two ELFs are compatible
@@ -134,10 +165,12 @@
return False
elif osabi1 != osabi2:
compat_sets = (
- frozenset('ELFOSABI_NONE', 'ELFOSABI_SYSV', 'ELFOSABI_LINUX'),
+ frozenset(['ELFOSABI_NONE', 'ELFOSABI_SYSV', 'ELFOSABI_LINUX']),
)
for cs in compat_sets:
- if (cs | osabi1) == (cs | osabi2):
+ cs1 = cs | set([osabi1])
+ cs2 = cs | set([osabi2])
+ if cs1 == cs2:
return True
return False
else:
@@ -169,8 +202,9 @@
"""Parse the ELF dependency tree of the specified file
Args:
- file:
- root:
+ file: The ELF to scan
+ root: The root tree to prepend to paths; this applies to interp and rpaths
+ only as |file| and |ldpaths| are expected to be prefixed already
ldpaths: dict containing library paths to search; should have the keys:
conf, env, interp
_first: Recursive use only; is this the first ELF ?
@@ -268,7 +302,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.5 2012/11/13 05:10:37 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.6 2012/11/15 19:33:08 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
@@ -391,24 +425,7 @@
if not files:
err('missing ELF files to scan')
- ldpaths = {
- 'conf': [],
- 'env': [],
- 'interp': [],
- }
-
- # Load up $LD_LIBRARY_PATH.
- ldpaths['env'] = []
- env_ldpath = os.environ.get('LD_LIBRARY_PATH')
- if not env_ldpath is None:
- if options.root != '/':
- warn('ignoring LD_LIBRARY_PATH due to ROOT usage')
- else:
- ldpaths['env'] = ParseLdPaths(env_ldpath)
-
- # Load up /etc/ld.so.conf.
- ldpaths['conf'] = ParseLdSoConf(options.root + 'etc/ld.so.conf', root=options.root)
-
+ ldpaths = LoadLdpaths(options.root)
if options.debug:
print('ldpaths[conf] =', ldpaths['conf'])
print('ldpaths[env] =', ldpaths['env'])
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-13 5:10 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-13 5:10 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/13 05:10:37
Modified: lddtree.py
Log:
lddtree.py: add a --copy-to-tree option so people can quickly copy ELFs and their dependencies to a different location (useful for initramfs and such)
Revision Changes Path
1.5 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.5&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.5&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.4&r2=1.5
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- lddtree.py 13 Nov 2012 02:33:01 -0000 1.4
+++ lddtree.py 13 Nov 2012 05:10:37 -0000 1.5
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.4 2012/11/13 02:33:01 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.5 2012/11/13 05:10:37 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -15,6 +15,7 @@
import glob
import optparse
import os
+import shutil
import sys
from elftools.elf.elffile import ELFFile
@@ -193,6 +194,7 @@
"""
ret = {
'interp': None,
+ 'path': file,
'needed': [],
'libs': _all_libs,
}
@@ -261,18 +263,94 @@
return ret
-def _NormalizeRoot(_option, _opt, value, parser):
- parser.values.root = normpath(value)
- if parser.values.root == '/':
- parser.values.root = ''
+def _NormalizePath(option, _opt, value, parser):
+ setattr(parser.values, option.dest, normpath(value))
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.4 2012/11/13 02:33:01 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.5 2012/11/13 05:10:37 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
+def _ActionShow(options, elf):
+ """Show the dependency tree for this ELF"""
+ def _show(lib, depth):
+ chain_libs.append(lib)
+ fullpath = elf['libs'][lib]['path']
+ if options.list:
+ print(fullpath or lib)
+ else:
+ print('%s%s => %s' % (' ' * depth, lib, fullpath))
+
+ new_libs = []
+ for lib in elf['libs'][lib]['needed']:
+ if lib in chain_libs:
+ if not options.list:
+ print('%s%s => !!! circular loop !!!' % (' ' * depth, lib))
+ continue
+ if options.all or not lib in shown_libs:
+ shown_libs.add(lib)
+ new_libs.append(lib)
+
+ for lib in new_libs:
+ _show(lib, depth + 1)
+ chain_libs.pop()
+
+ shown_libs = set(elf['needed'])
+ chain_libs = []
+ interp = elf['interp']
+ if interp:
+ shown_libs.add(os.path.basename(interp))
+ if options.list:
+ print(elf['path'])
+ if not interp is None:
+ print(interp)
+ else:
+ print('%s (interpreter => %s)' % (elf['path'], interp))
+ for lib in elf['needed']:
+ _show(lib, 1)
+
+
+def _ActionCopy(options, elf):
+ """Copy the ELF and its dependencies to a destination tree"""
+ def _copy(file):
+ if file is None:
+ return
+
+ dest = options.dest + file
+ if os.path.exists(dest):
+ # See if they're the same file.
+ ostat = os.stat(file)
+ nstat = os.stat(dest)
+ for field in ('mode', 'mtime', 'size'):
+ if getattr(ostat, 'st_' + field) != \
+ getattr(nstat, 'st_' + field):
+ break
+ else:
+ return
+
+ if options.verbose:
+ print('%s -> %s' % (file, dest))
+
+ try:
+ os.makedirs(os.path.dirname(dest))
+ except OSError as e:
+ if e.errno != os.errno.EEXIST:
+ raise
+ try:
+ shutil.copy2(file, dest)
+ return
+ except IOError:
+ os.unlink(dest)
+ shutil.copy2(file, dest)
+
+ _copy(elf['path'])
+ _copy(elf['interp'])
+ for lib in elf['libs']:
+ _copy(elf['libs'][lib]['path'])
+
+
def main(argv):
parser = optparse.OptionParser("""%prog [options] <ELFs>
@@ -282,24 +360,34 @@
help=('Show all duplicated dependencies'))
parser.add_option('-R', '--root',
dest='root', default=os.environ.get('ROOT', ''), type='string',
- action='callback', callback=_NormalizeRoot,
+ action='callback', callback=_NormalizePath,
help=('Show all duplicated dependencies'))
+ parser.add_option('--copy-to-tree',
+ dest='dest', default=None, type='string',
+ action='callback', callback=_NormalizePath,
+ help=('Copy all files to the specified tree'))
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('-V', '--version',
action='callback', callback=_ShowVersion,
help=('Show version information'))
(options, files) = parser.parse_args(argv)
files.pop(0)
- options.root += '/'
+ if options.root != '/':
+ options.root += '/'
if options.debug:
print('root =', options.root)
+ if options.dest:
+ print('dest =', options.dest)
if not files:
err('missing ELF files to scan')
@@ -325,29 +413,7 @@
print('ldpaths[conf] =', ldpaths['conf'])
print('ldpaths[env] =', ldpaths['env'])
- # Now show the tree for each specified ELF.
- def _show(lib, depth):
- chain_libs.append(lib)
- fullpath = elf['libs'][lib]['path']
- if options.list:
- print(fullpath or lib)
- else:
- print('%s%s => %s' % (' ' * depth, lib, fullpath))
-
- new_libs = []
- for lib in elf['libs'][lib]['needed']:
- if lib in chain_libs:
- if not options.list:
- print('%s%s => !!! circular loop !!!' % (' ' * depth, lib))
- continue
- if options.all or not lib in shown_libs:
- shown_libs.add(lib)
- new_libs.append(lib)
-
- for lib in new_libs:
- _show(lib, depth + 1)
- chain_libs.pop()
-
+ # Process all the files specified.
ret = 0
for file in files:
try:
@@ -356,19 +422,10 @@
ret = 1
warn('%s: %s' % (file, e))
continue
- shown_libs = set(elf['needed'])
- chain_libs = []
- interp = elf['interp']
- if interp:
- shown_libs.add(os.path.basename(interp))
- if options.list:
- print(file)
- if not interp is None:
- print(interp)
+ if options.dest is None:
+ _ActionShow(options, elf)
else:
- print('%s (interpreter => %s)' % (file, interp))
- for lib in elf['needed']:
- _show(lib, 1)
+ _ActionCopy(options, elf)
return ret
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-13 2:33 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-13 2:33 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/13 02:33:01
Modified: lddtree.py
Log:
lddtree.py: fix option rename
Revision Changes Path
1.4 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.4&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.4&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.3&r2=1.4
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- lddtree.py 13 Nov 2012 01:09:06 -0000 1.3
+++ lddtree.py 13 Nov 2012 02:33:01 -0000 1.4
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.3 2012/11/13 01:09:06 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.4 2012/11/13 02:33:01 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -268,7 +268,7 @@
def _ShowVersion(_option, _opt, _value, _parser):
- id = '$Id: lddtree.py,v 1.3 2012/11/13 01:09:06 vapier Exp $'.split()
+ id = '$Id: lddtree.py,v 1.4 2012/11/13 02:33:01 vapier Exp $'.split()
print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
sys.exit(0)
@@ -329,7 +329,7 @@
def _show(lib, depth):
chain_libs.append(lib)
fullpath = elf['libs'][lib]['path']
- if options.flat_list:
+ if options.list:
print(fullpath or lib)
else:
print('%s%s => %s' % (' ' * depth, lib, fullpath))
@@ -337,7 +337,7 @@
new_libs = []
for lib in elf['libs'][lib]['needed']:
if lib in chain_libs:
- if not options.flat_list:
+ if not options.list:
print('%s%s => !!! circular loop !!!' % (' ' * depth, lib))
continue
if options.all or not lib in shown_libs:
@@ -361,7 +361,7 @@
interp = elf['interp']
if interp:
shown_libs.add(os.path.basename(interp))
- if options.flat_list:
+ if options.list:
print(file)
if not interp is None:
print(interp)
^ permalink raw reply [flat|nested] 51+ messages in thread
* [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py
@ 2012-11-12 23:08 Mike Frysinger (vapier)
0 siblings, 0 replies; 51+ messages in thread
From: Mike Frysinger (vapier) @ 2012-11-12 23:08 UTC (permalink / raw
To: gentoo-commits
vapier 12/11/12 23:08:35
Modified: lddtree.py
Log:
lddtree.py: add a --version flag
Revision Changes Path
1.2 pax-utils/lddtree.py
file : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.2&view=markup
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?rev=1.2&content-type=text/plain
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-projects/pax-utils/lddtree.py?r1=1.1&r2=1.2
Index: lddtree.py
===================================================================
RCS file: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- lddtree.py 12 Nov 2012 21:57:23 -0000 1.1
+++ lddtree.py 12 Nov 2012 23:08:35 -0000 1.2
@@ -2,7 +2,7 @@
# Copyright 2012 Gentoo Foundation
# Copyright 2012 Mike Frysinger <vapier@gentoo.org>
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.1 2012/11/12 21:57:23 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/pax-utils/lddtree.py,v 1.2 2012/11/12 23:08:35 vapier Exp $
"""Read the ELF dependency tree and show it
@@ -267,6 +267,12 @@
parser.values.root = ''
+def _ShowVersion(_option, _opt, _value, _parser):
+ id = '$Id: lddtree.py,v 1.2 2012/11/12 23:08:35 vapier Exp $'.split()
+ print('%s-%s %s %s' % (id[1].split('.')[0], id[2], id[3], id[4]))
+ sys.exit(0)
+
+
def main(argv):
parser = optparse.OptionParser("""%prog [options] <ELFs>
@@ -281,6 +287,9 @@
parser.add_option('-x', '--debug',
action='store_true', default=False,
help=('Run with debugging'))
+ parser.add_option('-V', '--version',
+ action='callback', callback=_ShowVersion,
+ help=('Show version information'))
(options, files) = parser.parse_args(argv)
files.pop(0)
^ permalink raw reply [flat|nested] 51+ messages in thread
end of thread, other threads:[~2014-11-20 1:22 UTC | newest]
Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-07-30 4:06 [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py Mike Frysinger (vapier)
-- strict thread matches above, loose matches on Subject: below --
2014-11-20 1:22 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-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-25 22:35 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)
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox