public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Anthony G. Basile" <blueness@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/elfix:master commit in: scripts/
Date: Mon, 10 Oct 2011 23:21:13 +0000 (UTC)	[thread overview]
Message-ID: <b92738dd6e63b951a482027e784460951e4b9967.blueness@gentoo> (raw)

commit:     b92738dd6e63b951a482027e784460951e4b9967
Author:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 10 23:21:09 2011 +0000
Commit:     Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Mon Oct 10 23:21:09 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/elfix.git;a=commit;h=b92738dd

scripts/revdep-pax: add verbosity to output

---
 scripts/revdep-pax |  189 +++++++++++++++++++++++++++++++---------------------
 1 files changed, 114 insertions(+), 75 deletions(-)

diff --git a/scripts/revdep-pax b/scripts/revdep-pax
index bdf6004..4e35f1e 100755
--- a/scripts/revdep-pax
+++ b/scripts/revdep-pax
@@ -7,12 +7,12 @@ import subprocess
 import re
 import pax
 
-def get_ldd_linkings(elf):
+def get_ldd_linkings(binary):
 	try:
 		#When subprocess.DEVNULL makes it to python, change this: http://bugs.python.org/issue5870
-		ldd_output = subprocess.check_output(['/usr/bin/ldd', elf], stderr=subprocess.PIPE)
+		ldd_output = subprocess.check_output(['/usr/bin/ldd', binary], stderr=subprocess.PIPE)
 	except:
-		# We should record these elfs which are probably static
+		# We should record these binaries which are probably statically linked
 		return []
 	ldd_lines = ldd_output.split('\n')
 	linkings = []
@@ -24,12 +24,12 @@ def get_ldd_linkings(elf):
 		mapp = re.split('=>', ldd_lines[m] )
 		soname = mapp[0].strip()
 		soname = os.path.basename(soname)	# This is for ./libSDL-1.2.so.0
-		filename = re.sub('\(.*$', '', mapp[1]).strip()
-		if filename == '':
+		library = re.sub('\(.*$', '', mapp[1]).strip()
+		if library == '':
 			continue
-		filename = os.path.realpath(filename)
+		library = os.path.realpath(library)
 		linkings.append(soname)
-		mappings[soname] = filename
+		mappings[soname] = library 
 	return ( linkings, mappings )
 
 
@@ -49,9 +49,9 @@ def get_forward_linkings():
 				for line in needs:
 					line = line.strip()
 					link = re.split('\s', line)
-					elf = link[0]
-					( linkings, mappings ) = get_ldd_linkings(elf)
-					forward_linkings[elf] = linkings 
+					binary = link[0]
+					( linkings, mappings ) = get_ldd_linkings(binary)
+					forward_linkings[binary] = linkings 
 					so2filename_mappings.update(mappings)
 			except:
 				continue
@@ -61,38 +61,52 @@ def get_forward_linkings():
 
 def invert_linkings( forward_linkings ):
 	reverse_linkings = {}
-	for elf in forward_linkings:
-		for elf_dep in forward_linkings[elf]:
-			reverse_linkings[elf_dep] = []
+	for binary in forward_linkings:
+		for library in forward_linkings[binary]:
+			reverse_linkings[library] = []
 
-	for elf in forward_linkings:
-		for elf_dep in forward_linkings[elf]:
-			reverse_linkings[elf_dep].append(elf)
+	for binary in forward_linkings:
+		for library in forward_linkings[binary]:
+			reverse_linkings[library].append(binary)
 
 	return reverse_linkings 
 
 
-def print_forward_linkings( forward_linkings, so2filename_mappings ):
-	missing_elfs = []
+def print_forward_linkings( forward_linkings, so2filename_mappings, verbose ):
+	missing_binaries = []
 	missing_links = []
-	for elf in forward_linkings:
+	for binary in forward_linkings:
+
 		try:
-			print elf, '(',  pax.getflags(elf), ')'
+			binary_flags = pax.getflags(binary)
+			s = "%s ( %s )" % ( binary, binary_flags )
 		except:
-			missing_elfs.append(elf)
+			missing_binaries.append(binary)
 			continue
-		for elf_dep in forward_linkings[elf]:
+
+		count = 0
+		for soname in forward_linkings[binary]:
 			try:
