From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 0F3CF138010 for ; Tue, 26 Mar 2013 05:22:33 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5F462E0511; Tue, 26 Mar 2013 05:22:31 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id CE4EFE0511 for ; Tue, 26 Mar 2013 05:22:30 +0000 (UTC) Received: from flycatcher.gentoo.org (flycatcher.gentoo.org [81.93.255.6]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6E10933C878 for ; Tue, 26 Mar 2013 05:22:29 +0000 (UTC) Received: by flycatcher.gentoo.org (Postfix, from userid 559) id 3403D2171D; Tue, 26 Mar 2013 05:22:28 +0000 (UTC) From: "Mike Frysinger (vapier)" To: gentoo-commits@lists.gentoo.org Reply-To: gentoo-dev@lists.gentoo.org, vapier@gentoo.org Subject: [gentoo-commits] gentoo-projects commit in pax-utils: lddtree.py X-VCS-Repository: gentoo-projects X-VCS-Files: lddtree.py X-VCS-Directories: pax-utils X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Message-Id: <20130326052228.3403D2171D@flycatcher.gentoo.org> Date: Tue, 26 Mar 2013 05:22:28 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: b94e7f98-5801-46b7-888b-b5b952cc9eb7 X-Archives-Hash: 19e193b397fcf22d008a74e1bdd703e4 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 # 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'))