-				filename = so2filename_mappings[elf_dep]
-				flags = pax.getflags(filename)
-				print '\t', elf_dep, '\t', filename, '(', flags, ')'
+				library = so2filename_mappings[soname]
+				library_flags = pax.getflags(library)
+				s = "%s\n\t%s\t%s ( %s )" % ( s, soname, library, library_flags )
+				if binary_flags != library_flags:
+					count = count + 1
 			except:
-				missing_links.append(elf_dep)
+				missing_links.append(soname)
+
+		if verbose:
+			print s
+			if count == 0:
+				print 'No mismatches'
+		else:
+			if count != 0:
+				print s
 
-	missing_elfs = set(missing_elfs)
+	missing_binaries = set(missing_binaries)
 	print '\n\n'
-	print '**** Missing elfs ****'
-	for m in missing_elfs:
+	print '**** Missing binaries ****'
+	for m in missing_binaries:
 		print m
 
 	missing_links = set(missing_links)
@@ -104,27 +118,42 @@ def print_forward_linkings( forward_linkings, so2filename_mappings ):
 	print '\n\n'
 
 
-def print_reverse_linkings( reverse_linkings, so2filename_mappings ):
-	missing_elfs = []
+def print_reverse_linkings( reverse_linkings, so2filename_mappings, verbose ):
+	missing_sonames = []
 	missing_links = []
-	for elf in reverse_linkings:
+
+	for soname in reverse_linkings:
+
 		try:
-			filename = so2filename_mappings[elf]
-			flags = pax.getflags(filename)
-			print elf, '\t', filename, '(', flags, ')'
+			library = so2filename_mappings[soname]
+			library_flags = pax.getflags(library)
+			s = "%s\t%s ( %s )" % ( soname, library, library_flags )
 		except:
-			missing_elfs.append(elf)
-		for elf_dep in reverse_linkings[elf]:
+			missing_libraries.append(soname)
+			continue
+
+		count = 0
+		for binary in reverse_linkings[soname]:
 			try:
-				flags = pax.getflags(elf_dep)
-				print '\t', elf_dep, '(', flags, ')'
+				binary_flags = pax.getflags(binary)
+				s = "%s\n\t%s ( %s )" % ( s, binary, binary_flags )
+				if library_flags != binary_flags:
+					count = count + 1
 			except:
-				missing_links.append(elf_dep)
+				missing_links.append(binary)
 
-	missing_elfs = set(missing_elfs)
+		if verbose:
+			print s
+			if count == 0:
+				print 'No mismatches'
+		else:
+			if count != 0:
+				print s
+
+	missing_sonames = set(missing_sonames)
 	print '\n\n'
-	print '**** Missing elfs ****'
-	for m in missing_elfs:
+	print '**** Missing sonames ****'
+	for m in missing_sonames:
 		print m
 
 	missing_links = set(missing_links)
@@ -136,29 +165,32 @@ def print_reverse_linkings( reverse_linkings, so2filename_mappings ):
 	print '\n\n'
 
 
-def usage():
-	print 'Package Name : elfix\n'
+def run_usage():
+	print 'Package Name : elfix'
 	print 'Bug Reports  : http://bugs.gentoo.org/'
-	print 'Program Name : revdep-pax\n'
-	print 'Description  : Get or set pax flags on an ELF object\n\n'
-	print 'Usage        : revdep-pax [-fv] | [-rv] | -v [-b BINARY] | -v [-s SONAME] | -h\n\n'
-	print 'Options      : -f         print out all the forward mappings for all system binaries\n'
-	print '             : -r         print out all the reverse mappints for all system sonames\n'
-	print '             : -b BINARY  print all the forward mappings only for BINARY\n'
-	print '             : -s SONAME  print all the reverse mappings only for SONAME\n'
-	print '             : -v         verbose, otherwise just print mismatched pax flags \n'
-	print '             : -h         print out this help\n\n'
-
-
-def run_forward():
+	print 'Program Name : revdep-pax'
+	print 'Description  : Get or set pax flags on an ELF object'
+	print
+	print 'Usage        : revdep-pax [-fv] | [-rv] | -v [-b BINARY] | -v [-s SONAME] | -h'
+	print
+	print 'Options      : -f         print out all the forward mappings for all system binaries'
+	print '             : -r         print out all the reverse mappints for all system sonames'
+	print '             : -b BINARY  print all the forward mappings only for BINARY'
+	print '             : -s SONAME  print all the reverse mappings only for SONAME'
+	print '             : -v         verbose, otherwise just print mismatched pax flags'
+	print '             : -h         print out this help'
+	print
+
+
+def run_forward(verbose):
 	( forward_linkings, so2filename_mappings ) = get_forward_linkings()
-	print_forward_linkings( forward_linkings, so2filename_mappings )
+	print_forward_linkings( forward_linkings, so2filename_mappings, verbose)
 
 
-def run_reverse():
+def run_reverse(verbose):
 	( forward_linkings, so2filename_mappings ) = get_forward_linkings()
 	reverse_linkings = invert_linkings( forward_linkings )
-	print_reverse_linkings( reverse_linkings, so2filename_mappings )
+	print_reverse_linkings( reverse_linkings, so2filename_mappings, verbose )
 
 
 def run_binary(binary, verbose):
@@ -170,19 +202,20 @@ def run_binary(binary, verbose):
 	count = 0
 	for soname in linkings:
 		try:
-			filename = mappings[soname]
-			soname_flags = pax.getflags(filename)
+			library = mappings[soname]
+			library_flags = pax.getflags(library)
 			if verbose:
-				print '\t', soname, '\t', filename, '(', soname_flags, ')'
+				print '\t', soname, '\t', library, '(', library_flags, ')'
 			else:
-				if binary_flags != soname_flags:
-					print '\t', soname, '\t',filename, '(', soname_flags, ')'
+				if binary_flags != library_flags:
+					print '\t', soname, '\t', library, '(', library_flags, ')'
 					count = count + 1
 		except:
 			print "file for soname %s not found" % soname
 
 	if count == 0:
-		print '\nNo mismatches'
+		print
+		print 'No mismatches'
 
 
 def run_soname(soname, verbose):
@@ -191,17 +224,24 @@ def run_soname(soname, verbose):
 	linkings = reverse_linkings[soname]
 	library = so2filename_mappings[soname]
 
-	flags = pax.getflags(library)
-	if verbose:
-		print soname, '\t', library, '(', flags, ')'
+	library_flags = pax.getflags(library)
+	print soname, '\t', library, '(', library_flags, ')'
+
+	count = 0
 	for binary in linkings:
 		try:
-			flags = pax.getflags(binary)
+			binary_flags = pax.getflags(binary)
 			if verbose:
-				print '\t', binary, '(', flags, ')'
+				print '\t', binary, '(', binary_flags, ')'
+			else:
+				if library_flags != binary_flags:
+					print '\t', binary, '(', binary_flags, ')'
+					count = count + 1
 		except:
 			print "cannot obtain pax flags for %s" % binary
 
+	if count == 0:
+		print '\nNo mismatches'
 
 def main():
 	try:
@@ -242,21 +282,20 @@ def main():
 			print 'Please file a bug'
 			sys.exit(1)
 
-
 	if do_usage:
 		run_usage()
 
 	if do_forward:
-		run_forward()
+		run_forward(verbose)
 
 	if do_reverse:
-		run_reverse()
+		run_reverse(verbose)
 
 	if binary != None:
 		run_binary(binary, verbose)
 
 	if soname !=None:
-		run_soname(soname)
+		run_soname(soname, verbose)
 
 if __name__ == '__main__':
     main()



             reply	other threads:[~2011-10-10 23:21 UTC|newest]

Thread overview: 89+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10 23:21 Anthony G. Basile [this message]
  -- strict thread matches above, loose matches on Subject: below --
2019-11-18 18:21 [gentoo-commits] proj/elfix:master commit in: scripts/ Anthony G. Basile
2019-04-22 22:14 Anthony G. Basile
2015-10-27 19:37 Anthony G. Basile
2015-01-04 15:42 Anthony G. Basile
2014-12-22 17:29 Anthony G. Basile
2014-10-17 20:02 Anthony G. Basile
2014-01-23 16:22 Anthony G. Basile
2014-01-20 22:44 Anthony G. Basile
2013-05-20 19:47 Anthony G. Basile
2013-03-14  2:39 Anthony G. Basile
2013-01-06 17:19 Anthony G. Basile
2012-12-28 19:34 Anthony G. Basile
2012-12-23  3:49 Anthony G. Basile
2012-12-23  2:36 Anthony G. Basile
2012-12-23  1:04 Anthony G. Basile
2012-12-22 22:20 Anthony G. Basile
2012-12-22 20:17 Anthony G. Basile
2012-12-22 19:42 Anthony G. Basile
2012-12-22 19:29 Anthony G. Basile
2012-12-22 19:02 Anthony G. Basile
2012-12-22 18:31 Anthony G. Basile
2012-12-22 16:36 Anthony G. Basile
2012-12-22  1:04 Anthony G. Basile
2012-12-20  4:26 Anthony G. Basile
2012-12-19  4:09 Anthony G. Basile
2012-12-19  3:51 Anthony G. Basile
2012-12-15 20:03 Anthony G. Basile
2012-12-14  2:19 Anthony G. Basile
2012-12-14  2:16 Anthony G. Basile
2012-12-14  2:04 Anthony G. Basile
2012-12-14  1:59 Anthony G. Basile
2012-12-14  1:26 Anthony G. Basile
2012-12-14  1:20 Anthony G. Basile
2012-07-27 22:01 Anthony G. Basile
2012-07-23 19:18 Anthony G. Basile
2012-07-23 15:46 Anthony G. Basile
2012-07-23 15:27 Anthony G. Basile
2012-07-23 14:58 Anthony G. Basile
2012-07-23 14:15 Anthony G. Basile
2012-07-23 13:06 Anthony G. Basile
2012-07-23 11:47 Anthony G. Basile
2012-07-22 23:11 Anthony G. Basile
2012-07-22 22:22 Anthony G. Basile
2012-07-21 16:28 Anthony G. Basile
2012-07-21 15:44 Anthony G. Basile
2012-07-21 15:41 Anthony G. Basile
2012-07-21 13:53 Anthony G. Basile
2011-12-28 23:19 Anthony G. Basile
2011-12-28 23:18 Anthony G. Basile
2011-12-28 16:37 Anthony G. Basile
2011-12-28 15:39 Anthony G. Basile
2011-12-28 15:31 Anthony G. Basile
2011-12-26 22:24 Anthony G. Basile
2011-12-26 20:25 Anthony G. Basile
2011-12-04 21:43 Anthony G. Basile
2011-11-27  0:17 Anthony G. Basile
2011-11-26 22:08 Anthony G. Basile
2011-11-26 21:15 Anthony G. Basile
2011-11-26 19:08 Anthony G. Basile
2011-11-26 19:07 Anthony G. Basile
2011-10-17 20:55 Anthony G. Basile
2011-10-17 20:15 Anthony G. Basile
2011-10-17 19:28 Anthony G. Basile
2011-10-16 18:27 Anthony G. Basile
2011-10-16 18:27 Anthony G. Basile
2011-10-16 18:04 Anthony G. Basile
2011-10-13  4:36 Anthony G. Basile
2011-10-13  2:27 Anthony G. Basile
2011-10-13  0:36 Anthony G. Basile
2011-10-11  0:50 Anthony G. Basile
2011-10-10 23:42 Anthony G. Basile
2011-10-10 17:30 Anthony G. Basile
2011-10-10 17:29 Anthony G. Basile
2011-10-08 18:35 Anthony G. Basile
2011-10-08  2:03 Anthony G. Basile
2011-10-08  0:46 Anthony G. Basile
2011-10-07 22:14 Anthony G. Basile
2011-10-07 19:58 Anthony G. Basile
2011-10-07  1:56 Anthony G. Basile
2011-10-06 23:39 Anthony G. Basile
2011-10-06 20:14 Anthony G. Basile
2011-10-06 19:46 Anthony G. Basile
2011-10-06  4:19 Anthony G. Basile
2011-10-06  4:07 Anthony G. Basile
2011-10-06  3:14 Anthony G. Basile
2011-10-06  3:13 Anthony G. Basile
2011-10-06  2:20 Anthony G. Basile
2011-09-08 23:50 Anthony G. Basile

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b92738dd6e63b951a482027e784460951e4b9967.blueness@gentoo \
    --to=blueness@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox