public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-03-11 21:43 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2014-03-11 21:43 UTC (permalink / raw
  To: gentoo-commits

commit:     c6286bab8c4e96a7e54e05ab26244ca648ae9787
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 11 21:42:52 2014 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Mar 11 21:42:52 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=c6286bab

Remove unused revdep-rebuild.py

---
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py | 17 -----------------
 1 file changed, 17 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
deleted file mode 100755
index 2619ee0..0000000
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ /dev/null
@@ -1,17 +0,0 @@
-#!/usr/bin/python
-# -*- coding: utf-8 -*-
-
-
-# Author: Sławomir Lis <lis.slawek@gmail.com>
-# revdep-rebuild original author: Stanislav Brabec
-# revdep-rebuild original rewrite Author: Michael A. Smith
-# Current Maintainer: Paul Varner <fuzzyray@gentoo.org>
-
-# Creation date: 2010/10/17
-# License: BSD
-
-from rebuild import APP_NAME, VERSION, main
-
-if __name__ == '__main__':
-    # instead of revdep-rebuild.py call rebuild.py
-    main()


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2015-05-27 17:27 Mike Gilbert
  0 siblings, 0 replies; 115+ messages in thread
From: Mike Gilbert @ 2015-05-27 17:27 UTC (permalink / raw
  To: gentoo-commits

commit:     ea14aa4c915abbaf293d77ed70a947648143f401
Author:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
AuthorDate: Wed May 27 17:20:35 2015 +0000
Commit:     Mike Gilbert <floppym <AT> gentoo <DOT> org>
CommitDate: Wed May 27 17:20:35 2015 +0000
URL:        https://gitweb.gentoo.org/proj/gentoolkit.git/commit/?id=ea14aa4c

revdep-rebuild: Remove broken NO_PRETEND setting

This hasn't worked since the argparse conversion.

 pym/gentoolkit/revdep_rebuild/rebuild.py  | 8 --------
 pym/gentoolkit/revdep_rebuild/settings.py | 5 -----
 2 files changed, 13 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index d35906e..23fa694 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -134,14 +134,6 @@ def main(settings=None, logger=None):
 		logger.warn(blue(' * ') +
 			yellow('You are not root, adding --pretend to portage options'))
 		settings['PRETEND'] = True
-	elif not settings['PRETEND'] \
-			and settings['IS_DEV'] \
-			and not settings['NO_PRETEND']:
-		logger.warn(blue(' * ') +
-			yellow('Adding --pretend to portage options'))
-		logger.info(blue(' * ') +
-			'If you\'re sure, you can add --no-pretend to revdep options')
-		settings['PRETEND'] = True
 
 	logger.debug("\tmain(), _libs_to_check = %s" % str(_libs_to_check))
 

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 3a653a5..08220f8 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -27,11 +27,6 @@ DEFAULTS = {
 		#if program should use temporary files from previous run
 		'USE_TMP_FILES': True,
 
-		#True for dev. version, False for stable
-		#used when IS_DEV is True, False forces to call emerge with --pretend
-		# can be set True from the cli with the --no-pretend option
-		'IS_DEV': True,
-		'NO_PRETEND': False,
 		'VERBOSITY': 1,
 
 		'quiet': False,


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-11-12 21:29 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2014-11-12 21:29 UTC (permalink / raw
  To: gentoo-commits

commit:     758d932ca31ceb323bb988108e3f64e05cd5731d
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 12 21:28:58 2014 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Wed Nov 12 21:28:58 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=758d932c

revdep-rebuild.py: Fix recent changes to work with Python 3

---
 pym/gentoolkit/revdep_rebuild/settings.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index fa91685..3a653a5 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -53,7 +53,7 @@ def parse_options():
 
 	# TODO: Verify: options: no-ld-path, no-order, no-progress
 	#are not appliable
-	from rebuild import VERSION, APP_NAME
+	from .rebuild import VERSION, APP_NAME
 	settings = DEFAULTS.copy()
 	
 	parser = argparse.ArgumentParser(


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-11-12  7:16 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-11-12  7:16 UTC (permalink / raw
  To: gentoo-commits

commit:     3a9aced06871aa68dcc27e5eba1e56608ecc587d
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 12 06:50:01 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Wed Nov 12 06:50:01 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=3a9aced0

--library option - partial filename checking

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 33 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 18 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 556812d..c0e7231 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -148,24 +148,21 @@ class LibCheck(object):
 		'''Internal function.  Use the class's setlibs variable'''
 		sonames = []
 		for s in self.searchlibs:
-			par, soname = os.path.split(s)
-			if par:
-				# consider as this is full pathname
-				# we need soname only
-
-				if os.path.exists(s):
-					# try to extract some more info
-					for line in scan(['-BF', '%f %S %M'], [s], 1, self.logger):
-						_, soname, bits = line.split()
-						bits = bits[8:]
-						if bits == b:
-							# we don't want to look in inappropriate arch's libs
-							sonames.append(soname)
-					continue
-				sonames.append(soname)
-			else:
-				# this is only filename or it's part
-				sonames.append(soname)
+			if s in self.scanned_files[b].keys():
+				sonames.append(s)
+				continue
+
+			found_partial = [a for a in self.scanned_files[b].keys() if s in a]
+			if found_partial:
+				sonames += found_partial
+				continue
+
+			for k, v in self.scanned_files[b].items():
+				for vv in v.keys():
+					if s in vv:
+						sonames.append(k)
+						break
+
 		self.alllibs = '|'.join(sonames) + '|'
 		self.logger.debug("\tLibCheck._setslibs(), new alllibs: %s" %(self.alllibs))
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-11-07 20:41 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-11-07 20:41 UTC (permalink / raw
  To: gentoo-commits

commit:     bb2f5a95536dedf3fe300f7bcf5a385d255c3331
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  7 20:08:48 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Fri Nov  7 20:08:48 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=bb2f5a95

help text update

---
 pym/gentoolkit/revdep_rebuild/settings.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index e42a242..fa91685 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -79,8 +79,8 @@ def parse_options():
 	parser.add_argument('-L', '--library', 
 					 action='append', 
 					 help='Unconditionally emerge existing packages that use '
-						'the library with NAME. NAME can be a full or partial '
-						'name')
+						'the library with NAME. NAME can be a full path, full '
+						'or partial name')
 	parser.add_argument('-l', '--no-ld-path', 
 					 action='store_true', 
 					 help='Do not set LD_LIBRARY_PATH')
@@ -89,7 +89,7 @@ def parse_options():
 					 help='Do not check the build order '
 						'(Saves time, but may cause breakage.)')
 	parser.add_argument('-p', '--pretend', 
-					 action='store_true', 
+					 action='store_true',
 					 help='Do a trial run without actually emerging anything '
                         '(also passed to emerge command)')
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-11-07 20:41 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-11-07 20:41 UTC (permalink / raw
  To: gentoo-commits

commit:     615222489e54a707fd87342e6c8801c7e5eb1b68
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Wed Nov  5 12:46:24 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Wed Nov  5 12:46:24 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=61522248

using debug logging

---
 pym/gentoolkit/revdep_rebuild/settings.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 744b730..00c7e28 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -109,9 +109,9 @@ def parse_options():
 	parser.add_argument('portage_options', nargs='*')
 	
 	args = parser.parse_args()
-	
 	settings['VERBOSITY'] = 3 if args.debug else 2 if args.verbose else 0 if args.quiet else 1
 	settings['quiet'] = args.quiet
+	settings['debug'] = args.debug
 	settings['PRETEND'] = args.pretend
 	settings['nocolor'] = args.nocolor
 	if args.library:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-11-07 20:41 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-11-07 20:41 UTC (permalink / raw
  To: gentoo-commits

commit:     1d42d9f56121932daff89a0676956fe16884c60f
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  7 20:39:54 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Fri Nov  7 20:39:54 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=1d42d9f5

revdep --library fixes

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 29 ++++++++++++++++++++++++-----
 1 file changed, 24 insertions(+), 5 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index c553526..556812d 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -146,8 +146,27 @@ class LibCheck(object):
 
 	def _setslibs(self, l, b):
 		'''Internal function.  Use the class's setlibs variable'''
-		self.alllibs = '|'.join(
-			[x for x in self.searchlibs if ('lib%s' % (b) in x)]) + '|'
+		sonames = []
+		for s in self.searchlibs:
+			par, soname = os.path.split(s)
+			if par:
+				# consider as this is full pathname
+				# we need soname only
+
+				if os.path.exists(s):
+					# try to extract some more info
+					for line in scan(['-BF', '%f %S %M'], [s], 1, self.logger):
+						_, soname, bits = line.split()
+						bits = bits[8:]
+						if bits == b:
+							# we don't want to look in inappropriate arch's libs
+							sonames.append(soname)
+					continue
+				sonames.append(soname)
+			else:
+				# this is only filename or it's part
+				sonames.append(soname)
+		self.alllibs = '|'.join(sonames) + '|'
 		self.logger.debug("\tLibCheck._setslibs(), new alllibs: %s" %(self.alllibs))
 
 
@@ -248,15 +267,15 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	"""
 
 	searchbits = set()
-	if _libs_to_check:
+	'''if _libs_to_check:
 		for lib in _libs_to_check:
 			if "lib64" in lib:
 				searchbits.add('64')
 			elif "lib32" in lib:
 				searchbits.add('32')
 	else:
-		_libs_to_check = set()
-		searchbits.update(['64', '32'])
+		_libs_to_check = set()'''
+	searchbits.update(['64', '32'])
 
 	if libraries and la_libraries and libraries_links and binaries:
 		logger.info(blue(' * ') +


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-11-07 20:41 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-11-07 20:41 UTC (permalink / raw
  To: gentoo-commits

commit:     09c1115e0a3c4d12549993fb8a8a13a5723f5094
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  7 12:11:33 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Fri Nov  7 12:11:33 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=09c1115e

loggin update

---
 pym/gentoolkit/revdep_rebuild/settings.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 00c7e28..e42a242 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -111,7 +111,6 @@ def parse_options():
 	args = parser.parse_args()
 	settings['VERBOSITY'] = 3 if args.debug else 2 if args.verbose else 0 if args.quiet else 1
 	settings['quiet'] = args.quiet
-	settings['debug'] = args.debug
 	settings['PRETEND'] = args.pretend
 	settings['nocolor'] = args.nocolor
 	if args.library:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-11-07 20:41 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-11-07 20:41 UTC (permalink / raw
  To: gentoo-commits

commit:     17d016032df3a9af9cbdd8c6a1eec800fb4bd2f1
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Wed Nov  5 11:27:54 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Wed Nov  5 11:27:54 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=17d01603

updated default cache location for non-root

---
 pym/gentoolkit/revdep_rebuild/settings.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index cadd5f2..744b730 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -17,7 +17,7 @@ DEFAULTS = {
 		'DEFAULT_ENV_FILE': os.path.join(portage.root, 'etc/profile.env'),
 		'REVDEP_CONFDIR': os.path.join(portage.root, 'etc/revdep-rebuild/'),
 		'PKG_DIR': os.path.join(portage.root, 'var/db/pkg/'),
-		'DEFAULT_TMP_DIR': os.path.join(portage.root, '/var/cache/revdep-rebuild'), #cache default location
+		'DEFAULT_TMP_DIR': os.path.join(portage.root, '/tmp/revdep-rebuild' if os.getgid() else '/var/cache/revdep-rebuild'), #cache default location
 
 		# number of maximum allowed files to be parsed at once
 		'CMD_MAX_ARGS': 1000,


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-11-07 20:41 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-11-07 20:41 UTC (permalink / raw
  To: gentoo-commits

commit:     c20844cad28caf6554e90d65f8da3d072a2adb9f
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  7 20:38:35 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Fri Nov  7 20:38:35 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=c20844ca

logging level

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index fcbd76e..d35906e 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -53,7 +53,7 @@ def init_logger(settings):
 		logger.setLevel(logging.ERROR)
 	elif settings['VERBOSITY'] == 2:
 		logger.setLevel(logging.INFO)
-	elif settings['VERBOSITY'] == 3:
+	elif settings['VERBOSITY'] == 3 or settings['debug']:
 		logger.setLevel(logging.DEBUG)
 	else:
 		logger.setLevel(logging.WARNING)
@@ -107,7 +107,6 @@ def main(settings=None, logger=None):
 	@param logger: python logging module defaults to init_logger(settings)
 	@return boolean  success/failure
 	"""
-
 	if settings is None:
 		print("NO Input settings, using defaults...")
 		settings = DEFAULTS.copy()


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-10-30 18:56 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2014-10-30 18:56 UTC (permalink / raw
  To: gentoo-commits

commit:     ed4f69668755d222ae782d09e810c5bb1a94e67a
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Thu Oct 30 18:55:25 2014 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Thu Oct 30 18:55:25 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=ed4f6966

revdep-rebuild: Fix python version to honor --debug

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 216714c..fcbd76e 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -53,7 +53,7 @@ def init_logger(settings):
 		logger.setLevel(logging.ERROR)
 	elif settings['VERBOSITY'] == 2:
 		logger.setLevel(logging.INFO)
-	elif settings['debug']:
+	elif settings['VERBOSITY'] == 3:
 		logger.setLevel(logging.DEBUG)
 	else:
 		logger.setLevel(logging.WARNING)


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-08-28  7:37 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-08-28  7:37 UTC (permalink / raw
  To: gentoo-commits

commit:     d1452c3b44dddadbb4d46b9e813b25f8c742d54f
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Thu Aug 28 07:20:06 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Thu Aug 28 07:20:06 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=d1452c3b

output all messages into stdout instead of stderr

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 9d5bf9b..216714c 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -45,7 +45,7 @@ __productname__ = "revdep-ng"
 def init_logger(settings):
 	"""Creates and iitializes our logger according to the settings"""
 	logger = logging.getLogger()
-	log_handler = logging.StreamHandler()
+	log_handler = logging.StreamHandler(sys.stdout)
 	log_fmt = logging.Formatter('%(msg)s')
 	log_handler.setFormatter(log_fmt)
 	logger.addHandler(log_handler)


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-03-27  6:59 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-03-27  6:59 UTC (permalink / raw
  To: gentoo-commits

commit:     1f200fb1812faf22c048c83b17a7c27257b301c4
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 27 06:56:51 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Thu Mar 27 06:56:51 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=1f200fb1

Fixed bug when no libraries are passed

---
 pym/gentoolkit/revdep_rebuild/settings.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 4774cec..cadd5f2 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -114,7 +114,8 @@ def parse_options():
 	settings['quiet'] = args.quiet
 	settings['PRETEND'] = args.pretend
 	settings['nocolor'] = args.nocolor
-	settings['library'].update(set(args.library))
+	if args.library:
+		settings['library'].update(set(args.library))
 	settings['USE_TMP_FILES'] = not args.ignore
 	settings['pass_through_options'] = " " + " ".join(args.portage_options)
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-03-26  8:21 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-03-26  8:21 UTC (permalink / raw
  To: gentoo-commits

commit:     510e60106fdd7e12bfef37aa6d494f060bf30857
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 26 08:18:45 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Wed Mar 26 08:18:45 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=510e6010

Switch from getopt to argparse

---
 pym/gentoolkit/revdep_rebuild/settings.py | 137 ++++++++++++++----------------
 1 file changed, 64 insertions(+), 73 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 7909aa6..4774cec 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -4,7 +4,7 @@
 
 from __future__ import print_function
 
-import getopt
+import argparse
 import os
 import sys
 import re
@@ -48,84 +48,75 @@ DEFAULTS = {
 		}
 
 
-def print_usage():
-	"""Outputs the help message"""
-	print( APP_NAME + ': (' + VERSION +')')
-	print()
-	print('This is free software; see the source for copying conditions.')
-	print()
-	print('Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]')
-	print()
-	print('Broken reverse dependency rebuilder, python implementation.')
-	print()
-	print('Available options:')
-	print('''
-  -C, --nocolor         Turn off colored output
-  -d, --debug           Print debug informations
-  -e, --exact           Emerge based on exact package version
-  -h, --help            Print this usage
-  -i, --ignore          Ignore temporary files from previous runs
-                        (also won't create any)
-  -L, --library NAME    Unconditionally emerge existing packages that use
-      --library=NAME    the library with NAME. NAME can be a full or partial
-                        library name
-  -l, --no-ld-path      Do not set LD_LIBRARY_PATH
-  -o, --no-order        Do not check the build order
-                        (Saves time, but may cause breakage.)
-  -p, --pretend         Do a trial run without actually emerging anything
-                        (also passed to emerge command)
-  -q, --quiet           Be less verbose (also passed to emerge command)
-  -v, --verbose         Be more verbose (also passed to emerge command)
-''')
-	print( 'Calls emerge, options after -- are ignored by ' + APP_NAME)
-	print('and passed directly to emerge.')
-
-
 def parse_options():
 	"""Parses the command line options an sets settings accordingly"""
 
 	# TODO: Verify: options: no-ld-path, no-order, no-progress
 	#are not appliable
-
+	from rebuild import VERSION, APP_NAME
 	settings = DEFAULTS.copy()
-	try:
-		opts, args = getopt.getopt(sys.argv[1:],
-			'dehiklopqvCL:P',
-			['nocolor', 'debug', 'exact', 'help', 'ignore',
-			'keep-temp', 'library=', 'no-ld-path', 'no-order',
-			'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose'])
-
-		for key, val in opts:
-			if key in ('-h', '--help'):
-				print_usage()
-				sys.exit(0)
-			elif key in ('-q', '--quiet'):
-				settings['quiet'] = True
-				settings['VERBOSITY'] = 0
-			elif key in ('-v', '--verbose'):
-				settings['VERBOSITY'] = 2
-			elif key in ('-d', '--debug'):
-				settings['debug'] = True
-				settings['VERBOSITY'] = 3
-			elif key in ('-p', '--pretend'):
-				settings['PRETEND'] = True
-			elif key == '--no-pretend':
-				settings['NO_PRETEND'] = True
-			elif key in ('-e', '--exact'):
-				settings['EXACT'] = True
-			elif key in ('-C', '--nocolor', '--no-color'):
-				settings['nocolor'] = True
-			elif key in ('-L', '--library', '--library='):
-				settings['library'].update(val.split(','))
-			elif key in ('-i', '--ignore'):
-				settings['USE_TMP_FILES'] = False
-
-		settings['pass_through_options'] = " " + " ".join(args)
-	except getopt.GetoptError:
-		#logging.info(red('Unrecognized option\n'))
-		print(red('Unrecognized option\n'))
-		print_usage()
-		sys.exit(2)
+	
+	parser = argparse.ArgumentParser(
+		description='Broken reverse dependency rebuilder, python implementation.',
+		epilog='Calls emerge, options after -- are ignored by %s '
+				'and passed directly to emerge.' % APP_NAME,
+		add_help=False
+		)
+	
+	parser.add_argument('-h', '--help', 
+					 action='help', 
+					 help='Print this usage and exit')
+	parser.add_argument('-V', '--version', 
+					 action='version', 
+					 help='Show version informations',
+					 version='%(prog)s ' + VERSION)
+	
+	parser.add_argument('-i', '--ignore', 
+					 action='store_true', 
+					 help='Ignore temporary files from previous runs ' 
+						'(also won\'t create any)')
+
+	parser.add_argument('-L', '--library', 
+					 action='append', 
+					 help='Unconditionally emerge existing packages that use '
+						'the library with NAME. NAME can be a full or partial '
+						'name')
+	parser.add_argument('-l', '--no-ld-path', 
+					 action='store_true', 
+					 help='Do not set LD_LIBRARY_PATH')
+	parser.add_argument('-o', '--no-order', 
+					 action='store_true', 
+					 help='Do not check the build order '
+						'(Saves time, but may cause breakage.)')
+	parser.add_argument('-p', '--pretend', 
+					 action='store_true', 
+					 help='Do a trial run without actually emerging anything '
+                        '(also passed to emerge command)')
+
+	parser.add_argument('-C', '--nocolor', 
+					 action='store_true', 
+					 help='Turn off colored output')
+	parser.add_argument('-q', '--quiet', 
+					 action='store_true', 
+					 help='Be less verbose (also passed to emerge command)')
+	parser.add_argument('-v', '--verbose', 
+					 action='store_true', 
+					 help='Be more verbose (also passed to emerge command)')
+	parser.add_argument('-d', '--debug', 
+					 action='store_true', 
+					 help='Print debug informations')
+	
+	parser.add_argument('portage_options', nargs='*')
+	
+	args = parser.parse_args()
+	
+	settings['VERBOSITY'] = 3 if args.debug else 2 if args.verbose else 0 if args.quiet else 1
+	settings['quiet'] = args.quiet
+	settings['PRETEND'] = args.pretend
+	settings['nocolor'] = args.nocolor
+	settings['library'].update(set(args.library))
+	settings['USE_TMP_FILES'] = not args.ignore
+	settings['pass_through_options'] = " " + " ".join(args.portage_options)
 
 	return settings
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-03-24  7:17 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-03-24  7:17 UTC (permalink / raw
  To: gentoo-commits

commit:     4f2ad629e4802598878f5bc674462de23fcea51b
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 24 07:14:57 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Mon Mar 24 07:14:57 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4f2ad629

parsing revdep config refactor, added environment config read (as sugggested here: https://bugs.gentoo.org/show_bug.cgi?id=504654#c28)

---
 pym/gentoolkit/revdep_rebuild/settings.py | 33 ++++++++++++++++++++-----------
 1 file changed, 21 insertions(+), 12 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 057147c..7909aa6 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -130,13 +130,24 @@ def parse_options():
 	return settings
 
 
+def _parse_dirs_to_set(dir_str):
+	'''Changes space-delimited directory list into set with them
+	'''
+	_ret = set()
+	for search in dir_str.split():
+		if search == '-*':
+			break
+		_ret.update(glob.glob(search))
+	return _ret
+
+
 def parse_revdep_config(revdep_confdir):
 	''' Parses all files under and returns
 		tuple of: (masked_dirs, masked_files, search_dirs)'''
 
-	search_dirs = set()
-	masked_dirs = set()
-	masked_files = set()
+	search_dirs = os.environ.get('SEARCH_DIRS', '')
+	masked_dirs = os.environ.get('SEARCH_DIRS_MASK', '')
+	masked_files = os.environ.get('LD_LIBRARY_MASK', '')
 
 	for _file in os.listdir(revdep_confdir):
 		for line in open(os.path.join(revdep_confdir, _file)):
@@ -145,22 +156,20 @@ def parse_revdep_config(revdep_confdir):
 			if not line.startswith('#'):
 				match = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
 				if match is not None:
-					masks = match.group(1).split(' ')
-					masked_files.update(masks)
+					masked_files += ' ' + match.group(1)
 					continue
 				match = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
 				if match is not None:
-					searches = match.group(1).split(' ')
-					for search in searches:
-						masked_dirs.update(glob.glob(search))
+					masked_dirs += ' ' + match.group(1)
 					continue
 				match = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
 				if match is not None:
-					searches = match.group(1).split()
-					for search in searches:
-						search_dirs.update(glob.glob(search))
+					search_dirs += ' ' + match.group(1)
 					continue
 
-	print (masked_dirs, masked_files, search_dirs)
+	masked_files = set(masked_files.split(' '))
+	masked_dirs = _parse_dirs_to_set(masked_dirs)
+	search_dirs = _parse_dirs_to_set(search_dirs)
+
 	return (masked_dirs, masked_files, search_dirs)
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-03-24  7:17 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-03-24  7:17 UTC (permalink / raw
  To: gentoo-commits

commit:     39c99972049624c2504358c8455680da6acaee08
Author:     Slawek Lis <slis <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 24 06:32:53 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Mon Mar 24 06:32:53 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=39c99972

Moved option and config parsing into settings module

---
 pym/gentoolkit/revdep_rebuild/collect.py  |  34 +--------
 pym/gentoolkit/revdep_rebuild/rebuild.py  |  83 +-------------------
 pym/gentoolkit/revdep_rebuild/settings.py | 121 ++++++++++++++++++++++++++++++
 3 files changed, 123 insertions(+), 115 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 039dc76..2a431cb 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -12,6 +12,7 @@ import sys
 
 import portage
 from portage.output import blue, yellow
+from .settings import parse_revdep_config
 
 
 if sys.hexversion < 0x3000000:
@@ -87,39 +88,6 @@ def prepare_search_dirs(logger, settings):
 	return (bin_dirs, lib_dirs)
 
 
-def parse_revdep_config(revdep_confdir):
-	''' Parses all files under and returns
-		tuple of: (masked_dirs, masked_files, search_dirs)'''
-
-	search_dirs = set()
-	masked_dirs = set()
-	masked_files = set()
-
-	for _file in os.listdir(revdep_confdir):
-		for line in open(os.path.join(revdep_confdir, _file)):
-			line = line.strip()
-			#first check for comment, we do not want to regex all lines
-			if not line.startswith('#'):
-				match = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
-				if match is not None:
-					masks = match.group(1).split(' ')
-					masked_files.update(masks)
-					continue
-				match = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
-				if match is not None:
-					searches = match.group(1).split(' ')
-					for search in searches:
-						masked_dirs.update(glob.glob(search))
-					continue
-				match = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
-				if match is not None:
-					searches = match.group(1).split()
-					for search in searches:
-						search_dirs.update(glob.glob(search))
-					continue
-
-	return (masked_dirs, masked_files, search_dirs)
-
 
 def collect_libraries_from_dir(dirs, mask, logger):
 	''' Collects all libraries from specified list of directories.

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 314fb1f..9d5bf9b 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -18,7 +18,6 @@ from __future__ import print_function
 
 import os
 import sys
-import getopt
 import logging
 import subprocess
 import time
@@ -30,7 +29,7 @@ from portage.output import bold, red, blue, yellow, nocolor
 from .analyse import analyse
 from .cache import check_temp_files, read_cache
 from .assign import get_slotted_cps
-from .settings import DEFAULTS
+from .settings import DEFAULTS, parse_options
 from .stuff import filter_masked
 from . import __version__
 
@@ -43,39 +42,6 @@ __productname__ = "revdep-ng"
 
 # functions
 
-def print_usage():
-	"""Outputs the help message"""
-	print( APP_NAME + ': (' + VERSION +')')
-	print()
-	print('This is free software; see the source for copying conditions.')
-	print()
-	print('Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]')
-	print()
-	print('Broken reverse dependency rebuilder, python implementation.')
-	print()
-	print('Available options:')
-	print('''
-  -C, --nocolor         Turn off colored output
-  -d, --debug           Print debug informations
-  -e, --exact           Emerge based on exact package version
-  -h, --help            Print this usage
-  -i, --ignore          Ignore temporary files from previous runs
-                        (also won't create any)
-  -L, --library NAME    Unconditionally emerge existing packages that use
-      --library=NAME    the library with NAME. NAME can be a full or partial
-                        library name
-  -l, --no-ld-path      Do not set LD_LIBRARY_PATH
-  -o, --no-order        Do not check the build order
-                        (Saves time, but may cause breakage.)
-  -p, --pretend         Do a trial run without actually emerging anything
-                        (also passed to emerge command)
-  -q, --quiet           Be less verbose (also passed to emerge command)
-  -v, --verbose         Be more verbose (also passed to emerge command)
-''')
-	print( 'Calls emerge, options after -- are ignored by ' + APP_NAME)
-	print('and passed directly to emerge.')
-
-
 def init_logger(settings):
 	"""Creates and iitializes our logger according to the settings"""
 	logger = logging.getLogger()
@@ -94,53 +60,6 @@ def init_logger(settings):
 	return logger
 
 
-def parse_options():
-	"""Parses the command line options an sets settings accordingly"""
-
-	# TODO: Verify: options: no-ld-path, no-order, no-progress
-	#are not appliable
-
-	settings = DEFAULTS.copy()
-	try:
-		opts, args = getopt.getopt(sys.argv[1:],
-			'dehiklopqvCL:P',
-			['nocolor', 'debug', 'exact', 'help', 'ignore',
-			'keep-temp', 'library=', 'no-ld-path', 'no-order',
-			'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose'])
-
-		for key, val in opts:
-			if key in ('-h', '--help'):
-				print_usage()
-				sys.exit(0)
-			elif key in ('-q', '--quiet'):
-				settings['quiet'] = True
-				settings['VERBOSITY'] = 0
-			elif key in ('-v', '--verbose'):
-				settings['VERBOSITY'] = 2
-			elif key in ('-d', '--debug'):
-				settings['debug'] = True
-				settings['VERBOSITY'] = 3
-			elif key in ('-p', '--pretend'):
-				settings['PRETEND'] = True
-			elif key == '--no-pretend':
-				settings['NO_PRETEND'] = True
-			elif key in ('-e', '--exact'):
-				settings['EXACT'] = True
-			elif key in ('-C', '--nocolor', '--no-color'):
-				settings['nocolor'] = True
-			elif key in ('-L', '--library', '--library='):
-				settings['library'].update(val.split(','))
-			elif key in ('-i', '--ignore'):
-				settings['USE_TMP_FILES'] = False
-
-		settings['pass_through_options'] = " " + " ".join(args)
-	except getopt.GetoptError:
-		#logging.info(red('Unrecognized option\n'))
-		print(red('Unrecognized option\n'))
-		print_usage()
-		sys.exit(2)
-
-	return settings
 
 
 def rebuild(logger, assigned, settings):

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 2d6046f..057147c 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -4,8 +4,11 @@
 
 from __future__ import print_function
 
+import getopt
 import os
 import sys
+import re
+import glob
 
 import portage
 
@@ -43,3 +46,121 @@ DEFAULTS = {
 		'stdin': sys.stdin,
 		'stderr': sys.stderr
 		}
+
+
+def print_usage():
+	"""Outputs the help message"""
+	print( APP_NAME + ': (' + VERSION +')')
+	print()
+	print('This is free software; see the source for copying conditions.')
+	print()
+	print('Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]')
+	print()
+	print('Broken reverse dependency rebuilder, python implementation.')
+	print()
+	print('Available options:')
+	print('''
+  -C, --nocolor         Turn off colored output
+  -d, --debug           Print debug informations
+  -e, --exact           Emerge based on exact package version
+  -h, --help            Print this usage
+  -i, --ignore          Ignore temporary files from previous runs
+                        (also won't create any)
+  -L, --library NAME    Unconditionally emerge existing packages that use
+      --library=NAME    the library with NAME. NAME can be a full or partial
+                        library name
+  -l, --no-ld-path      Do not set LD_LIBRARY_PATH
+  -o, --no-order        Do not check the build order
+                        (Saves time, but may cause breakage.)
+  -p, --pretend         Do a trial run without actually emerging anything
+                        (also passed to emerge command)
+  -q, --quiet           Be less verbose (also passed to emerge command)
+  -v, --verbose         Be more verbose (also passed to emerge command)
+''')
+	print( 'Calls emerge, options after -- are ignored by ' + APP_NAME)
+	print('and passed directly to emerge.')
+
+
+def parse_options():
+	"""Parses the command line options an sets settings accordingly"""
+
+	# TODO: Verify: options: no-ld-path, no-order, no-progress
+	#are not appliable
+
+	settings = DEFAULTS.copy()
+	try:
+		opts, args = getopt.getopt(sys.argv[1:],
+			'dehiklopqvCL:P',
+			['nocolor', 'debug', 'exact', 'help', 'ignore',
+			'keep-temp', 'library=', 'no-ld-path', 'no-order',
+			'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose'])
+
+		for key, val in opts:
+			if key in ('-h', '--help'):
+				print_usage()
+				sys.exit(0)
+			elif key in ('-q', '--quiet'):
+				settings['quiet'] = True
+				settings['VERBOSITY'] = 0
+			elif key in ('-v', '--verbose'):
+				settings['VERBOSITY'] = 2
+			elif key in ('-d', '--debug'):
+				settings['debug'] = True
+				settings['VERBOSITY'] = 3
+			elif key in ('-p', '--pretend'):
+				settings['PRETEND'] = True
+			elif key == '--no-pretend':
+				settings['NO_PRETEND'] = True
+			elif key in ('-e', '--exact'):
+				settings['EXACT'] = True
+			elif key in ('-C', '--nocolor', '--no-color'):
+				settings['nocolor'] = True
+			elif key in ('-L', '--library', '--library='):
+				settings['library'].update(val.split(','))
+			elif key in ('-i', '--ignore'):
+				settings['USE_TMP_FILES'] = False
+
+		settings['pass_through_options'] = " " + " ".join(args)
+	except getopt.GetoptError:
+		#logging.info(red('Unrecognized option\n'))
+		print(red('Unrecognized option\n'))
+		print_usage()
+		sys.exit(2)
+
+	return settings
+
+
+def parse_revdep_config(revdep_confdir):
+	''' Parses all files under and returns
+		tuple of: (masked_dirs, masked_files, search_dirs)'''
+
+	search_dirs = set()
+	masked_dirs = set()
+	masked_files = set()
+
+	for _file in os.listdir(revdep_confdir):
+		for line in open(os.path.join(revdep_confdir, _file)):
+			line = line.strip()
+			#first check for comment, we do not want to regex all lines
+			if not line.startswith('#'):
+				match = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
+				if match is not None:
+					masks = match.group(1).split(' ')
+					masked_files.update(masks)
+					continue
+				match = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
+				if match is not None:
+					searches = match.group(1).split(' ')
+					for search in searches:
+						masked_dirs.update(glob.glob(search))
+					continue
+				match = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
+				if match is not None:
+					searches = match.group(1).split()
+					for search in searches:
+						search_dirs.update(glob.glob(search))
+					continue
+
+	print (masked_dirs, masked_files, search_dirs)
+	return (masked_dirs, masked_files, search_dirs)
+


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-03-17  6:50 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-03-17  6:50 UTC (permalink / raw
  To: gentoo-commits

commit:     ae20dbd7f2ef2810d3150e870ece6f5b7278f676
Author:     slis <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Mon Mar 17 06:48:19 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Mon Mar 17 06:48:19 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=ae20dbd7

Fix for non-existing libraries version (https://bugs.gentoo.org/show_bug.cgi?id=504654#c5)

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index d7b210b..bd1b6b7 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -185,7 +185,11 @@ class LibCheck(object):
 			scanned_files = self.scanned_files
 		found_libs = {}
 		for bits in self.searchbits:
-			scanned = scanned_files[bits]
+			try:
+				scanned = scanned_files[bits]
+			except KeyError:
+				self.logger.debug('There are no %s-bit libraries'%bits) 
+				continue
 			self.logger.debug(self.smsg % bits)
 			self.setlibs(sorted(scanned), bits)
 			for soname, filepaths in scanned.items():


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-03-17  6:50 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-03-17  6:50 UTC (permalink / raw
  To: gentoo-commits

commit:     c5baf551987e2fb412caa396ae34f7f4341ad819
Author:     slis <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Mon Mar 17 06:42:01 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Mon Mar 17 06:42:01 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=c5baf551

Fix #504654 - problem with encoding for non-ascii filenames

---
 pym/gentoolkit/revdep_rebuild/stuff.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index cc3da7b..7a8373d 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -22,7 +22,7 @@ def call_program(args):
 	subp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 	stdout, stderr = subp.communicate()
 	stdout = stdout.decode('utf-8')
-	return str(stdout)
+	return stdout
 
 
 def scan(params, files, max_args, logger):


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-03-11 21:22 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2014-03-11 21:22 UTC (permalink / raw
  To: gentoo-commits

commit:     e566d68dd4880a5bb6cfd2c8945f4eb23b40e8f3
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 11 21:22:41 2014 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Mar 11 21:22:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=e566d68d

Remove development version warning

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 0725c7c..314fb1f 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -220,10 +220,7 @@ def main(settings=None, logger=None):
 			and settings['IS_DEV'] \
 			and not settings['NO_PRETEND']:
 		logger.warn(blue(' * ') +
-			yellow('This is a development version, '
-				'so it may not work correctly'))
-		logger.warn(blue(' * ') +
-			yellow('Adding --pretend to portage options anyway'))
+			yellow('Adding --pretend to portage options'))
 		logger.info(blue(' * ') +
 			'If you\'re sure, you can add --no-pretend to revdep options')
 		settings['PRETEND'] = True


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  5:01 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  5:01 UTC (permalink / raw
  To: gentoo-commits

commit:     e39db54a6071281d71084579995e1fe34846c72d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 04:56:24 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 19 04:56:24 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=e39db54a

revdep_rebuild/rebuild.py: Migrate an os.system() call to subprocess.call()

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index c487b99..0725c7c 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -20,6 +20,7 @@ import os
 import sys
 import getopt
 import logging
+import subprocess
 import time
 current_milli_time = lambda: int(round(time.time() * 1000))
 
@@ -171,10 +172,9 @@ def rebuild(logger, assigned, settings):
 		bold(emerge_command))
 
 	stime = current_milli_time()
-	success = os.system(
-		'emerge ' + args +
-		' --oneshot --complete-graph=y ' +
-		emerge_command)
+	_args = 'emerge ' + args + ' --oneshot --complete-graph=y ' + emerge_command
+	_args = _args.split()
+	success = subprocess.call(_args)
 	ftime = current_milli_time()
 	logger.debug("\trebuild(); emerge call for %d ebuilds took: %s seconds"
 		% (len(_assigned), str((ftime-stime)/1000.0)))


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  4:33 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  4:33 UTC (permalink / raw
  To: gentoo-commits

commit:     06ef019388f27baccdc19dc5505c7c37321955f1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 04:28:38 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 19 04:28:38 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=06ef0193

revdep_rebuild/rebuild.py: Add debug timing info for the emerge call.

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 7ce145a..c487b99 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -20,6 +20,10 @@ import os
 import sys
 import getopt
 import logging
+import time
+current_milli_time = lambda: int(round(time.time() * 1000))
+
+
 from portage.output import bold, red, blue, yellow, nocolor
 
 from .analyse import analyse
@@ -166,10 +170,14 @@ def rebuild(logger, assigned, settings):
 		' --oneshot --complete-graph=y ' +
 		bold(emerge_command))
 
+	stime = current_milli_time()
 	success = os.system(
 		'emerge ' + args +
 		' --oneshot --complete-graph=y ' +
 		emerge_command)
+	ftime = current_milli_time()
+	logger.debug("\trebuild(); emerge call for %d ebuilds took: %s seconds"
+		% (len(_assigned), str((ftime-stime)/1000.0)))
 	return success
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  4:33 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  4:33 UTC (permalink / raw
  To: gentoo-commits

commit:     7df61421473ab9bf366f2a0f6b318a780d8548df
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 04:27:27 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 19 04:27:27 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=7df61421

revdep_rebuild/rebuild.py: Remove useless emerge_command reassignment to itself.

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index ea0c25a..7ce145a 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -161,8 +161,6 @@ def rebuild(logger, assigned, settings):
 		logger.warn(bold('\nThere is nothing to emerge. Exiting.'))
 		return 0
 
-	emerge_command = emerge_command
-
 	logger.warn(yellow(
 		'\nemerge') + args +
 		' --oneshot --complete-graph=y ' +


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  3:14 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  3:14 UTC (permalink / raw
  To: gentoo-commits

commit:     b681dae9a1de75c32b6c48965a4fbe2ab1cbbded
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 02:33:08 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 19 02:33:08 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=b681dae9

revdep_rebuild/assign.py: Downgrade a logging.info message to logging.debug

---
 pym/gentoolkit/revdep_rebuild/assign.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 5e56716..53e480d 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -77,7 +77,7 @@ def get_best_match(cpv, cp, logger):
 
 	slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])[0]
 	logger.warn('\t' + yellow('Warning: ebuild "' + cpv + '" not found.'))
-	logger.info('\tLooking for %s:%s' %(cp, slot))
+	logger.debug('\tLooking for %s:%s' %(cp, slot))
 	try:
 		match = portdb.match('%s:%s' %(cp, slot))
 	except portage.exception.InvalidAtom:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  3:14 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  3:14 UTC (permalink / raw
  To: gentoo-commits

commit:     dc4ea0ab56c1849c0f64d72762bd66c74ae0a522
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 03:09:42 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 19 03:09:42 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=dc4ea0ab

revdep_rebuild/assign.py: Improve a couple logger messages formatting.

---
 pym/gentoolkit/revdep_rebuild/assign.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 53e480d..412ed49 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -76,8 +76,8 @@ def get_best_match(cpv, cp, logger):
 	"""
 
 	slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])[0]
-	logger.warn('\t' + yellow('Warning: ebuild "' + cpv + '" not found.'))
-	logger.debug('\tLooking for %s:%s' %(cp, slot))
+	logger.warn('\t%s "%s" %s.' % (yellow('* Warning:'), cpv,bold('ebuild not found.')))
+	logger.debug('\tget_best_match(); Looking for %s:%s' %(cp, slot))
 	try:
 		match = portdb.match('%s:%s' %(cp, slot))
 	except portage.exception.InvalidAtom:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  3:14 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  3:14 UTC (permalink / raw
  To: gentoo-commits

commit:     8cc0df2e105ae75edf81fd9133511b8a8edb8815
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 00:56:47 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 19 00:58:03 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=8cc0df2e

revdep_rebuild/analyse.py: Improve LibCheck.search() totals debug output.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 5346c3e..d7b210b 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -140,6 +140,7 @@ class LibCheck(object):
 			self.pmsg = green(' * ') + bold('Broken files that requires:') + ' %s (%s bits)'
 			self.setlibs = self._setlibs
 			self.check = self._checkbroken
+		self.sfmsg = "\tLibCheck.search(); Total found: %(count)d libs, %(deps)d files in %(time)d milliseconds"
 		self.alllibs = None
 
 
@@ -179,6 +180,7 @@ class LibCheck(object):
 		'''
 		stime = current_milli_time()
 		count = 0
+		fcount = 0
 		if not scanned_files:
 			scanned_files = self.scanned_files
 		found_libs = {}
@@ -197,11 +199,12 @@ class LibCheck(object):
 							except KeyError:
 								found_libs[bits][l] = set([filename])
 								count += 1
+							fcount += 1
 							self.logger.debug("\tLibCheck.search(); FOUND:"
-									" %s, %s, %s" % (bits, l, filename))
+									" %sbit, %s, %s" % (bits, l, filename))
 		ftime = current_milli_time()
-		self.logger.debug("\tLibCheck.search(); total libs found: %d in %d milliseconds"
-			% (count, ftime-stime))
+		self.logger.debug(self.sfmsg % {'count': count, 'deps': fcount,
+			'time': ftime-stime})
 		return found_libs
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  3:14 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  3:14 UTC (permalink / raw
  To: gentoo-commits

commit:     5943100c1a6b0e9e4ce95f5f635a90c9862c8c5c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 22:29:20 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 18 23:02:17 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=5943100c

revdep_rebuild/analyse.py: Correctly set search bits for -L searches...

Determine the searchbits needed.
Limit the scan() return accordingly
Mask any unneeded search libs according to the searchbits set.
Modify the LibCheck class:
   - break the search into a set searchbit order.
   - replace _lambda() with _setslibs() to filter searchlibs
     to the bit length being searched.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 51 ++++++++++++++++++++++----------
 1 file changed, 35 insertions(+), 16 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index f65c503..09d88d6 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -19,7 +19,7 @@ from .cache import save_cache
 current_milli_time = lambda: int(round(time.time() * 1000))
 
 
-def scan_files(libs_and_bins, cmd_max_args, logger):
+def scan_files(libs_and_bins, cmd_max_args, logger, searchbits):
 	'''Calls stuff.scan() and processes the data into a dictionary
 	of scanned files information.
 
@@ -47,6 +47,8 @@ def scan_files(libs_and_bins, cmd_max_args, logger):
 		filename = os.path.realpath(filename)
 		needed = needed.split(',')
 		bits = bits[8:] # 8: -> strlen('ELFCLASS')
+		if bits not in searchbits:
+			continue
 		if not soname:
 			soname = sfilename
 
@@ -113,7 +115,7 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 
 
 class LibCheck(object):
-	def __init__(self, scanned_files, logger, searchlibs=None):
+	def __init__(self, scanned_files, logger, searchlibs=None, searchbits=None):
 		'''LibCheck init function.
 
 		@param scanned_files: optional dictionary if the type created by
@@ -126,29 +128,30 @@ class LibCheck(object):
 		self.scanned_files = scanned_files
 		self.logger = logger
 		self.searchlibs = searchlibs
+		self.searchbits = sorted(searchbits) or ['32', '64']
 		if searchlibs:
 			self.smsg = '\tLibCheck.search(), Checking for %s bit dependants'
 			self.pmsg = yellow(" * ") + 'Files that depend on: %s (%s bits)'
-			self.alllibs = '|'.join(sorted(searchlibs)) + '|'
-			self.setlibs = self._lamda
+			self.setlibs = self._setslibs
 			self.check = self._checkforlib
 		else:
 			self.smsg = '\tLibCheck.search(), Checking for broken %s bit libs'
 			self.pmsg = green(' * ') + bold('Broken files that requires:') + ' %s (%s bits)'
 			self.setlibs = self._setlibs
 			self.check = self._checkbroken
-			self.alllibs = None
+		self.alllibs = None
 
 
-	@staticmethod
-	def _lamda(l):
+	def _setslibs(self, l, b):
 		'''Internal function.  Use the class's setlibs variable'''
-		pass
+		self.alllibs = '|'.join(
+			[x for x in self.searchlibs if ('lib%s' % (b) in x)]) + '|'
+		self.logger.debug("\tLibCheck._setslibs(), new alllibs: %s" %(self.alllibs))
 
 
-	def _setlibs(self, l):
+	def _setlibs(self, l, b):
 		'''Internal function.  Use the class's setlibs variable'''
-		self.alllibs = '|'.join(sorted(l)) + '|'
+		self.alllibs = '|'.join(l) + '|'
 
 
 	def _checkforlib(self, l):
@@ -178,10 +181,11 @@ class LibCheck(object):
 		if not scanned_files:
 			scanned_files = self.scanned_files
 		found_libs = {}
-		for bits, libs in scanned_files.items():
-			self.setlibs(libs)
+		for bits in self.searchbits:
+			scanned = scanned_files[bits]
 			self.logger.debug(self.smsg % bits)
-			for soname, filepaths in libs.items():
+			self.setlibs(sorted(scanned), bits)
+			for soname, filepaths in scanned.items():
 				for filename, needed in filepaths.items():
 					for l in needed:
 						if self.check(l):
@@ -235,8 +239,17 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	@rtype list: list of pkgs that need rebuilding
 	"""
 
-	if _libs_to_check == None:
+	searchbits = set()
+	if _libs_to_check:
+		for lib in _libs_to_check:
+			if "lib64" in lib:
+				searchbits.add('64')
+			elif "lib32" in lib:
+				searchbits.add('32')
+	else:
 		_libs_to_check = set()
+		searchbits.update(['64', '32'])
+
 	if libraries and la_libraries and libraries_links and binaries:
 		logger.info(blue(' * ') +
 			bold('Found a valid cache, skipping collecting phase'))
@@ -260,6 +273,11 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 				'/lib64/modules',
 			])
 		)
+		if '64' not in searchbits:
+			masked_dirs.update(['/lib64', '/usr/lib64'])
+		elif '32' not in searchbits:
+			masked_dirs.update(['/lib32', '/usr/lib32'])
+
 		logger.debug('\tanalyse(), bin directories:')
 		for x in sorted(bin_dirs):
 			logger.debug('\t\t%s' % (x))
@@ -300,7 +318,8 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 
 	libs_and_bins = libraries.union(binaries)
 
-	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'], logger)
+	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'],
+		logger, searchbits)
 
 	logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
 	logger.debug(
@@ -308,7 +327,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 		% (len(libs_and_bins), len(libraries)+len(libraries_links))
 	)
 
-	libcheck = LibCheck(scanned_files, logger, _libs_to_check)
+	libcheck = LibCheck(scanned_files, logger, _libs_to_check, searchbits)
 
 	broken_pathes = libcheck.process_results(libcheck.search())
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  3:14 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  3:14 UTC (permalink / raw
  To: gentoo-commits

commit:     f9b0cf555a5178883ab1e817bd801e4a7ff4b83c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 00:37:20 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 19 00:57:47 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=f9b0cf55

recdep_rebuild/analyse.py: Fix LibCheck.search() overwiting found_libs...

When multiple bit lengths were being searched, only the last bit length was surviving.
Added extra debug output to discover the problem.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 82393a6..5346c3e 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -129,6 +129,7 @@ class LibCheck(object):
 		self.logger = logger
 		self.searchlibs = searchlibs
 		self.searchbits = sorted(searchbits) or ['32', '64']
+		self.logger.debug("\tLibCheck.__init__(), new searchlibs: %s" %(self.searchbits))
 		if searchlibs:
 			self.smsg = '\tLibCheck.search(), Checking for %s bit dependants'
 			self.pmsg = yellow(" * ") + 'Files that depend on: %s (%s bits)'
@@ -189,15 +190,15 @@ class LibCheck(object):
 				for filename, needed in filepaths.items():
 					for l in needed:
 						if self.check(l):
+							if not bits in found_libs:
+								found_libs[bits] = {}
 							try:
 								found_libs[bits][l].add(filename)
 							except KeyError:
-								try:
-									found_libs[bits][l] = set([filename])
-									count += 1
-								except KeyError:
-									found_libs = {bits: {l: set([filename])}}
-									count += 1
+								found_libs[bits][l] = set([filename])
+								count += 1
+							self.logger.debug("\tLibCheck.search(); FOUND:"
+									" %s, %s, %s" % (bits, l, filename))
 		ftime = current_milli_time()
 		self.logger.debug("\tLibCheck.search(); total libs found: %d in %d milliseconds"
 			% (count, ftime-stime))


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  3:14 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  3:14 UTC (permalink / raw
  To: gentoo-commits

commit:     b671399841845b2d9bb593b22a46852b48fb52bf
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 02:32:12 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 19 02:32:12 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=b6713998

revdep_rebuild.py/assign.py: Fix a bug in the slot assignment.

---
 pym/gentoolkit/revdep_rebuild/assign.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 22565e8..5e56716 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -75,7 +75,7 @@ def get_best_match(cpv, cp, logger):
 	@rtype tuple: ([cpv,...], SLOT)
 	"""
 
-	slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])
+	slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])[0]
 	logger.warn('\t' + yellow('Warning: ebuild "' + cpv + '" not found.'))
 	logger.info('\tLooking for %s:%s' %(cp, slot))
 	try:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  3:14 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  3:14 UTC (permalink / raw
  To: gentoo-commits

commit:     3ecac0c4a444eca19f19542db19a8061d796a02f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 22:30:37 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 18 23:10:19 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=3ecac0c4

revdep_rebuild/analyse.py: No need to convert to a set  before updating masked_directories.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 09d88d6..82393a6 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -266,12 +266,11 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 			parse_revdep_config(settings['REVDEP_CONFDIR'])
 		lib_dirs.update(ld)
 		bin_dirs.update(ld)
-		masked_dirs.update(
-			set([
-				'/lib/modules',
-				'/lib32/modules',
-				'/lib64/modules',
-			])
+		masked_dirs.update([
+			'/lib/modules',
+			'/lib32/modules',
+			'/lib64/modules',
+			]
 		)
 		if '64' not in searchbits:
 			masked_dirs.update(['/lib64', '/usr/lib64'])


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-19  3:14 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-19  3:14 UTC (permalink / raw
  To: gentoo-commits

commit:     b053a6e175467e0d28854e8ec6f008e3dbaf811c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 19 02:30:20 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 19 02:30:20 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=b053a6e1

revdep_rebuild: Fix pkgs to merge being incorrectly filtered.

Move masked package filtering to a function.
Relocate the masking check to rebuild() only for exact version rebuilds.
Filtering was already done in get_slotted_cps().

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 26 ++++++--------------------
 pym/gentoolkit/revdep_rebuild/stuff.py   | 26 ++++++++++++++++++++++++++
 2 files changed, 32 insertions(+), 20 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 3e91058..ea0c25a 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -20,13 +20,13 @@ import os
 import sys
 import getopt
 import logging
-from portage.output import bold, red, blue, yellow, green, nocolor
+from portage.output import bold, red, blue, yellow, nocolor
 
 from .analyse import analyse
-from .stuff import get_masking_status
 from .cache import check_temp_files, read_cache
 from .assign import get_slotted_cps
 from .settings import DEFAULTS
+from .stuff import filter_masked
 from . import __version__
 
 
@@ -143,9 +143,11 @@ def rebuild(logger, assigned, settings):
 
 	args = settings['pass_through_options']
 	if settings['EXACT']:
-		emerge_command = '=' + ' ='.join(assigned)
+		_assigned = filter_masked(assigned, logger)
+		emerge_command = '=' + ' ='.join(_assigned)
 	else:
-		emerge_command = ' '.join(get_slotted_cps(assigned, logger))
+		_assigned = get_slotted_cps(assigned, logger)
+		emerge_command = ' '.join(_assigned)
 	if settings['PRETEND']:
 		args += ' --pretend'
 	if settings['VERBOSITY'] >= 2:
@@ -253,22 +255,6 @@ def main(settings=None, logger=None):
 		for filename in orphaned:
 			logger.warn(red('\t* ') + filename)
 
-	has_masked = False
-	tmp = []
-	for ebuild in assigned:
-		if get_masking_status(ebuild):
-			has_masked = True
-			logger.warn(' !!! ' + red('All ebuilds that could satisfy: ') +
-				green(ebuild) + red(' have been masked'))
-		else:
-			tmp.append(ebuild)
-	assigned = tmp
-
-	if has_masked:
-		logger.info('\t' + red('* ') +
-			'Unmask all ebuild(s) listed above and call revdep-rebuild '
-			'again or manually emerge given packages.')
-
 	success = rebuild(logger, assigned, settings)
 	logger.debug("rebuild return code = %i" %success)
 	return success

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index e0fc7b5..cc3da7b 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -8,6 +8,7 @@ from __future__ import print_function
 import subprocess
 
 import portage
+from portage.output import green, red
 
 
 # util. functions
@@ -75,6 +76,31 @@ def _match_str_in_list(lst, stri):
 	return False
 
 
+def filter_masked(assigned, logger):
+	'''Filter out masked pkgs/ebuilds'''
+
+	def is_masked(ebuild):
+		if get_masking_status(ebuild):
+			logger.warn(' !!! ' + red('All ebuilds that could satisfy: ') +
+				green(ebuild) + red(' have been masked'))
+			return True
+		return False
+
+	has_masked = False
+	tmp = []
+	for ebuild in assigned:
+		if not is_masked(ebuild):
+			tmp.append(ebuild)
+		else:
+			has_masked = True
+	if has_masked:
+		logger.info('\t' + red('* ') +
+			'Unmask all ebuild(s) listed above and call revdep-rebuild '
+			'again or manually emerge given packages.')
+	return tmp
+
+
+
 
 if __name__ == '__main__':
 	print("There is nothing to run here.")


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-18 18:51 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-18 18:51 UTC (permalink / raw
  To: gentoo-commits

commit:     8a154181f49888b7a68299ede1161e9c41d3ddb1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 18:46:38 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 18 18:46:38 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=8a154181

revdep_rebuild: Remove unused symlink_pairs code.

Remove some other commented code left over from the sets() conversion.

---
 pym/gentoolkit/revdep_rebuild/analyse.py |  2 +-
 pym/gentoolkit/revdep_rebuild/collect.py | 18 +++---------------
 2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 64aca04..f65c503 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -278,7 +278,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 		stime = current_milli_time()
 		logger.info(green(' * ') +
 			bold('Collecting dynamic linking informations'))
-		libraries, la_libraries, libraries_links, symlink_pairs = \
+		libraries, la_libraries, libraries_links = \
 			collect_libraries_from_dir(lib_dirs, masked_dirs, logger)
 		binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
 		ftime = current_milli_time()

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 550569d..039dc76 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -134,8 +134,6 @@ def collect_libraries_from_dir(dirs, mask, logger):
 	found_files = set()
 	found_symlinks = set()
 	found_la_files = set() # la libraries
-	symlink_pairs = []  # list of pairs symlink_id->library_id
-
 
 	for _dir in dirs:
 		if _dir in mask:
@@ -158,18 +156,9 @@ def collect_libraries_from_dir(dirs, mask, logger):
 						listing.endswith('.a') or
 						'.so.' in listing
 						):
-						#if listing in found_files or listing in found_symlinks:
-							#continue
 
 						if os.path.islink(listing):
 							found_symlinks.add(listing)
-							#abs_path = os.path.realpath(listing)
-							#if abs_path in found_files:
-								#index = found_files.index(abs_path)
-							#else:
-								#found_files.append(abs_path)
-								#index = len(found_files)-1
-							#symlink_pairs.append((len(found_symlinks)-1, index,))
 						else:
 							found_files.add(listing)
 						continue
@@ -195,13 +184,12 @@ def collect_libraries_from_dir(dirs, mask, logger):
 				blue('%s')  %str(ex)))
 
 	if found_directories:
-		_file, la_file, link, pair = \
+		_file, la_file, link = \
 			collect_libraries_from_dir(found_directories, mask, logger)
 		found_files.update(_file)
 		found_la_files.update(la_file)
 		found_symlinks.update(link)
-		symlink_pairs += pair
-	return (found_files, found_la_files, found_symlinks, symlink_pairs)
+	return (found_files, found_la_files, found_symlinks)
 
 
 def collect_binaries_from_dir(dirs, mask, logger):
@@ -269,7 +257,7 @@ if __name__ == '__main__':
 		])
 	)
 
-	libraries, la_libraries, libraries_links, msymlink_pairs = \
+	libraries, la_libraries, libraries_links = \
 		collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
 	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-18 18:51 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-18 18:51 UTC (permalink / raw
  To: gentoo-commits

commit:     ddabed641fcf824d3f27e068674145211fa530dd
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 18:08:00 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 18 18:08:00 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=ddabed64

revdep_rebuild/analyse.py: Remove the -n option from the scanelf parameters. 

It is not needed when using the -F option.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 0c22b0e..64aca04 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -30,7 +30,7 @@ def scan_files(libs_and_bins, cmd_max_args, logger):
 	'''
 	stime = current_milli_time()
 	scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...}
-	lines = scan(['-nBF', '%F %f %S %n %M'],
+	lines = scan(['-BF', '%F %f %S %n %M'],
 				 libs_and_bins, cmd_max_args, logger)
 	ftime = current_milli_time()
 	logger.debug("\tscan_files(); total time to get scanelf data is "


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-18 17:59 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-18 17:59 UTC (permalink / raw
  To: gentoo-commits

commit:     4ab0f13a7a736544b7a970ec6b1f3222db3cd731
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 17:55:17 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 18 17:55:17 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4ab0f13a

revdep_rebuild/collect.py: Fix incorrect usage of set.union(), should have been set.update()

This reduced the total number of binaries significantly by not adding the recursive results
to the set.

---
 pym/gentoolkit/revdep_rebuild/collect.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 9fba58a..550569d 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -248,7 +248,7 @@ def collect_binaries_from_dir(dirs, mask, logger):
 				blue('%s') %str(ex)))
 
 	if found_directories:
-		found_files.union(collect_binaries_from_dir(found_directories, mask, logger))
+		found_files.update(collect_binaries_from_dir(found_directories, mask, logger))
 
 	return found_files
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-18 17:23 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-18 17:23 UTC (permalink / raw
  To: gentoo-commits

commit:     6a1b982db786de23bd8a201827be4b3b34c53a75
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 17:16:16 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 18 17:16:16 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=6a1b982d

Revert "revdep-rebuild/analyse.py: Change the scanelf call parameters."

This reverts commit f47a75c4815415aa4da6a4b41fb2ba18ef753ef2.
I added the parameter incorrectly, then didn't notice the that
no info was returned.
When I add the --use-ldpath correctly, it seems to detect that
nearly everything is broken.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 595d4f5..0c22b0e 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -30,7 +30,7 @@ def scan_files(libs_and_bins, cmd_max_args, logger):
 	'''
 	stime = current_milli_time()
 	scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...}
-	lines = scan(['--use-ldpath -BF', '%F %f %S %n %M'],
+	lines = scan(['-nBF', '%F %f %S %n %M'],
 				 libs_and_bins, cmd_max_args, logger)
 	ftime = current_milli_time()
 	logger.debug("\tscan_files(); total time to get scanelf data is "


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-18  7:30 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-18  7:30 UTC (permalink / raw
  To: gentoo-commits

commit:     f47a75c4815415aa4da6a4b41fb2ba18ef753ef2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 07:25:17 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 18 07:25:17 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=f47a75c4

revdep-rebuild/analyse.py: Change the scanelf call parameters.

Remove the redundant -n option due to the -F option.
Add --use-ldpath to help prevent false detection of libs in a 
different path than the lib is linked to.
Changes recommended by: Douglas Freed

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 0c22b0e..595d4f5 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -30,7 +30,7 @@ def scan_files(libs_and_bins, cmd_max_args, logger):
 	'''
 	stime = current_milli_time()
 	scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...}
-	lines = scan(['-nBF', '%F %f %S %n %M'],
+	lines = scan(['--use-ldpath -BF', '%F %f %S %n %M'],
 				 libs_and_bins, cmd_max_args, logger)
 	ftime = current_milli_time()
 	logger.debug("\tscan_files(); total time to get scanelf data is "


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-18  6:15 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-18  6:15 UTC (permalink / raw
  To: gentoo-commits

commit:     1d981aeb603714c0a75c4acacda3dd031ef6301d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 06:09:32 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 18 06:09:32 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=1d981aeb

revdep-rebuild/cache.py: Convert cache loading to sets()

---
 pym/gentoolkit/revdep_rebuild/cache.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 49ddc10..3d925d8 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -22,16 +22,16 @@ def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 	'''
 
 	ret = {
-		'libraries':[],
-		'la_libraries':[],
-		'libraries_links':[],
-		'binaries':[]
+		'libraries': set(),
+		'la_libraries': set(),
+		'libraries_links': set(),
+		'binaries': set()
 		}
 	try:
 		for key,val in ret.items():
 			_file = open(os.path.join(temp_path, key))
 			for line in _file.readlines():
-				val.append(line.strip())
+				val.add(line.strip())
 			#libraries.remove('\n')
 			_file .close()
 	except EnvironmentError:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-17 10:31 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-02-17 10:31 UTC (permalink / raw
  To: gentoo-commits

commit:     228e257887a48de8b27e36e9f8305d8bf6c0a579
Author:     slis <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Mon Feb 17 10:29:49 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Mon Feb 17 10:29:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=228e2578

fixed commented out rebuild

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 257bc02..3e91058 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -269,7 +269,7 @@ def main(settings=None, logger=None):
 			'Unmask all ebuild(s) listed above and call revdep-rebuild '
 			'again or manually emerge given packages.')
 
-	#success = rebuild(logger, assigned, settings)
+	success = rebuild(logger, assigned, settings)
 	logger.debug("rebuild return code = %i" %success)
 	return success
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-17  8:50 Slawek Lis
  0 siblings, 0 replies; 115+ messages in thread
From: Slawek Lis @ 2014-02-17  8:50 UTC (permalink / raw
  To: gentoo-commits

commit:     b2130a2aca2a202444ddd57ab6fe65f05c5c3571
Author:     slis <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Mon Feb 17 08:48:20 2014 +0000
Commit:     Slawek Lis <slis <AT> gentoo <DOT> org>
CommitDate: Mon Feb 17 08:48:20 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=b2130a2a

Using sets in collect module

---
 pym/gentoolkit/revdep_rebuild/analyse.py |  4 +--
 pym/gentoolkit/revdep_rebuild/collect.py | 57 ++++++++++++++++----------------
 pym/gentoolkit/revdep_rebuild/rebuild.py |  2 +-
 3 files changed, 32 insertions(+), 31 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index d844906..0c22b0e 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -298,7 +298,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	)
 	logger.info(green(' * ') + bold('Scanning files'))
 
-	libs_and_bins = set(libraries + binaries)
+	libs_and_bins = libraries.union(binaries)
 
 	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'], logger)
 
@@ -313,7 +313,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	broken_pathes = libcheck.process_results(libcheck.search())
 
 	broken_la = extract_dependencies_from_la(la_libraries,
-		libraries+libraries_links, _libs_to_check, logger)
+		libraries.union(libraries_links), _libs_to_check, logger)
 	broken_pathes += broken_la
 
 	logger.warn(green(' * ') + bold('Assign files to packages'))

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 4ce0e7b..9fba58a 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -130,12 +130,13 @@ def collect_libraries_from_dir(dirs, mask, logger):
 
 	# contains list of directories found
 	# allows us to reduce number of fnc calls
-	found_directories = []
-	found_files = []
-	found_symlinks = []
-	found_la_files = [] # la libraries
+	found_directories = set()
+	found_files = set()
+	found_symlinks = set()
+	found_la_files = set() # la libraries
 	symlink_pairs = []  # list of pairs symlink_id->library_id
 
+
 	for _dir in dirs:
 		if _dir in mask:
 			continue
@@ -151,43 +152,43 @@ def collect_libraries_from_dir(dirs, mask, logger):
 						#we do not want scan symlink-directories
 						pass
 					else:
-						found_directories.append(listing)
+						found_directories.add(listing)
 				elif os.path.isfile(listing):
 					if (listing.endswith('.so') or
 						listing.endswith('.a') or
 						'.so.' in listing
 						):
-						if listing in found_files or listing in found_symlinks:
-							continue
+						#if listing in found_files or listing in found_symlinks:
+							#continue
 
 						if os.path.islink(listing):
-							found_symlinks.append(listing)
-							abs_path = os.path.realpath(listing)
-							if abs_path in found_files:
-								index = found_files.index(abs_path)
-							else:
-								found_files.append(abs_path)
-								index = len(found_files)-1
-							symlink_pairs.append((len(found_symlinks)-1, index,))
+							found_symlinks.add(listing)
+							#abs_path = os.path.realpath(listing)
+							#if abs_path in found_files:
+								#index = found_files.index(abs_path)
+							#else:
+								#found_files.append(abs_path)
+								#index = len(found_files)-1
+							#symlink_pairs.append((len(found_symlinks)-1, index,))
 						else:
-							found_files.append(listing)
+							found_files.add(listing)
 						continue
 					elif listing.endswith('.la'):
 						if listing in found_la_files:
 							continue
 
-						found_la_files.append(listing)
+						found_la_files.add(listing)
 					else:
 						# sometimes there are binaries in libs' subdir,
 						# for example in nagios
 						if not os.path.islink(listing):
-							if listing in found_files or listing in found_symlinks:
-								continue
+							#if listing in found_files or listing in found_symlinks:
+								#continue
 							prv = os.stat(listing)[stat.ST_MODE]
 							if prv & stat.S_IXUSR == stat.S_IXUSR or \
 									prv & stat.S_IXGRP == stat.S_IXGRP or \
 									prv & stat.S_IXOTH == stat.S_IXOTH:
-								found_files.append(listing)
+								found_files.add(listing)
 		except Exception as ex:
 			logger.debug('\t' +
 				yellow('Exception collecting libraries: ' +
@@ -196,9 +197,9 @@ def collect_libraries_from_dir(dirs, mask, logger):
 	if found_directories:
 		_file, la_file, link, pair = \
 			collect_libraries_from_dir(found_directories, mask, logger)
-		found_files += _file
-		found_la_files += la_file
-		found_symlinks += link
+		found_files.update(_file)
+		found_la_files.update(la_file)
+		found_symlinks.update(link)
 		symlink_pairs += pair
 	return (found_files, found_la_files, found_symlinks, symlink_pairs)
 
@@ -212,8 +213,8 @@ def collect_binaries_from_dir(dirs, mask, logger):
 
 	# contains list of directories found
 	# allows us to reduce number of fnc calls
-	found_directories = []
-	found_files = []
+	found_directories = set()
+	found_files = set()
 
 	for _dir in dirs:
 		if _dir in mask:
@@ -230,7 +231,7 @@ def collect_binaries_from_dir(dirs, mask, logger):
 						#we do not want scan symlink-directories
 						pass
 					else:
-						found_directories.append(listing)
+						found_directories.add(listing)
 				elif os.path.isfile(listing):
 					# we're looking for binaries
 					# and with binaries we do not need links
@@ -240,14 +241,14 @@ def collect_binaries_from_dir(dirs, mask, logger):
 						if prv & stat.S_IXUSR == stat.S_IXUSR or \
 								prv & stat.S_IXGRP == stat.S_IXGRP or \
 								prv & stat.S_IXOTH == stat.S_IXOTH:
-							found_files.append(listing)
+							found_files.add(listing)
 		except Exception as ex:
 			logger.debug('\t' +
 				yellow('Exception during binaries collecting: '+
 				blue('%s') %str(ex)))
 
 	if found_directories:
-		found_files += collect_binaries_from_dir(found_directories, mask, logger)
+		found_files.union(collect_binaries_from_dir(found_directories, mask, logger))
 
 	return found_files
 

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 3e91058..257bc02 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -269,7 +269,7 @@ def main(settings=None, logger=None):
 			'Unmask all ebuild(s) listed above and call revdep-rebuild '
 			'again or manually emerge given packages.')
 
-	success = rebuild(logger, assigned, settings)
+	#success = rebuild(logger, assigned, settings)
 	logger.debug("rebuild return code = %i" %success)
 	return success
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-16 20:55 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-16 20:55 UTC (permalink / raw
  To: gentoo-commits

commit:     4d043024d6d94a87dd495d07f4ac645e90812d8a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 16 20:51:03 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Feb 16 20:51:03 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4d043024

revdep-rebuild/analyse.py: Add bin, lib, masked directories and files to the debug output.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index c118369..d844906 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -260,6 +260,19 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 				'/lib64/modules',
 			])
 		)
+		logger.debug('\tanalyse(), bin directories:')
+		for x in sorted(bin_dirs):
+			logger.debug('\t\t%s' % (x))
+		logger.debug('\tanalyse(), lib directories:')
+		for x in sorted(lib_dirs):
+			logger.debug('\t\t%s' % (x))
+		logger.debug('\tanalyse(), masked directories:')
+		for x in sorted(masked_dirs):
+			logger.debug('\t\t%s' % (x))
+		logger.debug('\tanalyse(), masked files:')
+		for x in sorted(masked_files):
+			logger.debug('\t\t%s' % (x))
+
 		ftime = current_milli_time()
 		logger.debug('\ttime to complete task: %d milliseconds' % (ftime-stime))
 		stime = current_milli_time()


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-13 22:08 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2014-02-13 22:08 UTC (permalink / raw
  To: gentoo-commits

commit:     8efbfa771e341b1aac91a098fac7d7fb89e261b5
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 13 22:07:26 2014 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Thu Feb 13 22:07:26 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=8efbfa77

Open CONTENTS files as utf-8 to prevent UnicodeDecodeError.

---
 pym/gentoolkit/revdep_rebuild/assign.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 2df6532..22565e8 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -7,6 +7,7 @@ Functions used for determining the package the broken lib belongs to.
 from __future__ import print_function
 
 import os
+import io
 import re
 import time
 current_milli_time = lambda: int(round(time.time() * 1000))
@@ -39,7 +40,7 @@ def assign_packages(broken, logger, settings):
 			f = pkgpath + '/CONTENTS'
 			if os.path.exists(f):
 				try:
-					with open(f, 'r') as cnt:
+					with io.open(f, 'r', encoding='utf_8') as cnt:
 						for line in cnt.readlines():
 							m = re.match('^obj (/[^ ]+)', line)
 							if m is not None:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-12 21:12 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2014-02-12 21:12 UTC (permalink / raw
  To: gentoo-commits

commit:     0bb06b4a715d4d16be5d7983ec5aa19c6b9bd4ee
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 12 21:11:25 2014 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Wed Feb 12 21:11:25 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=0bb06b4a

Update warning to indicate prerelease and where to file bugs.

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 843f611..3e91058 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -195,11 +195,14 @@ def main(settings=None, logger=None):
 
 	#TODO: Development warning
 	logger.warn(blue(' * ') +
-		yellow('This is a development version, '
+		yellow('This is a prerelease version, '
 			'so it may not work correctly'))
 	logger.warn(blue(' * ') +
 		yellow('The original revdep-rebuild script is '
 			'installed as revdep-rebuild.sh'))
+	logger.warn(blue(' * ') +
+		yellow('Please files bugs at: '
+			'https://bugs.gentoo.org/'))
 
 	if os.getuid() != 0 and not settings['PRETEND']:
 		logger.warn(blue(' * ') +


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-12 16:20 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-12 16:20 UTC (permalink / raw
  To: gentoo-commits

commit:     456fd8bbc43d877b1df6f8fa0fca97cccfa4fd2c
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 12 16:15:39 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 12 16:15:39 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=456fd8bb

revdep_rebuild/collect.py: Minor grmmar correction.

---
 pym/gentoolkit/revdep_rebuild/collect.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index c4c7a40..4ce0e7b 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -190,7 +190,7 @@ def collect_libraries_from_dir(dirs, mask, logger):
 								found_files.append(listing)
 		except Exception as ex:
 			logger.debug('\t' +
-				yellow('Exception during collecting libraries: ' +
+				yellow('Exception collecting libraries: ' +
 				blue('%s')  %str(ex)))
 
 	if found_directories:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-12 16:20 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-12 16:20 UTC (permalink / raw
  To: gentoo-commits

commit:     cd686cb56a3d7653066d749296b455ef6692e79b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 12 16:14:47 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 12 16:14:47 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=cd686cb5

revdep_rebuild: Add task timing information to debug output.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 37 ++++++++++++++++++++++++++++----
 pym/gentoolkit/revdep_rebuild/assign.py  |  7 ++++++
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 3194f48..c118369 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -6,6 +6,7 @@ from __future__ import print_function
 
 import os
 import re
+import time
 
 from portage.output import bold, blue, yellow, green
 
@@ -15,6 +16,8 @@ from .collect import (prepare_search_dirs, parse_revdep_config,
 from .assign import assign_packages
 from .cache import save_cache
 
+current_milli_time = lambda: int(round(time.time() * 1000))
+
 
 def scan_files(libs_and_bins, cmd_max_args, logger):
 	'''Calls stuff.scan() and processes the data into a dictionary
@@ -25,9 +28,16 @@ def scan_files(libs_and_bins, cmd_max_args, logger):
 	@param logger: python style Logging function to use for output.
 	@returns dict: {bit_length: {soname: {filename: set(needed)}}}
 	'''
+	stime = current_milli_time()
 	scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...}
-	for line in scan(['-nBF', '%F %f %S %n %M'],
-					 libs_and_bins, cmd_max_args, logger):
+	lines = scan(['-nBF', '%F %f %S %n %M'],
+				 libs_and_bins, cmd_max_args, logger)
+	ftime = current_milli_time()
+	logger.debug("\tscan_files(); total time to get scanelf data is "
+		"%d milliseconds" % (ftime-stime))
+	stime = current_milli_time()
+	count = 0
+	for line in lines:
 		parts = line.split(' ')
 		if len(parts) < 5:
 			logger.error("\tscan_files(); error processing lib: %s" % line)
@@ -46,9 +56,12 @@ def scan_files(libs_and_bins, cmd_max_args, logger):
 			scanned_files[bits][soname] = {}
 		if filename not in scanned_files[bits][soname]:
 			scanned_files[bits][soname][filename] = set(needed)
+			count += 1
 		else:
 			scanned_files[bits][soname][filename].update(needed)
-
+	ftime = current_milli_time()
+	logger.debug("\tscan_files(); total filenames found: %d in %d milliseconds"
+		% (count, ftime-stime))
 	return scanned_files
 
 
@@ -160,6 +173,8 @@ class LibCheck(object):
 				scan_files(). Defaults to the class instance of scanned_files
 		@ returns: dict: {bit_length: {found_lib: set(file_paths)}}.
 		'''
+		stime = current_milli_time()
+		count = 0
 		if not scanned_files:
 			scanned_files = self.scanned_files
 		found_libs = {}
@@ -175,8 +190,13 @@ class LibCheck(object):
 							except KeyError:
 								try:
 									found_libs[bits][l] = set([filename])
+									count += 1
 								except KeyError:
 									found_libs = {bits: {l: set([filename])}}
+									count += 1
+		ftime = current_milli_time()
+		self.logger.debug("\tLibCheck.search(); total libs found: %d in %d milliseconds"
+			% (count, ftime-stime))
 		return found_libs
 
 
@@ -188,6 +208,7 @@ class LibCheck(object):
 				scan_files().  Defaults to the class instance of scanned_files
 		@ returns: list: of filepaths from teh search results.
 		'''
+		stime = current_milli_time()
 		if not scanned_files:
 			scanned_files = self.scanned_files
 		found_pathes = []
@@ -197,6 +218,9 @@ class LibCheck(object):
 				for fp in sorted(files):
 					self.logger.info('\t' +yellow('* ') + fp)
 					found_pathes.append(fp)
+		ftime = current_milli_time()
+		self.logger.debug("\tLibCheck.process_results(); total filepaths found: "
+			"%d in %d milliseconds" % (len(found_pathes), ftime-stime))
 		return found_pathes
 
 
@@ -220,6 +244,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 		#TODO: add partial cache (for ex. only libraries)
 		# when found for some reason
 
+		stime = current_milli_time()
 		logger.warn(green(' * ') +
 			bold('Collecting system binaries and libraries'))
 		bin_dirs, lib_dirs = prepare_search_dirs(logger, settings)
@@ -235,12 +260,16 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 				'/lib64/modules',
 			])
 		)
-
+		ftime = current_milli_time()
+		logger.debug('\ttime to complete task: %d milliseconds' % (ftime-stime))
+		stime = current_milli_time()
 		logger.info(green(' * ') +
 			bold('Collecting dynamic linking informations'))
 		libraries, la_libraries, libraries_links, symlink_pairs = \
 			collect_libraries_from_dir(lib_dirs, masked_dirs, logger)
 		binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
+		ftime = current_milli_time()
+		logger.debug('\ttime to complete task: %d milliseconds' % (ftime-stime))
 
 		if settings['USE_TMP_FILES']:
 			save_cache(logger=logger,

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 40d04b7..2df6532 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -8,6 +8,8 @@ from __future__ import print_function
 
 import os
 import re
+import time
+current_milli_time = lambda: int(round(time.time() * 1000))
 
 import portage
 from portage import portdb
@@ -23,6 +25,7 @@ def assign_packages(broken, logger, settings):
 	''' Finds and returns packages that owns files placed in broken.
 		Broken is list of files
 	'''
+	stime = current_milli_time()
 	assigned_pkgs = set()
 	assigned_filenames = set()
 	for group in os.listdir(settings['PKG_DIR']):
@@ -53,6 +56,10 @@ def assign_packages(broken, logger, settings):
 
 	broken_filenames = set(broken)
 	orphaned = broken_filenames.difference(assigned_filenames)
+	ftime = current_milli_time()
+	logger.debug("\tassign_packages(); assigned "
+		"%d packages, %d orphans in %d milliseconds"
+		% (len(assigned_pkgs), len(orphaned), ftime-stime))
 
 	return (assigned_pkgs, orphaned)
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-12 10:42 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-12 10:42 UTC (permalink / raw
  To: gentoo-commits

commit:     2b2c74c74a042ce20acd74a6f03b1af026e56ffa
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 12 10:37:07 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 12 10:37:07 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=2b2c74c7

revdep_rebuild/assign.py: Add missed green import

---
 pym/gentoolkit/revdep_rebuild/assign.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 5704974..40d04b7 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -11,7 +11,7 @@ import re
 
 import portage
 from portage import portdb
-from portage.output import bold, red, yellow
+from portage.output import bold, red, yellow, green
 
 # Make all str conversions unicode
 try:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-12 10:22 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-12 10:22 UTC (permalink / raw
  To: gentoo-commits

commit:     35a2f04842ceb544dcd6685b5ef87da5b5860c8a
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 12 10:11:25 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 12 10:11:25 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=35a2f048

revdep_rebuild/rebuild.py: Add library search message type for orphaned files.

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 37909b1..843f611 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -241,6 +241,12 @@ def main(settings=None, logger=None):
 	elif orphaned:
 		# blank line for beter visibility of the following lines
 		logger.warn('')
+		if settings['library']:
+			logger.warn(red(' !!! Dependant orphaned files: ') +
+				bold('No installed package was found for the following:'))
+		else:
+			logger.warn(red(' !!! Broken orphaned files: ') +
+				bold('No installed package was found for the following:'))
 		for filename in orphaned:
 			logger.warn(red('\t* ') + filename)
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-12 10:22 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-12 10:22 UTC (permalink / raw
  To: gentoo-commits

commit:     ec50e457e860d12faeb41563ff47ca31e14f1541
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 12 10:12:26 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 12 10:12:26 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=ec50e457

revdep_rebuild/analyse.py: Add docstring to scan_files()

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index b5daff9..3194f48 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -17,7 +17,14 @@ from .cache import save_cache
 
 
 def scan_files(libs_and_bins, cmd_max_args, logger):
-
+	'''Calls stuff.scan() and processes the data into a dictionary
+	of scanned files information.
+
+	@param libs_and_bins: set of libraries and binaries to scan for lib links.
+	@param cmd_max_args: maximum number of files to pass into scanelf calls.
+	@param logger: python style Logging function to use for output.
+	@returns dict: {bit_length: {soname: {filename: set(needed)}}}
+	'''
 	scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...}
 	for line in scan(['-nBF', '%F %f %S %n %M'],
 					 libs_and_bins, cmd_max_args, logger):


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-12 10:22 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-12 10:22 UTC (permalink / raw
  To: gentoo-commits

commit:     d41016eee6a5d40fc77e283a7d49c950d8a171f7
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 12 10:09:36 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 12 10:09:36 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=d41016ee

revdep_rebuild: Unify debug and detail output for a more consistent look.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 13 +++++++------
 pym/gentoolkit/revdep_rebuild/assign.py  | 13 +++++++------
 pym/gentoolkit/revdep_rebuild/cache.py   |  4 ++--
 pym/gentoolkit/revdep_rebuild/collect.py | 10 +++++-----
 pym/gentoolkit/revdep_rebuild/rebuild.py | 10 +++++-----
 pym/gentoolkit/revdep_rebuild/stuff.py   |  4 ++--
 6 files changed, 28 insertions(+), 26 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index daeb4fc..b5daff9 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -23,8 +23,8 @@ def scan_files(libs_and_bins, cmd_max_args, logger):
 					 libs_and_bins, cmd_max_args, logger):
 		parts = line.split(' ')
 		if len(parts) < 5:
-			logger.error("scan_files(); error processing lib: %s" % line)
-			logger.error("scan_files(); parts = %s" % str(parts))
+			logger.error("\tscan_files(); error processing lib: %s" % line)
+			logger.error("\tscan_files(); parts = %s" % str(parts))
 			continue
 		filename, sfilename, soname, needed, bits = parts
 		filename = os.path.realpath(filename)
@@ -86,7 +86,7 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 								if not _break:
 									continue
 
-							logger.info(yellow(' * ') + _file +
+							logger.info('\t' + yellow(' * ') + _file +
 								' is broken (requires: ' + bold(el)+')')
 							broken.append(_file)
 	return broken
@@ -244,7 +244,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 			)
 
 
-	logger.debug('      analyse(), Found %i libraries (+%i symlinks) and %i binaries' %
+	logger.debug('\tanalyse(), Found %i libraries (+%i symlinks) and %i binaries' %
 		(len(libraries), len(libraries_links), len(binaries))
 	)
 	logger.info(green(' * ') + bold('Scanning files'))
@@ -254,8 +254,9 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'], logger)
 
 	logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
-	logger.debug('      analyse(), Searching for %i libs, bins within %i libraries and links' %
-		(len(libs_and_bins), len(libraries)+len(libraries_links))
+	logger.debug(
+		'\tanalyse(), Searching for %i libs, bins within %i libraries and links'
+		% (len(libs_and_bins), len(libraries)+len(libraries_links))
 	)
 
 	libcheck = LibCheck(scanned_files, logger, _libs_to_check)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 8575532..5704974 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -45,7 +45,8 @@ def assign_packages(broken, logger, settings):
 									found = group+'/'+pkg
 									assigned_pkgs.add(found)
 									assigned_filenames.add(m)
-									logger.info('\t' + m + ' -> ' + bold(found))
+									logger.info('\t' + green('* ') + m +
+												' -> ' + bold(found))
 				except Exception as e:
 					logger.warn(red(' !! Failed to read ' + f))
 					logger.warn(red(' !! Error was:' + str(e)))
@@ -67,20 +68,20 @@ def get_best_match(cpv, cp, logger):
 	"""
 
 	slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])
-	logger.warn(yellow('Warning: ebuild "' + cpv + '" not found.'))
-	logger.info('Looking for %s:%s' %(cp, slot))
+	logger.warn('\t' + yellow('Warning: ebuild "' + cpv + '" not found.'))
+	logger.info('\tLooking for %s:%s' %(cp, slot))
 	try:
 		match = portdb.match('%s:%s' %(cp, slot))
 	except portage.exception.InvalidAtom:
 		match = None
 
 	if not match:
-		logger.warn(red('!!') + ' ' + yellow(
+		logger.warn('\t' + red('!!') + ' ' + yellow(
 			'Could not find ebuild for %s:%s' %(cp, slot)))
 		slot = ['']
 		match = portdb.match(cp)
 		if not match:
-			logger.warn(red('!!') + ' ' +
+			logger.warn('\t' + red('!!') + ' ' +
 				yellow('Could not find ebuild for ' + cp))
 	return match, slot
 
@@ -100,7 +101,7 @@ def get_slotted_cps(cpvs, logger):
 		except KeyError:
 			match, slot = get_best_match(cpv, cp, logger)
 			if not match:
-				logger.warn(red("Installed package: "
+				logger.warn('\t' + red("Installed package: "
 					"%s is no longer available" %cp))
 				continue
 

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 862638d..49ddc10 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -62,7 +62,7 @@ def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 				_file.write(line + '\n')
 			_file.close()
 	except Exception as ex:
-		logger.warn(red('Could not save cache: %s' %str(ex)))
+		logger.warn('\t' + red('Could not save cache: %s' %str(ex)))
 
 
 
@@ -90,7 +90,7 @@ def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600,
 		_file .close()
 	except Exception as ex:
 		if logger:
-			logger.debug("check_temp_files(); error retrieving"
+			logger.debug("\tcheck_temp_files(); error retrieving"
 				" timestamp_path:\n" + str(ex))
 		timestamp = 0
 		return False

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index a044398..c4c7a40 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -51,7 +51,7 @@ def parse_conf(conf_file, visited=None, logger=None):
 					else:
 						lib_dirs.add(line)
 		except EnvironmentError:
-			logger.warn(yellow('Error when parsing file %s' %conf))
+			logger.warn('\t' + yellow('Error when parsing file %s' %conf))
 
 	if visited is None:
 		visited = set()
@@ -81,7 +81,7 @@ def prepare_search_dirs(logger, settings):
 			if match is not None:
 				bin_dirs.update(set(match.group(2).split(':')))
 	#except EnvironmentError:
-		#logger.debug(yellow('Could not open file %s' % f))
+		#logger.debug('\t' + yellow('Could not open file %s' % f))
 
 	lib_dirs = parse_conf(settings['DEFAULT_LD_FILE'], logger=logger)
 	return (bin_dirs, lib_dirs)
@@ -189,8 +189,8 @@ def collect_libraries_from_dir(dirs, mask, logger):
 									prv & stat.S_IXOTH == stat.S_IXOTH:
 								found_files.append(listing)
 		except Exception as ex:
-			logger.debug(
-				yellow('      Exception during collecting libraries: ' +
+			logger.debug('\t' +
+				yellow('Exception during collecting libraries: ' +
 				blue('%s')  %str(ex)))
 
 	if found_directories:
@@ -242,7 +242,7 @@ def collect_binaries_from_dir(dirs, mask, logger):
 								prv & stat.S_IXOTH == stat.S_IXOTH:
 							found_files.append(listing)
 		except Exception as ex:
-			logger.debug(
+			logger.debug('\t' +
 				yellow('Exception during binaries collecting: '+
 				blue('%s') %str(ex)))
 

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 21ede45..37909b1 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -217,6 +217,8 @@ def main(settings=None, logger=None):
 			'If you\'re sure, you can add --no-pretend to revdep options')
 		settings['PRETEND'] = True
 
+	logger.debug("\tmain(), _libs_to_check = %s" % str(_libs_to_check))
+
 	if settings['USE_TMP_FILES'] \
 			and check_temp_files(settings['DEFAULT_TMP_DIR'], logger=logger):
 		libraries, la_libraries, libraries_links, binaries = read_cache(
@@ -239,24 +241,22 @@ def main(settings=None, logger=None):
 	elif orphaned:
 		# blank line for beter visibility of the following lines
 		logger.warn('')
-		logger.warn(red('!!! Broken orphaned files: ') +
-			bold('No installed package was found for the following:'))
 		for filename in orphaned:
-			logger.warn(red(' * ') + filename)
+			logger.warn(red('\t* ') + filename)
 
 	has_masked = False
 	tmp = []
 	for ebuild in assigned:
 		if get_masking_status(ebuild):
 			has_masked = True
-			logger.warn('!!! ' + red('All ebuilds that could satisfy: ') +
+			logger.warn(' !!! ' + red('All ebuilds that could satisfy: ') +
 				green(ebuild) + red(' have been masked'))
 		else:
 			tmp.append(ebuild)
 	assigned = tmp
 
 	if has_masked:
-		logger.info(red(' * ') +
+		logger.info('\t' + red('* ') +
 			'Unmask all ebuild(s) listed above and call revdep-rebuild '
 			'again or manually emerge given packages.')
 

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 0608702..e0fc7b5 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -36,7 +36,7 @@ def scan(params, files, max_args, logger):
 
 		@return scanelf output (joined if was called several times)
 	'''
-	logger.debug("      scan(), scanelf params = %s, # files: %d" % (params, len(files)))
+	logger.debug("\tscan(), scanelf params = %s, # files: %d" % (params, len(files)))
 	# change it to a sorted list for group processing
 	_files = sorted(files)
 	out = []
@@ -46,7 +46,7 @@ def scan(params, files, max_args, logger):
 		output = [x for x in output if x != '']
 		if output:
 			out.extend(output)
-	logger.debug("      scan(), final output length: %d" % len(out))
+	logger.debug("\tscan(), final output length: %d" % len(out))
 	return out
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-12 10:22 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-12 10:22 UTC (permalink / raw
  To: gentoo-commits

commit:     da09ff6866ac6a7425996af920d716d8e2ce5d0b
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 12 10:06:51 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Feb 12 10:06:51 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=da09ff68

revdep_rebuild/analyse.py: Create LibCheck class for searching & processing the data.

Move find_broken2() and main_checks2() into the new class.
Rename them to search(), process_results() to better reflect their roles.
Enable the class to do both broken libs searches and specified lib searches.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 128 ++++++++++++++++++++++++-------
 1 file changed, 100 insertions(+), 28 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index fb75bc8..daeb4fc 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -92,34 +92,105 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 	return broken
 
 
-def find_broken2(scanned_files, logger):
-	broken_libs = {}
-	for bits, libs in scanned_files.items():
-		logger.debug('find_broken2(), Checking for %s bit libs' % bits)
-		alllibs = '|'.join(sorted(libs)) + '|'
-		for soname, filepaths in libs.items():
-			for filename, needed in filepaths.items():
-				for l in needed:
-					if l+'|' not in alllibs:
-						try:
-							broken_libs[bits][l].add(filename)
-						except KeyError:
+class LibCheck(object):
+	def __init__(self, scanned_files, logger, searchlibs=None):
+		'''LibCheck init function.
+
+		@param scanned_files: optional dictionary if the type created by
+				scan_files().  Defaults to the class instance of scanned_files
+		@param logger: python style Logging function to use for output.
+		@param searchlibs: optional set() of libraries to search for. If defined
+				it toggles several settings to configure this class for
+				a target search rather than a broken libs search.
+		'''
+		self.scanned_files = scanned_files
+		self.logger = logger
+		self.searchlibs = searchlibs
+		if searchlibs:
+			self.smsg = '\tLibCheck.search(), Checking for %s bit dependants'
+			self.pmsg = yellow(" * ") + 'Files that depend on: %s (%s bits)'
+			self.alllibs = '|'.join(sorted(searchlibs)) + '|'
+			self.setlibs = self._lamda
+			self.check = self._checkforlib
+		else:
+			self.smsg = '\tLibCheck.search(), Checking for broken %s bit libs'
+			self.pmsg = green(' * ') + bold('Broken files that requires:') + ' %s (%s bits)'
+			self.setlibs = self._setlibs
+			self.check = self._checkbroken
+			self.alllibs = None
+
+
+	@staticmethod
+	def _lamda(l):
+		'''Internal function.  Use the class's setlibs variable'''
+		pass
+
+
+	def _setlibs(self, l):
+		'''Internal function.  Use the class's setlibs variable'''
+		self.alllibs = '|'.join(sorted(l)) + '|'
+
+
+	def _checkforlib(self, l):
+		'''Internal function.  Use the class's check variable'''
+		if l:
+			return l+'|' in self.alllibs
+		return False
+
+
+	def _checkbroken(self, l):
+		'''Internal function.  Use the class's check variable'''
+		if l:
+			return l+'|' not in self.alllibs
+		return False
+
+
+	def search(self, scanned_files=None):
+		'''Searches the scanned files for broken lib links
+		or for libs to search for
+
+		@param scanned_files: optional dictionary if the type created by
+				scan_files(). Defaults to the class instance of scanned_files
+		@ returns: dict: {bit_length: {found_lib: set(file_paths)}}.
+		'''
+		if not scanned_files:
+			scanned_files = self.scanned_files
+		found_libs = {}
+		for bits, libs in scanned_files.items():
+			self.setlibs(libs)
+			self.logger.debug(self.smsg % bits)
+			for soname, filepaths in libs.items():
+				for filename, needed in filepaths.items():
+					for l in needed:
+						if self.check(l):
 							try:
-								broken_libs[bits][l] = set([filename])
+								found_libs[bits][l].add(filename)
 							except KeyError:
-								broken_libs = {bits: {l: set([filename])}}
-	return broken_libs
-
-
-def main_checks2(broken, scanned_files, logger):
-	broken_pathes = []
-	for bits, _broken in broken.items():
-		for lib, files in _broken.items():
-			logger.info('Broken files that requires: %s (%s bits)' % (bold(lib), bits))
-			for fp in sorted(files):
-				logger.info(yellow(' * ') + fp)
-				broken_pathes.append(fp)
-	return broken_pathes
+								try:
+									found_libs[bits][l] = set([filename])
+								except KeyError:
+									found_libs = {bits: {l: set([filename])}}
+		return found_libs
+
+
+	def process_results(self, found_libs, scanned_files=None):
+		'''Processes the search results, logs the files found
+
+		@param found_libs: dictionary of the type returned by search()
+		@param scanned_files: optional dictionary if the type created by
+				scan_files().  Defaults to the class instance of scanned_files
+		@ returns: list: of filepaths from teh search results.
+		'''
+		if not scanned_files:
+			scanned_files = self.scanned_files
+		found_pathes = []
+		for bits, found in found_libs.items():
+			for lib, files in found.items():
+				self.logger.info(self.pmsg  % (bold(lib), bits))
+				for fp in sorted(files):
+					self.logger.info('\t' +yellow('* ') + fp)
+					found_pathes.append(fp)
+		return found_pathes
 
 
 def analyse(settings, logger, libraries=None, la_libraries=None,
@@ -187,8 +258,9 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 		(len(libs_and_bins), len(libraries)+len(libraries_links))
 	)
 
-	broken = find_broken2(scanned_files, logger)
-	broken_pathes = main_checks2(broken, scanned_files, logger)
+	libcheck = LibCheck(scanned_files, logger, _libs_to_check)
+
+	broken_pathes = libcheck.process_results(libcheck.search())
 
 	broken_la = extract_dependencies_from_la(la_libraries,
 		libraries+libraries_links, _libs_to_check, logger)


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11 19:39 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11 19:39 UTC (permalink / raw
  To: gentoo-commits

commit:     392a3de48db2d7b56a0919603f5c6e7f80970551
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 19:14:04 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 19:14:04 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=392a3de4

recdep_rebuild: Python 3 fixes.

---
 pym/gentoolkit/revdep_rebuild/cache.py   | 4 ++--
 pym/gentoolkit/revdep_rebuild/collect.py | 9 ++++++++-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 06f4c67..862638d 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -28,7 +28,7 @@ def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 		'binaries':[]
 		}
 	try:
-		for key,val in ret.iteritems():
+		for key,val in ret.items():
 			_file = open(os.path.join(temp_path, key))
 			for line in _file.readlines():
 				val.append(line.strip())
@@ -56,7 +56,7 @@ def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 		_file.write(str(int(time.time())))
 		_file.close()
 
-		for key,val in to_save.iteritems():
+		for key,val in to_save.items():
 			_file = open(os.path.join(temp_path, key), 'w')
 			for line in val:
 				_file.write(line + '\n')

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 55a244c..a044398 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -8,11 +8,18 @@ import re
 import os
 import glob
 import stat
+import sys
 
 import portage
 from portage.output import blue, yellow
 
 
+if sys.hexversion < 0x3000000:
+	_basestring = basestring
+else:
+	_basestring = str
+
+
 def parse_conf(conf_file, visited=None, logger=None):
 	''' Parses supplied conf_file for libraries pathes.
 		conf_file is file or files to parse
@@ -21,7 +28,7 @@ def parse_conf(conf_file, visited=None, logger=None):
 	lib_dirs = set()
 	to_parse = set()
 
-	if isinstance(conf_file, basestring):
+	if isinstance(conf_file, _basestring):
 		conf_file = [conf_file]
 
 	for conf in conf_file:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11 18:49 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11 18:49 UTC (permalink / raw
  To: gentoo-commits

commit:     bf0c591a818d6ddc13b3bb7929f924c529482bed
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 18:31:13 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 18:36:11 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=bf0c591a

revdep_rebuild/assign.py: Remove dead code.

---
 pym/gentoolkit/revdep_rebuild/assign.py | 24 ------------------------
 1 file changed, 24 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index fb2058c..fc10187 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -12,7 +12,6 @@ import re
 import portage
 from portage import portdb
 from portage.output import bold, red, yellow
-#from gentoolkit.package import Package
 
 # Make all str conversions unicode
 try:
@@ -51,29 +50,6 @@ def assign_packages(broken, logger, settings):
 
 	return assigned
 
-	## Map all files in CONTENTS database to package names
-	#fname_pkg_dict = {}
-	#for pkg in pkgset:
-		#contents = Package(pkg).parsed_contents()
-		#for fname in contents.keys():
-			#if contents[fname][0] == "obj":
-				#fname_pkg_dict[fname] = str(pkg)
-
-	#for fname in broken:
-		#realname = os.path.realpath(fname)
-		#if realname in fname_pkg_dict.keys():
-			#pkgname = fname_pkg_dict[realname]
-		#elif fname in fname_pkg_dict.keys():
-			#pkgname = fname_pkg_dict[fname]
-		#else:
-			#pkgname = None
-		#if pkgname and pkgname not in assigned:
-			#assigned.add(pkgname)
-		#if not pkgname:
-			#pkgname = "(none)"
-		#logger.info('\t' + fname + ' -> ' + bold(pkgname))
-
-	#return assigned
 
 def get_best_match(cpv, cp, logger):
 	"""Tries to find another version of the pkg with the same slot


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11 18:49 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11 18:49 UTC (permalink / raw
  To: gentoo-commits

commit:     fe9ab48e320da2f78325b493bf7b41c8799cb019
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 18:33:45 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 18:36:25 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=fe9ab48e

revdep_rebuild: Track and report broken orphaned files.

---
 pym/gentoolkit/revdep_rebuild/assign.py  | 11 ++++++++---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 13 ++++++++++---
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index fc10187..8575532 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -23,7 +23,8 @@ def assign_packages(broken, logger, settings):
 	''' Finds and returns packages that owns files placed in broken.
 		Broken is list of files
 	'''
-	assigned = set()
+	assigned_pkgs = set()
+	assigned_filenames = set()
 	for group in os.listdir(settings['PKG_DIR']):
 		grppath = settings['PKG_DIR'] + group
 		if not os.path.isdir(grppath):
@@ -42,13 +43,17 @@ def assign_packages(broken, logger, settings):
 								m = m.group(1)
 								if m in broken:
 									found = group+'/'+pkg
-									assigned.add(found)
+									assigned_pkgs.add(found)
+									assigned_filenames.add(m)
 									logger.info('\t' + m + ' -> ' + bold(found))
 				except Exception as e:
 					logger.warn(red(' !! Failed to read ' + f))
 					logger.warn(red(' !! Error was:' + str(e)))
 
-	return assigned
+	broken_filenames = set(broken)
+	orphaned = broken_filenames.difference(assigned_filenames)
+
+	return (assigned_pkgs, orphaned)
 
 
 def get_best_match(cpv, cp, logger):

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 81e2b34..21ede45 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -221,7 +221,7 @@ def main(settings=None, logger=None):
 			and check_temp_files(settings['DEFAULT_TMP_DIR'], logger=logger):
 		libraries, la_libraries, libraries_links, binaries = read_cache(
 			settings['DEFAULT_TMP_DIR'])
-		assigned = analyse(
+		assigned, orphaned = analyse(
 			settings=settings,
 			logger=logger,
 			libraries=libraries,
@@ -230,12 +230,19 @@ def main(settings=None, logger=None):
 			binaries=binaries,
 			_libs_to_check=_libs_to_check)
 	else:
-		assigned = analyse(settings, logger, _libs_to_check=_libs_to_check)
+		assigned, orphaned = analyse(settings, logger, _libs_to_check=_libs_to_check)
 
-	if not assigned:
+	if not assigned and not orphaned:
 		logger.warn('\n' + bold('Your system is consistent'))
 		# return the correct exit code
 		return 0
+	elif orphaned:
+		# blank line for beter visibility of the following lines
+		logger.warn('')
+		logger.warn(red('!!! Broken orphaned files: ') +
+			bold('No installed package was found for the following:'))
+		for filename in orphaned:
+			logger.warn(red(' * ') + filename)
 
 	has_masked = False
 	tmp = []


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11 18:49 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11 18:49 UTC (permalink / raw
  To: gentoo-commits

commit:     c5db713779edc9483b8ec30c23338d244a3d406f
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 18:35:31 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 18:36:25 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=c5db7137

revdep_rebuild/analyse.py: Cleanup some debug code, remove a blank line.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 8b6bb23..fb75bc8 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -45,7 +45,6 @@ def scan_files(libs_and_bins, cmd_max_args, logger):
 	return scanned_files
 
 
-
 def extract_dependencies_from_la(la, libraries, to_check, logger):
 	broken = []
 
@@ -98,8 +97,6 @@ def find_broken2(scanned_files, logger):
 	for bits, libs in scanned_files.items():
 		logger.debug('find_broken2(), Checking for %s bit libs' % bits)
 		alllibs = '|'.join(sorted(libs)) + '|'
-		#print(alllibs)
-		#print()
 		for soname, filepaths in libs.items():
 			for filename, needed in filepaths.items():
 				for l in needed:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11 18:49 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11 18:49 UTC (permalink / raw
  To: gentoo-commits

commit:     8ba9173f9c082a432a965621b4282e5bbf510e47
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 18:21:20 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 18:21:20 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=8ba9173f

Fix incorrect reporting of some broken files, pkgs.

Fixes previous commit.
commit: cfeb731d0dc40988cf11f6c225e7082f563d5b18
Brian Dolbec <dolsen <AT> gentoo.org> (Tue 11 Feb 2014 12:08:38 AM PST)
revdep_rebuild/analyse.py: Fix the bug that caused some breakage to not be detected.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 19 +++++++------------
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 8b64835..c416c3c 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -106,28 +106,23 @@ def find_broken2(scanned_files, logger):
 				for l in needed:
 					if l+'|' not in alllibs:
 						try:
-							broken_libs[bits][l].add(soname)
+							broken_libs[bits][l].add(filename)
 						except KeyError:
 							try:
-								broken_libs[bits][l] = set([soname])
+								broken_libs[bits][l] = set([filename])
 							except KeyError:
-								broken_libs = {bits: {l: set([soname])}}
-						#print("BROKEN:", soname, l)
-
+								broken_libs = {bits: {l: set([filename])}}
 	return broken_libs
 
 
 def main_checks2(broken, scanned_files, logger):
 	broken_pathes = []
 	for bits, _broken in broken.items():
-		for lib, needed in _broken.items():
-			#print("lib, needed:", lib, needed)
+		for lib, files in _broken.items():
 			logger.info('Broken files that requires: %s (%s bits)' % (bold(lib), bits))
-			for n in needed:
-				#print(sorted(needed))
-				for fp in sorted(scanned_files[bits][n]):
-					logger.info(yellow(' * ') + n + ' (' + fp + ')')
-					broken_pathes.append(fp)
+			for fp in sorted(files):
+				logger.info(yellow(' * ') + fp)
+				broken_pathes.append(fp)
 	return broken_pathes
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11 18:49 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11 18:49 UTC (permalink / raw
  To: gentoo-commits

commit:     a731b473410c133c9f6b9f5ecf86c00b8cc51669
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 18:27:41 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 18:27:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=a731b473

revdep_rebuild: Minor indent changes for debug messages, improves output.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 4 ++--
 pym/gentoolkit/revdep_rebuild/collect.py | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index c774d9f..8b6bb23 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -176,7 +176,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 			)
 
 
-	logger.debug('analyse(), Found %i libraries (+%i symlinks) and %i binaries' %
+	logger.debug('      analyse(), Found %i libraries (+%i symlinks) and %i binaries' %
 		(len(libraries), len(libraries_links), len(binaries))
 	)
 	logger.info(green(' * ') + bold('Scanning files'))
@@ -186,7 +186,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'], logger)
 
 	logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
-	logger.debug('analyse(), Searching for %i libs, bins within %i libraries and links' %
+	logger.debug('      analyse(), Searching for %i libs, bins within %i libraries and links' %
 		(len(libs_and_bins), len(libraries)+len(libraries_links))
 	)
 

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index b1d1eeb..55a244c 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -183,7 +183,7 @@ def collect_libraries_from_dir(dirs, mask, logger):
 								found_files.append(listing)
 		except Exception as ex:
 			logger.debug(
-				yellow('Exception during collecting libraries: ' +
+				yellow('      Exception during collecting libraries: ' +
 				blue('%s')  %str(ex)))
 
 	if found_directories:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11 18:49 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11 18:49 UTC (permalink / raw
  To: gentoo-commits

commit:     d9f4c8c06b9536de14d5b0d88c32957755df6108
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 18:24:16 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 18:24:16 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=d9f4c8c0

revdep_rebuild: Add logger parameter to scan_files(), scan()

Convert earlier debug print()s to logging.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 13 ++++++-------
 pym/gentoolkit/revdep_rebuild/stuff.py   |  8 ++++----
 2 files changed, 10 insertions(+), 11 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index c416c3c..c774d9f 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -16,14 +16,15 @@ from .assign import assign_packages
 from .cache import save_cache
 
 
-def scan_files(libs_and_bins, cmd_max_args):
+def scan_files(libs_and_bins, cmd_max_args, logger):
 
 	scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...}
-	for line in scan(['-nBF', '%F %f %S %n %M'], libs_and_bins, cmd_max_args):
+	for line in scan(['-nBF', '%F %f %S %n %M'],
+					 libs_and_bins, cmd_max_args, logger):
 		parts = line.split(' ')
 		if len(parts) < 5:
-			print("scan_files(); error processing lib: %s" % line)
-			print("scan_files(); parts = %s" % str(parts))
+			logger.error("scan_files(); error processing lib: %s" % line)
+			logger.error("scan_files(); parts = %s" % str(parts))
 			continue
 		filename, sfilename, soname, needed, bits = parts
 		filename = os.path.realpath(filename)
@@ -41,8 +42,6 @@ def scan_files(libs_and_bins, cmd_max_args):
 		else:
 			scanned_files[bits][soname][filename].update(needed)
 
-	#print("scanned_files['64'] =")
-	#print(scanned_files['64'])
 	return scanned_files
 
 
@@ -184,7 +183,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 
 	libs_and_bins = set(libraries + binaries)
 
-	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'])
+	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'], logger)
 
 	logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
 	logger.debug('analyse(), Searching for %i libs, bins within %i libraries and links' %

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 7f8c574..0608702 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -24,7 +24,7 @@ def call_program(args):
 	return str(stdout)
 
 
-def scan(params, files, max_args):
+def scan(params, files, max_args, logger):
 	''' Calls scanelf with given params and files to scan.
 		@param params is list of parameters that should
 			be passed into scanelf app.
@@ -36,8 +36,8 @@ def scan(params, files, max_args):
 
 		@return scanelf output (joined if was called several times)
 	'''
-	#print("SCAN(), params = ", params, len(files))
-	# change it to a list for group processing
+	logger.debug("      scan(), scanelf params = %s, # files: %d" % (params, len(files)))
+	# change it to a sorted list for group processing
 	_files = sorted(files)
 	out = []
 	for i in range(0, len(_files), max_args):
@@ -46,7 +46,7 @@ def scan(params, files, max_args):
 		output = [x for x in output if x != '']
 		if output:
 			out.extend(output)
-	#print("SCAN(), final output length:", len(out))
+	logger.debug("      scan(), final output length: %d" % len(out))
 	return out
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     5ed37394edd07ed052f7da897c6112324385d510
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 07:34:32 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:09:22 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=5ed37394

revdep_rebuild/analyse.py: Fix a long line.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index cdbf537..8b64835 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -199,7 +199,8 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	broken = find_broken2(scanned_files, logger)
 	broken_pathes = main_checks2(broken, scanned_files, logger)
 
-	broken_la = extract_dependencies_from_la(la_libraries, libraries+libraries_links, _libs_to_check, logger)
+	broken_la = extract_dependencies_from_la(la_libraries,
+		libraries+libraries_links, _libs_to_check, logger)
 	broken_pathes += broken_la
 
 	logger.warn(green(' * ') + bold('Assign files to packages'))


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     283a06f819c669268bbc06c5f7f4e640566cf2dc
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 07:36:34 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:09:22 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=283a06f8

revdep_rebuild/collect.py: remove some blank lines.

---
 pym/gentoolkit/revdep_rebuild/collect.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 6057080..b1d1eeb 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -186,7 +186,6 @@ def collect_libraries_from_dir(dirs, mask, logger):
 				yellow('Exception during collecting libraries: ' +
 				blue('%s')  %str(ex)))
 
-
 	if found_directories:
 		_file, la_file, link, pair = \
 			collect_libraries_from_dir(found_directories, mask, logger)
@@ -194,7 +193,6 @@ def collect_libraries_from_dir(dirs, mask, logger):
 		found_la_files += la_file
 		found_symlinks += link
 		symlink_pairs += pair
-
 	return (found_files, found_la_files, found_symlinks, symlink_pairs)
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     8f70e214507ce7aa4a2e0170ad427536e71768ca
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 07:37:50 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:09:23 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=8f70e214

revdep_rebuild/assign.py: assigned is a set, remove redundant if statement.

---
 pym/gentoolkit/revdep_rebuild/assign.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index fe56129..fb2058c 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -43,8 +43,7 @@ def assign_packages(broken, logger, settings):
 								m = m.group(1)
 								if m in broken:
 									found = group+'/'+pkg
-									if found not in assigned:
-										assigned.add(found)
+									assigned.add(found)
 									logger.info('\t' + m + ' -> ' + bold(found))
 				except Exception as e:
 					logger.warn(red(' !! Failed to read ' + f))


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     f8fa6f768bfd8b1682724dc5f0ee2bf41bb1d5e1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 07:35:50 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:09:22 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=f8fa6f76

revdep_rebuild/collect.py: Fix unknown variables.

---
 pym/gentoolkit/revdep_rebuild/collect.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 281c156..6057080 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -264,8 +264,8 @@ if __name__ == '__main__':
 	)
 
 	libraries, la_libraries, libraries_links, msymlink_pairs = \
-		collect_libraries_from_dir(mlib_dirs, mmasked_dirs, logging)
-	binaries = collect_binaries_from_dir(mbin_dirs, mmasked_dirs, logging)
+		collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
+	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
 
 	logging.debug(
 		'Found: %i binaries and %i libraries.' %(


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     f6a7b7cad3df68cc62a2784f7f922adaa91848f2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 08:00:38 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:09:23 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=f6a7b7ca

revdep_rebuild/stuff.py: Sort the set of files to scan.

Comment out the debug print()s.
Sorting was also a double check that the new scan_files() processing was correct.
It previously failed to find the same breakage when the list was sorted.

---
 pym/gentoolkit/revdep_rebuild/stuff.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 817396e..7f8c574 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -36,9 +36,9 @@ def scan(params, files, max_args):
 
 		@return scanelf output (joined if was called several times)
 	'''
-	print("SCAN(), params = ", params, len(files))
-	# change it to a sorted list for group processing
-	_files = list(files)
+	#print("SCAN(), params = ", params, len(files))
+	# change it to a list for group processing
+	_files = sorted(files)
 	out = []
 	for i in range(0, len(_files), max_args):
 		output = call_program(
@@ -46,7 +46,7 @@ def scan(params, files, max_args):
 		output = [x for x in output if x != '']
 		if output:
 			out.extend(output)
-	print("SCAN(), final output length:", len(out))
+	#print("SCAN(), final output length:", len(out))
 	return out
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     276eabfceb04d74aad206d2e85394759bdc00658
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 16:48:07 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:06:34 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=276eabfc

revdep_rebuild/cache.py: Remove inccorrect bash shebang.

---
 pym/gentoolkit/revdep_rebuild/cache.py | 1 -
 1 file changed, 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 0a250d3..45b86bd 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -1,4 +1,3 @@
-#!/bin/bash
 
 """Caching module
 Functions for reading, saving and verifying the data caches


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     6f420c5883d10511f7d339a6843de3be74b0eb68
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 07:31:59 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:09:22 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=6f420c58

revdep-rebuild: Use set().update() instead of set().union().

---
 pym/gentoolkit/revdep_rebuild/analyse.py |  6 +++---
 pym/gentoolkit/revdep_rebuild/cache.py   |  6 +++---
 pym/gentoolkit/revdep_rebuild/collect.py | 18 +++++++++---------
 pym/gentoolkit/revdep_rebuild/rebuild.py |  2 +-
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 131849b..6f1787a 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -157,9 +157,9 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 
 		masked_dirs, masked_files, ld = \
 			parse_revdep_config(settings['REVDEP_CONFDIR'])
-		lib_dirs = lib_dirs.union(ld)
-		bin_dirs = bin_dirs.union(ld)
-		masked_dirs = masked_dirs.union(
+		lib_dirs.update(ld)
+		bin_dirs.update(ld)
+		masked_dirs.update(
 			set([
 				'/lib/modules',
 				'/lib32/modules',

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 45b86bd..06f4c67 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -110,9 +110,9 @@ if __name__ == '__main__':
 	bin_dirs, lib_dirs = prepare_search_dirs()
 
 	masked_dirs, masked_files, ld = parse_revdep_config()
-	lib_dirs = lib_dirs.union(ld)
-	bin_dirs = bin_dirs.union(ld)
-	masked_dirs = masked_dirs.union(
+	lib_dirs.update(ld)
+	bin_dirs.update(ld)
+	masked_dirs.update(
 		set([
 			'/lib/modules',
 			'/lib32/modules',

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index f8ee60d..281c156 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -40,7 +40,7 @@ def parse_conf(conf_file, visited=None, logger=None):
 							else:
 								path = included
 
-							to_parse = to_parse.union(glob.glob(path))
+							to_parse.update(glob.glob(path))
 					else:
 						lib_dirs.add(line)
 		except EnvironmentError:
@@ -49,10 +49,10 @@ def parse_conf(conf_file, visited=None, logger=None):
 	if visited is None:
 		visited = set()
 
-	visited = visited.union(conf_file)
+	visited.update(conf_file)
 	to_parse = to_parse.difference(visited)
 	if to_parse:
-		lib_dirs = lib_dirs.union(parse_conf(to_parse, visited, logger=logger))
+		lib_dirs.update(parse_conf(to_parse, visited, logger=logger))
 
 	return lib_dirs
 
@@ -96,19 +96,19 @@ def parse_revdep_config(revdep_confdir):
 				match = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
 				if match is not None:
 					masks = match.group(1).split(' ')
-					masked_files = masked_files.union(masks)
+					masked_files.update(masks)
 					continue
 				match = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
 				if match is not None:
 					searches = match.group(1).split(' ')
 					for search in searches:
-						masked_dirs = masked_dirs.union(glob.glob(search))
+						masked_dirs.update(glob.glob(search))
 					continue
 				match = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
 				if match is not None:
 					searches = match.group(1).split()
 					for search in searches:
-						search_dirs = search_dirs.union(glob.glob(search))
+						search_dirs.update(glob.glob(search))
 					continue
 
 	return (masked_dirs, masked_files, search_dirs)
@@ -253,9 +253,9 @@ if __name__ == '__main__':
 	bin_dirs, lib_dirs = prepare_search_dirs(logging)
 
 	masked_dirs, masked_files, ld = parse_revdep_config()
-	lib_dirs = lib_dirs.union(ld)
-	bin_dirs = bin_dirs.union(ld)
-	masked_dirs = masked_dirs.union(
+	lib_dirs.update(ld)
+	bin_dirs.update(ld)
+	masked_dirs.update(
 		set([
 			'/lib/modules',
 			'/lib32/modules',

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 888fa47..81e2b34 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -124,7 +124,7 @@ def parse_options():
 			elif key in ('-C', '--nocolor', '--no-color'):
 				settings['nocolor'] = True
 			elif key in ('-L', '--library', '--library='):
-				settings['library'] = settings['library'].union(val.split(','))
+				settings['library'].update(val.split(','))
 			elif key in ('-i', '--ignore'):
 				settings['USE_TMP_FILES'] = False
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     7b700febab305270afd3a05e4742ab733eddfc1d
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 17:01:16 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:07:14 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=7b700feb

revdep_rebuild/stuff.py: Remove unused exithandler()

---
 pym/gentoolkit/revdep_rebuild/stuff.py | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index aa91be2..ea27ef2 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -46,10 +46,6 @@ def scan(params, files, max_args):
 	return out
 
 
-def exithandler(signum, frame):
-	sys.exit(1)
-
-
 def get_masking_status(ebuild):
 	"""returns the masking status of an ebuild
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     7f9d43fa1cc2b5c3785443d0ae8ec97ddd3a5deb
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 17:03:02 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:07:35 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=7f9d43fa

revdep_rebuild/analyse.py: Fix default parameter assignment.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 079157a..6ef4d90 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -201,7 +201,7 @@ def main_checks2(broken, scanned_files, logger):
 
 
 def analyse(settings, logger, libraries=None, la_libraries=None,
-		libraries_links=None, binaries=None, _libs_to_check=set()):
+		libraries_links=None, binaries=None, _libs_to_check=None):
 	"""Main program body.  It will collect all info and determine the
 	pkgs needing rebuilding.
 
@@ -211,6 +211,8 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	@rtype list: list of pkgs that need rebuilding
 	"""
 
+	if _libs_to_check == None:
+		_libs_to_check = set()
 	if libraries and la_libraries and libraries_links and binaries:
 		logger.info(blue(' * ') +
 			bold('Found a valid cache, skipping collecting phase'))


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     f8360d99befc33909d0769464c209806777e7db2
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 20:27:45 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:07:35 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=f8360d99

revdep_rebuild: Remove duplicate files for the scanelf checks.

Convert the file lists to a set to remove teh duplicates.  This can reduce the number of files to nealry half.
Convert it back to a list for the scanelf loop for easier batch processing.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 2 +-
 pym/gentoolkit/revdep_rebuild/stuff.py   | 8 ++++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 6ef4d90..9cee906 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -256,7 +256,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	)
 	logger.info(green(' * ') + bold('Scanning files'))
 
-	libs_and_bins = libraries+binaries
+	libs_and_bins = set(libraries + binaries)
 
 	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'])
 

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index ea27ef2..817396e 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -36,13 +36,17 @@ def scan(params, files, max_args):
 
 		@return scanelf output (joined if was called several times)
 	'''
+	print("SCAN(), params = ", params, len(files))
+	# change it to a sorted list for group processing
+	_files = list(files)
 	out = []
-	for i in range(0, len(files), max_args):
+	for i in range(0, len(_files), max_args):
 		output = call_program(
-			['scanelf'] + params + files[i:i+max_args]).strip().split('\n')
+			['scanelf'] + params + _files[i:i+max_args]).strip().split('\n')
 		output = [x for x in output if x != '']
 		if output:
 			out.extend(output)
+	print("SCAN(), final output length:", len(out))
 	return out
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     1ef7ee6bde1b12946471db650f27d0b0de9226e5
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 03:34:45 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:08:06 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=1ef7ee6b

revdep_rebuild/analyse.py: Remove unused or commented out code

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 132 -------------------------------
 1 file changed, 132 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 9cee906..e2e1edd 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -16,43 +16,6 @@ from .assign import assign_packages
 from .cache import save_cache
 
 
-def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
-	''' Calls scanelf for all files_to_check,
-	then returns found libraries and dependencies
-	'''
-
-	# libs found by scanelf
-	libs = []
-	# list of lists of files (from file_to_check) that uses
-	# library (for dependencies[id] and libs[id] => id==id)
-	dependencies = []
-
-	bits = []
-
-
-#	from runner import ScanRunner
-#	sr = ScanRunner(['-M', str(bits), '-nBF', '%F %n'], files_to_check, cmd_max_args)
-#	sr.wait()
-
-	for line in scan(['-M', str(bits), '-nBF', '%F %n %M'], files_to_check, cmd_max_args):
-	#call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
-		r = line.strip().split(' ')
-		if len(r) < 2: # no dependencies?
-			continue
-
-		deps = r[1].split(',')
-		for d in deps:
-			if d in libs:
-				i = libs.index(d)
-				dependencies[i].append(r[0])
-			else:
-				#print d, 'bits:', r[2][8:] # 8: -> strlen('ELFCLASS')
-				libs.append(d)
-				dependencies.append([r[0],])
-
-	return (libs, dependencies)
-
-
 def scan_files(libs_and_bins, cmd_max_args):
 
 	scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...}
@@ -125,32 +88,6 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 	return broken
 
 
-def find_broken(found_libs, system_libraries, to_check):
-	''' Search for broken libraries.
-		Check if system_libraries contains found_libs, where
-		system_libraries is list of obsolute pathes and found_libs
-		is list of library names.
-	'''
-
-	# join libraries and looking at it as string
-	# is way faster than for-jumping
-
-	broken = []
-	syslibs = '|'.join(system_libraries)
-
-	if not to_check:
-		for found in found_libs:
-			if found + '|' not in syslibs:
-				broken.append(found_libs.index(found))
-	else:
-		for tc in to_check:
-			for found in found_libs:
-				if tc in found:# and found+'|' not in syslibs:
-					broken.append(found_libs.index(found))
-
-	return broken
-
-
 def find_broken2(scanned_files, logger):
 	broken_libs = {}
 	for bits, libs in scanned_files.items():
@@ -170,24 +107,6 @@ def find_broken2(scanned_files, logger):
 	return broken_libs
 
 
-def main_checks(found_libs, broken_list, dependencies, logger):
-	''' Checks for broken dependencies.
-		found_libs have to be the same as returned by prepare_checks
-		broken_list is list of libraries found by scanelf
-		dependencies is the value returned by prepare_checks
-	'''
-
-	broken_pathes = []
-
-	for broken in broken_list:
-		found = found_libs[broken]
-		logger.info('Broken files that requires: ' + bold(found))
-		for dep_path in dependencies[broken]:
-			logger.info(yellow(' * ') + dep_path)
-			broken_pathes.append(dep_path)
-	return broken_pathes
-
-
 def main_checks2(broken, scanned_files, logger):
 	broken_pathes = []
 	for bits, _broken in broken.items():
@@ -275,57 +194,6 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 
 	return assign_packages(broken_pathes, logger, settings)
 
-	#import sys
-	#sys.exit()
-
-	#l = []
-	#for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'):
-		#l.append(line)
-	#libraries = l
-
-	## old version from here
-	#found_libs = []
-	#dependencies = []
-
-	#if _libs_to_check:
-		#nltc = []
-		#for ltc in _libs_to_check:
-			#if os.path.isfile(ltc):
-				#ltc = scan(['-nBSF', '%S'], [ltc,], settings['CMD_MAX_ARGS'])[0].split()[0]
-			#nltc += [ltc,]
-		#_libs_to_check = nltc
-
-	#_bits, linkg = platform.architecture()
-	#if _bits.startswith('32'):
-		#bits = 32
-	#elif _bits.startswith('64'):
-		#bits = 64
-
-	#import time
-	#broken = []
-	#for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
-		#bits = int(av_bits[4:])
-
-		##_libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, settings['CMD_MAX_ARGS'])
-		#_libraries = libraries+libraries_links
-
-		#found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits, settings['CMD_MAX_ARGS'])
-		#broken = find_broken(found_libs, _libraries, _libs_to_check)
-
-		#bits /= 2
-		#bits = int(bits)
-
-	#broken_la = extract_dependencies_from_la(la_libraries, libraries+libraries_links, _libs_to_check, logger)
-
-
-	#broken_pathes = main_checks(found_libs, broken, dependencies, logger)
-	#broken_pathes += broken_la
-
-	#logger.warn(green(' * ') + bold('Assign files to packages'))
-
-	#return assign_packages(broken_pathes, logger, settings)
-
-
 
 if __name__ == '__main__':
 	print("This script shouldn't be called directly")


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     68f8234770afccdd6d37916f6bb095cb4fb7a892
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 07:33:46 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:09:22 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=68f82347

revdep-rebuild: Add the function name to the debug messages

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 6f1787a..cdbf537 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -182,7 +182,7 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 			)
 
 
-	logger.debug('Found %i libraries (+%i symlinks) and %i binaries' %
+	logger.debug('analyse(), Found %i libraries (+%i symlinks) and %i binaries' %
 		(len(libraries), len(libraries_links), len(binaries))
 	)
 	logger.info(green(' * ') + bold('Scanning files'))
@@ -192,8 +192,8 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'])
 
 	logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
-	logger.debug('Search for %i within %i' %
-		(len(binaries)+len(libraries), len(libraries)+len(libraries_links))
+	logger.debug('analyse(), Searching for %i libs, bins within %i libraries and links' %
+		(len(libs_and_bins), len(libraries)+len(libraries_links))
 	)
 
 	broken = find_broken2(scanned_files, logger)


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     cfeb731d0dc40988cf11f6c225e7082f563d5b18
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 11 07:26:27 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:08:38 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=cfeb731d

revdep_rebuild/analyse.py: Fix the bug that caused some breakage to not be detected.

scan_files() was not tracking the filenames and needed correctly.
This was causing data loss for files that need to be checked.
I found there could be several filenames for any given soname.
Each filename has a set of needed libs to track.
find_broken2 and main_checks2 needed updating for the different scanned_files structure.

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 50 ++++++++++++++++++++------------
 1 file changed, 31 insertions(+), 19 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index e2e1edd..131849b 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -32,11 +32,17 @@ def scan_files(libs_and_bins, cmd_max_args):
 		if not soname:
 			soname = sfilename
 
-		try:
-			scanned_files[bits][soname] = (filename, needed)
-		except KeyError:
+		if bits not in scanned_files:
 			scanned_files[bits] = {}
-			scanned_files[bits][soname] = (filename, needed)
+		if soname not in scanned_files[bits]:
+			scanned_files[bits][soname] = {}
+		if filename not in scanned_files[bits][soname]:
+			scanned_files[bits][soname][filename] = set(needed)
+		else:
+			scanned_files[bits][soname][filename].update(needed)
+
+	#print("scanned_files['64'] =")
+	#print(scanned_files['64'])
 	return scanned_files
 
 
@@ -91,18 +97,22 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 def find_broken2(scanned_files, logger):
 	broken_libs = {}
 	for bits, libs in scanned_files.items():
-		logger.debug('Checking for bits: %s' % bits)
-		alllibs = '|'.join(libs.keys()) + '|'
-		for soname, needed in libs.items():
-			for l in needed[1]:
-				if not l+'|' in alllibs:
-					try:
-						broken_libs[bits][l].add(soname)
-					except KeyError:
+		logger.debug('find_broken2(), Checking for %s bit libs' % bits)
+		alllibs = '|'.join(sorted(libs)) + '|'
+		#print(alllibs)
+		#print()
+		for soname, filepaths in libs.items():
+			for filename, needed in filepaths.items():
+				for l in needed:
+					if l+'|' not in alllibs:
 						try:
-							broken_libs[bits][l] = set([soname])
+							broken_libs[bits][l].add(soname)
 						except KeyError:
-							broken_libs = {bits: {l: set([soname])}}
+							try:
+								broken_libs[bits][l] = set([soname])
+							except KeyError:
+								broken_libs = {bits: {l: set([soname])}}
+						#print("BROKEN:", soname, l)
 
 	return broken_libs
 
@@ -110,12 +120,14 @@ def find_broken2(scanned_files, logger):
 def main_checks2(broken, scanned_files, logger):
 	broken_pathes = []
 	for bits, _broken in broken.items():
-		for soname, needed in _broken.items():
-			logger.info('Broken files that requires: %s (%s bits)' % (bold(soname), bits))
+		for lib, needed in _broken.items():
+			#print("lib, needed:", lib, needed)
+			logger.info('Broken files that requires: %s (%s bits)' % (bold(lib), bits))
 			for n in needed:
-				fp = scanned_files[bits][n][0]
-				logger.info(yellow(' * ') + n  + ' (' + fp + ')')
-				broken_pathes.append(fp)
+				#print(sorted(needed))
+				for fp in sorted(scanned_files[bits][n]):
+					logger.info(yellow(' * ') + n + ' (' + fp + ')')
+					broken_pathes.append(fp)
 	return broken_pathes
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     def28142f9b0106486c03a0b3f86e9a4aa014b70
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 16:44:53 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:05:14 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=def28142

revdep_rebuild/rebuild.py: Add missing logger.warn() call

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index a4f6544..48a8ec6 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -211,6 +211,7 @@ def main(settings=None, logger=None):
 		logger.warn(blue(' * ') +
 			yellow('This is a development version, '
 				'so it may not work correctly'))
+		logger.warn(blue(' * ') +
 			yellow('Adding --pretend to portage options anyway'))
 		logger.info(blue(' * ') +
 			'If you\'re sure, you can add --no-pretend to revdep options')


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     ab9e5871becd130c7463c9944e1a8f5f6e0f60c9
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 16:45:38 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:05:36 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=ab9e5871

revdep_rebuild/assign.py: Fix unused error assignment

---
 pym/gentoolkit/revdep_rebuild/assign.py | 1 +
 1 file changed, 1 insertion(+)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 11f7178..fe56129 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -48,6 +48,7 @@ def assign_packages(broken, logger, settings):
 									logger.info('\t' + m + ' -> ' + bold(found))
 				except Exception as e:
 					logger.warn(red(' !! Failed to read ' + f))
+					logger.warn(red(' !! Error was:' + str(e)))
 
 	return assigned
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     70edf148e08d843abe5c2a8bea262dc5e98330e1
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 16:36:15 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:03:31 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=70edf148

revdep_rebuild: Initial pyflakes import and variable cleanup.

Comment out some unused code for now which were causing some variable errors in pyflakes.

---
 pym/gentoolkit/revdep_rebuild/analyse.py |  9 ++----
 pym/gentoolkit/revdep_rebuild/assign.py  | 50 +++++++++++++++-----------------
 2 files changed, 27 insertions(+), 32 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index a32ea05..4b79c2b 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -6,8 +6,6 @@ from __future__ import print_function
 
 import os
 import re
-import platform
-import glob
 
 from portage.output import bold, blue, yellow, green
 
@@ -56,7 +54,6 @@ def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
 
 
 def scan_files(libs_and_bins, cmd_max_args):
-	import os
 
 	scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...}
 	for line in scan(['-nBF', '%F %f %S %n %M'], libs_and_bins, cmd_max_args):
@@ -184,7 +181,7 @@ def main_checks(found_libs, broken_list, dependencies, logger):
 
 	for broken in broken_list:
 		found = found_libs[broken]
-		logger.info('Broken files that requires: ' + bold(f))
+		logger.info('Broken files that requires: ' + bold(found))
 		for dep_path in dependencies[broken]:
 			logger.info(yellow(' * ') + dep_path)
 			broken_pathes.append(dep_path)
@@ -276,9 +273,9 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 
 	return assign_packages(broken_pathes, logger, settings)
 
-	import sys
-	sys.exit()
 	
+	#import sys
+	#sys.exit()
 	#l = []
 	#for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'):
 		#l.append(line)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 2a93fe1..4842ea9 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -10,11 +10,9 @@ import os
 import re
 
 import portage
-from portage.versions import catpkgsplit
 from portage import portdb
 from portage.output import bold, red, yellow
-from gentoolkit.helpers import get_installed_cpvs
-from gentoolkit.package import Package
+#from gentoolkit.package import Package
 
 # Make all str conversions unicode
 try:
@@ -47,29 +45,29 @@ def assign_packages(broken, logger, settings):
 
 	return assigned
 
-	# Map all files in CONTENTS database to package names
-	fname_pkg_dict = {}
-	for pkg in pkgset:
-		contents = Package(pkg).parsed_contents()
-		for fname in contents.keys():
-			if contents[fname][0] == "obj":
-				fname_pkg_dict[fname] = str(pkg)
-
-	for fname in broken:
-		realname = os.path.realpath(fname)
-		if realname in fname_pkg_dict.keys():
-			pkgname = fname_pkg_dict[realname]
-		elif fname in fname_pkg_dict.keys():
-			pkgname = fname_pkg_dict[fname]
-		else:
-			pkgname = None
-		if pkgname and pkgname not in assigned:
-			assigned.add(pkgname)
-		if not pkgname:
-			pkgname = "(none)"
-		logger.info('\t' + fname + ' -> ' + bold(pkgname))
-
-	return assigned
+	## Map all files in CONTENTS database to package names
+	#fname_pkg_dict = {}
+	#for pkg in pkgset:
+		#contents = Package(pkg).parsed_contents()
+		#for fname in contents.keys():
+			#if contents[fname][0] == "obj":
+				#fname_pkg_dict[fname] = str(pkg)
+
+	#for fname in broken:
+		#realname = os.path.realpath(fname)
+		#if realname in fname_pkg_dict.keys():
+			#pkgname = fname_pkg_dict[realname]
+		#elif fname in fname_pkg_dict.keys():
+			#pkgname = fname_pkg_dict[fname]
+		#else:
+			#pkgname = None
+		#if pkgname and pkgname not in assigned:
+			#assigned.add(pkgname)
+		#if not pkgname:
+			#pkgname = "(none)"
+		#logger.info('\t' + fname + ' -> ' + bold(pkgname))
+
+	#return assigned
 
 def get_best_match(cpv, cp, logger):
 	"""Tries to find another version of the pkg with the same slot


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     a479fdadc1f806fa018887512cf4c32f6a298bd8
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 16:47:20 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:06:11 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=a479fdad

revdep_rebuild: Fix missing logger variable in check_temp_files().

---
 pym/gentoolkit/revdep_rebuild/cache.py   | 3 ++-
 pym/gentoolkit/revdep_rebuild/rebuild.py | 2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 42bf1ea..0a250d3 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -67,7 +67,8 @@ def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 
 
 
-def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600):
+def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600,
+		logger=None):
 	''' Checks if temporary files from previous run are still available
 		and if they aren't too old
 		@param temp_path is directory, where temporary files should be found

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 48a8ec6..888fa47 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -218,7 +218,7 @@ def main(settings=None, logger=None):
 		settings['PRETEND'] = True
 
 	if settings['USE_TMP_FILES'] \
-			and check_temp_files(settings['DEFAULT_TMP_DIR']):
+			and check_temp_files(settings['DEFAULT_TMP_DIR'], logger=logger):
 		libraries, la_libraries, libraries_links, binaries = read_cache(
 			settings['DEFAULT_TMP_DIR'])
 		assigned = analyse(


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     aed173120942ee652be1844b6a020136de31f4c7
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 16:29:40 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:02:48 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=aed17312

revdep_rebuild: Fix tracebacks due to empy results returned from scanelf calls.

Add blank line removal to scan().
Add incorrect parts length detection to scan_files()  (just in case)

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 7 ++++++-
 pym/gentoolkit/revdep_rebuild/stuff.py   | 5 ++++-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 7b17517..a32ea05 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -60,7 +60,12 @@ def scan_files(libs_and_bins, cmd_max_args):
 
 	scanned_files = {} # {bits: {soname: (filename, needed), ...}, ...}
 	for line in scan(['-nBF', '%F %f %S %n %M'], libs_and_bins, cmd_max_args):
-		filename, sfilename, soname, needed, bits = line.split(' ')
+		parts = line.split(' ')
+		if len(parts) < 5:
+			print("scan_files(); error processing lib: %s" % line)
+			print("scan_files(); parts = %s" % str(parts))
+			continue
+		filename, sfilename, soname, needed, bits = parts
 		filename = os.path.realpath(filename)
 		needed = needed.split(',')
 		bits = bits[8:] # 8: -> strlen('ELFCLASS')

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 0bebce2..aa91be2 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -38,8 +38,11 @@ def scan(params, files, max_args):
 	'''
 	out = []
 	for i in range(0, len(files), max_args):
-		out += call_program(
+		output = call_program(
 			['scanelf'] + params + files[i:i+max_args]).strip().split('\n')
+		output = [x for x in output if x != '']
+		if output:
+			out.extend(output)
 	return out
 
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     4146685fe619563f014e70613409ff26a891b808
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 16:43:55 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:04:53 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4146685f

revdep_rebuild/rebuild.pt: Remove unused variables

---
 pym/gentoolkit/revdep_rebuild/rebuild.py | 2 --
 1 file changed, 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 95f2b5e..a4f6544 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -103,7 +103,6 @@ def parse_options():
 			'keep-temp', 'library=', 'no-ld-path', 'no-order',
 			'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose'])
 
-		do_help = False
 		for key, val in opts:
 			if key in ('-h', '--help'):
 				print_usage()
@@ -217,7 +216,6 @@ def main(settings=None, logger=None):
 			'If you\'re sure, you can add --no-pretend to revdep options')
 		settings['PRETEND'] = True
 
-	analyze_cache = {}
 	if settings['USE_TMP_FILES'] \
 			and check_temp_files(settings['DEFAULT_TMP_DIR']):
 		libraries, la_libraries, libraries_links, binaries = read_cache(


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     38c80ed1434f0b03b0d7c5fa2095f3310f913c36
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 16:41:04 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:04:10 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=38c80ed1

revdep_rebuild/assign.py: Make assign_packages() ignore files found in /var/db/pkg/

---
 pym/gentoolkit/revdep_rebuild/assign.py | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 4842ea9..11f7178 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -26,8 +26,14 @@ def assign_packages(broken, logger, settings):
 	'''
 	assigned = set()
 	for group in os.listdir(settings['PKG_DIR']):
-		for pkg in os.listdir(settings['PKG_DIR'] + group):
-			f = settings['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
+		grppath = settings['PKG_DIR'] + group
+		if not os.path.isdir(grppath):
+			continue
+		for pkg in os.listdir(grppath):
+			pkgpath = settings['PKG_DIR'] + group + '/' + pkg
+			if not os.path.isdir(pkgpath):
+				continue
+			f = pkgpath + '/CONTENTS'
 			if os.path.exists(f):
 				try:
 					with open(f, 'r') as cnt:


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2014-02-11  8:40 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2014-02-11  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     4e1cf9a4949072a02c7857dd5715e0dd42116238
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 16:38:19 2014 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Feb 11 08:03:54 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4e1cf9a4

revdep_rebuild: Whitespace cleanup

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 18 +++++++++---------
 pym/gentoolkit/revdep_rebuild/cache.py   |  8 ++++----
 pym/gentoolkit/revdep_rebuild/rebuild.py |  5 ++---
 3 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 4b79c2b..079157a 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -49,7 +49,7 @@ def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
 				#print d, 'bits:', r[2][8:] # 8: -> strlen('ELFCLASS')
 				libs.append(d)
 				dependencies.append([r[0],])
-	
+
 	return (libs, dependencies)
 
 
@@ -68,7 +68,7 @@ def scan_files(libs_and_bins, cmd_max_args):
 		bits = bits[8:] # 8: -> strlen('ELFCLASS')
 		if not soname:
 			soname = sfilename
-		
+
 		try:
 			scanned_files[bits][soname] = (filename, needed)
 		except KeyError:
@@ -249,23 +249,23 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 			)
 
 
-	logger.debug('Found %i libraries (+%i symlinks) and %i binaries' % 
+	logger.debug('Found %i libraries (+%i symlinks) and %i binaries' %
 		(len(libraries), len(libraries_links), len(binaries))
 	)
 	logger.info(green(' * ') + bold('Scanning files'))
-	
+
 	libs_and_bins = libraries+binaries
 
 	scanned_files = scan_files(libs_and_bins, settings['CMD_MAX_ARGS'])
-	
+
 	logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
-	logger.debug('Search for %i within %i' % 
+	logger.debug('Search for %i within %i' %
 		(len(binaries)+len(libraries), len(libraries)+len(libraries_links))
 	)
-	
+
 	broken = find_broken2(scanned_files, logger)
 	broken_pathes = main_checks2(broken, scanned_files, logger)
-	
+
 	broken_la = extract_dependencies_from_la(la_libraries, libraries+libraries_links, _libs_to_check, logger)
 	broken_pathes += broken_la
 
@@ -273,9 +273,9 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 
 	return assign_packages(broken_pathes, logger, settings)
 
-	
 	#import sys
 	#sys.exit()
+
 	#l = []
 	#for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'):
 		#l.append(line)

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 1be8cb0..42bf1ea 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -114,8 +114,8 @@ if __name__ == '__main__':
 	bin_dirs = bin_dirs.union(ld)
 	masked_dirs = masked_dirs.union(
 		set([
-			'/lib/modules', 
-			'/lib32/modules', 
+			'/lib/modules',
+			'/lib32/modules',
 			'/lib64/modules',
 		])
 	)
@@ -123,8 +123,8 @@ if __name__ == '__main__':
 	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
 	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
 
-	save_cache(logger=logging, 
-		to_save={'libraries':libraries, 'la_libraries':la_libraries, 
+	save_cache(logger=logging,
+		to_save={'libraries':libraries, 'la_libraries':la_libraries,
 			'libraries_links':libraries_links, 'binaries':binaries}
 		)
 

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 386ac33..95f2b5e 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -209,12 +209,11 @@ def main(settings=None, logger=None):
 	elif not settings['PRETEND'] \
 			and settings['IS_DEV'] \
 			and not settings['NO_PRETEND']:
-		logger.warn(blue(' * ') + 
+		logger.warn(blue(' * ') +
 			yellow('This is a development version, '
 				'so it may not work correctly'))
-		logger.warn(blue(' * ') + 
 			yellow('Adding --pretend to portage options anyway'))
-		logger.info(blue(' * ') + 
+		logger.info(blue(' * ') +
 			'If you\'re sure, you can add --no-pretend to revdep options')
 		settings['PRETEND'] = True
 


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2012-11-09 14:16 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2012-11-09 14:16 UTC (permalink / raw
  To: gentoo-commits

commit:     800b1f431fe35dcb9ed76e7170f6853664196e09
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Fri Nov  9 14:08:25 2012 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Fri Nov  9 14:08:25 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=800b1f43

Fix bug 381581 - revdep-rebuild unicode error

Changed the function to use gentoolkit functions instead of
reading the vardb directly.

---
 pym/gentoolkit/revdep_rebuild/assign.py |   66 +++++++++++++++---------------
 1 files changed, 33 insertions(+), 33 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 76b41fc..96b7eaa 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -13,49 +13,49 @@ import portage
 from portage.versions import catpkgsplit
 from portage import portdb
 from portage.output import bold, red, yellow
+from gentoolkit.helpers import get_installed_cpvs
+from gentoolkit.package import Package
 
-# ignore these files or directories if found
-IGNORED = ['.cache', 'world', 'world~', 'world.bak']
+# Make all str conversions unicode
+try:
+	str = unicode
+except NameError:
+	pass
 
 def assign_packages(broken, logger, settings):
 	''' Finds and returns packages that owns files placed in broken.
 		Broken is list of files
 	'''
 	assigned = set()
-	for group in os.listdir(settings['PKG_DIR']):
-		if group in IGNORED:
-			continue
-		elif os.path.isfile(settings['PKG_DIR'] + group):
-			if not group.startswith('.keep_'):
-				logger.warn(yellow(" * Invalid category found in the installed pkg db: ") +
-					bold(settings['PKG_DIR'] + group))
-			continue
-		for pkg in os.listdir(settings['PKG_DIR'] + group):
-			if '-MERGING-' in pkg:
-				logger.warn(yellow(" * Invalid/incomplete package merge found in the installed pkg db: ") +
-						bold(settings['PKG_DIR'] + pkg))
-				continue
-			_file = settings['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
-			if os.path.exists(_file):
-				try:
-					with open(_file, 'r') as cnt:
-						for line in cnt:
-							matches = re.match('^obj (/[^ ]+)', line)
-							if matches is not None:
-								match = matches.group(1)
-								if match in broken:
-									found = group+'/'+pkg
-									if found not in assigned:
-										assigned.add(found)
-									logger.info('\t' + match + ' -> '
-										+ bold(found))
-				except Exception as ex:
-					logger.warn(red(' !! Failed to read ' + _file) +
-						" Original exception was:\n" + str(ex))
+	if not broken:
+		return assigned
+
+	pkgset = set(get_installed_cpvs())
+
+	# Map all files in CONTENTS database to package names
+	fname_pkg_dict = {}
+	for pkg in pkgset:
+		contents = Package(pkg).parsed_contents()
+		for fname in contents.keys():
+			if contents[fname][0] == "obj":
+				fname_pkg_dict[fname] = str(pkg)
+
+	for fname in broken:
+		realname = os.path.realpath(fname)
+		if realname in fname_pkg_dict.keys():
+			pkgname = fname_pkg_dict[realname]
+		elif fname in fname_pkg_dict.keys():
+			pkgname = fname_pkg_dict[fname]
+		else:
+			pkgname = None
+		if pkgname and pkgname not in assigned:
+			assigned.add(pkgname)
+		if not pkgname:
+			pkgname = "(none)"
+		logger.info('\t' + fname + ' -> ' + bold(pkgname))
 
 	return assigned
 
-
 def get_best_match(cpv, cp, logger):
 	"""Tries to find another version of the pkg with the same slot
 	as the deprecated installed version.  Failing that attempt to get any version


^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2012-03-19  6:50 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2012-03-19  6:50 UTC (permalink / raw
  To: gentoo-commits

commit:     fd5b792c965f9d8e2a01b01c23ecf4f835a5eb99
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 19 06:49:20 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Mar 19 06:49:20 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=fd5b792c

fix a missed hardcoded path not using the portage.root.

---
 pym/gentoolkit/revdep_rebuild/settings.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 3c8b9d3..54d7f9e 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -14,7 +14,7 @@ DEFAULTS = {
 		'DEFAULT_ENV_FILE': os.path.join(portage.root, 'etc/profile.env'),
 		'REVDEP_CONFDIR': os.path.join(portage.root, 'etc/revdep-rebuild/'),
 		'PKG_DIR': os.path.join(portage.root, 'var/db/pkg/'),
-		'DEFAULT_TMP_DIR': '/var/cache/revdep-rebuild', #cache default location
+		'DEFAULT_TMP_DIR': os.path.join(portage.root, '/var/cache/revdep-rebuild'), #cache default location
 
 		# number of maximum allowed files to be parsed at once
 		'CMD_MAX_ARGS': 1000, 



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2012-03-04  7:41 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2012-03-04  7:41 UTC (permalink / raw
  To: gentoo-commits

commit:     602246c01709980ada3036cc995e74f6e06c90ef
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun Mar  4 07:40:54 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Mar  4 07:40:54 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=602246c0

Add ignored files/directories check.
Add a warning for incomplete pkg merges with -MERGING- in the name.

---
 pym/gentoolkit/revdep_rebuild/assign.py |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 73f20a9..76b41fc 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -14,6 +14,8 @@ from portage.versions import catpkgsplit
 from portage import portdb
 from portage.output import bold, red, yellow
 
+# ignore these files or directories if found
+IGNORED = ['.cache', 'world', 'world~', 'world.bak']
 
 def assign_packages(broken, logger, settings):
 	''' Finds and returns packages that owns files placed in broken.
@@ -21,12 +23,18 @@ def assign_packages(broken, logger, settings):
 	'''
 	assigned = set()
 	for group in os.listdir(settings['PKG_DIR']):
-		if os.path.isfile(settings['PKG_DIR'] + group):
+		if group in IGNORED:
+			continue
+		elif os.path.isfile(settings['PKG_DIR'] + group):
 			if not group.startswith('.keep_'):
 				logger.warn(yellow(" * Invalid category found in the installed pkg db: ") +
 					bold(settings['PKG_DIR'] + group))
 			continue
 		for pkg in os.listdir(settings['PKG_DIR'] + group):
+			if '-MERGING-' in pkg:
+				logger.warn(yellow(" * Invalid/incomplete package merge found in the installed pkg db: ") +
+						bold(settings['PKG_DIR'] + pkg))
+				continue
 			_file = settings['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
 			if os.path.exists(_file):
 				try:



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2012-03-02 17:47 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2012-03-02 17:47 UTC (permalink / raw
  To: gentoo-commits

commit:     2d303c857523978de043c0844f213567113feda5
Author:     Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  2 17:46:28 2012 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Mar  2 17:46:28 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=2d303c85

fix bug 406613. ignore any .keep_* files in /var/db/pkg.  Print a warning for any other files found.

---
 pym/gentoolkit/revdep_rebuild/assign.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index af82b27..73f20a9 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -21,6 +21,11 @@ def assign_packages(broken, logger, settings):
 	'''
 	assigned = set()
 	for group in os.listdir(settings['PKG_DIR']):
+		if os.path.isfile(settings['PKG_DIR'] + group):
+			if not group.startswith('.keep_'):
+				logger.warn(yellow(" * Invalid category found in the installed pkg db: ") +
+					bold(settings['PKG_DIR'] + group))
+			continue
 		for pkg in os.listdir(settings['PKG_DIR'] + group):
 			_file = settings['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
 			if os.path.exists(_file):



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-10-10 17:36 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2011-10-10 17:36 UTC (permalink / raw
  To: gentoo-commits

commit:     dc41d03793e898319b791b3844b452fab211fdae
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Oct 10 17:34:56 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Oct 10 17:34:56 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=dc41d037

reverse the logging message in analyse.py since it is not correct.

---
 pym/gentoolkit/revdep_rebuild/analyse.py |    2 --
 1 files changed, 0 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 79b8fe3..f992db0 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -206,8 +206,6 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 		for ltc in _libs_to_check:
 			if os.path.isfile(ltc):
 				ltc = scan(['-nBSF', '%S'], [ltc,], settings['CMD_MAX_ARGS'])[0].split()[0]
-			else:
-				logger.warn(yellow(' * ') + bold('Library "%s" was not found' % ltc))
 			nltc += [ltc,]
 		_libs_to_check = nltc
 



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-10-10 16:09 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2011-10-10 16:09 UTC (permalink / raw
  To: gentoo-commits

commit:     4fd527a67416ea278e450602c2bc73fe97ef06bc
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Oct 10 16:03:32 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Oct 10 16:03:32 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4fd527a6

add --library output to revdep-rebuild.

---
 pym/gentoolkit/revdep_rebuild/analyse.py |    2 ++
 pym/gentoolkit/revdep_rebuild/rebuild.py |    4 ++++
 2 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index f992db0..79b8fe3 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -206,6 +206,8 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 		for ltc in _libs_to_check:
 			if os.path.isfile(ltc):
 				ltc = scan(['-nBSF', '%S'], [ltc,], settings['CMD_MAX_ARGS'])[0].split()[0]
+			else:
+				logger.warn(yellow(' * ') + bold('Library "%s" was not found' % ltc))
 			nltc += [ltc,]
 		_libs_to_check = nltc
 

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index c8e0b37..fe00069 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -205,6 +205,10 @@ def main(settings=None, logger=None):
 			yellow('You are not root, adding --pretend to portage options'))
 		settings['PRETEND'] = True
 
+	if settings['library']:
+		logger.warn(green(' * ') + 
+			"Looking for libraries: %s" % (bold(', '.join(settings['library']))))
+
 	if settings['USE_TMP_FILES'] \
 			and check_temp_files(settings['DEFAULT_TMP_DIR'], logger=logger):
 		libraries, la_libraries, libraries_links, binaries = read_cache(



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-14 18:29 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-14 18:29 UTC (permalink / raw
  To: gentoo-commits

commit:     b150d5882b03a35a9b83707e4ed505446ab06b8a
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 18:29:09 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 18:29:09 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=b150d588

Fix call_program to actually return stdout as string under py3k

---
 pym/gentoolkit/revdep_rebuild/stuff.py |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 43be461..a2c317e 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -18,9 +18,9 @@ def call_program(args):
 	@param, args: arument list to pass to subprocess
 	@return str
 	'''
-	subp = subprocess.Popen(args, stdout=subprocess.PIPE, \
-								stderr=subprocess.PIPE)
+	subp = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
 	stdout, stderr = subp.communicate()
+	stdout = stdout.decode('utf-8')
 	return str(stdout)
 
 



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-14 18:29 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-14 18:29 UTC (permalink / raw
  To: gentoo-commits

commit:     8e3f935090fe8680fea7eb5980142e4bb3e6e88e
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 18:27:44 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 18:27:44 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=8e3f9350

Change default cache directory to '/var/cache/revdep-rebuild'

---
 pym/gentoolkit/revdep_rebuild/cache.py    |    5 +++--
 pym/gentoolkit/revdep_rebuild/settings.py |    2 +-
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 2bb9f59..d62fe12 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -52,8 +52,9 @@ def save_cache(logger, to_save=None, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 	if to_save is None:
 		to_save = {}
 
-	if not os.path.exists(temp_path):
-		os.makedirs(temp_path)
+# TODO: Don't blindly make the cache directory, see Bug 203414
+#	if not os.path.exists(temp_path):
+#		os.makedirs(temp_path)
 
 	try:
 		_file = open(os.path.join(temp_path, 'timestamp'), 'w')

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index c0e5aa7..3c8b9d3 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -14,7 +14,7 @@ DEFAULTS = {
 		'DEFAULT_ENV_FILE': os.path.join(portage.root, 'etc/profile.env'),
 		'REVDEP_CONFDIR': os.path.join(portage.root, 'etc/revdep-rebuild/'),
 		'PKG_DIR': os.path.join(portage.root, 'var/db/pkg/'),
-		'DEFAULT_TMP_DIR': '/tmp/revdep-rebuild', #cache default location
+		'DEFAULT_TMP_DIR': '/var/cache/revdep-rebuild', #cache default location
 
 		# number of maximum allowed files to be parsed at once
 		'CMD_MAX_ARGS': 1000, 



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-14  2:32 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-14  2:32 UTC (permalink / raw
  To: gentoo-commits

commit:     e3369415de42875dba4523b352f9a2d2899d2aac
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Thu Jul 14 02:31:41 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Thu Jul 14 02:31:41 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=e3369415

Make development warning always print

---
 pym/gentoolkit/revdep_rebuild/rebuild.py |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 5f64473..c8e0b37 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -192,19 +192,18 @@ def main(settings=None, logger=None):
 	if not settings['stdout'].isatty() or settings['nocolor']:
 		nocolor()
 
+	#TODO: Development warning
+	logger.warn(blue(' * ') + 
+		yellow('This is a development version, '
+			'so it may not work correctly'))
+	logger.warn(blue(' * ') + 
+		yellow('The original revdep-rebuild script is '
+			'installed as revdep-rebuild.sh'))
+
 	if os.getuid() != 0 and not settings['PRETEND']:
 		logger.warn(blue(' * ') + 
 			yellow('You are not root, adding --pretend to portage options'))
 		settings['PRETEND'] = True
-	elif not settings['PRETEND'] \
-			and settings['IS_DEV'] \
-			and not settings['NO_PRETEND']:
-		logger.warn(blue(' * ') + 
-			yellow('This is a development version, '
-				'so it may not work correctly'))
-		logger.warn(blue(' * ') + 
-			yellow('The original revdep-rebuild script is '
-				'installed as revdep-rebuild.sh'))
 
 	if settings['USE_TMP_FILES'] \
 			and check_temp_files(settings['DEFAULT_TMP_DIR'], logger=logger):



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-14  1:44 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2011-07-14  1:44 UTC (permalink / raw
  To: gentoo-commits

commit:     59abbce2ffb3a430f22d450a77f2fc91ac13274b
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Thu Jul 14 01:37:51 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Jul 14 01:37:51 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=59abbce2

major pylint cleanup, 2 probable bugs fixed along the way.

---
 pym/gentoolkit/revdep_rebuild/analyse.py |  154 +++++++++++++++++-------------
 pym/gentoolkit/revdep_rebuild/assign.py  |   52 ++++++-----
 pym/gentoolkit/revdep_rebuild/cache.py   |   79 ++++++++++------
 pym/gentoolkit/revdep_rebuild/collect.py |  151 +++++++++++++++--------------
 pym/gentoolkit/revdep_rebuild/rebuild.py |    5 +-
 pym/gentoolkit/revdep_rebuild/stuff.py   |   16 ++-
 6 files changed, 258 insertions(+), 199 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 5494270..f992db0 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -9,36 +9,42 @@ import re
 import platform
 import glob
 
-from portage.output import bold, red, blue, yellow, green, nocolor
+from portage.output import bold, blue, yellow, green
 
 from .stuff import scan
-from .collect import prepare_search_dirs, parse_revdep_config, collect_libraries_from_dir, collect_binaries_from_dir
+from .collect import (prepare_search_dirs, parse_revdep_config,
+	collect_libraries_from_dir, collect_binaries_from_dir)
 from .assign import assign_packages
 from .cache import save_cache
 
 
 def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
-	''' Calls scanelf for all files_to_check, then returns found libraries and dependencies
+	''' Calls scanelf for all files_to_check, 
+	then returns found libraries and dependencies
 	'''
 
-	libs = [] # libs found by scanelf
-	dependencies = [] # list of lists of files (from file_to_check) that uses
-					  # library (for dependencies[id] and libs[id] => id==id)
+	# libs found by scanelf
+	libs = []
+	# list of lists of files (from file_to_check) that uses
+	# library (for dependencies[id] and libs[id] => id==id)
+	dependencies = []
+	for line in scan(
+		['-M', str(bits), '-nBF', '%F %n'],
+		files_to_check, cmd_max_args
+		):
 
-	for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check, cmd_max_args):
-	#call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
-		r = line.strip().split(' ')
-		if len(r) < 2: # no dependencies?
+		parts = line.strip().split(' ')
+		if len(parts) < 2: # no dependencies?
 			continue
 
-		deps = r[1].split(',')
-		for d in deps:
-			if d in libs:
-				i = libs.index(d)
-				dependencies[i].append(r[0])
+		deps = parts[1].split(',')
+		for dep in deps:
+			if dep in libs:
+				index = libs.index(dep)
+				dependencies[index].append(parts[0])
 			else:
-				libs.append(d)
-				dependencies.append([r[0],])
+				libs.append(dep)
+				dependencies.append([parts[0],])
 	
 	return (libs, dependencies)
 
@@ -47,25 +53,27 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 	broken = []
 
 	libnames = []
-	for l in libraries:
-		m = re.match('.+\/(.+)\.(so|la|a)(\..+)?', l)
-		if m is not None:
-			ln = m.group(1)
-			if ln not in libnames:
-				libnames += [ln, ]
-
-	for f in la:
-		if not os.path.exists(f):
+	for lib in libraries:
+		match = re.match('.+\/(.+)\.(so|la|a)(\..+)?', lib)
+		if match is not None:
+			libname = match.group(1)
+			if libname not in libnames:
+				libnames += [libname, ]
+
+	for _file in la:
+		if not os.path.exists(_file):
 			continue
 
-		for line in open(f, 'r').readlines():
+		for line in open(_file, 'r').readlines():
 			line = line.strip()
 			if line.startswith('dependency_libs='):
-				m = re.match("dependency_libs='([^']+)'", line)
-				if m is not None:
-					for el in m.group(1).split(' '):
+				match = re.match("dependency_libs='([^']+)'", line)
+				if match is not None:
+					for el in match.group(1).split(' '):
 						el = el.strip()
-						if len(el) < 1 or el.startswith('-L') or el.startswith('-R'):
+						if (len(el) < 1 or el.startswith('-L')
+							or el.startswith('-R')
+							):
 							continue
 
 						if el.startswith('-l') and 'lib'+el[2:] in libnames:
@@ -82,8 +90,9 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 								if not _break:
 									continue
 
-							logger.info(yellow(' * ') + f + ' is broken (requires: ' + bold(el)+')')
-							broken.append(f)
+							logger.info(yellow(' * ') + _file + 
+								' is broken (requires: ' + bold(el)+')')
+							broken.append(_file)
 	return broken
 
 
@@ -94,39 +103,40 @@ def find_broken(found_libs, system_libraries, to_check):
 		is list of library names.
 	'''
 
-	# join libraries and looking at it as string is way too faster than for-jumping
+	# join libraries and looking at it as string
+	# is way faster than for-jumping
 
 	broken = []
-	sl = '|'.join(system_libraries)
+	syslibs = '|'.join(system_libraries)
 
 	if not to_check:
-		for f in found_libs:
-			if f+'|' not in sl:
-				broken.append(found_libs.index(f))
+		for found in found_libs:
+			if found + '|' not in syslibs:
+				broken.append(found_libs.index(found))
 	else:
 		for tc in to_check:
-			for f in found_libs:
-				if tc in f:# and f+'|' not in sl:
-					broken.append(found_libs.index(f))
+			for found in found_libs:
+				if tc in found:# and found+'|' not in syslibs:
+					broken.append(found_libs.index(found))
 
 	return broken
 
 
-def main_checks(found_libs, broken, dependencies, logger):
+def main_checks(found_libs, broken_list, dependencies, logger):
 	''' Checks for broken dependencies.
 		found_libs have to be the same as returned by prepare_checks
-		broken is list of libraries found by scanelf
+		broken_list is list of libraries found by scanelf
 		dependencies is the value returned by prepare_checks
 	'''
 
 	broken_pathes = []
 
-	for b in broken:
-		f = found_libs[b]
-		logger.info('Broken files that requires: ' + bold(f))
-		for d in dependencies[b]:
-			logger.info(yellow(' * ') + d)
-			broken_pathes.append(d)
+	for broken in broken_list:
+		found = found_libs[broken]
+		logger.info('Broken files that requires: ' + bold(found))
+		for dep_path in dependencies[broken]:
+			logger.info(yellow(' * ') + dep_path)
+			broken_pathes.append(dep_path)
 	return broken_pathes
 
 
@@ -142,20 +152,31 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	"""
 
 	if libraries and la_libraries and libraries_links and binaries:
-		logger.info(blue(' * ') + bold('Found a valid cache, skipping collecting phase'))
+		logger.info(blue(' * ') + 
+			bold('Found a valid cache, skipping collecting phase'))
 	else:
-		#TODO: add partial cache (for ex. only libraries) when found for some reason
+		#TODO: add partial cache (for ex. only libraries)
+		# when found for some reason
 
-		logger.warn(green(' * ') + bold('Collecting system binaries and libraries'))
+		logger.warn(green(' * ') + 
+			bold('Collecting system binaries and libraries'))
 		bin_dirs, lib_dirs = prepare_search_dirs(logger, settings)
 
-		masked_dirs, masked_files, ld = parse_revdep_config(settings['REVDEP_CONFDIR'])
+		masked_dirs, masked_files, ld = \
+			parse_revdep_config(settings['REVDEP_CONFDIR'])
 		lib_dirs.update(ld)
 		bin_dirs.update(ld)
-		masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+		masked_dirs.update([
+			'/lib/modules',
+			'/lib32/modules',
+			'/lib64/modules'
+			]
+			)
 
-		logger.info(green(' * ') + bold('Collecting dynamic linking informations'))
-		libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logger)
+		logger.info(green(' * ') +
+			bold('Collecting dynamic linking informations'))
+		libraries, la_libraries, libraries_links, symlink_pairs = \
+			collect_libraries_from_dir(lib_dirs, masked_dirs, logger)
 		binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
 
 		if settings['USE_TMP_FILES']:
@@ -167,17 +188,16 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 			)
 
 
-	logger.debug('Found '+ str(len(libraries)) + ' libraries (+' + str(len(libraries_links)) + ' symlinks) and ' + str(len(binaries)) + ' binaries')
+	logger.debug('Found '+ str(len(libraries)) + 
+		' libraries (+' + str(len(libraries_links)) +
+		' symlinks) and ' + str(len(binaries)) +
+		' binaries')
 
 	logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
-	logger.debug('Search for ' + str(len(binaries)+len(libraries)) + ' within ' + str(len(libraries)+len(libraries_links)))
+	logger.debug('Search for ' + str(len(binaries)+len(libraries)) +
+		' within ' + str(len(libraries)+len(libraries_links)))
 	libs_and_bins = libraries+binaries
 
-	#l = []
-	#for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'):
-		#l.append(line)
-	#libraries = l
-
 	found_libs = []
 	dependencies = []
 
@@ -195,21 +215,21 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	elif _bits.startswith('64'):
 		bits = 64
 
-	import time
 	broken = []
 	for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
 		bits = int(av_bits[4:])
 
-		#_libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, settings['CMD_MAX_ARGS'])
 		_libraries = libraries+libraries_links
 
-		found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits, settings['CMD_MAX_ARGS'])
+		found_libs, dependencies = prepare_checks(libs_and_bins,
+			_libraries, bits, settings['CMD_MAX_ARGS'])
 		broken = find_broken(found_libs, _libraries, _libs_to_check)
 
 		bits /= 2
 		bits = int(bits)
 
-	broken_la = extract_dependencies_from_la(la_libraries, libraries+libraries_links, _libs_to_check, logger)
+	broken_la = extract_dependencies_from_la(la_libraries,
+		libraries+libraries_links, _libs_to_check, logger)
 
 
 	broken_pathes = main_checks(found_libs, broken, dependencies, logger)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index bbe409b..af82b27 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -10,8 +10,9 @@ import os
 import re
 
 import portage
+from portage.versions import catpkgsplit
 from portage import portdb
-from portage.output import bold, red, blue, yellow, green, nocolor
+from portage.output import bold, red, yellow
 
 
 def assign_packages(broken, logger, settings):
@@ -21,21 +22,23 @@ def assign_packages(broken, logger, settings):
 	assigned = set()
 	for group in os.listdir(settings['PKG_DIR']):
 		for pkg in os.listdir(settings['PKG_DIR'] + group):
-			f = settings['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
-			if os.path.exists(f):
+			_file = settings['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
+			if os.path.exists(_file):
 				try:
-					with open(f, 'r') as cnt:
+					with open(_file, 'r') as cnt:
 						for line in cnt:
-							m = re.match('^obj (/[^ ]+)', line)
-							if m is not None:
-								m = m.group(1)
-								if m in broken:
+							matches = re.match('^obj (/[^ ]+)', line)
+							if matches is not None:
+								match = matches.group(1)
+								if match in broken:
 									found = group+'/'+pkg
 									if found not in assigned:
 										assigned.add(found)
-									logger.info('\t' + m + ' -> ' + bold(found))
-				except Exception as e:
-					logger.warn(red(' !! Failed to read ' + f))
+									logger.info('\t' + match + ' -> '
+										+ bold(found))
+				except Exception as ex:
+					logger.warn(red(' !! Failed to read ' + _file) +
+						" Original exception was:\n" + str(ex))
 
 	return assigned
 
@@ -54,24 +57,24 @@ def get_best_match(cpv, cp, logger):
 	logger.warn(yellow('Warning: ebuild "' + cpv + '" not found.'))
 	logger.info('Looking for %s:%s' %(cp, slot))
 	try:
-		m = portdb.match('%s:%s' %(cp, slot))
+		match = portdb.match('%s:%s' %(cp, slot))
 	except portage.exception.InvalidAtom:
-		m = None
+		match = None
 
-	if not m:
-		logger.warn(red('!!') + ' ' + yellow('Could not find ebuild for %s:%s' %(cp, slot)))
+	if not match:
+		logger.warn(red('!!') + ' ' + yellow(
+			'Could not find ebuild for %s:%s' %(cp, slot)))
 		slot = ['']
-		m = portdb.match(cp)
-		if not m:
-			logger.warn(red('!!') + ' ' + yellow('Could not find ebuild for ' + cp))
-	return m, slot
+		match = portdb.match(cp)
+		if not match:
+			logger.warn(red('!!') + ' ' + 
+				yellow('Could not find ebuild for ' + cp))
+	return match, slot
 
 
 def get_slotted_cps(cpvs, logger):
 	"""Uses portage to reduce the cpv list into a cp:slot list and returns it
 	"""
-	from portage.versions import catpkgsplit
-	from portage import portdb
 
 	cps = []
 	for cpv in cpvs:
@@ -80,9 +83,10 @@ def get_slotted_cps(cpvs, logger):
 		try:
 			slot = portdb.aux_get(cpv, ["SLOT"])
 		except KeyError:
-			m, slot = get_best_match(cpv, cp, logger)
-			if not m:
-				logger.warn(red("Installed package: %s is no longer available" %cp))
+			match, slot = get_best_match(cpv, cp, logger)
+			if not match:
+				logger.warn(red("Installed package: "
+					"%s is no longer available" %cp))
 				continue
 
 		if slot[0]:

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 7dc9a8d..2bb9f59 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -18,53 +18,65 @@ def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 		This function does not checks if files exists nor timestamps,
 		check_temp_files should be called first
 		@param temp_path: directory where all temp files should reside
-		@return tuple with values of: libraries, la_libraries, libraries_links, symlink_pairs, binaries
+		@return tuple with values of: 
+			libraries, la_libraries, libraries_links, symlink_pairs, binaries
 	'''
 
-	ret = {'libraries':[], 'la_libraries':[], 'libraries_links':[], 'binaries':[]}
+	ret = {
+		'libraries':[],
+		'la_libraries':[],
+		'libraries_links':[],
+		'binaries':[]
+		}
 	try:
-		for key,val in list(ret.items()):
-			f = open(os.path.join(temp_path, key))
-			for line in f.readlines():
+		for key, val in list(ret.items()):
+			_file  = open(os.path.join(temp_path, key))
+			for line in _file .readlines():
 				val.append(line.strip())
 			#libraries.remove('\n')
-			f.close()
+			_file .close()
 	except EnvironmentError:
 		pass
 
-	return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
+	return (ret['libraries'], ret['la_libraries'], 
+		ret['libraries_links'], ret['binaries'])
 
 
-def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
+def save_cache(logger, to_save=None, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 	''' Tries to store caching information.
 		@param logger
-		@param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
+		@param to_save have to be dict with keys: 
+			libraries, la_libraries, libraries_links and binaries
 	'''
+	
+	if to_save is None:
+		to_save = {}
 
 	if not os.path.exists(temp_path):
 		os.makedirs(temp_path)
 
 	try:
-		f = open(os.path.join(temp_path, 'timestamp'), 'w')
-		f.write(str(int(time.time())))
-		f.close()
+		_file = open(os.path.join(temp_path, 'timestamp'), 'w')
+		_file.write(str(int(time.time())))
+		_file.close()
 
-		for key,val in list(to_save.items()):
-			f = open(os.path.join(temp_path, key), 'w')
+		for key, val in list(to_save.items()):
+			_file = open(os.path.join(temp_path, key), 'w')
 			for line in val:
-				f.write(line + '\n')
-			f.close()
+				_file.write(line + '\n')
+			_file.close()
 	except Exception as ex:
 		logger.warn(red('Could not save cache: %s' %str(ex)))
 
 
 
-def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600):
+def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600,
+		logger=None):
 	''' Checks if temporary files from previous run are still available
 		and if they aren't too old
 		@param temp_path is directory, where temporary files should be found
-		@param max_delay is maximum time difference (in seconds) when those files
-				are still considered fresh and useful
+		@param max_delay is maximum time difference (in seconds) 
+			when those files are still considered fresh and useful
 		returns True, when files can be used, or False, when they don't
 		exists or they are too old
 	'''
@@ -77,10 +89,13 @@ def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600):
 		return False
 
 	try:
-		f = open(timestamp_path)
-		timestamp = int(f.readline())
-		f.close()
-	except:
+		_file = open(timestamp_path)
+		timestamp = int(_file.readline())
+		_file .close()
+	except Exception as ex:
+		if logger:
+			logger.debug("check_temp_files(); error retrieving"
+				" timestamp_path:\n" + str(ex))
 		timestamp = 0
 		return False
 
@@ -92,17 +107,25 @@ def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600):
 if __name__ == '__main__':
 	print('Preparing cache ... ')
 
-	from .collect import *
+	from .collect import (prepare_search_dirs, parse_revdep_config,
+		collect_libraries_from_dir, collect_binaries_from_dir)
+
 	import logging
 
-	bin_dirs, lib_dirs = prepare_search_dirs()
+	bin_dirs, lib_dirs = prepare_search_dirs(logging, DEFAULTS)
 
-	masked_dirs, masked_files, ld = parse_revdep_config()
+	masked_dirs, masked_files, ld = parse_revdep_config("/etc/revdep-rebuild/")
 	lib_dirs.update(ld)
 	bin_dirs.update(ld)
-	masked_dirs = masked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules',])
+	masked_dirs = masked_dirs.update([
+			'/lib/modules',
+			'/lib32/modules', 
+			'/lib64/modules'
+			]
+		)
 
-	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
+	libraries, la_libraries, libraries_links, symlink_pairs = \
+		collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
 	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
 
 	save_cache(logger=logging, 

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 8239feb..3aae709 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -10,7 +10,7 @@ import glob
 import stat
 
 import portage
-from portage.output import bold, red, blue, yellow, green, nocolor
+from portage.output import blue, yellow
 
 
 def parse_conf(conf_file, visited=None, logger=None):
@@ -66,12 +66,13 @@ def prepare_search_dirs(logger, settings):
 	lib_dirs = set(['/lib', '/usr/lib', ])
 
 	#try:
-	with open(os.path.join(portage.root, settings['DEFAULT_ENV_FILE']), 'r') as _file:
+	with open(os.path.join(
+		portage.root, settings['DEFAULT_ENV_FILE']), 'r') as _file:
 		for line in _file:
 			line = line.strip()
-			m = re.match("^export (ROOT)?PATH='([^']+)'", line)
-			if m is not None:
-				bin_dirs.update(set(m.group(2).split(':')))
+			match = re.match("^export (ROOT)?PATH='([^']+)'", line)
+			if match is not None:
+				bin_dirs.update(set(match.group(2).split(':')))
 	#except EnvironmentError:
 		#logger.debug(yellow('Could not open file %s' % f))
 
@@ -80,35 +81,34 @@ def prepare_search_dirs(logger, settings):
 
 
 def parse_revdep_config(revdep_confdir):
-	''' Parses all files under /etc/revdep-rebuild/ and returns
+	''' Parses all files under and returns
 		tuple of: (masked_dirs, masked_files, search_dirs)'''
 
 	search_dirs = set()
 	masked_dirs = set()
 	masked_files = set()
 
-	#TODO: remove hard-coded path
 	for _file in os.listdir(revdep_confdir):
-		for line in open(os.path.join('/etc/revdep-rebuild', _file)):
+		for line in open(os.path.join(revdep_confdir, _file)):
 			line = line.strip()
 			#first check for comment, we do not want to regex all lines
 			if not line.startswith('#'): 
-				m = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
-				if m is not None:
-					s = m.group(1).split(' ')
-					masked_files = masked_files.union(s)
+				match = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
+				if match is not None:
+					masks = match.group(1).split(' ')
+					masked_files = masked_files.union(masks)
 					continue
-				m = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
-				if m is not None:
-					s = m.group(1).split(' ')
-					for ss in s:
-						masked_dirs = masked_dirs.union(glob.glob(ss))
+				match = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
+				if match is not None:
+					searches = match.group(1).split(' ')
+					for search in searches:
+						masked_dirs = masked_dirs.union(glob.glob(search))
 					continue
-				m = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
-				if m is not None:
-					s = m.group(1).split()
-					for ss in s:
-						search_dirs = search_dirs.union(glob.glob(ss))
+				match = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
+				if match is not None:
+					searches = match.group(1).split()
+					for search in searches:
+						search_dirs = search_dirs.union(glob.glob(search))
 					continue
 
 	return (masked_dirs, masked_files, search_dirs)
@@ -129,54 +129,58 @@ def collect_libraries_from_dir(dirs, mask, logger):
 	found_la_files = [] # la libraries
 	symlink_pairs = []  # list of pairs symlink_id->library_id
 
-	for d in dirs:
-		if d in mask:
+	for _dir in dirs:
+		if _dir in mask:
 			continue
 
 		try:
-			for l in os.listdir(d):
-				l = os.path.join(d, l)
-				if l in mask:
+			for listing in os.listdir(_dir):
+				listing = os.path.join(_dir, listing)
+				if listing in mask:
 					continue
 
-				if os.path.isdir(l):
-					if os.path.islink(l):
+				if os.path.isdir(listing):
+					if os.path.islink(listing):
 						#we do not want scan symlink-directories
 						pass
 					else:
-						found_directories.append(l)
-				elif os.path.isfile(l):
-					if l.endswith('.so') or l.endswith('.a') or '.so.' in l:
-						if l in found_files or l in found_symlinks:
+						found_directories.append(listing)
+				elif os.path.isfile(listing):
+					if (listing.endswith('.so') or 
+						listing.endswith('.a') or 
+						'.so.' in listing
+						):
+						if listing in found_files or listing in found_symlinks:
 							continue
 
-						if os.path.islink(l):
-							found_symlinks.append(l)
-							abs_path = os.path.realpath(l)
+						if os.path.islink(listing):
+							found_symlinks.append(listing)
+							abs_path = os.path.realpath(listing)
 							if abs_path in found_files:
-								i = found_files.index(abs_path)
+								index = found_files.index(abs_path)
 							else:
 								found_files.append(abs_path)
-								i = len(found_files)-1
-							symlink_pairs.append((len(found_symlinks)-1, i,))
+								index = len(found_files)-1
+							symlink_pairs.append((len(found_symlinks)-1, index,))
 						else:
-							found_files.append(l)
+							found_files.append(listing)
 						continue
-					elif l.endswith('.la'):
-						if l in found_la_files:
+					elif listing.endswith('.la'):
+						if listing in found_la_files:
 							continue
 
-						found_la_files.append(l)
+						found_la_files.append(listing)
 					else:
-						# sometimes there are binaries in libs' subdir, for example in nagios
-						if not os.path.islink(l):
-							if l in found_files or l in found_symlinks:
+						# sometimes there are binaries in libs' subdir,
+						# for example in nagios
+						if not os.path.islink(listing):
+							if listing in found_files or listing in found_symlinks:
 								continue
-							prv = os.stat(l)[stat.ST_MODE]
+							prv = os.stat(listing)[stat.ST_MODE]
 							if prv & stat.S_IXUSR == stat.S_IXUSR or \
 									prv & stat.S_IXGRP == stat.S_IXGRP or \
 									prv & stat.S_IXOTH == stat.S_IXOTH:
-								found_files.append(l)
+								found_files.append(listing)
 		except Exception as ex:
 			logger.debug(
 				yellow('Exception during collecting libraries: ' + 
@@ -184,18 +188,20 @@ def collect_libraries_from_dir(dirs, mask, logger):
 
 
 	if found_directories:
-		f, a, l, p = collect_libraries_from_dir(found_directories, mask, logger)
-		found_files += f
-		found_la_files += a
-		found_symlinks += l
-		symlink_pairs += p
+		_file, la_file, link, pair = \
+			collect_libraries_from_dir(found_directories, mask, logger)
+		found_files += _file
+		found_la_files += la_file
+		found_symlinks += link
+		symlink_pairs += pair
 
 	return (found_files, found_la_files, found_symlinks, symlink_pairs)
 
 
 def collect_binaries_from_dir(dirs, mask, logger):
 	''' Collects all binaries from specified list of directories.
-		mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
+		mask is list of pathes, that are ommited in scanning,
+		can be eighter single file or entire directory
 		Returns list of binaries
 	'''
 
@@ -204,36 +210,36 @@ def collect_binaries_from_dir(dirs, mask, logger):
 	found_directories = []  
 	found_files = []
 
-	for d in dirs:
-		if d in mask:
+	for _dir in dirs:
+		if _dir in mask:
 			continue
 
 		try:
-			for l in os.listdir(d):
-				l = os.path.join(d, l)
-				if d in mask:
+			for listing in os.listdir(_dir):
+				listing = os.path.join(_dir, listing)
+				if listing in mask:
 					continue
 
-				if os.path.isdir(l):
-					if os.path.islink(l):
+				if os.path.isdir(listing):
+					if os.path.islink(listing):
 						#we do not want scan symlink-directories
 						pass
 					else:
-						found_directories.append(l)
-				elif os.path.isfile(l):
+						found_directories.append(listing)
+				elif os.path.isfile(listing):
 					# we're looking for binaries
 					# and with binaries we do not need links
 					# thus we can optimize a bit
-					if not os.path.islink(l):
-						prv = os.stat(l)[stat.ST_MODE]
+					if not os.path.islink(listing):
+						prv = os.stat(listing)[stat.ST_MODE]
 						if prv & stat.S_IXUSR == stat.S_IXUSR or \
 								prv & stat.S_IXGRP == stat.S_IXGRP or \
 								prv & stat.S_IXOTH == stat.S_IXOTH:
-							found_files.append(l)
-		except Exception as e:
+							found_files.append(listing)
+		except Exception as ex:
 			logger.debug(
 				yellow('Exception during binaries collecting: '+
-				blue('%s') %str(e)))
+				blue('%s') %str(ex)))
 
 	if found_directories:
 		found_files += collect_binaries_from_dir(found_directories, mask, logger)
@@ -244,15 +250,16 @@ def collect_binaries_from_dir(dirs, mask, logger):
 
 if __name__ == '__main__':
 	import logging
-	mbin_dirs, mlib_dirs = prepare_search_dirs(logging)
+	from .settings import DEFAULTS
+	mbin_dirs, mlib_dirs = prepare_search_dirs(logging, DEFAULTS)
 
-	mmasked_dirs, mmasked_files, mld = parse_revdep_config()
+	mmasked_dirs, mmasked_files, mld = parse_revdep_config("/etc/revdep-rebuild/")
 	mlib_dirs.update(mld)
 	mbin_dirs.update(mld)
 	mmasked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules'])
 
-	libraries, la_libraries, libraries_links, msymlink_pairs = collect_libraries_from_dir(
-		mlib_dirs, mmasked_dirs, logging)
+	libraries, la_libraries, libraries_links, msymlink_pairs = \
+		collect_libraries_from_dir(mlib_dirs, mmasked_dirs, logging)
 	binaries = collect_binaries_from_dir(mbin_dirs, mmasked_dirs, logging)
 
 	logging.debug(

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index b529f37..5f64473 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -16,7 +16,6 @@ License: BSD
 
 from __future__ import print_function
 
-import subprocess
 import os
 import sys
 import getopt
@@ -24,7 +23,7 @@ import logging
 from portage.output import bold, red, blue, yellow, green, nocolor
 
 from .analyse import analyse
-from .stuff import exithandler, get_masking_status
+from .stuff import get_masking_status
 from .cache import check_temp_files, read_cache
 from .assign import get_slotted_cps
 from .settings import DEFAULTS
@@ -208,7 +207,7 @@ def main(settings=None, logger=None):
 				'installed as revdep-rebuild.sh'))
 
 	if settings['USE_TMP_FILES'] \
-			and check_temp_files(settings['DEFAULT_TMP_DIR']):
+			and check_temp_files(settings['DEFAULT_TMP_DIR'], logger=logger):
 		libraries, la_libraries, libraries_links, binaries = read_cache(
 			settings['DEFAULT_TMP_DIR'])
 		assigned = analyse(

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index bffb936..43be461 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -12,7 +12,12 @@ import portage
 
 # util. functions
 def call_program(args):
-	''' Calls program with specified parameters and returns stdout as a str object '''
+	''' Calls program with specified parameters
+	and returns the stdout as a str object.
+	
+	@param, args: arument list to pass to subprocess
+	@return str
+	'''
 	subp = subprocess.Popen(args, stdout=subprocess.PIPE, \
 								stderr=subprocess.PIPE)
 	stdout, stderr = subp.communicate()
@@ -21,7 +26,8 @@ def call_program(args):
 
 def scan(params, files, max_args):
 	''' Calls scanelf with given params and files to scan.
-		@param params is list of parameters that should be passed into scanelf app.
+		@param params is list of parameters that should
+			be passed into scanelf app.
 		@param files list of files to scan.
 		@param max_args number of files to process at once
 
@@ -56,9 +62,9 @@ def _match_str_in_list(lst, stri):
 	@param stri: string
 	@return boolean or list menber that matches stri.endswith(member)
 	"""
-	for l in lst:
-		if stri.endswith(l):
-			return l
+	for item in lst:
+		if stri.endswith(item):
+			return item
 	return False
 
 



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-14  1:44 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2011-07-14  1:44 UTC (permalink / raw
  To: gentoo-commits

commit:     c639b2341b63d784840c039ea08ef5f08e21bde8
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Wed Jul 13 22:37:00 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Jul 13 22:37:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=c639b234

partial pylint cleanup

---
 pym/gentoolkit/revdep_rebuild/collect.py  |   67 +++++++++++++++++-----------
 pym/gentoolkit/revdep_rebuild/rebuild.py  |   42 ++++++++++--------
 pym/gentoolkit/revdep_rebuild/settings.py |   17 ++++---
 pym/gentoolkit/revdep_rebuild/stuff.py    |   20 ++++++--
 4 files changed, 89 insertions(+), 57 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index e8075d8..d1b23c0 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -1,5 +1,7 @@
 #!/usr/bin/python
 
+"""Data collection module"""
+
 import re
 import os
 import glob
@@ -22,8 +24,8 @@ def parse_conf(conf_file, visited=None, logger=None):
 
 	for conf in conf_file:
 		try:
-			with open(conf) as f:
-				for line in f:
+			with open(conf) as _file:
+				for line in _file:
 					line = line.strip()
 					if line.startswith('#'):
 						continue
@@ -62,8 +64,8 @@ def prepare_search_dirs(logger, settings):
 	lib_dirs = set(['/lib', '/usr/lib', ])
 
 	#try:
-	with open(os.path.join(portage.root, settings['DEFAULT_ENV_FILE']), 'r') as f:
-		for line in f:
+	with open(os.path.join(portage.root, settings['DEFAULT_ENV_FILE']), 'r') as _file:
+		for line in _file:
 			line = line.strip()
 			m = re.match("^export (ROOT)?PATH='([^']+)'", line)
 			if m is not None:
@@ -84,10 +86,11 @@ def parse_revdep_config(revdep_confdir):
 	masked_files = set()
 
 	#TODO: remove hard-coded path
-	for f in os.listdir(revdep_confdir):
-		for line in open(os.path.join('/etc/revdep-rebuild', f)):
+	for _file in os.listdir(revdep_confdir):
+		for line in open(os.path.join('/etc/revdep-rebuild', _file)):
 			line = line.strip()
-			if not line.startswith('#'): #first check for comment, we do not want to regex all lines
+			#first check for comment, we do not want to regex all lines
+			if not line.startswith('#'): 
 				m = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
 				if m is not None:
 					s = m.group(1).split(' ')
@@ -116,8 +119,9 @@ def collect_libraries_from_dir(dirs, mask, logger):
 		(symlink_id, library_id) for resolving dependencies
 	'''
 
-
-	found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
+	# contains list of directories found
+	# allows us to reduce number of fnc calls
+	found_directories = []  
 	found_files = []
 	found_symlinks = []
 	found_la_files = [] # la libraries
@@ -172,15 +176,17 @@ def collect_libraries_from_dir(dirs, mask, logger):
 									prv & stat.S_IXOTH == stat.S_IXOTH:
 								found_files.append(l)
 		except Exception as ex:
-			logger.debug(yellow('Exception during collecting libraries: ' + blue('%s')  %str(ex)))
+			logger.debug(
+				yellow('Exception during collecting libraries: ' + 
+				blue('%s')  %str(ex)))
 
 
 	if found_directories:
-		f,a,l,p = collect_libraries_from_dir(found_directories, mask, logger)
-		found_files+=f
-		found_la_files+=a
-		found_symlinks+=l
-		symlink_pairs+=p
+		f, a, l, p = collect_libraries_from_dir(found_directories, mask, logger)
+		found_files += f
+		found_la_files += a
+		found_symlinks += l
+		symlink_pairs += p
 
 	return (found_files, found_la_files, found_symlinks, symlink_pairs)
 
@@ -191,7 +197,9 @@ def collect_binaries_from_dir(dirs, mask, logger):
 		Returns list of binaries
 	'''
 
-	found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
+	# contains list of directories found
+	# allows us to reduce number of fnc calls
+	found_directories = []  
 	found_files = []
 
 	for d in dirs:
@@ -211,7 +219,9 @@ def collect_binaries_from_dir(dirs, mask, logger):
 					else:
 						found_directories.append(l)
 				elif os.path.isfile(l):
-					#we're looking for binaries, and with binaries we do not need links, thus we can optimize a bit
+					# we're looking for binaries
+					# and with binaries we do not need links
+					# thus we can optimize a bit
 					if not os.path.islink(l):
 						prv = os.stat(l)[stat.ST_MODE]
 						if prv & stat.S_IXUSR == stat.S_IXUSR or \
@@ -219,7 +229,9 @@ def collect_binaries_from_dir(dirs, mask, logger):
 								prv & stat.S_IXOTH == stat.S_IXOTH:
 							found_files.append(l)
 		except Exception as e:
-			logger.debug(yellow('Exception during binaries collecting: '+blue('%s') %str(e)))
+			logger.debug(
+				yellow('Exception during binaries collecting: '+
+				blue('%s') %str(e)))
 
 	if found_directories:
 		found_files += collect_binaries_from_dir(found_directories, mask, logger)
@@ -230,17 +242,20 @@ def collect_binaries_from_dir(dirs, mask, logger):
 
 if __name__ == '__main__':
 	import logging
-	bin_dirs, lib_dirs = prepare_search_dirs(logging)
+	mbin_dirs, mlib_dirs = prepare_search_dirs(logging)
 
-	masked_dirs, masked_files, ld = parse_revdep_config()
-	lib_dirs.update(ld)
-	bin_dirs.update(ld)
-	masked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules'])
+	mmasked_dirs, mmasked_files, mld = parse_revdep_config()
+	mlib_dirs.update(mld)
+	mbin_dirs.update(mld)
+	mmasked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules'])
 
-	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
-	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
+	libraries, la_libraries, libraries_links, msymlink_pairs = collect_libraries_from_dir(
+		mlib_dirs, mmasked_dirs, logging)
+	binaries = collect_binaries_from_dir(mbin_dirs, mmasked_dirs, logging)
 
-	logging.debug('Found: %i binaries and %i libraries.' %(len(binaries), len(libraries)))
+	logging.debug(
+		'Found: %i binaries and %i libraries.' %(
+		len(binaries), len(libraries)))
 
 
 

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 9ac4811..04fb96c 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -10,18 +10,10 @@
 # Creation date: 2010/10/17
 # License: BSD
 
-import subprocess
 import os
 import sys
-import re
 import getopt
-import signal
-import stat
-import time
-import glob
-import portage
 import logging
-from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
 
 from analyse import analyse
@@ -41,6 +33,7 @@ __productname__ = "revdep-ng"
 # functions
 
 def print_usage():
+	"""Outputs the help message"""
 	print( APP_NAME + ': (' + VERSION +')')
 	print
 	print('This is free software; see the source for copying conditions.')
@@ -93,8 +86,8 @@ def init_logger(settings):
 def parse_options():
 	"""Parses the command line options an sets settings accordingly"""
 
-	# @TODO: Verify: options: no-ld-path, no-order, no-progress are not appliable 
-	# for revdep-ng
+	# TODO: Verify: options: no-ld-path, no-order, no-progress
+	#are not appliable
 
 	settings = DEFAULTS.copy()
 	try:
@@ -161,14 +154,25 @@ def rebuild(logger, assigned, settings):
 
 	emerge_command = emerge_command
 
-	logger.warn(yellow('\nemerge') + args + ' --oneshot --complete-graph=y ' + bold(emerge_command))
+	logger.warn(yellow(
+		'\nemerge') + args + 
+		' --oneshot --complete-graph=y ' +
+		bold(emerge_command))
 	
-	success = os.system('emerge ' + args + ' --oneshot --complete-graph=y ' + emerge_command)
+	success = os.system(
+		'emerge ' + args + 
+		' --oneshot --complete-graph=y ' + 
+		emerge_command)
 	return success
 
 
-# Runs from here
 def main(settings=None, logger=None):
+	"""Main program operation method....
+	
+	@param settings: dict.  defaults to settings.DEFAULTS
+	@param logger: python logging module defaults to init_logger(settings)
+	@return boolean  success/failure
+	"""
 
 	if settings is None:
 		print("NO Input settings, using defaults...")
@@ -193,9 +197,9 @@ def main(settings=None, logger=None):
 			yellow('This is a development version, '
 				'so it may not work correctly'))
 		logger.warn(blue(' * ') + 
-			yellow('The original revdep-rebuild script is installed as revdep-rebuild.sh'))
+			yellow('The original revdep-rebuild script is '
+				'installed as revdep-rebuild.sh'))
 
-	analyze_cache = {}
 	if settings['USE_TMP_FILES'] \
 			and check_temp_files(settings['DEFAULT_TMP_DIR']):
 		libraries, la_libraries, libraries_links, binaries = read_cache(
@@ -218,13 +222,13 @@ def main(settings=None, logger=None):
 
 	has_masked = False
 	tmp = []
-	for a in assigned:
-		if get_masking_status(a):
+	for ebuild in assigned:
+		if get_masking_status(ebuild):
 			has_masked = True
 			logger.warn('!!! ' + red('All ebuilds that could satisfy: ') + 
-				green(a) + red(' have been masked'))
+				green(ebuild) + red(' have been masked'))
 		else:
-			tmp.append(a)
+			tmp.append(ebuild)
 	assigned = tmp
 
 	if has_masked:

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 96aa491..b56f812 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -1,5 +1,7 @@
 #!/usr/bin/python
 
+"""Default settings"""
+
 import os
 import sys
 
@@ -12,17 +14,18 @@ DEFAULTS = {
 		'PKG_DIR': os.path.join(portage.root, 'var/db/pkg/'),
 		'DEFAULT_TMP_DIR': '/tmp/revdep-rebuild', #cache default location
 
-
-		'USE_TMP_FILES': True, #if program should use temporary files from previous run
-		'CMD_MAX_ARGS': 1000, # number of maximum allowed files to be parsed at once
+		# number of maximum allowed files to be parsed at once
+		'CMD_MAX_ARGS': 1000, 
 
 		'PRETEND': False,     #pretend only
 		'EXACT': False,      #exact package version
-		'USE_TMP_FILES': True, #if program should use temporary files from previous run
+		#if program should use temporary files from previous run
+		'USE_TMP_FILES': True, 
 
-		'IS_DEV': True,       #True for dev. version, False for stable
-				#used when IS_DEV is True, False forces to call emerge with --pretend
-				# can be set True from the cli with the --no-pretend option
+		#True for dev. version, False for stable
+		#used when IS_DEV is True, False forces to call emerge with --pretend
+		# can be set True from the cli with the --no-pretend option
+		'IS_DEV': True,
 		'NO_PRETEND': False,
 		'VERBOSITY': 1,
 		

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 1ab21f2..163cc7d 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -1,5 +1,8 @@
 #!/usr/bin/python
 
+"""Utilities submodule"""
+
+
 import subprocess
 
 import portage
@@ -27,15 +30,17 @@ def scan(params, files, max_args):
 	'''
 	out = []
 	for i in range(0, len(files), max_args):
-		out += call_program(['scanelf'] + params + files[i:i+max_args]).strip().split('\n')
+		out += call_program(
+			['scanelf'] + params + files[i:i+max_args]).strip().split('\n')
 	return out
 
 
-def exithandler(signum, frame):
-	sys.exit(1)
-
-
 def get_masking_status(ebuild):
+	"""returns the masking status of an ebuild
+	
+	@param ebuild: str
+	@return list
+	"""
 	try:
 		status = portage.getmaskingstatus(ebuild)
 	except KeyError:
@@ -44,6 +49,11 @@ def get_masking_status(ebuild):
 
 
 def _match_str_in_list(lst, stri):
+	"""
+	@param lst: list
+	@param stri: string
+	@return boolean or list menber that matches stri.endswith(member)
+	"""
 	for l in lst:
 		if stri.endswith(l):
 			return l



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-13 20:06 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-13 20:06 UTC (permalink / raw
  To: gentoo-commits

commit:     0f177509d8384c822240f62d4416afa1ea56d540
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 13 20:06:13 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Wed Jul 13 20:06:13 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=0f177509

Fix python 3 incompatible code

---
 pym/gentoolkit/revdep_rebuild/analyse.py |    8 ++++----
 pym/gentoolkit/revdep_rebuild/cache.py   |    8 ++++----
 pym/gentoolkit/revdep_rebuild/collect.py |    2 +-
 pym/gentoolkit/revdep_rebuild/rebuild.py |   12 ++++++------
 pym/gentoolkit/revdep_rebuild/stuff.py   |    4 ++--
 5 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index f0ef323..700c966 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -9,10 +9,10 @@ import glob
 
 from portage.output import bold, red, blue, yellow, green, nocolor
 
-from stuff import scan
-from collect import prepare_search_dirs, parse_revdep_config, collect_libraries_from_dir, collect_binaries_from_dir
-from assign import assign_packages
-from cache import save_cache
+from .stuff import scan
+from .collect import prepare_search_dirs, parse_revdep_config, collect_libraries_from_dir, collect_binaries_from_dir
+from .assign import assign_packages
+from .cache import save_cache
 
 
 def prepare_checks(files_to_check, libraries, bits, cmd_max_args):

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index a1cb1ec..ca2ab1b 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -5,7 +5,7 @@ import os
 import time
 
 from portage.output import red
-from settings import DEFAULTS
+from .settings import DEFAULTS
 
 
 def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
@@ -18,7 +18,7 @@ def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 
 	ret = {'libraries':[], 'la_libraries':[], 'libraries_links':[], 'binaries':[]}
 	try:
-		for key,val in ret.iteritems():
+		for key,val in list(ret.items()):
 			f = open(os.path.join(temp_path, key))
 			for line in f.readlines():
 				val.append(line.strip())
@@ -44,7 +44,7 @@ def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 		f.write(str(int(time.time())))
 		f.close()
 
-		for key,val in to_save.iteritems():
+		for key,val in list(to_save.items()):
 			f = open(os.path.join(temp_path, key), 'w')
 			for line in val:
 				f.write(line + '\n')
@@ -87,7 +87,7 @@ def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600):
 if __name__ == '__main__':
 	print('Preparing cache ... ')
 
-	from collect import *
+	from .collect import *
 	import logging
 
 	bin_dirs, lib_dirs = prepare_search_dirs()

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index b9e9c0d..3f05161 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -18,7 +18,7 @@ def parse_conf(conf_file, visited=None, logger=None):
 	lib_dirs = set()
 	to_parse = set()
 
-	if isinstance(conf_file, basestring):
+	if isinstance(conf_file, str):
 		conf_file = [conf_file]
 
 	for conf in conf_file:

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index d26e186..aa802bb 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -25,12 +25,12 @@ import logging
 from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
 
-from analyse import analyse
-from stuff import exithandler, get_masking_status
-from cache import check_temp_files, read_cache
-from assign import get_slotted_cps
-from settings import DEFAULTS
-from gentoolkit.revdep_rebuild import __version__
+from .analyse import analyse
+from .stuff import exithandler, get_masking_status
+from .cache import check_temp_files, read_cache
+from .assign import get_slotted_cps
+from .settings import DEFAULTS
+from . import __version__
 
 
 APP_NAME = sys.argv[0]

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 66f5769..64b9601 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -8,11 +8,11 @@ import portage
 
 # util. functions
 def call_program(args):
-	''' Calls program with specified parameters and returns stdout '''
+	''' Calls program with specified parameters and returns stdout as a str object '''
 	subp = subprocess.Popen(args, stdout=subprocess.PIPE, \
 								stderr=subprocess.PIPE)
 	stdout, stderr = subp.communicate()
-	return stdout
+	return str(stdout)
 
 
 def scan(params, files, max_args):



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-13 16:01 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-13 16:01 UTC (permalink / raw
  To: gentoo-commits

commit:     4aea8eb88ca81e2c977634567d94f9f68ba0a06c
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 13 16:00:52 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Wed Jul 13 16:00:52 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4aea8eb8

Add from __future__ import print_function for python 3 compatability

---
 pym/gentoolkit/revdep_rebuild/analyse.py  |    2 ++
 pym/gentoolkit/revdep_rebuild/assign.py   |    1 +
 pym/gentoolkit/revdep_rebuild/cache.py    |    1 +
 pym/gentoolkit/revdep_rebuild/collect.py  |    1 +
 pym/gentoolkit/revdep_rebuild/rebuild.py  |    9 +++++----
 pym/gentoolkit/revdep_rebuild/settings.py |    1 +
 pym/gentoolkit/revdep_rebuild/stuff.py    |    1 +
 7 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 69651ca..f0ef323 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -1,5 +1,7 @@
 #!/usr/bin/python
 
+from __future__ import print_function
+
 import os
 import re
 import platform

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 5ed938e..ed0f698 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 
+from __future__ import print_function
 import os
 import re
 

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index ef46314..a1cb1ec 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -1,5 +1,6 @@
 #!/bin/bash
 
+from __future__ import print_function
 import os
 import time
 

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index e8075d8..b9e9c0d 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 
+from __future__ import print_function
 import re
 import os
 import glob

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 9ac4811..d26e186 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -10,6 +10,7 @@
 # Creation date: 2010/10/17
 # License: BSD
 
+from __future__ import print_function
 import subprocess
 import os
 import sys
@@ -42,13 +43,13 @@ __productname__ = "revdep-ng"
 
 def print_usage():
 	print( APP_NAME + ': (' + VERSION +')')
-	print
+	print()
 	print('This is free software; see the source for copying conditions.')
-	print
+	print()
 	print('Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]')
-	print
+	print()
 	print('Broken reverse dependency rebuilder, python implementation.')
-	print
+	print()
 	print('Available options:')
 	print('''
   -C, --nocolor         Turn off colored output

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 96aa491..b95e8ff 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 
+from __future__ import print_function
 import os
 import sys
 

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 1ab21f2..66f5769 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -1,5 +1,6 @@
 #!/usr/bin/python
 
+from __future__ import print_function
 import subprocess
 
 import portage



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-13 15:35 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2011-07-13 15:35 UTC (permalink / raw
  To: gentoo-commits

commit:     2664f68f9553b94a9bb93dc0282de6ffbf8232f9
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Wed Jul 13 15:35:44 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Jul 13 15:35:44 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=2664f68f

fix the placement of the l.endswith('.a') in the if

---
 pym/gentoolkit/revdep_rebuild/collect.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 8d80e21..e8075d8 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -140,7 +140,7 @@ def collect_libraries_from_dir(dirs, mask, logger):
 					else:
 						found_directories.append(l)
 				elif os.path.isfile(l):
-					if l.endswith('.so') or '.so.' or l.endswith('.a') in l:
+					if l.endswith('.so') or l.endswith('.a') or '.so.' in l:
 						if l in found_files or l in found_symlinks:
 							continue
 



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-13  5:53 Brian Dolbec
  0 siblings, 0 replies; 115+ messages in thread
From: Brian Dolbec @ 2011-07-13  5:53 UTC (permalink / raw
  To: gentoo-commits

commit:     4576c230e52a09fae3f45d872be158259297846a
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Wed Jul 13 05:32:42 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Jul 13 05:32:42 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4576c230

fix the use of set updates and the with statement.

---
 pym/gentoolkit/revdep_rebuild/analyse.py |    4 ++--
 pym/gentoolkit/revdep_rebuild/assign.py  |    2 +-
 pym/gentoolkit/revdep_rebuild/cache.py   |    6 +++---
 pym/gentoolkit/revdep_rebuild/collect.py |   20 ++++++++++----------
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 34ef55b..69651ca 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -146,8 +146,8 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 		bin_dirs, lib_dirs = prepare_search_dirs(logger, settings)
 
 		masked_dirs, masked_files, ld = parse_revdep_config(settings['REVDEP_CONFDIR'])
-		lib_dirs = lib_dirs.union(ld)
-		bin_dirs = bin_dirs.union(ld)
+		lib_dirs.update(ld)
+		bin_dirs.update(ld)
 		masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
 
 		logger.info(green(' * ') + bold('Collecting dynamic linking informations'))

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index f7f0304..5ed938e 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -19,7 +19,7 @@ def assign_packages(broken, logger, settings):
 			if os.path.exists(f):
 				try:
 					with open(f, 'r') as cnt:
-						for line in cnt.readlines():
+						for line in cnt:
 							m = re.match('^obj (/[^ ]+)', line)
 							if m is not None:
 								m = m.group(1)

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 6d21016..ef46314 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -92,9 +92,9 @@ if __name__ == '__main__':
 	bin_dirs, lib_dirs = prepare_search_dirs()
 
 	masked_dirs, masked_files, ld = parse_revdep_config()
-	lib_dirs = lib_dirs.union(ld)
-	bin_dirs = bin_dirs.union(ld)
-	masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+	lib_dirs.update(ld)
+	bin_dirs.update(ld)
+	masked_dirs = masked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules',])
 
 	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
 	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index e5df8e3..8d80e21 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -23,7 +23,7 @@ def parse_conf(conf_file, visited=None, logger=None):
 	for conf in conf_file:
 		try:
 			with open(conf) as f:
-				for line in f.readlines():
+				for line in f:
 					line = line.strip()
 					if line.startswith('#'):
 						continue
@@ -36,7 +36,7 @@ def parse_conf(conf_file, visited=None, logger=None):
 							else:
 								path = included
 
-							to_parse = to_parse.union(glob.glob(path))
+							to_parse.update(glob.glob(path))
 					else:
 						lib_dirs.add(line)
 		except EnvironmentError:
@@ -45,10 +45,10 @@ def parse_conf(conf_file, visited=None, logger=None):
 	if visited is None:
 		visited = set()
 
-	visited = visited.union(conf_file)
-	to_parse = to_parse.difference(visited)
+	visited.update(conf_file)
+	to_parse.difference_update(visited)
 	if to_parse:
-		lib_dirs = lib_dirs.union(parse_conf(to_parse, visited, logger=logger))
+		lib_dirs.update(parse_conf(to_parse, visited, logger=logger))
 
 	return lib_dirs
 
@@ -63,11 +63,11 @@ def prepare_search_dirs(logger, settings):
 
 	#try:
 	with open(os.path.join(portage.root, settings['DEFAULT_ENV_FILE']), 'r') as f:
-		for line in f.readlines():
+		for line in f:
 			line = line.strip()
 			m = re.match("^export (ROOT)?PATH='([^']+)'", line)
 			if m is not None:
-				bin_dirs = bin_dirs.union(set(m.group(2).split(':')))
+				bin_dirs.update(set(m.group(2).split(':')))
 	#except EnvironmentError:
 		#logger.debug(yellow('Could not open file %s' % f))
 
@@ -233,9 +233,9 @@ if __name__ == '__main__':
 	bin_dirs, lib_dirs = prepare_search_dirs(logging)
 
 	masked_dirs, masked_files, ld = parse_revdep_config()
-	lib_dirs = lib_dirs.union(ld)
-	bin_dirs = bin_dirs.union(ld)
-	masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+	lib_dirs.update(ld)
+	bin_dirs.update(ld)
+	masked_dirs.update(['/lib/modules', '/lib32/modules', '/lib64/modules'])
 
 	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
 	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     e7ed5b3dfb74f524d298aedf7a4207d50dbee689
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 12 21:26:14 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=e7ed5b3d

Remove automatic adding of pretend to revdep-rebuild options.
Fix la file checker to find .a libraries referenced.
Add --complete-graph=y to emerge command.

---
 pym/gentoolkit/revdep_rebuild/analyse.py |    2 +-
 pym/gentoolkit/revdep_rebuild/collect.py |    2 +-
 pym/gentoolkit/revdep_rebuild/rebuild.py |    9 +++------
 3 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 3061328..34ef55b 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -61,7 +61,7 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 				if m is not None:
 					for el in m.group(1).split(' '):
 						el = el.strip()
-						if len(el) < 1 or el.startswith('-L'):
+						if len(el) < 1 or el.startswith('-L') or el.startswith('-R'):
 							continue
 
 						if el.startswith('-l') and 'lib'+el[2:] in libnames:

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index b7ed469..e5df8e3 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -140,7 +140,7 @@ def collect_libraries_from_dir(dirs, mask, logger):
 					else:
 						found_directories.append(l)
 				elif os.path.isfile(l):
-					if l.endswith('.so') or '.so.' in l:
+					if l.endswith('.so') or '.so.' or l.endswith('.a') in l:
 						if l in found_files or l in found_symlinks:
 							continue
 

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 778c528..9ac4811 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -161,9 +161,9 @@ def rebuild(logger, assigned, settings):
 
 	emerge_command = emerge_command
 
-	logger.warn(yellow('\nemerge') + args + ' --oneshot ' + bold(emerge_command))
+	logger.warn(yellow('\nemerge') + args + ' --oneshot --complete-graph=y ' + bold(emerge_command))
 	
-	success = os.system('emerge ' + args + ' --oneshot ' + emerge_command)
+	success = os.system('emerge ' + args + ' --oneshot --complete-graph=y ' + emerge_command)
 	return success
 
 
@@ -193,10 +193,7 @@ def main(settings=None, logger=None):
 			yellow('This is a development version, '
 				'so it may not work correctly'))
 		logger.warn(blue(' * ') + 
-			yellow('Adding --pretend to portage options anyway'))
-		logger.info(blue(' * ') + 
-			'If you\'re sure, you can add --no-pretend to revdep options')
-		settings['PRETEND'] = True
+			yellow('The original revdep-rebuild script is installed as revdep-rebuild.sh'))
 
 	analyze_cache = {}
 	if settings['USE_TMP_FILES'] \



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     1bc82cc11fde5b0db852c1bd3954cfb70db61d25
Author:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 12 20:31:33 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=1bc82cc1

Fix python 3 syntax errors with new revdep-rebuild. Change VERSION to
reference __version__.

---
 pym/gentoolkit/revdep_rebuild/analyse.py |    2 +-
 pym/gentoolkit/revdep_rebuild/assign.py  |    2 +-
 pym/gentoolkit/revdep_rebuild/cache.py   |    4 ++--
 pym/gentoolkit/revdep_rebuild/rebuild.py |   21 +++++++++++----------
 pym/gentoolkit/revdep_rebuild/stuff.py   |    2 +-
 5 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index d94365e..3061328 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -218,4 +218,4 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 
 
 if __name__ == '__main__':
-	print "This script shouldn't be called directly"
+	print("This script shouldn't be called directly")

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index bb9ec1f..f7f0304 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -89,4 +89,4 @@ def get_slotted_cps(cpvs, logger):
 
 
 if __name__ == '__main__':
-	print 'Nothing to call here'
+	print('Nothing to call here')

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 8b1a8ed..6d21016 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -84,7 +84,7 @@ def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600):
 
 
 if __name__ == '__main__':
-	print 'Preparing cache ... '
+	print('Preparing cache ... ')
 
 	from collect import *
 	import logging
@@ -104,4 +104,4 @@ if __name__ == '__main__':
 			'libraries_links':libraries_links, 'binaries':binaries}
 		)
 
-	print 'Done.'
+	print('Done.')

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 834170e..778c528 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -29,10 +29,11 @@ from stuff import exithandler, get_masking_status
 from cache import check_temp_files, read_cache
 from assign import get_slotted_cps
 from settings import DEFAULTS
+from gentoolkit.revdep_rebuild import __version__
 
 
 APP_NAME = sys.argv[0]
-VERSION = '0.1-r7'
+VERSION = __version__
 
 __productname__ = "revdep-ng"
 
@@ -40,16 +41,16 @@ __productname__ = "revdep-ng"
 # functions
 
 def print_usage():
-	print APP_NAME + ': (' + VERSION +')'
+	print( APP_NAME + ': (' + VERSION +')')
 	print
-	print 'This is free software; see the source for copying conditions.'
+	print('This is free software; see the source for copying conditions.')
 	print
-	print 'Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]'
+	print('Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]')
 	print
-	print 'Broken reverse dependency rebuilder, python implementation.'
+	print('Broken reverse dependency rebuilder, python implementation.')
 	print
-	print 'Available options:'
-	print '''
+	print('Available options:')
+	print('''
   -C, --nocolor         Turn off colored output
   -d, --debug           Print debug informations
   -e, --exact           Emerge based on exact package version
@@ -66,9 +67,9 @@ def print_usage():
                         (also passed to emerge command)
   -q, --quiet           Be less verbose (also passed to emerge command)
   -v, --verbose         Be more verbose (also passed to emerge command)
-'''
-	print 'Calls emerge, options after -- are ignored by ' + APP_NAME
-	print 'and passed directly to emerge.'
+''')
+	print( 'Calls emerge, options after -- are ignored by ' + APP_NAME)
+	print('and passed directly to emerge.')
 
 
 def init_logger(settings):

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 7b287b1..1ab21f2 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -52,4 +52,4 @@ def _match_str_in_list(lst, stri):
 
 
 if __name__ == '__main__':
-	print "There is nothing to run here."
+	print("There is nothing to run here.")



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     aa3bfe1ebf070858e3f0dbea5727b1ef1f9616bd
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:22:11 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=aa3bfe1e

move unused function to stuff.py

---
 pym/gentoolkit/revdep_rebuild/rebuild.py |    7 -------
 pym/gentoolkit/revdep_rebuild/stuff.py   |   10 +++++++++-
 2 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 6c08f5b..e0ab7d1 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -71,13 +71,6 @@ def print_usage():
 	print 'and passed directly to emerge.'
 
 
-def _match_str_in_list(lst, stri):
-	for l in lst:
-		if stri.endswith(l):
-			return l
-	return False
-
-
 def init_logger(settings):
 	"""Creates and iitializes our logger according to the settings"""
 	logger = logging.getLogger()

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index 459301f..7b287b1 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -31,7 +31,6 @@ def scan(params, files, max_args):
 	return out
 
 
-
 def exithandler(signum, frame):
 	sys.exit(1)
 
@@ -43,5 +42,14 @@ def get_masking_status(ebuild):
 		status = ['unavailable']
 	return status
 
+
+def _match_str_in_list(lst, stri):
+	for l in lst:
+		if stri.endswith(l):
+			return l
+	return False
+
+
+
 if __name__ == '__main__':
 	print "There is nothing to run here."



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     32a725f9f33c6bd3036f13cac5363717157ac494
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Thu Apr 28 09:41:35 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=32a725f9

Fixed --library checking when not using cache

---
 pym/gentoolkit/revdep_rebuild/rebuild.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 5385b0e..834170e 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -211,7 +211,7 @@ def main(settings=None, logger=None):
 			binaries=binaries,
 			_libs_to_check=_libs_to_check)
 	else:
-		assigned = analyse(settings, logger)
+		assigned = analyse(settings, logger, _libs_to_check=_libs_to_check)
 
 	if not assigned:
 		logger.warn('\n' + bold('Your system is consistent'))



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     2f8da3a3f36faf57ba5d117fe725cbbfbff7ae7f
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:23:55 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=2f8da3a3

pass the nocolor setting on to emerge.

---
 pym/gentoolkit/revdep_rebuild/rebuild.py |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index e0ab7d1..ef3a476 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -148,6 +148,8 @@ def rebuild(logger, assigned, settings):
 		args += ' --verbose'
 	elif settings['VERBOSITY'] < 1:
 		args += ' --quiet'
+	if settings['nocolor']:
+		args += ' --color n'
 
 	if len(emerge_command) == 0:
 		logger.warn(bold('\nThere is nothing to emerge. Exiting.'))



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     8d6b825b2d8e5eb69568619223721ae5c7e0aa07
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Tue Apr 26 07:08:24 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=8d6b825b

Fixed .la files parser. Some minor logging fixes.

---
 pym/gentoolkit/revdep_rebuild/analyse.py |   23 ++++++++++++++++++-----
 pym/gentoolkit/revdep_rebuild/collect.py |    6 +++---
 pym/gentoolkit/revdep_rebuild/rebuild.py |    4 ++--
 3 files changed, 23 insertions(+), 10 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 521d8b9..be696d1 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -40,6 +40,15 @@ def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
 
 def extract_dependencies_from_la(la, libraries, to_check, logger):
 	broken = []
+
+	libnames = []
+	for l in libraries:
+		m = re.match('.+\/(.+)\.(so|la|a)(\..+)?', l)
+		if m is not None:
+			ln = m.group(1)
+			if ln not in libnames:
+				libnames += [ln, ]
+
 	for f in la:
 		if not os.path.exists(f):
 			continue
@@ -51,10 +60,12 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 				if m is not None:
 					for el in m.group(1).split(' '):
 						el = el.strip()
-						if len(el) < 1 or el.startswith('-'):
+						if len(el) < 1 or el.startswith('-L'):
 							continue
 
-						if el in la or el in libraries:
+						if el.startswith('-l') and 'lib'+el[2:] in libnames:
+							pass
+						elif el in la or el in libraries:
 							pass
 						else:
 							if to_check:
@@ -66,7 +77,7 @@ def extract_dependencies_from_la(la, libraries, to_check, logger):
 								if not _break:
 									continue
 
-							logger.info(yellow(' * ') + f + ' is broken (requires: ' + bold(el))
+							logger.info(yellow(' * ') + f + ' is broken (requires: ' + bold(el)+')')
 							broken.append(f)
 	return broken
 
@@ -178,13 +189,15 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 		#call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
 
 		found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits, settings['CMD_MAX_ARGS'])
-
+		#print dependencies
 		broken = find_broken(found_libs, _libraries, _libs_to_check)
-		broken_la = extract_dependencies_from_la(la_libraries, _libraries, _libs_to_check, logger)
 
 		bits /= 2
 		bits = int(bits)
 
+	broken_la = extract_dependencies_from_la(la_libraries, libraries+libraries_links, _libs_to_check, logger)
+
+
 	broken_pathes = main_checks(found_libs, broken, dependencies, logger)
 	broken_pathes += broken_la
 

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index b408edc..b7ed469 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -172,7 +172,7 @@ def collect_libraries_from_dir(dirs, mask, logger):
 									prv & stat.S_IXOTH == stat.S_IXOTH:
 								found_files.append(l)
 		except Exception as ex:
-			logger.debug(yellow('Exception during collecting libraries: %s' %str(ex)))
+			logger.debug(yellow('Exception during collecting libraries: ' + blue('%s')  %str(ex)))
 
 
 	if found_directories:
@@ -219,7 +219,7 @@ def collect_binaries_from_dir(dirs, mask, logger):
 								prv & stat.S_IXOTH == stat.S_IXOTH:
 							found_files.append(l)
 		except Exception as e:
-			logger.debug(yellow('Exception during binaries collecting: %s' %str(e)))
+			logger.debug(yellow('Exception during binaries collecting: '+blue('%s') %str(e)))
 
 	if found_directories:
 		found_files += collect_binaries_from_dir(found_directories, mask, logger)
@@ -240,7 +240,7 @@ if __name__ == '__main__':
 	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
 	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
 
-	print 'Found: %i binaries and %i libraries.' %(len(binaries), len(libraries))
+	logging.debug('Found: %i binaries and %i libraries.' %(len(binaries), len(libraries)))
 
 
 

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index ef3a476..f77d98c 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -32,7 +32,7 @@ from settings import DEFAULTS
 
 
 APP_NAME = sys.argv[0]
-VERSION = '0.1-r6'
+VERSION = '0.1-r7'
 
 __productname__ = "revdep-ng"
 
@@ -232,5 +232,5 @@ def main(settings=None, logger=None):
 			'again or manually emerge given packages.')
 
 	success = rebuild(logger, assigned, settings)
-	logger.debug("rebuild return code =", success)
+	logger.debug("rebuild return code = %i" %success)
 	return success



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     c7d95a92e5ec1b12f15536866bb05a77eae7e466
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Wed Apr 27 04:21:03 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=c7d95a92

Added support for file path in -L option

---
 pym/gentoolkit/revdep_rebuild/analyse.py |   16 +++++++++++++---
 pym/gentoolkit/revdep_rebuild/rebuild.py |    9 ++++++---
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index be696d1..d94365e 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -35,6 +35,7 @@ def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
 			else:
 				libs.append(d)
 				dependencies.append([r[0],])
+	
 	return (libs, dependencies)
 
 
@@ -176,6 +177,13 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	found_libs = []
 	dependencies = []
 
+	if _libs_to_check:
+		nltc = []
+		for ltc in _libs_to_check:
+			if os.path.isfile(ltc):
+				ltc = scan(['-nBSF', '%S'], [ltc,], settings['CMD_MAX_ARGS'])[0].split()[0]
+			nltc += [ltc,]
+		_libs_to_check = nltc
 
 	_bits, linkg = platform.architecture()
 	if _bits.startswith('32'):
@@ -183,13 +191,15 @@ def analyse(settings, logger, libraries=None, la_libraries=None,
 	elif _bits.startswith('64'):
 		bits = 64
 
+	import time
+	broken = []
 	for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
 		bits = int(av_bits[4:])
-		_libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, settings['CMD_MAX_ARGS'])
-		#call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
+
+		#_libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, settings['CMD_MAX_ARGS'])
+		_libraries = libraries+libraries_links
 
 		found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits, settings['CMD_MAX_ARGS'])
-		#print dependencies
 		broken = find_broken(found_libs, _libraries, _libs_to_check)
 
 		bits /= 2

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index f77d98c..5385b0e 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -92,6 +92,9 @@ def init_logger(settings):
 def parse_options():
 	"""Parses the command line options an sets settings accordingly"""
 
+	# @TODO: Verify: options: no-ld-path, no-order, no-progress are not appliable 
+	# for revdep-ng
+
 	settings = DEFAULTS.copy()
 	try:
 		opts, args = getopt.getopt(sys.argv[1:], 
@@ -155,11 +158,11 @@ def rebuild(logger, assigned, settings):
 		logger.warn(bold('\nThere is nothing to emerge. Exiting.'))
 		return 0
 
-	emerge_command = args + ' --oneshot ' + emerge_command
+	emerge_command = emerge_command
 
-	logger.warn(yellow('\nemerge') + bold(emerge_command))
+	logger.warn(yellow('\nemerge') + args + ' --oneshot ' + bold(emerge_command))
 	
-	success = os.system('emerge ' + emerge_command)
+	success = os.system('emerge ' + args + ' --oneshot ' + emerge_command)
 	return success
 
 



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     145d392512611f94168419b2fa7aa6a0cf8dd7a1
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 06:18:44 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=145d3925

migrate away from a global SETTINGS usage.
Better for tests and api usability.

---
 pym/gentoolkit/revdep_rebuild/analyse.py  |   21 ++++++++++-----------
 pym/gentoolkit/revdep_rebuild/assign.py   |   10 ++++------
 pym/gentoolkit/revdep_rebuild/cache.py    |    8 ++++----
 pym/gentoolkit/revdep_rebuild/collect.py  |   15 +++++++--------
 pym/gentoolkit/revdep_rebuild/settings.py |   17 +++++++++++++++--
 5 files changed, 40 insertions(+), 31 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index a9ac753..5ee0c7b 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -11,11 +11,9 @@ from stuff import scan
 from collect import prepare_search_dirs, parse_revdep_config, collect_libraries_from_dir, collect_binaries_from_dir
 from assign import assign_packages
 from cache import save_cache
-from settings import SETTINGS
 
 
-
-def prepare_checks(files_to_check, libraries, bits):
+def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
 	''' Calls scanelf for all files_to_check, then returns found libraries and dependencies
 	'''
 
@@ -23,7 +21,7 @@ def prepare_checks(files_to_check, libraries, bits):
 	dependencies = [] # list of lists of files (from file_to_check) that uses
 					  # library (for dependencies[id] and libs[id] => id==id)
 
-	for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check, SETTINGS['CMD_MAX_ARGS']):
+	for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check, cmd_max_args):
 	#call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
 		r = line.strip().split(' ')
 		if len(r) < 2: # no dependencies?
@@ -116,7 +114,8 @@ def main_checks(found_libs, broken, dependencies, logger):
 	return broken_pathes
 
 
-def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=None, binaries=None, _libs_to_check=set()):
+def analyse(settings=None, logger=None, libraries=None, la_libraries=None,
+		libraries_links=None, binaries=None, _libs_to_check=set()):
 	"""Main program body.  It will collect all info and determine the
 	pkgs needing rebuilding.
 
@@ -132,9 +131,9 @@ def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=N
 		#TODO: add partial cache (for ex. only libraries) when found for some reason
 
 		logger.warn(green(' * ') + bold('Collecting system binaries and libraries'))
-		bin_dirs, lib_dirs = prepare_search_dirs(logger)
+		bin_dirs, lib_dirs = prepare_search_dirs(logger, settings)
 
-		masked_dirs, masked_files, ld = parse_revdep_config()
+		masked_dirs, masked_files, ld = parse_revdep_config(settings['REVDEP_CONFDIR'])
 		lib_dirs = lib_dirs.union(ld)
 		bin_dirs = bin_dirs.union(ld)
 		masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
@@ -143,7 +142,7 @@ def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=N
 		libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logger)
 		binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
 
-		if SETTINGS['USE_TMP_FILES']:
+		if settings['USE_TMP_FILES']:
 			save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
 
 
@@ -170,10 +169,10 @@ def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=N
 
 	for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
 		bits = int(av_bits[4:])
-		_libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, SETTINGS['CMD_MAX_ARGS'])
+		_libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, settings['CMD_MAX_ARGS'])
 		#call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
 
-		found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits)
+		found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits, settings['CMD_MAX_ARGS'])
 
 		broken = find_broken(found_libs, _libraries, _libs_to_check)
 		broken_la = extract_dependencies_from_la(la_libraries, _libraries, _libs_to_check, logger)
@@ -186,7 +185,7 @@ def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=N
 
 	logger.warn(green(' * ') + bold('Assign files to packages'))
 
-	return assign_packages(broken_pathes, logger)
+	return assign_packages(broken_pathes, logger, settings)
 
 
 

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index c4ae750..9eb177d 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -2,21 +2,19 @@
 
 import os
 import re
-import logging
 import portage
 from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
-from settings import SETTINGS
 
 
-def assign_packages(broken, logger=logging):
+def assign_packages(broken, logger, settings):
 	''' Finds and returns packages that owns files placed in broken.
 		Broken is list of files
 	'''
 	assigned = set()
-	for group in os.listdir(SETTINGS['PKG_DIR']):
-		for pkg in os.listdir(SETTINGS['PKG_DIR'] + group):
-			f = SETTINGS['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
+	for group in os.listdir(settings['PKG_DIR']):
+		for pkg in os.listdir(settings['PKG_DIR'] + group):
+			f = settings['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
 			if os.path.exists(f):
 				try:
 					with open(f, 'r') as cnt:

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 616ef79..e1a8e11 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -4,10 +4,10 @@ import os
 import time
 import logging
 from portage.output import red
-from settings import SETTINGS
+from settings import DEFAULTS
 
 
-def read_cache(temp_path=SETTINGS['DEFAULT_TMP_DIR']):
+def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 	''' Reads cache information needed by analyse function.
 		This function does not checks if files exists nor timestamps,
 		check_temp_files should be called first
@@ -29,7 +29,7 @@ def read_cache(temp_path=SETTINGS['DEFAULT_TMP_DIR']):
 	return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
 
 
-def save_cache(logger=logging, to_save={}, temp_path=SETTINGS['DEFAULT_TMP_DIR']):
+def save_cache(logger=logging, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 	''' Tries to store caching information.
 		@param logger
 		@param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
@@ -53,7 +53,7 @@ def save_cache(logger=logging, to_save={}, temp_path=SETTINGS['DEFAULT_TMP_DIR']
 
 
 
-def check_temp_files(temp_path=SETTINGS['DEFAULT_TMP_DIR'], max_delay=3600):
+def check_temp_files(temp_path=DEFAULTS['DEFAULT_TMP_DIR'], max_delay=3600):
 	''' Checks if temporary files from previous run are still available
 		and if they aren't too old
 		@param temp_path is directory, where temporary files should be found

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 613749a..735857b 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -7,10 +7,9 @@ import stat
 import logging
 import portage
 from portage.output import bold, red, blue, yellow, green, nocolor
-from settings import SETTINGS
 
 
-def parse_conf(conf_file=SETTINGS['DEFAULT_LD_FILE'], visited=None, logger=logging):
+def parse_conf(conf_file, visited=None, logger=None):
 	''' Parses supplied conf_file for libraries pathes.
 		conf_file is file or files to parse
 		visited is set of files already parsed
@@ -54,7 +53,7 @@ def parse_conf(conf_file=SETTINGS['DEFAULT_LD_FILE'], visited=None, logger=loggi
 	return lib_dirs
 
 
-def prepare_search_dirs(logger=logging):
+def prepare_search_dirs(logger, settings):
 	''' Lookup for search dirs. Returns tuple with two lists,
 		(list_of_bin_dirs, list_of_lib_dirs)
 	'''
@@ -63,7 +62,7 @@ def prepare_search_dirs(logger=logging):
 	lib_dirs = set(['/lib', '/usr/lib', ])
 
 	#try:
-	with open(os.path.join(portage.root, SETTINGS['DEFAULT_ENV_FILE']), 'r') as f:
+	with open(os.path.join(portage.root, settings['DEFAULT_ENV_FILE']), 'r') as f:
 		for line in f.readlines():
 			line = line.strip()
 			m = re.match("^export (ROOT)?PATH='([^']+)'", line)
@@ -72,11 +71,11 @@ def prepare_search_dirs(logger=logging):
 	#except EnvironmentError:
 		#logger.debug(yellow('Could not open file %s' % f))
 
-	lib_dirs = parse_conf(logger=logger)
+	lib_dirs = parse_conf(settings['DEFAULT_LD_FILE'], logger=logger)
 	return (bin_dirs, lib_dirs)
 
 
-def parse_revdep_config():
+def parse_revdep_config(revdep_confdir):
 	''' Parses all files under /etc/revdep-rebuild/ and returns
 		tuple of: (masked_dirs, masked_files, search_dirs)'''
 
@@ -85,7 +84,7 @@ def parse_revdep_config():
 	masked_files = set()
 
 	#TODO: remove hard-coded path
-	for f in os.listdir(SETTINGS['REVDEP_CONFDIR']):
+	for f in os.listdir(revdep_confdir):
 		for line in open(os.path.join('/etc/revdep-rebuild', f)):
 			line = line.strip()
 			if not line.startswith('#'): #first check for comment, we do not want to regex all lines
@@ -110,7 +109,7 @@ def parse_revdep_config():
 	return (masked_dirs, masked_files, search_dirs)
 
 
-def collect_libraries_from_dir(dirs, mask, logger=logging):
+def collect_libraries_from_dir(dirs, mask, logger):
 	''' Collects all libraries from specified list of directories.
 		mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
 		Returns tuple composed of: list of libraries, list of symlinks, and toupe with pair

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index b47cb3e..7747ac2 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -1,9 +1,10 @@
 #!/usr/bin/python
 
 import os
+import sys
 import portage
 
-SETTINGS = {
+DEFAULTS = {
 		'DEFAULT_LD_FILE': os.path.join(portage.root, 'etc/ld.so.conf'),
 		'DEFAULT_ENV_FILE': os.path.join(portage.root, 'etc/profile.env'),
 		'REVDEP_CONFDIR': os.path.join(portage.root, 'etc/revdep-rebuild/'),
@@ -23,4 +24,16 @@ SETTINGS = {
 				# can be set True from the cli with the --no-pretend option
 		'NO_PRETEND': False,
 		'VERBOSITY': 1,
-	}
+		
+		'quiet': False,
+		'nocolor': False,
+		'library': set(),
+		'no-progress': False,
+		'debug': False,
+		'no-ld-path': False,
+		'no-order': False,
+		'pass_through_options': '',
+		'stdout': sys.stdout,
+		'stdin': sys.stdin,
+		'stderr': sys.stderr
+		}



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     f5f252ee461ee514bd13a4025ca47b268212ddb6
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Apr 24 22:24:01 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=f5f252ee

convert to gentoolkit's standard tab indent.

---
 pym/gentoolkit/revdep_rebuild/analyse.py  |  268 +++++++++---------
 pym/gentoolkit/revdep_rebuild/assign.py   |  136 +++++-----
 pym/gentoolkit/revdep_rebuild/cache.py    |  138 +++++-----
 pym/gentoolkit/revdep_rebuild/collect.py  |  416 ++++++++++++++--------------
 pym/gentoolkit/revdep_rebuild/settings.py |   32 ++--
 pym/gentoolkit/revdep_rebuild/stuff.py    |   48 ++--
 6 files changed, 519 insertions(+), 519 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index c1c755b..a9ac753 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -16,179 +16,179 @@ from settings import SETTINGS
 
 
 def prepare_checks(files_to_check, libraries, bits):
-    ''' Calls scanelf for all files_to_check, then returns found libraries and dependencies
-    '''
-
-    libs = [] # libs found by scanelf
-    dependencies = [] # list of lists of files (from file_to_check) that uses
-                      # library (for dependencies[id] and libs[id] => id==id)
-
-    for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check, SETTINGS['CMD_MAX_ARGS']):
-    #call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
-        r = line.strip().split(' ')
-        if len(r) < 2: # no dependencies?
-            continue
-
-        deps = r[1].split(',')
-        for d in deps:
-            if d in libs:
-                i = libs.index(d)
-                dependencies[i].append(r[0])
-            else:
-                libs.append(d)
-                dependencies.append([r[0],])
-    return (libs, dependencies)
+	''' Calls scanelf for all files_to_check, then returns found libraries and dependencies
+	'''
+
+	libs = [] # libs found by scanelf
+	dependencies = [] # list of lists of files (from file_to_check) that uses
+					  # library (for dependencies[id] and libs[id] => id==id)
+
+	for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check, SETTINGS['CMD_MAX_ARGS']):
+	#call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
+		r = line.strip().split(' ')
+		if len(r) < 2: # no dependencies?
+			continue
+
+		deps = r[1].split(',')
+		for d in deps:
+			if d in libs:
+				i = libs.index(d)
+				dependencies[i].append(r[0])
+			else:
+				libs.append(d)
+				dependencies.append([r[0],])
+	return (libs, dependencies)
 
 
 def extract_dependencies_from_la(la, libraries, to_check, logger):
-    broken = []
-    for f in la:
-        if not os.path.exists(f):
-            continue
-
-        for line in open(f, 'r').readlines():
-            line = line.strip()
-            if line.startswith('dependency_libs='):
-                m = re.match("dependency_libs='([^']+)'", line)
-                if m is not None:
-                    for el in m.group(1).split(' '):
-                        el = el.strip()
-                        if len(el) < 1 or el.startswith('-'):
-                            continue
-
-                        if el in la or el in libraries:
-                            pass
-                        else:
-                            if to_check:
-                                _break = False
-                                for tc in to_check:
-                                    if tc in el:
-                                        _break = True
-                                        break
-                                if not _break:
-                                    continue
-
-                            logger.info(yellow(' * ') + f + ' is broken (requires: ' + bold(el))
-                            broken.append(f)
-    return broken
+	broken = []
+	for f in la:
+		if not os.path.exists(f):
+			continue
+
+		for line in open(f, 'r').readlines():
+			line = line.strip()
+			if line.startswith('dependency_libs='):
+				m = re.match("dependency_libs='([^']+)'", line)
+				if m is not None:
+					for el in m.group(1).split(' '):
+						el = el.strip()
+						if len(el) < 1 or el.startswith('-'):
+							continue
+
+						if el in la or el in libraries:
+							pass
+						else:
+							if to_check:
+								_break = False
+								for tc in to_check:
+									if tc in el:
+										_break = True
+										break
+								if not _break:
+									continue
+
+							logger.info(yellow(' * ') + f + ' is broken (requires: ' + bold(el))
+							broken.append(f)
+	return broken
 
 
 def find_broken(found_libs, system_libraries, to_check):
-    ''' Search for broken libraries.
-        Check if system_libraries contains found_libs, where
-        system_libraries is list of obsolute pathes and found_libs
-        is list of library names.
-    '''
+	''' Search for broken libraries.
+		Check if system_libraries contains found_libs, where
+		system_libraries is list of obsolute pathes and found_libs
+		is list of library names.
+	'''
 
-    # join libraries and looking at it as string is way too faster than for-jumping
+	# join libraries and looking at it as string is way too faster than for-jumping
 
-    broken = []
-    sl = '|'.join(system_libraries)
+	broken = []
+	sl = '|'.join(system_libraries)
 
-    if not to_check:
-        for f in found_libs:
-            if f+'|' not in sl:
-                broken.append(found_libs.index(f))
-    else:
-        for tc in to_check:
-            for f in found_libs:
-                if tc in f:# and f+'|' not in sl:
-                    broken.append(found_libs.index(f))
+	if not to_check:
+		for f in found_libs:
+			if f+'|' not in sl:
+				broken.append(found_libs.index(f))
+	else:
+		for tc in to_check:
+			for f in found_libs:
+				if tc in f:# and f+'|' not in sl:
+					broken.append(found_libs.index(f))
 
-    return broken
+	return broken
 
 
 def main_checks(found_libs, broken, dependencies, logger):
-    ''' Checks for broken dependencies.
-        found_libs have to be the same as returned by prepare_checks
-        broken is list of libraries found by scanelf
-        dependencies is the value returned by prepare_checks
-    '''
+	''' Checks for broken dependencies.
+		found_libs have to be the same as returned by prepare_checks
+		broken is list of libraries found by scanelf
+		dependencies is the value returned by prepare_checks
+	'''
 
-    broken_pathes = []
+	broken_pathes = []
 
-    for b in broken:
-        f = found_libs[b]
-        logger.info('Broken files that requires: ' + bold(f))
-        for d in dependencies[b]:
-            logger.info(yellow(' * ') + d)
-            broken_pathes.append(d)
-    return broken_pathes
+	for b in broken:
+		f = found_libs[b]
+		logger.info('Broken files that requires: ' + bold(f))
+		for d in dependencies[b]:
+			logger.info(yellow(' * ') + d)
+			broken_pathes.append(d)
+	return broken_pathes
 
 
 def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=None, binaries=None, _libs_to_check=set()):
-    """Main program body.  It will collect all info and determine the
-    pkgs needing rebuilding.
+	"""Main program body.  It will collect all info and determine the
+	pkgs needing rebuilding.
 
-    @param logger: logger used for logging messages, instance of logging.Logger
-                   class. Can be logging (RootLogger).
-    @param _libs_to_check Libraries that need to be checked only
-    @rtype list: list of pkgs that need rebuilding
-    """
+	@param logger: logger used for logging messages, instance of logging.Logger
+				   class. Can be logging (RootLogger).
+	@param _libs_to_check Libraries that need to be checked only
+	@rtype list: list of pkgs that need rebuilding
+	"""
 
-    if libraries and la_libraries and libraries_links and binaries:
-        logger.info(blue(' * ') + bold('Found a valid cache, skipping collecting phase'))
-    else:
-        #TODO: add partial cache (for ex. only libraries) when found for some reason
+	if libraries and la_libraries and libraries_links and binaries:
+		logger.info(blue(' * ') + bold('Found a valid cache, skipping collecting phase'))
+	else:
+		#TODO: add partial cache (for ex. only libraries) when found for some reason
 
-        logger.warn(green(' * ') + bold('Collecting system binaries and libraries'))
-        bin_dirs, lib_dirs = prepare_search_dirs(logger)
+		logger.warn(green(' * ') + bold('Collecting system binaries and libraries'))
+		bin_dirs, lib_dirs = prepare_search_dirs(logger)
 
-        masked_dirs, masked_files, ld = parse_revdep_config()
-        lib_dirs = lib_dirs.union(ld)
-        bin_dirs = bin_dirs.union(ld)
-        masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+		masked_dirs, masked_files, ld = parse_revdep_config()
+		lib_dirs = lib_dirs.union(ld)
+		bin_dirs = bin_dirs.union(ld)
+		masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
 
-        logger.info(green(' * ') + bold('Collecting dynamic linking informations'))
-        libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logger)
-        binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
+		logger.info(green(' * ') + bold('Collecting dynamic linking informations'))
+		libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logger)
+		binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
 
-        if SETTINGS['USE_TMP_FILES']:
-            save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
+		if SETTINGS['USE_TMP_FILES']:
+			save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
 
 
-    logger.debug('Found '+ str(len(libraries)) + ' libraries (+' + str(len(libraries_links)) + ' symlinks) and ' + str(len(binaries)) + ' binaries')
+	logger.debug('Found '+ str(len(libraries)) + ' libraries (+' + str(len(libraries_links)) + ' symlinks) and ' + str(len(binaries)) + ' binaries')
 
-    logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
-    logger.debug('Search for ' + str(len(binaries)+len(libraries)) + ' within ' + str(len(libraries)+len(libraries_links)))
-    libs_and_bins = libraries+binaries
+	logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
+	logger.debug('Search for ' + str(len(binaries)+len(libraries)) + ' within ' + str(len(libraries)+len(libraries_links)))
+	libs_and_bins = libraries+binaries
 
-    #l = []
-    #for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'):
-        #l.append(line)
-    #libraries = l
+	#l = []
+	#for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'):
+		#l.append(line)
+	#libraries = l
 
-    found_libs = []
-    dependencies = []
+	found_libs = []
+	dependencies = []
 
 
-    _bits, linkg = platform.architecture()
-    if _bits.startswith('32'):
-        bits = 32
-    elif _bits.startswith('64'):
-        bits = 64
+	_bits, linkg = platform.architecture()
+	if _bits.startswith('32'):
+		bits = 32
+	elif _bits.startswith('64'):
+		bits = 64
 
-    for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
-        bits = int(av_bits[4:])
-        _libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, SETTINGS['CMD_MAX_ARGS'])
-        #call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
+	for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
+		bits = int(av_bits[4:])
+		_libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, SETTINGS['CMD_MAX_ARGS'])
+		#call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
 
-        found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits)
+		found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits)
 
-        broken = find_broken(found_libs, _libraries, _libs_to_check)
-        broken_la = extract_dependencies_from_la(la_libraries, _libraries, _libs_to_check, logger)
+		broken = find_broken(found_libs, _libraries, _libs_to_check)
+		broken_la = extract_dependencies_from_la(la_libraries, _libraries, _libs_to_check, logger)
 
-        bits /= 2
-        bits = int(bits)
+		bits /= 2
+		bits = int(bits)
 
-    broken_pathes = main_checks(found_libs, broken, dependencies, logger)
-    broken_pathes += broken_la
+	broken_pathes = main_checks(found_libs, broken, dependencies, logger)
+	broken_pathes += broken_la
 
-    logger.warn(green(' * ') + bold('Assign files to packages'))
+	logger.warn(green(' * ') + bold('Assign files to packages'))
 
-    return assign_packages(broken_pathes, logger)
+	return assign_packages(broken_pathes, logger)
 
 
 
 if __name__ == '__main__':
-    print "This script shouldn't be called directly"
+	print "This script shouldn't be called directly"

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 6dcf6e3..c4ae750 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -10,84 +10,84 @@ from settings import SETTINGS
 
 
 def assign_packages(broken, logger=logging):
-    ''' Finds and returns packages that owns files placed in broken.
-        Broken is list of files
-    '''
-    assigned = set()
-    for group in os.listdir(SETTINGS['PKG_DIR']):
-        for pkg in os.listdir(SETTINGS['PKG_DIR'] + group):
-            f = SETTINGS['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
-            if os.path.exists(f):
-                try:
-                    with open(f, 'r') as cnt:
-                        for line in cnt.readlines():
-                            m = re.match('^obj (/[^ ]+)', line)
-                            if m is not None:
-                                m = m.group(1)
-                                if m in broken:
-                                    found = group+'/'+pkg
-                                    if found not in assigned:
-                                        assigned.add(found)
-                                    logger.info('\t' + m + ' -> ' + bold(found))
-                except Exception as e:
-                    logger.warn(red(' !! Failed to read ' + f))
-
-    return assigned
+	''' Finds and returns packages that owns files placed in broken.
+		Broken is list of files
+	'''
+	assigned = set()
+	for group in os.listdir(SETTINGS['PKG_DIR']):
+		for pkg in os.listdir(SETTINGS['PKG_DIR'] + group):
+			f = SETTINGS['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
+			if os.path.exists(f):
+				try:
+					with open(f, 'r') as cnt:
+						for line in cnt.readlines():
+							m = re.match('^obj (/[^ ]+)', line)
+							if m is not None:
+								m = m.group(1)
+								if m in broken:
+									found = group+'/'+pkg
+									if found not in assigned:
+										assigned.add(found)
+									logger.info('\t' + m + ' -> ' + bold(found))
+				except Exception as e:
+					logger.warn(red(' !! Failed to read ' + f))
+
+	return assigned
 
 
 def get_best_match(cpv, cp, logger):
-    """Tries to find another version of the pkg with the same slot
-    as the deprecated installed version.  Failing that attempt to get any version
-    of the same app
-
-    @param cpv: string
-    @param cp: string
-    @rtype tuple: ([cpv,...], SLOT)
-    """
-
-    slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])
-    logger.warn(yellow('Warning: ebuild "' + cpv + '" not found.'))
-    logger.info('Looking for %s:%s' %(cp, slot))
-    try:
-        m = portdb.match('%s:%s' %(cp, slot))
-    except portage.exception.InvalidAtom:
-        m = None
-
-    if not m:
-        logger.warn(red('!!') + ' ' + yellow('Could not find ebuild for %s:%s' %(cp, slot)))
-        slot = ['']
-        m = portdb.match(cp)
-        if not m:
-            logger.warn(red('!!') + ' ' + yellow('Could not find ebuild for ' + cp))
-    return m, slot
+	"""Tries to find another version of the pkg with the same slot
+	as the deprecated installed version.  Failing that attempt to get any version
+	of the same app
+
+	@param cpv: string
+	@param cp: string
+	@rtype tuple: ([cpv,...], SLOT)
+	"""
+
+	slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])
+	logger.warn(yellow('Warning: ebuild "' + cpv + '" not found.'))
+	logger.info('Looking for %s:%s' %(cp, slot))
+	try:
+		m = portdb.match('%s:%s' %(cp, slot))
+	except portage.exception.InvalidAtom:
+		m = None
+
+	if not m:
+		logger.warn(red('!!') + ' ' + yellow('Could not find ebuild for %s:%s' %(cp, slot)))
+		slot = ['']
+		m = portdb.match(cp)
+		if not m:
+			logger.warn(red('!!') + ' ' + yellow('Could not find ebuild for ' + cp))
+	return m, slot
 
 
 def get_slotted_cps(cpvs, logger):
-    """Uses portage to reduce the cpv list into a cp:slot list and returns it
-    """
-    from portage.versions import catpkgsplit
-    from portage import portdb
+	"""Uses portage to reduce the cpv list into a cp:slot list and returns it
+	"""
+	from portage.versions import catpkgsplit
+	from portage import portdb
 
-    cps = []
-    for cpv in cpvs:
-        parts = catpkgsplit(cpv)
-        cp = parts[0] + '/' + parts[1]
-        try:
-            slot = portdb.aux_get(cpv, ["SLOT"])
-        except KeyError:
-            m, slot = get_best_match(cpv, cp, logger)
-            if not m:
-                logger.warn(red("Installed package: %s is no longer available" %cp))
-                continue
+	cps = []
+	for cpv in cpvs:
+		parts = catpkgsplit(cpv)
+		cp = parts[0] + '/' + parts[1]
+		try:
+			slot = portdb.aux_get(cpv, ["SLOT"])
+		except KeyError:
+			m, slot = get_best_match(cpv, cp, logger)
+			if not m:
+				logger.warn(red("Installed package: %s is no longer available" %cp))
+				continue
 
-        if slot[0]:
-            cps.append(cp + ":" + slot[0])
-        else:
-            cps.append(cp)
+		if slot[0]:
+			cps.append(cp + ":" + slot[0])
+		else:
+			cps.append(cp)
 
-    return cps
+	return cps
 
 
 
 if __name__ == '__main__':
-    print 'Nothing to call here'
+	print 'Nothing to call here'

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 421e22d..616ef79 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -8,96 +8,96 @@ from settings import SETTINGS
 
 
 def read_cache(temp_path=SETTINGS['DEFAULT_TMP_DIR']):
-    ''' Reads cache information needed by analyse function.
-        This function does not checks if files exists nor timestamps,
-        check_temp_files should be called first
-        @param temp_path: directory where all temp files should reside
-        @return tuple with values of: libraries, la_libraries, libraries_links, symlink_pairs, binaries
-    '''
-
-    ret = {'libraries':[], 'la_libraries':[], 'libraries_links':[], 'binaries':[]}
-    try:
-        for key,val in ret.iteritems():
-            f = open(os.path.join(temp_path, key))
-            for line in f.readlines():
-                val.append(line.strip())
-            #libraries.remove('\n')
-            f.close()
-    except EnvironmentError:
-        pass
-
-    return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
+	''' Reads cache information needed by analyse function.
+		This function does not checks if files exists nor timestamps,
+		check_temp_files should be called first
+		@param temp_path: directory where all temp files should reside
+		@return tuple with values of: libraries, la_libraries, libraries_links, symlink_pairs, binaries
+	'''
+
+	ret = {'libraries':[], 'la_libraries':[], 'libraries_links':[], 'binaries':[]}
+	try:
+		for key,val in ret.iteritems():
+			f = open(os.path.join(temp_path, key))
+			for line in f.readlines():
+				val.append(line.strip())
+			#libraries.remove('\n')
+			f.close()
+	except EnvironmentError:
+		pass
+
+	return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
 
 
 def save_cache(logger=logging, to_save={}, temp_path=SETTINGS['DEFAULT_TMP_DIR']):
-    ''' Tries to store caching information.
-        @param logger
-        @param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
-    '''
+	''' Tries to store caching information.
+		@param logger
+		@param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
+	'''
 
-    if not os.path.exists(temp_path):
-        os.makedirs(temp_path)
+	if not os.path.exists(temp_path):
+		os.makedirs(temp_path)
 
-    try:
-        f = open(os.path.join(temp_path, 'timestamp'), 'w')
-        f.write(str(int(time.time())))
-        f.close()
+	try:
+		f = open(os.path.join(temp_path, 'timestamp'), 'w')
+		f.write(str(int(time.time())))
+		f.close()
 
-        for key,val in to_save.iteritems():
-            f = open(os.path.join(temp_path, key), 'w')
-            for line in val:
-                f.write(line + '\n')
-            f.close()
-    except Exception as ex:
-        logger.warn(red('Could not save cache: %s' %str(ex)))
+		for key,val in to_save.iteritems():
+			f = open(os.path.join(temp_path, key), 'w')
+			for line in val:
+				f.write(line + '\n')
+			f.close()
+	except Exception as ex:
+		logger.warn(red('Could not save cache: %s' %str(ex)))
 
 
 
 def check_temp_files(temp_path=SETTINGS['DEFAULT_TMP_DIR'], max_delay=3600):
-    ''' Checks if temporary files from previous run are still available
-        and if they aren't too old
-        @param temp_path is directory, where temporary files should be found
-        @param max_delay is maximum time difference (in seconds) when those files
-                are still considered fresh and useful
-        returns True, when files can be used, or False, when they don't
-        exists or they are too old
-    '''
+	''' Checks if temporary files from previous run are still available
+		and if they aren't too old
+		@param temp_path is directory, where temporary files should be found
+		@param max_delay is maximum time difference (in seconds) when those files
+				are still considered fresh and useful
+		returns True, when files can be used, or False, when they don't
+		exists or they are too old
+	'''
 
-    if not os.path.exists(temp_path) or not os.path.isdir(temp_path):
-        return False
+	if not os.path.exists(temp_path) or not os.path.isdir(temp_path):
+		return False
 
-    timestamp_path = os.path.join(temp_path, 'timestamp')
-    if not os.path.exists(timestamp_path) or not os.path.isfile(timestamp_path):
-        return False
+	timestamp_path = os.path.join(temp_path, 'timestamp')
+	if not os.path.exists(timestamp_path) or not os.path.isfile(timestamp_path):
+		return False
 
-    try:
-        f = open(timestamp_path)
-        timestamp = int(f.readline())
-        f.close()
-    except:
-        timestamp = 0
-        return False
+	try:
+		f = open(timestamp_path)
+		timestamp = int(f.readline())
+		f.close()
+	except:
+		timestamp = 0
+		return False
 
-    diff = int(time.time()) - timestamp
-    return max_delay > diff
+	diff = int(time.time()) - timestamp
+	return max_delay > diff
 
 
 
 if __name__ == '__main__':
-    print 'Preparing cache ... '
+	print 'Preparing cache ... '
 
-    from collect import *
+	from collect import *
 
-    bin_dirs, lib_dirs = prepare_search_dirs()
+	bin_dirs, lib_dirs = prepare_search_dirs()
 
-    masked_dirs, masked_files, ld = parse_revdep_config()
-    lib_dirs = lib_dirs.union(ld)
-    bin_dirs = bin_dirs.union(ld)
-    masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+	masked_dirs, masked_files, ld = parse_revdep_config()
+	lib_dirs = lib_dirs.union(ld)
+	bin_dirs = bin_dirs.union(ld)
+	masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
 
-    libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs)
-    binaries = collect_binaries_from_dir(bin_dirs, masked_dirs)
+	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs)
+	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs)
 
-    save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
+	save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
 
-    print 'Done.'
+	print 'Done.'

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 4a0714b..613749a 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -11,236 +11,236 @@ from settings import SETTINGS
 
 
 def parse_conf(conf_file=SETTINGS['DEFAULT_LD_FILE'], visited=None, logger=logging):
-    ''' Parses supplied conf_file for libraries pathes.
-        conf_file is file or files to parse
-        visited is set of files already parsed
-    '''
-    lib_dirs = set()
-    to_parse = set()
-
-    if isinstance(conf_file, basestring):
-        conf_file = [conf_file]
-
-    for conf in conf_file:
-        try:
-            with open(conf) as f:
-                for line in f.readlines():
-                    line = line.strip()
-                    if line.startswith('#'):
-                        continue
-                    elif line.startswith('include'):
-                        include_line = line.split()[1:]
-                        for included in include_line:
-                            if not included.startswith('/'):
-                                path = os.path.join(os.path.dirname(conf), \
-                                                    included)
-                            else:
-                                path = included
-
-                            to_parse = to_parse.union(glob.glob(path))
-                    else:
-                        lib_dirs.add(line)
-        except EnvironmentError:
-            logger.warn(yellow('Error when parsing file %s' %conf))
-
-    if visited is None:
-        visited = set()
-
-    visited = visited.union(conf_file)
-    to_parse = to_parse.difference(visited)
-    if to_parse:
-        lib_dirs = lib_dirs.union(parse_conf(to_parse, visited, logger=logger))
-
-    return lib_dirs
+	''' Parses supplied conf_file for libraries pathes.
+		conf_file is file or files to parse
+		visited is set of files already parsed
+	'''
+	lib_dirs = set()
+	to_parse = set()
+
+	if isinstance(conf_file, basestring):
+		conf_file = [conf_file]
+
+	for conf in conf_file:
+		try:
+			with open(conf) as f:
+				for line in f.readlines():
+					line = line.strip()
+					if line.startswith('#'):
+						continue
+					elif line.startswith('include'):
+						include_line = line.split()[1:]
+						for included in include_line:
+							if not included.startswith('/'):
+								path = os.path.join(os.path.dirname(conf), \
+													included)
+							else:
+								path = included
+
+							to_parse = to_parse.union(glob.glob(path))
+					else:
+						lib_dirs.add(line)
+		except EnvironmentError:
+			logger.warn(yellow('Error when parsing file %s' %conf))
+
+	if visited is None:
+		visited = set()
+
+	visited = visited.union(conf_file)
+	to_parse = to_parse.difference(visited)
+	if to_parse:
+		lib_dirs = lib_dirs.union(parse_conf(to_parse, visited, logger=logger))
+
+	return lib_dirs
 
 
 def prepare_search_dirs(logger=logging):
-    ''' Lookup for search dirs. Returns tuple with two lists,
-        (list_of_bin_dirs, list_of_lib_dirs)
-    '''
+	''' Lookup for search dirs. Returns tuple with two lists,
+		(list_of_bin_dirs, list_of_lib_dirs)
+	'''
 
-    bin_dirs = set(['/bin', '/usr/bin', ])
-    lib_dirs = set(['/lib', '/usr/lib', ])
+	bin_dirs = set(['/bin', '/usr/bin', ])
+	lib_dirs = set(['/lib', '/usr/lib', ])
 
-    #try:
-    with open(os.path.join(portage.root, SETTINGS['DEFAULT_ENV_FILE']), 'r') as f:
-        for line in f.readlines():
-            line = line.strip()
-            m = re.match("^export (ROOT)?PATH='([^']+)'", line)
-            if m is not None:
-                bin_dirs = bin_dirs.union(set(m.group(2).split(':')))
-    #except EnvironmentError:
-        #logger.debug(yellow('Could not open file %s' % f))
+	#try:
+	with open(os.path.join(portage.root, SETTINGS['DEFAULT_ENV_FILE']), 'r') as f:
+		for line in f.readlines():
+			line = line.strip()
+			m = re.match("^export (ROOT)?PATH='([^']+)'", line)
+			if m is not None:
+				bin_dirs = bin_dirs.union(set(m.group(2).split(':')))
+	#except EnvironmentError:
+		#logger.debug(yellow('Could not open file %s' % f))
 
-    lib_dirs = parse_conf(logger=logger)
-    return (bin_dirs, lib_dirs)
+	lib_dirs = parse_conf(logger=logger)
+	return (bin_dirs, lib_dirs)
 
 
 def parse_revdep_config():
-    ''' Parses all files under /etc/revdep-rebuild/ and returns
-        tuple of: (masked_dirs, masked_files, search_dirs)'''
-
-    search_dirs = set()
-    masked_dirs = set()
-    masked_files = set()
-
-    #TODO: remove hard-coded path
-    for f in os.listdir(SETTINGS['REVDEP_CONFDIR']):
-        for line in open(os.path.join('/etc/revdep-rebuild', f)):
-            line = line.strip()
-            if not line.startswith('#'): #first check for comment, we do not want to regex all lines
-                m = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
-                if m is not None:
-                    s = m.group(1).split(' ')
-                    masked_files = masked_files.union(s)
-                    continue
-                m = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
-                if m is not None:
-                    s = m.group(1).split(' ')
-                    for ss in s:
-                        masked_dirs = masked_dirs.union(glob.glob(ss))
-                    continue
-                m = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
-                if m is not None:
-                    s = m.group(1).split()
-                    for ss in s:
-                        search_dirs = search_dirs.union(glob.glob(ss))
-                    continue
-
-    return (masked_dirs, masked_files, search_dirs)
+	''' Parses all files under /etc/revdep-rebuild/ and returns
+		tuple of: (masked_dirs, masked_files, search_dirs)'''
+
+	search_dirs = set()
+	masked_dirs = set()
+	masked_files = set()
+
+	#TODO: remove hard-coded path
+	for f in os.listdir(SETTINGS['REVDEP_CONFDIR']):
+		for line in open(os.path.join('/etc/revdep-rebuild', f)):
+			line = line.strip()
+			if not line.startswith('#'): #first check for comment, we do not want to regex all lines
+				m = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
+				if m is not None:
+					s = m.group(1).split(' ')
+					masked_files = masked_files.union(s)
+					continue
+				m = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
+				if m is not None:
+					s = m.group(1).split(' ')
+					for ss in s:
+						masked_dirs = masked_dirs.union(glob.glob(ss))
+					continue
+				m = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
+				if m is not None:
+					s = m.group(1).split()
+					for ss in s:
+						search_dirs = search_dirs.union(glob.glob(ss))
+					continue
+
+	return (masked_dirs, masked_files, search_dirs)
 
 
 def collect_libraries_from_dir(dirs, mask, logger=logging):
-    ''' Collects all libraries from specified list of directories.
-        mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
-        Returns tuple composed of: list of libraries, list of symlinks, and toupe with pair
-        (symlink_id, library_id) for resolving dependencies
-    '''
-
-
-    found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
-    found_files = []
-    found_symlinks = []
-    found_la_files = [] # la libraries
-    symlink_pairs = []  # list of pairs symlink_id->library_id
-
-    for d in dirs:
-        if d in mask:
-            continue
-
-        try:
-            for l in os.listdir(d):
-                l = os.path.join(d, l)
-                if l in mask:
-                    continue
-
-                if os.path.isdir(l):
-                    if os.path.islink(l):
-                        #we do not want scan symlink-directories
-                        pass
-                    else:
-                        found_directories.append(l)
-                elif os.path.isfile(l):
-                    if l.endswith('.so') or '.so.' in l:
-                        if l in found_files or l in found_symlinks:
-                            continue
-
-                        if os.path.islink(l):
-                            found_symlinks.append(l)
-                            abs_path = os.path.realpath(l)
-                            if abs_path in found_files:
-                                i = found_files.index(abs_path)
-                            else:
-                                found_files.append(abs_path)
-                                i = len(found_files)-1
-                            symlink_pairs.append((len(found_symlinks)-1, i,))
-                        else:
-                            found_files.append(l)
-                        continue
-                    elif l.endswith('.la'):
-                        if l in found_la_files:
-                            continue
-
-                        found_la_files.append(l)
-                    else:
-                        # sometimes there are binaries in libs' subdir, for example in nagios
-                        if not os.path.islink(l):
-                            if l in found_files or l in found_symlinks:
-                                continue
-                            prv = os.stat(l)[stat.ST_MODE]
-                            if prv & stat.S_IXUSR == stat.S_IXUSR or \
-                                    prv & stat.S_IXGRP == stat.S_IXGRP or \
-                                    prv & stat.S_IXOTH == stat.S_IXOTH:
-                                found_files.append(l)
-        except Exception as ex:
-            logger.debug(yellow('Exception during collecting libraries: %s' %str(ex)))
-
-
-    if found_directories:
-        f,a,l,p = collect_libraries_from_dir(found_directories, mask, logger)
-        found_files+=f
-        found_la_files+=a
-        found_symlinks+=l
-        symlink_pairs+=p
-
-    return (found_files, found_la_files, found_symlinks, symlink_pairs)
+	''' Collects all libraries from specified list of directories.
+		mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
+		Returns tuple composed of: list of libraries, list of symlinks, and toupe with pair
+		(symlink_id, library_id) for resolving dependencies
+	'''
+
+
+	found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
+	found_files = []
+	found_symlinks = []
+	found_la_files = [] # la libraries
+	symlink_pairs = []  # list of pairs symlink_id->library_id
+
+	for d in dirs:
+		if d in mask:
+			continue
+
+		try:
+			for l in os.listdir(d):
+				l = os.path.join(d, l)
+				if l in mask:
+					continue
+
+				if os.path.isdir(l):
+					if os.path.islink(l):
+						#we do not want scan symlink-directories
+						pass
+					else:
+						found_directories.append(l)
+				elif os.path.isfile(l):
+					if l.endswith('.so') or '.so.' in l:
+						if l in found_files or l in found_symlinks:
+							continue
+
+						if os.path.islink(l):
+							found_symlinks.append(l)
+							abs_path = os.path.realpath(l)
+							if abs_path in found_files:
+								i = found_files.index(abs_path)
+							else:
+								found_files.append(abs_path)
+								i = len(found_files)-1
+							symlink_pairs.append((len(found_symlinks)-1, i,))
+						else:
+							found_files.append(l)
+						continue
+					elif l.endswith('.la'):
+						if l in found_la_files:
+							continue
+
+						found_la_files.append(l)
+					else:
+						# sometimes there are binaries in libs' subdir, for example in nagios
+						if not os.path.islink(l):
+							if l in found_files or l in found_symlinks:
+								continue
+							prv = os.stat(l)[stat.ST_MODE]
+							if prv & stat.S_IXUSR == stat.S_IXUSR or \
+									prv & stat.S_IXGRP == stat.S_IXGRP or \
+									prv & stat.S_IXOTH == stat.S_IXOTH:
+								found_files.append(l)
+		except Exception as ex:
+			logger.debug(yellow('Exception during collecting libraries: %s' %str(ex)))
+
+
+	if found_directories:
+		f,a,l,p = collect_libraries_from_dir(found_directories, mask, logger)
+		found_files+=f
+		found_la_files+=a
+		found_symlinks+=l
+		symlink_pairs+=p
+
+	return (found_files, found_la_files, found_symlinks, symlink_pairs)
 
 
 def collect_binaries_from_dir(dirs, mask, logger=logging):
-    ''' Collects all binaries from specified list of directories.
-        mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
-        Returns list of binaries
-    '''
-
-    found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
-    found_files = []
-
-    for d in dirs:
-        if d in mask:
-            continue
-
-        try:
-            for l in os.listdir(d):
-                l = os.path.join(d, l)
-                if d in mask:
-                    continue
-
-                if os.path.isdir(l):
-                    if os.path.islink(l):
-                        #we do not want scan symlink-directories
-                        pass
-                    else:
-                        found_directories.append(l)
-                elif os.path.isfile(l):
-                    #we're looking for binaries, and with binaries we do not need links, thus we can optimize a bit
-                    if not os.path.islink(l):
-                        prv = os.stat(l)[stat.ST_MODE]
-                        if prv & stat.S_IXUSR == stat.S_IXUSR or \
-                                prv & stat.S_IXGRP == stat.S_IXGRP or \
-                                prv & stat.S_IXOTH == stat.S_IXOTH:
-                            found_files.append(l)
-        except Exception as e:
-            logger.debug(yellow('Exception during binaries collecting: %s' %str(e)))
-
-    if found_directories:
-        found_files += collect_binaries_from_dir(found_directories, mask, logger)
-
-    return found_files
+	''' Collects all binaries from specified list of directories.
+		mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
+		Returns list of binaries
+	'''
+
+	found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
+	found_files = []
+
+	for d in dirs:
+		if d in mask:
+			continue
+
+		try:
+			for l in os.listdir(d):
+				l = os.path.join(d, l)
+				if d in mask:
+					continue
+
+				if os.path.isdir(l):
+					if os.path.islink(l):
+						#we do not want scan symlink-directories
+						pass
+					else:
+						found_directories.append(l)
+				elif os.path.isfile(l):
+					#we're looking for binaries, and with binaries we do not need links, thus we can optimize a bit
+					if not os.path.islink(l):
+						prv = os.stat(l)[stat.ST_MODE]
+						if prv & stat.S_IXUSR == stat.S_IXUSR or \
+								prv & stat.S_IXGRP == stat.S_IXGRP or \
+								prv & stat.S_IXOTH == stat.S_IXOTH:
+							found_files.append(l)
+		except Exception as e:
+			logger.debug(yellow('Exception during binaries collecting: %s' %str(e)))
+
+	if found_directories:
+		found_files += collect_binaries_from_dir(found_directories, mask, logger)
+
+	return found_files
 
 
 
 if __name__ == '__main__':
-    bin_dirs, lib_dirs = prepare_search_dirs(logging)
+	bin_dirs, lib_dirs = prepare_search_dirs(logging)
 
-    masked_dirs, masked_files, ld = parse_revdep_config()
-    lib_dirs = lib_dirs.union(ld)
-    bin_dirs = bin_dirs.union(ld)
-    masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+	masked_dirs, masked_files, ld = parse_revdep_config()
+	lib_dirs = lib_dirs.union(ld)
+	bin_dirs = bin_dirs.union(ld)
+	masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
 
-    libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
-    binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
+	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
+	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
 
-    print 'Found: %i binaries and %i libraries.' %(len(binaries), len(libraries))
+	print 'Found: %i binaries and %i libraries.' %(len(binaries), len(libraries))
 
 
 

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index ea6b1ec..b47cb3e 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -4,23 +4,23 @@ import os
 import portage
 
 SETTINGS = {
-        'DEFAULT_LD_FILE': os.path.join(portage.root, 'etc/ld.so.conf'),
-        'DEFAULT_ENV_FILE': os.path.join(portage.root, 'etc/profile.env'),
-        'REVDEP_CONFDIR': os.path.join(portage.root, 'etc/revdep-rebuild/'),
-        'PKG_DIR': os.path.join(portage.root, 'var/db/pkg/'),
-        'DEFAULT_TMP_DIR': '/tmp/revdep-rebuild', #cache default location
+		'DEFAULT_LD_FILE': os.path.join(portage.root, 'etc/ld.so.conf'),
+		'DEFAULT_ENV_FILE': os.path.join(portage.root, 'etc/profile.env'),
+		'REVDEP_CONFDIR': os.path.join(portage.root, 'etc/revdep-rebuild/'),
+		'PKG_DIR': os.path.join(portage.root, 'var/db/pkg/'),
+		'DEFAULT_TMP_DIR': '/tmp/revdep-rebuild', #cache default location
 
 
-        'USE_TMP_FILES': True, #if program should use temporary files from previous run
-        'CMD_MAX_ARGS': 1000, # number of maximum allowed files to be parsed at once
+		'USE_TMP_FILES': True, #if program should use temporary files from previous run
+		'CMD_MAX_ARGS': 1000, # number of maximum allowed files to be parsed at once
 
-        'PRETEND': False,     #pretend only
-        'EXACT': False,      #exact package version
-        'USE_TMP_FILES': True, #if program should use temporary files from previous run
+		'PRETEND': False,     #pretend only
+		'EXACT': False,      #exact package version
+		'USE_TMP_FILES': True, #if program should use temporary files from previous run
 
-        'IS_DEV': True,       #True for dev. version, False for stable
-                #used when IS_DEV is True, False forces to call emerge with --pretend
-                # can be set True from the cli with the --no-pretend option
-        'NO_PRETEND': False,
-        'VERBOSITY': 1,
-    }
+		'IS_DEV': True,       #True for dev. version, False for stable
+				#used when IS_DEV is True, False forces to call emerge with --pretend
+				# can be set True from the cli with the --no-pretend option
+		'NO_PRETEND': False,
+		'VERBOSITY': 1,
+	}

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index d153908..b1b6709 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -6,41 +6,41 @@ import portage
 
 # util. functions
 def call_program(args):
-    ''' Calls program with specified parameters and returns stdout '''
-    subp = subprocess.Popen(args, stdout=subprocess.PIPE, \
-                                stderr=subprocess.PIPE)
-    stdout, stderr = subp.communicate()
-    return stdout
+	''' Calls program with specified parameters and returns stdout '''
+	subp = subprocess.Popen(args, stdout=subprocess.PIPE, \
+								stderr=subprocess.PIPE)
+	stdout, stderr = subp.communicate()
+	return stdout
 
 
 def scan(params, files, max_args):
-    ''' Calls scanelf with given params and files to scan.
-        @param params is list of parameters that should be passed into scanelf app.
-        @param files list of files to scan.
-        @param max_args number of files to process at once
+	''' Calls scanelf with given params and files to scan.
+		@param params is list of parameters that should be passed into scanelf app.
+		@param files list of files to scan.
+		@param max_args number of files to process at once
 
-        When files count is greater CMD_MAX_ARGS, it'll be divided
-        into several parts
+		When files count is greater CMD_MAX_ARGS, it'll be divided
+		into several parts
 
-        @return scanelf output (joined if was called several times)
-    '''
-    out = []
-    for i in range(0, len(files), max_args):
-        out += call_program(['scanelf'] + params + files[i:i+max_args]).strip().split('\n')
-    return out
+		@return scanelf output (joined if was called several times)
+	'''
+	out = []
+	for i in range(0, len(files), max_args):
+		out += call_program(['scanelf'] + params + files[i:i+max_args]).strip().split('\n')
+	return out
 
 
 
 def exithandler(signum, frame):
-    sys.exit(1)
+	sys.exit(1)
 
 
 def get_masking_status(ebuild):
-    try:
-        status = portage.getmaskingstatus(ebuild)
-    except KeyError:
-        status = ['deprecated']
-    return status
+	try:
+		status = portage.getmaskingstatus(ebuild)
+	except KeyError:
+		status = ['deprecated']
+	return status
 
 if __name__ == '__main__':
-    print "There is nothing to run here."
+	print "There is nothing to run here."



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     b882067397b613421b07a068749afee55bfff9a1
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:04:33 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=b8820673

whitespace separation from system imports

---
 pym/gentoolkit/revdep_rebuild/assign.py   |    1 +
 pym/gentoolkit/revdep_rebuild/settings.py |    1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 9eb177d..bb9ec1f 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -2,6 +2,7 @@
 
 import os
 import re
+
 import portage
 from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
index 7747ac2..96aa491 100644
--- a/pym/gentoolkit/revdep_rebuild/settings.py
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -2,6 +2,7 @@
 
 import os
 import sys
+
 import portage
 
 DEFAULTS = {



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     4a02c44bbe7457249caeb07464e240b6bc035cc0
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:03:20 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4a02c44b

more cleanup of importing logging.  Use the one defined or passed in to in main(). 

---
 pym/gentoolkit/revdep_rebuild/analyse.py |   11 ++++++++---
 pym/gentoolkit/revdep_rebuild/cache.py   |   14 +++++++++-----
 pym/gentoolkit/revdep_rebuild/collect.py |    5 +++--
 pym/gentoolkit/revdep_rebuild/rebuild.py |   17 ++++++++++++-----
 4 files changed, 32 insertions(+), 15 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 5ee0c7b..521d8b9 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -3,8 +3,8 @@
 import os
 import re
 import platform
-import logging
 import glob
+
 from portage.output import bold, red, blue, yellow, green, nocolor
 
 from stuff import scan
@@ -114,7 +114,7 @@ def main_checks(found_libs, broken, dependencies, logger):
 	return broken_pathes
 
 
-def analyse(settings=None, logger=None, libraries=None, la_libraries=None,
+def analyse(settings, logger, libraries=None, la_libraries=None,
 		libraries_links=None, binaries=None, _libs_to_check=set()):
 	"""Main program body.  It will collect all info and determine the
 	pkgs needing rebuilding.
@@ -143,7 +143,12 @@ def analyse(settings=None, logger=None, libraries=None, la_libraries=None,
 		binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
 
 		if settings['USE_TMP_FILES']:
-			save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
+			save_cache(logger=logger, 
+				to_save={'libraries':libraries, 'la_libraries':la_libraries,
+					'libraries_links':libraries_links, 'binaries':binaries
+				},
+			temp_path=settings['DEFAULT_TMP_DIR']
+			)
 
 
 	logger.debug('Found '+ str(len(libraries)) + ' libraries (+' + str(len(libraries_links)) + ' symlinks) and ' + str(len(binaries)) + ' binaries')

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index e1a8e11..8b1a8ed 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -2,7 +2,7 @@
 
 import os
 import time
-import logging
+
 from portage.output import red
 from settings import DEFAULTS
 
@@ -29,7 +29,7 @@ def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 	return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
 
 
-def save_cache(logger=logging, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
+def save_cache(logger, to_save={}, temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
 	''' Tries to store caching information.
 		@param logger
 		@param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
@@ -87,6 +87,7 @@ if __name__ == '__main__':
 	print 'Preparing cache ... '
 
 	from collect import *
+	import logging
 
 	bin_dirs, lib_dirs = prepare_search_dirs()
 
@@ -95,9 +96,12 @@ if __name__ == '__main__':
 	bin_dirs = bin_dirs.union(ld)
 	masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
 
-	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs)
-	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs)
+	libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
+	binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
 
-	save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
+	save_cache(logger=logging, 
+		to_save={'libraries':libraries, 'la_libraries':la_libraries, 
+			'libraries_links':libraries_links, 'binaries':binaries}
+		)
 
 	print 'Done.'

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index 735857b..b408edc 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -4,7 +4,7 @@ import re
 import os
 import glob
 import stat
-import logging
+
 import portage
 from portage.output import bold, red, blue, yellow, green, nocolor
 
@@ -185,7 +185,7 @@ def collect_libraries_from_dir(dirs, mask, logger):
 	return (found_files, found_la_files, found_symlinks, symlink_pairs)
 
 
-def collect_binaries_from_dir(dirs, mask, logger=logging):
+def collect_binaries_from_dir(dirs, mask, logger):
 	''' Collects all binaries from specified list of directories.
 		mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
 		Returns list of binaries
@@ -229,6 +229,7 @@ def collect_binaries_from_dir(dirs, mask, logger=logging):
 
 
 if __name__ == '__main__':
+	import logging
 	bin_dirs, lib_dirs = prepare_search_dirs(logging)
 
 	masked_dirs, masked_files, ld = parse_revdep_config()

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 6185e0c..6c08f5b 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -169,13 +169,14 @@ def rebuild(logger, assigned, settings):
 
 
 # Runs from here
-def main(settings=None):
+def main(settings=None, logger=None):
 
 	if settings is None:
 		print("NO Input settings, using defaults...")
 		settings = DEFAULTS.copy()
 
-	logger = init_logger(settings)
+	if logger is None:
+		logger = init_logger(settings)
 
 	_libs_to_check = settings['library']
 
@@ -199,9 +200,15 @@ def main(settings=None):
 		settings['PRETEND'] = True
 
 	analyze_cache = {}
-	if settings['USE_TMP_FILES'] and check_temp_files():
-		libraries, la_libraries, libraries_links, binaries = read_cache()
-		assigned = analyse(libraries=libraries, la_libraries=la_libraries, 
+	if settings['USE_TMP_FILES'] \
+			and check_temp_files(settings['DEFAULT_TMP_DIR']):
+		libraries, la_libraries, libraries_links, binaries = read_cache(
+			settings['DEFAULT_TMP_DIR'])
+		assigned = analyse(
+			settings=settings,
+			logger=logger,
+			libraries=libraries,
+			la_libraries=la_libraries, 
 			libraries_links=libraries_links,
 			binaries=binaries,
 			_libs_to_check=_libs_to_check)



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     4174b0474707148651c66a9c9d0cb0372e699130
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:05:43 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=4174b047

change the masking status message.

---
 pym/gentoolkit/revdep_rebuild/stuff.py |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index b1b6709..459301f 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import subprocess
+
 import portage
 
 
@@ -39,7 +40,7 @@ def get_masking_status(ebuild):
 	try:
 		status = portage.getmaskingstatus(ebuild)
 	except KeyError:
-		status = ['deprecated']
+		status = ['unavailable']
 	return status
 
 if __name__ == '__main__':



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     a6964c2141e4cc95760a29b4a471a31d25dacb53
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Fri Jan  7 05:46:19 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=a6964c21

Fixed error in reading cache. Fixed problem with too many files to check.

---
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |   51 +++++++++++++++--------
 1 files changed, 34 insertions(+), 17 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
index ebc0c3b..ac2a6c8 100755
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -25,7 +25,7 @@ from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
 
 APP_NAME = sys.argv[0]
-VERSION = '0.1-r3'
+VERSION = '0.1-r4'
 
 
 __productname__ = "revdep-ng"
@@ -51,6 +51,7 @@ IS_DEV = True       #True for dev. version, False for stable
 # can be set True from the cli with the --no-pretend option
 NO_PRETEND = False 
 
+CMD_MAX_ARGS = 1000 # number of maximum allowed files to be parsed at once
 
 
 # util. functions
@@ -62,6 +63,22 @@ def call_program(args):
     return stdout
 
 
+def scan(params, files):
+    ''' Calls scanelf with given params and files to scan.
+        @param params is list of parameters that should be passed into scanelf app.
+        @param files list of files to scan.
+
+        When files count is greater CMD_MAX_ARGS, it'll be divided
+        into several parts
+
+        @return scanelf output (joined if was called several times)
+    '''
+    out = []
+    for i in range(0, len(files), CMD_MAX_ARGS):
+        out += call_program(['scanelf'] + params + files[i:i+CMD_MAX_ARGS]).strip().split('\n')
+    return out
+
+
 def print_v(verbosity, args):
     """Prints to stdout according to the verbosity level 
     and the global VERBOSITY level
@@ -75,10 +92,6 @@ def print_v(verbosity, args):
 
 
 def exithandler(signum, frame):
-    print 'Signal caught!'
-    print 'Bye!'
-    signal.signal(signal.SIGINT, signal.SIG_IGN)
-    signal.signal(signal.SIGTERM, signal.SIG_IGN)
     sys.exit(1)
 
 
@@ -350,7 +363,8 @@ def prepare_checks(files_to_check, libraries, bits):
     dependencies = [] # list of lists of files (from file_to_check) that uses
                       # library (for dependencies[id] and libs[id] => id==id)
 
-    for line in call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
+    for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check):
+    #call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
         r = line.strip().split(' ')
         if len(r) < 2: # no dependencies?
             continue
@@ -463,7 +477,7 @@ def assign_packages(broken, output):
                                     if found not in assigned:
                                         assigned.add(found)
                                     print_v(1, '\t' + m + ' -> ' + bold(found))
-                except:
+                except Exception as e:
                     output(1, red(' !! Failed to read ' + f))
 
     return assigned
@@ -544,7 +558,7 @@ def read_cache(temp_path=DEFAULT_TMP_DIR):
     return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
 
 
-def save_cache(to_save, temp_path=DEFAULT_TMP_DIR):
+def save_cache(output=print_v, to_save={}, temp_path=DEFAULT_TMP_DIR):
     ''' Tries to store caching information.
         @param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
     '''
@@ -552,16 +566,18 @@ def save_cache(to_save, temp_path=DEFAULT_TMP_DIR):
     if not os.path.exists(temp_path):
         os.makedirs(temp_path)
 
-    f = open(os.path.join(temp_path, 'timestamp'), 'w')
-    f.write(str(int(time.time())))
-    f.close()
-
-    for key,val in to_save.iteritems():
-        f = open(os.path.join(temp_path, key), 'w')
-        for line in val:
-            f.write(line + '\n')
+    try:
+        f = open(os.path.join(temp_path, 'timestamp'), 'w')
+        f.write(str(int(time.time())))
         f.close()
 
+        for key,val in to_save.iteritems():
+            f = open(os.path.join(temp_path, key), 'w')
+            for line in val:
+                f.write(line + '\n')
+            f.close()
+    except Exception as ex:
+        output(1, red('Could not save cache %s' %str(ex)))
 
 def analyse(output=print_v, libraries=None, la_libraries=None, libraries_links=None, binaries=None):
     """Main program body.  It will collect all info and determine the
@@ -616,7 +632,8 @@ def analyse(output=print_v, libraries=None, la_libraries=None, libraries_links=N
 
     for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
         bits = int(av_bits[4:])
-        _libraries = call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
+        _libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links)
+        #call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
 
         found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits)
 



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     1d7e4e88a4d4cd4220ef33160bc0b121caaf20dd
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Apr 24 22:18:27 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=1d7e4e88

rename revdep-rebuild.py due to a python error if a '-' is used in the name.

---
 .../{revdep-rebuild.py => rebuild.py}              |    0
 1 files changed, 0 insertions(+), 0 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
similarity index 100%
rename from pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
rename to pym/gentoolkit/revdep_rebuild/rebuild.py



^ permalink raw reply	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     0cf2ba868fbd6a1da4b6f5b3ae286845d538a066
Author:     Slawomir Lis <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Mon Jan 17 12:31:33 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=0cf2ba86

Split to several files. Introduced logging (instead of print_v)

---
 pym/gentoolkit/revdep_rebuild/analyse.py           |  194 ++++++
 pym/gentoolkit/revdep_rebuild/assign.py            |   94 +++
 pym/gentoolkit/revdep_rebuild/cache.py             |  103 ++++
 pym/gentoolkit/revdep_rebuild/collect.py           |  248 ++++++++
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py    |  630 +-------------------
 pym/gentoolkit/revdep_rebuild/revdep_rebuild.kdev4 |    3 +
 pym/gentoolkit/revdep_rebuild/stuff.py             |   39 ++
 pym/gentoolkit/revdep_rebuild/test.py              |    7 +
 8 files changed, 717 insertions(+), 601 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
new file mode 100644
index 0000000..5141f6f
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -0,0 +1,194 @@
+#!/usr/bin/python
+
+import platform
+import logging
+import glob
+from portage.output import bold, red, blue, yellow, green, nocolor
+
+from stuff import *
+from collect import *
+from assign import assign_packages
+
+
+USE_TMP_FILES = True #if program should use temporary files from previous run
+CMD_MAX_ARGS = 1000 # number of maximum allowed files to be parsed at once
+
+
+
+def prepare_checks(files_to_check, libraries, bits):
+    ''' Calls scanelf for all files_to_check, then returns found libraries and dependencies
+    '''
+
+    libs = [] # libs found by scanelf
+    dependencies = [] # list of lists of files (from file_to_check) that uses
+                      # library (for dependencies[id] and libs[id] => id==id)
+
+    for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check, CMD_MAX_ARGS):
+    #call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
+        r = line.strip().split(' ')
+        if len(r) < 2: # no dependencies?
+            continue
+
+        deps = r[1].split(',')
+        for d in deps:
+            if d in libs:
+                i = libs.index(d)
+                dependencies[i].append(r[0])
+            else:
+                libs.append(d)
+                dependencies.append([r[0],])
+    return (libs, dependencies)
+
+
+def extract_dependencies_from_la(la, libraries, to_check, logger):
+    broken = []
+    for f in la:
+        if not os.path.exists(f):
+            continue
+
+        for line in open(f, 'r').readlines():
+            line = line.strip()
+            if line.startswith('dependency_libs='):
+                m = re.match("dependency_libs='([^']+)'", line)
+                if m is not None:
+                    for el in m.group(1).split(' '):
+                        el = el.strip()
+                        if len(el) < 1 or el.startswith('-'):
+                            continue
+
+                        if el in la or el in libraries:
+                            pass
+                        else:
+                            if to_check:
+                                _break = False
+                                for tc in to_check:
+                                    if tc in el:
+                                        _break = True
+                                        break
+                                if not _break:
+                                    continue
+
+                            logger.info(yellow(' * ') + f + ' is broken (requires: ' + bold(el))
+                            broken.append(f)
+    return broken
+
+
+def find_broken(found_libs, system_libraries, to_check):
+    ''' Search for broken libraries.
+        Check if system_libraries contains found_libs, where
+        system_libraries is list of obsolute pathes and found_libs
+        is list of library names.
+    '''
+
+    # join libraries and looking at it as string is way too faster than for-jumping
+
+    broken = []
+    sl = '|'.join(system_libraries)
+
+    if not to_check:
+        for f in found_libs:
+            if f+'|' not in sl:
+                broken.append(found_libs.index(f))
+    else:
+        for tc in to_check:
+            for f in found_libs:
+                if tc in f:# and f+'|' not in sl:
+                    broken.append(found_libs.index(f))
+
+    return broken
+
+
+def main_checks(found_libs, broken, dependencies, logger):
+    ''' Checks for broken dependencies.
+        found_libs have to be the same as returned by prepare_checks
+        broken is list of libraries found by scanelf
+        dependencies is the value returned by prepare_checks
+    '''
+
+    broken_pathes = []
+
+    for b in broken:
+        f = found_libs[b]
+        logger.info('Broken files that requires: ' + bold(f))
+        for d in dependencies[b]:
+            logger.info(yellow(' * ') + d)
+            broken_pathes.append(d)
+    return broken_pathes
+
+
+def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=None, binaries=None, _libs_to_check=set()):
+    """Main program body.  It will collect all info and determine the
+    pkgs needing rebuilding.
+
+    @param logger: logger used for logging messages, instance of logging.Logger
+                   class. Can be logging (RootLogger).
+    @param _libs_to_check Libraries that need to be checked only
+    @rtype list: list of pkgs that need rebuilding
+    """
+
+    if libraries and la_libraries and libraries_links and binaries:
+        logger.info(blue(' * ') + bold('Found a valid cache, skipping collecting phase'))
+    else:
+        #TODO: add partial cache (for ex. only libraries) when found for some reason
+
+        logger.info(green(' * ') + bold('Collecting system binaries and libraries'))
+        bin_dirs, lib_dirs = prepare_search_dirs(logger)
+
+        masked_dirs, masked_files, ld = parse_revdep_config()
+        lib_dirs = lib_dirs.union(ld)
+        bin_dirs = bin_dirs.union(ld)
+        masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+
+        logger.info(green(' * ') + bold('Collecting dynamic linking informations'))
+        libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logger)
+        binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
+
+        if USE_TMP_FILES:
+            save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
+
+
+    logger.debug('Found '+ str(len(libraries)) + ' libraries (+' + str(len(libraries_links)) + ' symlinks) and ' + str(len(binaries)) + ' binaries')
+
+    logger.warn(green(' * ') + bold('Checking dynamic linking consistency'))
+    logger.debug('Search for ' + str(len(binaries)+len(libraries)) + ' within ' + str(len(libraries)+len(libraries_links)))
+    libs_and_bins = libraries+binaries
+
+    #l = []
+    #for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'):
+        #l.append(line)
+    #libraries = l
+
+    found_libs = []
+    dependencies = []
+
+
+    _bits, linkg = platform.architecture()
+    if _bits.startswith('32'):
+        bits = 32
+    elif _bits.startswith('64'):
+        bits = 64
+
+    for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
+        bits = int(av_bits[4:])
+        _libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, CMD_MAX_ARGS)
+        #call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
+
+        found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits)
+
+        broken = find_broken(found_libs, _libraries, _libs_to_check)
+        broken_la = extract_dependencies_from_la(la_libraries, _libraries, _libs_to_check, logger)
+
+        bits /= 2
+        bits = int(bits)
+
+    broken_pathes = main_checks(found_libs, broken, dependencies, logger)
+    broken_pathes += broken_la
+
+    logger.warn(green(' * ') + bold('Assign files to packages'))
+
+    return assign_packages(broken_pathes, logger)
+
+
+
+if __name__ == '__main__':
+    print "This script shouldn't be called directly"

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
new file mode 100644
index 0000000..836e792
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -0,0 +1,94 @@
+#!/usr/bin/python
+
+import os
+import re
+import logging
+import portage
+from portage import portdb
+from portage.output import bold, red, blue, yellow, green, nocolor
+
+
+
+def assign_packages(broken, logger=logging):
+    ''' Finds and returns packages that owns files placed in broken.
+        Broken is list of files
+    '''
+    assigned = set()
+    for group in os.listdir('/var/db/pkg'):
+        for pkg in os.listdir('/var/db/pkg/' + group):
+            f = '/var/db/pkg/' + group + '/' + pkg + '/CONTENTS'
+            if os.path.exists(f):
+                try:
+                    with open(f, 'r') as cnt:
+                        for line in cnt.readlines():
+                            m = re.match('^obj (/[^ ]+)', line)
+                            if m is not None:
+                                m = m.group(1)
+                                if m in broken:
+                                    found = group+'/'+pkg
+                                    if found not in assigned:
+                                        assigned.add(found)
+                                    logger.info('\t' + m + ' -> ' + bold(found))
+                except Exception as e:
+                    logger.warn(red(' !! Failed to read ' + f))
+
+    return assigned
+
+
+def get_best_match(cpv, cp, logger):
+    """Tries to find another version of the pkg with the same slot
+    as the deprecated installed version.  Failing that attempt to get any version
+    of the same app
+
+    @param cpv: string
+    @param cp: string
+    @rtype tuple: ([cpv,...], SLOT)
+    """
+
+    slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])
+    logger.warn(yellow('Warning: ebuild "' + cpv + '" not found.'))
+    logger.info('Looking for %s:%s' %(cp, slot))
+    try:
+        m = portdb.match('%s:%s' %(cp, slot))
+    except portage.exception.InvalidAtom:
+        m = None
+
+    if not m:
+        logger.warn(red('!!') + ' ' + yellow('Could not find ebuild for %s:%s' %(cp, slot)))
+        slot = ['']
+        m = portdb.match(cp)
+        if not m:
+            logger.warn(red('!!') + ' ' + yellow('Could not find ebuild for ' + cp))
+    return m, slot
+
+
+def get_slotted_cps(cpvs, logger):
+    """Uses portage to reduce the cpv list into a cp:slot list and returns it
+    """
+    from portage.versions import catpkgsplit
+    from portage import portdb
+
+    cps = []
+    for cpv in cpvs:
+        parts = catpkgsplit(cpv)
+        print cpv
+        cp = parts[0] + '/' + parts[1]
+        try:
+            slot = portdb.aux_get(cpv, ["SLOT"])
+        except KeyError:
+            m, slot = get_best_match(cpv, cp, logger)
+            if not m:
+                logger.warn(red("Installed package: %s is no longer available" %cp))
+                continue
+
+        if slot[0]:
+            cps.append(cp + ":" + slot[0])
+        else:
+            cps.append(cp)
+
+    return cps
+
+
+
+if __name__ == '__main__':
+    print 'Nothing to call here'

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
new file mode 100644
index 0000000..5f7b932
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -0,0 +1,103 @@
+#!/bin/bash
+
+import os
+import time
+import logging
+
+
+DEFAULT_TMP_DIR = '/tmp/revdep-rebuild' #cache default location
+
+def read_cache(temp_path=DEFAULT_TMP_DIR):
+    ''' Reads cache information needed by analyse function.
+        This function does not checks if files exists nor timestamps,
+        check_temp_files should be called first
+        @param temp_path: directory where all temp files should reside
+        @return tuple with values of: libraries, la_libraries, libraries_links, symlink_pairs, binaries
+    '''
+
+    ret = {'libraries':[], 'la_libraries':[], 'libraries_links':[], 'binaries':[]}
+    try:
+        for key,val in ret.iteritems():
+            f = open(os.path.join(temp_path, key))
+            for line in f.readlines():
+                val.append(line.strip())
+            #libraries.remove('\n')
+            f.close()
+    except EnvironmentError:
+        pass
+
+    return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
+
+
+def save_cache(logger=logging, to_save={}, temp_path=DEFAULT_TMP_DIR):
+    ''' Tries to store caching information.
+        @param logger
+        @param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
+    '''
+
+    if not os.path.exists(temp_path):
+        os.makedirs(temp_path)
+
+    try:
+        f = open(os.path.join(temp_path, 'timestamp'), 'w')
+        f.write(str(int(time.time())))
+        f.close()
+
+        for key,val in to_save.iteritems():
+            f = open(os.path.join(temp_path, key), 'w')
+            for line in val:
+                f.write(line + '\n')
+            f.close()
+    except Exception as ex:
+        logger.warn(red('Could not save cache: %s' %str(ex)))
+
+
+
+def check_temp_files(temp_path=DEFAULT_TMP_DIR, max_delay=3600):
+    ''' Checks if temporary files from previous run are still available
+        and if they aren't too old
+        @param temp_path is directory, where temporary files should be found
+        @param max_delay is maximum time difference (in seconds) when those files
+                are still considered fresh and useful
+        returns True, when files can be used, or False, when they don't
+        exists or they are too old
+    '''
+
+    if not os.path.exists(temp_path) or not os.path.isdir(temp_path):
+        return False
+
+    timestamp_path = os.path.join(temp_path, 'timestamp')
+    if not os.path.exists(timestamp_path) or not os.path.isfile(timestamp_path):
+        return False
+
+    try:
+        f = open(timestamp_path)
+        timestamp = int(f.readline())
+        f.close()
+    except:
+        timestamp = 0
+        return False
+
+    diff = int(time.time()) - timestamp
+    return max_delay > diff
+
+
+
+if __name__ == '__main__':
+    print 'Preparing cache ... '
+
+    from collect import *
+
+    bin_dirs, lib_dirs = prepare_search_dirs()
+
+    masked_dirs, masked_files, ld = parse_revdep_config()
+    lib_dirs = lib_dirs.union(ld)
+    bin_dirs = bin_dirs.union(ld)
+    masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+
+    libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs)
+    binaries = collect_binaries_from_dir(bin_dirs, masked_dirs)
+
+    save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
+
+    print 'Done.'

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
new file mode 100644
index 0000000..ca71d3d
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -0,0 +1,248 @@
+#!/usr/bin/python
+
+import re
+import os
+import glob
+import stat
+import logging
+import portage
+from portage.output import bold, red, blue, yellow, green, nocolor
+
+DEFAULT_LD_FILE = 'etc/ld.so.conf'
+DEFAULT_ENV_FILE = 'etc/profile.env'
+
+
+def parse_conf(conf_file=os.path.join(portage.root, DEFAULT_LD_FILE), visited=None, logger=logging):
+    ''' Parses supplied conf_file for libraries pathes.
+        conf_file is file or files to parse
+        visited is set of files already parsed
+    '''
+    lib_dirs = set()
+    to_parse = set()
+
+    if isinstance(conf_file, basestring):
+        conf_file = [conf_file]
+
+    for conf in conf_file:
+        try:
+            with open(conf) as f:
+                for line in f.readlines():
+                    line = line.strip()
+                    if line.startswith('#'):
+                        continue
+                    elif line.startswith('include'):
+                        include_line = line.split()[1:]
+                        for included in include_line:
+                            if not included.startswith('/'):
+                                path = os.path.join(os.path.dirname(conf), \
+                                                    included)
+                            else:
+                                path = included
+
+                            to_parse = to_parse.union(glob.glob(path))
+                    else:
+                        lib_dirs.add(line)
+        except EnvironmentError:
+            logger.warn(yellow('Error when parsing file %s' %conf))
+
+    if visited is None:
+        visited = set()
+
+    visited = visited.union(conf_file)
+    to_parse = to_parse.difference(visited)
+    if to_parse:
+        lib_dirs = lib_dirs.union(parse_conf(to_parse, visited, logger=logger))
+
+    return lib_dirs
+
+
+def prepare_search_dirs(logger=logging):
+    ''' Lookup for search dirs. Returns tuple with two lists,
+        (list_of_bin_dirs, list_of_lib_dirs)
+    '''
+
+    bin_dirs = set(['/bin', '/usr/bin', ])
+    lib_dirs = set(['/lib', '/usr/lib', ])
+
+    try:
+        with open(os.path.join(portage.root, DEFAULT_ENV_FILE), 'r') as f:
+            for line in f.readlines():
+                line = line.strip()
+                m = re.match("^export (ROOT)?PATH='([^']+)'", line)
+                if m is not None:
+                    bin_dirs = bin_dirs.union(set(m.group(2).split(':')))
+    except EnvironmentError:
+        logger.debug(yellow('Could not open file %s' % f))
+
+    lib_dirs = parse_conf(logger=logger)
+    return (bin_dirs, lib_dirs)
+
+
+def parse_revdep_config():
+    ''' Parses all files under /etc/revdep-rebuild/ and returns
+        tuple of: (masked_dirs, masked_files, search_dirs)'''
+
+    search_dirs = set()
+    masked_dirs = set()
+    masked_files = set()
+
+    #TODO: remove hard-coded path
+    for f in os.listdir('/etc/revdep-rebuild/'):
+        for line in open(os.path.join('/etc/revdep-rebuild', f)):
+            line = line.strip()
+            if not line.startswith('#'): #first check for comment, we do not want to regex all lines
+                m = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
+                if m is not None:
+                    s = m.group(1).split(' ')
+                    masked_files = masked_files.union(s)
+                    continue
+                m = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
+                if m is not None:
+                    s = m.group(1).split(' ')
+                    for ss in s:
+                        masked_dirs = masked_dirs.union(glob.glob(ss))
+                    continue
+                m = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
+                if m is not None:
+                    s = m.group(1).split()
+                    for ss in s:
+                        search_dirs = search_dirs.union(glob.glob(ss))
+                    continue
+
+    return (masked_dirs, masked_files, search_dirs)
+
+
+def collect_libraries_from_dir(dirs, mask, logger=logging):
+    ''' Collects all libraries from specified list of directories.
+        mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
+        Returns tuple composed of: list of libraries, list of symlinks, and toupe with pair
+        (symlink_id, library_id) for resolving dependencies
+    '''
+
+
+    found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
+    found_files = []
+    found_symlinks = []
+    found_la_files = [] # la libraries
+    symlink_pairs = []  # list of pairs symlink_id->library_id
+
+    for d in dirs:
+        if d in mask:
+            continue
+
+        try:
+            for l in os.listdir(d):
+                l = os.path.join(d, l)
+                if l in mask:
+                    continue
+
+                if os.path.isdir(l):
+                    if os.path.islink(l):
+                        #we do not want scan symlink-directories
+                        pass
+                    else:
+                        found_directories.append(l)
+                elif os.path.isfile(l):
+                    if l.endswith('.so') or '.so.' in l:
+                        if l in found_files or l in found_symlinks:
+                            continue
+
+                        if os.path.islink(l):
+                            found_symlinks.append(l)
+                            abs_path = os.path.realpath(l)
+                            if abs_path in found_files:
+                                i = found_files.index(abs_path)
+                            else:
+                                found_files.append(abs_path)
+                                i = len(found_files)-1
+                            symlink_pairs.append((len(found_symlinks)-1, i,))
+                        else:
+                            found_files.append(l)
+                        continue
+                    elif l.endswith('.la'):
+                        if l in found_la_files:
+                            continue
+
+                        found_la_files.append(l)
+                    else:
+                        # sometimes there are binaries in libs' subdir, for example in nagios
+                        if not os.path.islink(l):
+                            if l in found_files or l in found_symlinks:
+                                continue
+                            prv = os.stat(l)[stat.ST_MODE]
+                            if prv & stat.S_IXUSR == stat.S_IXUSR or \
+                                    prv & stat.S_IXGRP == stat.S_IXGRP or \
+                                    prv & stat.S_IXOTH == stat.S_IXOTH:
+                                found_files.append(l)
+        except Exception as ex:
+            logger.debug(yellow('Exception during collecting libraries: %s' %str(ex)))
+
+
+    if found_directories:
+        f,a,l,p = collect_libraries_from_dir(found_directories, mask, logger)
+        found_files+=f
+        found_la_files+=a
+        found_symlinks+=l
+        symlink_pairs+=p
+
+    return (found_files, found_la_files, found_symlinks, symlink_pairs)
+
+
+def collect_binaries_from_dir(dirs, mask, logger=logging):
+    ''' Collects all binaries from specified list of directories.
+        mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
+        Returns list of binaries
+    '''
+
+    found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
+    found_files = []
+
+    for d in dirs:
+        if d in mask:
+            continue
+
+        try:
+            for l in os.listdir(d):
+                l = os.path.join(d, l)
+                if d in mask:
+                    continue
+
+                if os.path.isdir(l):
+                    if os.path.islink(l):
+                        #we do not want scan symlink-directories
+                        pass
+                    else:
+                        found_directories.append(l)
+                elif os.path.isfile(l):
+                    #we're looking for binaries, and with binaries we do not need links, thus we can optimize a bit
+                    if not os.path.islink(l):
+                        prv = os.stat(l)[stat.ST_MODE]
+                        if prv & stat.S_IXUSR == stat.S_IXUSR or \
+                                prv & stat.S_IXGRP == stat.S_IXGRP or \
+                                prv & stat.S_IXOTH == stat.S_IXOTH:
+                            found_files.append(l)
+        except Exception as e:
+            logger.debug(yellow('Exception during binaries collecting: %s' %str(e)))
+
+    if found_directories:
+        found_files += collect_binaries_from_dir(found_directories, mask, logger)
+
+    return found_files
+
+
+
+if __name__ == '__main__':
+    bin_dirs, lib_dirs = prepare_search_dirs(logging)
+
+    masked_dirs, masked_files, ld = parse_revdep_config()
+    lib_dirs = lib_dirs.union(ld)
+    bin_dirs = bin_dirs.union(ld)
+    masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+
+    libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logging)
+    binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logging)
+
+    print 'Found: %i binaries and %i libraries.' %(len(binaries), len(libraries))
+
+
+

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
index ac2a6c8..c28b1b0 100755
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -20,12 +20,18 @@ import stat
 import time
 import glob
 import portage
-import platform
+import logging
 from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
 
+from analyse import analyse
+from stuff import *
+from cache import *
+from assign import get_slotted_cps
+
+
 APP_NAME = sys.argv[0]
-VERSION = '0.1-r4'
+VERSION = '0.1-r5'
 
 
 __productname__ = "revdep-ng"
@@ -49,51 +55,11 @@ VERBOSITY = 1      #verbosity level; 0-quiet, 1-norm., 2-verbose
 IS_DEV = True       #True for dev. version, False for stable
 #used when IS_DEV is True, False forces to call emerge with --pretend
 # can be set True from the cli with the --no-pretend option
-NO_PRETEND = False 
+NO_PRETEND = False
 
 CMD_MAX_ARGS = 1000 # number of maximum allowed files to be parsed at once
 
 
-# util. functions
-def call_program(args):
-    ''' Calls program with specified parameters and returns stdout '''
-    subp = subprocess.Popen(args, stdout=subprocess.PIPE, \
-                                stderr=subprocess.PIPE)
-    stdout, stderr = subp.communicate()
-    return stdout
-
-
-def scan(params, files):
-    ''' Calls scanelf with given params and files to scan.
-        @param params is list of parameters that should be passed into scanelf app.
-        @param files list of files to scan.
-
-        When files count is greater CMD_MAX_ARGS, it'll be divided
-        into several parts
-
-        @return scanelf output (joined if was called several times)
-    '''
-    out = []
-    for i in range(0, len(files), CMD_MAX_ARGS):
-        out += call_program(['scanelf'] + params + files[i:i+CMD_MAX_ARGS]).strip().split('\n')
-    return out
-
-
-def print_v(verbosity, args):
-    """Prints to stdout according to the verbosity level 
-    and the global VERBOSITY level
-    
-    @param verbosity: integer
-    @param args: string to print
-    """
-    if verbosity > VERBOSITY:
-        return
-    print args
-
-
-def exithandler(signum, frame):
-    sys.exit(1)
-
 
 def print_usage():
     print APP_NAME + ': (' + VERSION +')'
@@ -127,225 +93,6 @@ def print_usage():
 
 
 # functions
-def parse_conf(conf_file=None, visited=None):
-    ''' Parses supplied conf_file for libraries pathes.
-        conf_file is file or files to parse
-        visited is set of files already parsed
-    '''
-
-    if conf_file is None:
-        conf_file = os.path.join(portage.root, DEFAULT_LD_FILE)
-
-    lib_dirs = set()
-    to_parse = set()
-
-    if isinstance(conf_file, basestring):
-        conf_file = [conf_file]
-
-    for conf in conf_file:
-        try:
-            with open(conf) as f:
-                for line in f.readlines():
-                    line = line.strip()
-                    if line.startswith('#'):
-                        continue
-                    elif line.startswith('include'):
-                        include_line = line.split()[1:]
-                        for included in include_line:
-                            if not included.startswith('/'):
-                                path = os.path.join(os.path.dirname(conf), \
-                                                    included)
-                            else:
-                                path = included
-
-                            to_parse = to_parse.union(glob.glob(path))
-                    else:
-                        lib_dirs.add(line)
-        except EnvironmentError:
-            print_v(2, 'Error when parsing file %s' %conf)
-
-    if visited is None:
-        visited = set()
-
-    visited = visited.union(conf_file)
-    to_parse = to_parse.difference(visited)
-    if to_parse:
-        lib_dirs = lib_dirs.union(parse_conf(to_parse, visited))
-
-    return lib_dirs
-
-
-def prepare_search_dirs():
-    ''' Lookup for search dirs. Returns tuple with two lists,
-        (list_of_bin_dirs, list_of_lib_dirs)
-    '''
-
-    bin_dirs = set(['/bin', '/usr/bin', ])
-    lib_dirs = set(['/lib', '/usr/lib', ])
-
-    try:
-        with open(os.path.join(portage.root, DEFAULT_ENV_FILE), 'r') as f:
-            for line in f.readlines():
-                line = line.strip()
-                m = re.match("^export (ROOT)?PATH='([^']+)'", line)
-                if m is not None:
-                    bin_dirs = bin_dirs.union(set(m.group(2).split(':')))
-    except EnvironmentError:
-        print_v(2, 'Could not open file %s' % f)
-
-    lib_dirs = parse_conf()
-    return (bin_dirs, lib_dirs)
-
-
-def parse_revdep_config():
-    ''' Parses all files under /etc/revdep-rebuild/ and returns
-        tuple of: (masked_dirs, masked_files, search_dirs)'''
-
-    search_dirs = set()
-    masked_dirs = set()
-    masked_files = set()
-
-    for f in os.listdir('/etc/revdep-rebuild/'):
-        for line in open(os.path.join('/etc/revdep-rebuild', f)):
-            line = line.strip()
-            if not line.startswith('#'): #first check for comment, we do not want to regex all lines
-                m = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
-                if m is not None:
-                    s = m.group(1).split(' ')
-                    masked_files = masked_files.union(s)
-                    continue
-                m = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
-                if m is not None:
-                    s = m.group(1).split(' ')
-                    for ss in s:
-                        masked_dirs = masked_dirs.union(glob.glob(ss))
-                    continue
-                m = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
-                if m is not None:
-                    s = m.group(1).split()
-                    for ss in s:
-                        search_dirs = search_dirs.union(glob.glob(ss))
-                    continue
-
-    return (masked_dirs, masked_files, search_dirs)
-
-
-def collect_libraries_from_dir(dirs, mask):
-    ''' Collects all libraries from specified list of directories.
-        mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
-        Returns tuple composed of: list of libraries, list of symlinks, and toupe with pair
-        (symlink_id, library_id) for resolving dependencies
-    '''
-
-
-    found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
-    found_files = []
-    found_symlinks = []
-    found_la_files = [] # la libraries
-    symlink_pairs = []  # list of pairs symlink_id->library_id
-
-    for d in dirs:
-        if d in mask:
-            continue
-
-        try:
-            for l in os.listdir(d):
-                l = os.path.join(d, l)
-                if l in mask:
-                    continue
-
-                if os.path.isdir(l):
-                    if os.path.islink(l):
-                        #we do not want scan symlink-directories
-                        pass
-                    else:
-                        found_directories.append(l)
-                elif os.path.isfile(l):
-                    if l.endswith('.so') or '.so.' in l:
-                        if l in found_files or l in found_symlinks:
-                            continue
-
-                        if os.path.islink(l):
-                            found_symlinks.append(l)
-                            abs_path = os.path.realpath(l)
-                            if abs_path in found_files:
-                                i = found_files.index(abs_path)
-                            else:
-                                found_files.append(abs_path)
-                                i = len(found_files)-1
-                            symlink_pairs.append((len(found_symlinks)-1, i,))
-                        else:
-                            found_files.append(l)
-                        continue
-                    elif l.endswith('.la'):
-                        if l in found_la_files:
-                            continue
-
-                        found_la_files.append(l)
-                    else:
-                        # sometimes there are binaries in libs' subdir, for example in nagios
-                        if not os.path.islink(l):
-                            if l in found_files or l in found_symlinks:
-                                continue
-                            prv = os.stat(l)[stat.ST_MODE]
-                            if prv & stat.S_IXUSR == stat.S_IXUSR or \
-                                    prv & stat.S_IXGRP == stat.S_IXGRP or \
-                                    prv & stat.S_IXOTH == stat.S_IXOTH:
-                                found_files.append(l)
-        except:
-            pass
-
-
-    if found_directories:
-        f,a,l,p = collect_libraries_from_dir(found_directories, mask)
-        found_files+=f
-        found_la_files+=a
-        found_symlinks+=l
-        symlink_pairs+=p
-
-    return (found_files, found_la_files, found_symlinks, symlink_pairs)
-
-
-def collect_binaries_from_dir(dirs, mask):
-    ''' Collects all binaries from specified list of directories.
-        mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
-        Returns list of binaries
-    '''
-
-    found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
-    found_files = []
-
-    for d in dirs:
-        if d in mask:
-            continue
-
-        try:
-            for l in os.listdir(d):
-                l = os.path.join(d, l)
-                if d in mask:
-                    continue
-
-                if os.path.isdir(l):
-                    if os.path.islink(l):
-                        #we do not want scan symlink-directories
-                        pass
-                    else:
-                        found_directories.append(l)
-                elif os.path.isfile(l):
-                    #we're looking for binaries, and with binaries we do not need links, thus we can optimize a bit
-                    if not os.path.islink(l):
-                        prv = os.stat(l)[stat.ST_MODE]
-                        if prv & stat.S_IXUSR == stat.S_IXUSR or \
-                                prv & stat.S_IXGRP == stat.S_IXGRP or \
-                                prv & stat.S_IXOTH == stat.S_IXOTH:
-                            found_files.append(l)
-        except:
-            pass
-
-    if found_directories:
-        found_files += collect_binaries_from_dir(found_directories, mask)
-
-    return found_files
 
 
 def _match_str_in_list(lst, stri):
@@ -355,333 +102,15 @@ def _match_str_in_list(lst, stri):
     return False
 
 
-def prepare_checks(files_to_check, libraries, bits):
-    ''' Calls scanelf for all files_to_check, then returns found libraries and dependencies
-    '''
-
-    libs = [] # libs found by scanelf
-    dependencies = [] # list of lists of files (from file_to_check) that uses
-                      # library (for dependencies[id] and libs[id] => id==id)
-
-    for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check):
-    #call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
-        r = line.strip().split(' ')
-        if len(r) < 2: # no dependencies?
-            continue
-
-        deps = r[1].split(',')
-        for d in deps:
-            if d in libs:
-                i = libs.index(d)
-                dependencies[i].append(r[0])
-            else:
-                libs.append(d)
-                dependencies.append([r[0],])
-    return (libs, dependencies)
-
-
-def extract_dependencies_from_la(la, libraries, to_check):
-    broken = []
-    for f in la:
-        if not os.path.exists(f):
-            continue
-
-        for line in open(f, 'r').readlines():
-            line = line.strip()
-            if line.startswith('dependency_libs='):
-                m = re.match("dependency_libs='([^']+)'", line)
-                if m is not None:
-                    for el in m.group(1).split(' '):
-                        el = el.strip()
-                        if len(el) < 1 or el.startswith('-'):
-                            continue
-
-                        if el in la or el in libraries:
-                            pass
-                        else:
-                            if to_check:
-                                _break = False
-                                for tc in to_check:
-                                    if tc in el:
-                                        _break = True
-                                        break
-                                if not _break:
-                                    continue
-
-                            print_v(1, yellow(' * ') + f + ' is broken (requires: ' + bold(el))
-                            broken.append(f)
-    return broken
-
-
-
-def find_broken(found_libs, system_libraries, to_check):
-    ''' Search for broken libraries.
-        Check if system_libraries contains found_libs, where
-        system_libraries is list of obsolute pathes and found_libs
-        is list of library names.
-    '''
-
-    # join libraries and looking at it as string is way too faster than for-jumping
-
-    broken = []
-    sl = '|'.join(system_libraries)
-
-    if not to_check:
-        for f in found_libs:
-            if f+'|' not in sl:
-                broken.append(found_libs.index(f))
-    else:
-        for tc in to_check:
-            for f in found_libs:
-                if tc in f:# and f+'|' not in sl:
-                    broken.append(found_libs.index(f))
-
-    return broken
-
-
-def main_checks(found_libs, broken, dependencies):
-    ''' Checks for broken dependencies.
-        found_libs have to be the same as returned by prepare_checks
-        broken is list of libraries found by scanelf
-        dependencies is the value returned by prepare_checks
-    '''
-
-    broken_pathes = []
-
-    for b in broken:
-        f = found_libs[b]
-        print_v(1, 'Broken files that requires: ' + bold(f))
-        for d in dependencies[b]:
-            print_v(1, yellow(' * ') + d)
-            broken_pathes.append(d)
-    return broken_pathes
-
-
-def assign_packages(broken, output):
-    ''' Finds and returns packages that owns files placed in broken.
-        Broken is list of files
-    '''
-    assigned = set()
-    for group in os.listdir('/var/db/pkg'):
-        for pkg in os.listdir('/var/db/pkg/' + group):
-            f = '/var/db/pkg/' + group + '/' + pkg + '/CONTENTS'
-            if os.path.exists(f):
-                try:
-                    with open(f, 'r') as cnt:
-                        for line in cnt.readlines():
-                            m = re.match('^obj (/[^ ]+)', line)
-                            if m is not None:
-                                m = m.group(1)
-                                if m in broken:
-                                    found = group+'/'+pkg
-                                    if found not in assigned:
-                                        assigned.add(found)
-                                    print_v(1, '\t' + m + ' -> ' + bold(found))
-                except Exception as e:
-                    output(1, red(' !! Failed to read ' + f))
-
-    return assigned
-
-
-def get_best_match(cpv, cp):
-    """Tries to find another version of the pkg with the same slot
-    as the deprecated installed version.  Failing that attempt to get any version
-    of the same app
-    
-    @param cpv: string
-    @param cp: string
-    @rtype tuple: ([cpv,...], SLOT)
-    """
-
-    slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])
-    print_v(1, yellow('Warning: ebuild "' + cpv + '" not found.'))
-    print_v(1, 'Looking for %s:%s' %(cp, slot))
-    try:
-        m = portdb.match('%s:%s' %(cp, slot))
-    except portage.exception.InvalidAtom:
-        m = None
-
-    if not m:
-        print_v(1, red('Could not find ebuild for %s:%s' %(cp, slot)))
-        slot = ['']
-        m = portdb.match(cp)
-        if not m:
-            print_v(1, red('Could not find ebuild for ' + cp))
-    return m, slot
-
-
-def get_slotted_cps(cpvs):
-    """Uses portage to reduce the cpv list into a cp:slot list and returns it
-    """
-    from portage.versions import catpkgsplit
-    from portage import portdb
-
-    cps = []
-    for cpv in cpvs:
-        parts = catpkgsplit(cpv)
-        cp = parts[0] + '/' + parts[1]
-        try:
-            slot = portdb.aux_get(cpv, ["SLOT"])
-        except KeyError:
-            m, slot = get_best_match(cpv, cp)
-            if not m:
-                print_v(1, red("Installed package: %s is no longer available" %cp))
-                continue
-
-        if slot[0]:
-            cps.append(cp + ":" + slot[0])
-        else:
-            cps.append(cp)
-
-    return cps
-
-
-def read_cache(temp_path=DEFAULT_TMP_DIR):
-    ''' Reads cache information needed by analyse function.
-        This function does not checks if files exists nor timestamps,
-        check_temp_files should be called first
-        @param temp_path: directory where all temp files should reside
-        @return tuple with values of: libraries, la_libraries, libraries_links, symlink_pairs, binaries
-    '''
-
-    ret = {'libraries':[], 'la_libraries':[], 'libraries_links':[], 'binaries':[]}
-    try:
-        for key,val in ret.iteritems():
-            f = open(os.path.join(temp_path, key))
-            for line in f.readlines():
-                val.append(line.strip())
-            #libraries.remove('\n')
-            f.close()
-    except EnvironmentError:
-        pass
-
-    return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
-
-
-def save_cache(output=print_v, to_save={}, temp_path=DEFAULT_TMP_DIR):
-    ''' Tries to store caching information.
-        @param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
-    '''
-
-    if not os.path.exists(temp_path):
-        os.makedirs(temp_path)
-
-    try:
-        f = open(os.path.join(temp_path, 'timestamp'), 'w')
-        f.write(str(int(time.time())))
-        f.close()
-
-        for key,val in to_save.iteritems():
-            f = open(os.path.join(temp_path, key), 'w')
-            for line in val:
-                f.write(line + '\n')
-            f.close()
-    except Exception as ex:
-        output(1, red('Could not save cache %s' %str(ex)))
-
-def analyse(output=print_v, libraries=None, la_libraries=None, libraries_links=None, binaries=None):
-    """Main program body.  It will collect all info and determine the
-    pkgs needing rebuilding.
-
-    @param output: optional print/data gathering routine. Defaults to print_v
-            which prints to sys.stdout. Refer to print_v parameters for more detail.
-    @rtype list: list of pkgs that need rebuilding
-    """
-
-    if libraries and la_libraries and libraries_links and binaries:
-        output(1, blue(' * ') + bold('Found a valid cache, skipping collecting phase'))
-    else:
-        #TODO: add partial cache (for ex. only libraries) when found for some reason
-
-        output(1, green(' * ') + bold('Collecting system binaries and libraries'))
-        bin_dirs, lib_dirs = prepare_search_dirs()
-
-        masked_dirs, masked_files, ld = parse_revdep_config()
-        lib_dirs = lib_dirs.union(ld)
-        bin_dirs = bin_dirs.union(ld)
-        masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
-
-        output(1, green(' * ') + bold('Collecting dynamic linking informations'))
-        libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs)
-        binaries = collect_binaries_from_dir(bin_dirs, masked_dirs)
-
-        if USE_TMP_FILES:
-            save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
-
-
-    output(2, 'Found '+ str(len(libraries)) + ' libraries (+' + str(len(libraries_links)) + ' symlinks) and ' + str(len(binaries)) + ' binaries')
-
-    output(1, green(' * ') + bold('Checking dynamic linking consistency'))
-    output(2,'Search for ' + str(len(binaries)+len(libraries)) + ' within ' + str(len(libraries)+len(libraries_links)))
-    libs_and_bins = libraries+binaries
-
-    #l = []
-    #for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'):
-        #l.append(line)
-    #libraries = l
-
-    found_libs = []
-    dependencies = []
-
-
-    _bits, linkg = platform.architecture()
-    if _bits.startswith('32'):
-        bits = 32
-    elif _bits.startswith('64'):
-        bits = 64
-
-    for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
-        bits = int(av_bits[4:])
-        _libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links)
-        #call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
-
-        found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits)
-
-        broken = find_broken(found_libs, _libraries, _libs_to_check)
-        broken_la = extract_dependencies_from_la(la_libraries, _libraries, _libs_to_check)
-
-        bits /= 2
-        bits = int(bits)
-
-    broken_pathes = main_checks(found_libs, broken, dependencies)
-    broken_pathes += broken_la
-
-    output(1, green(' * ') + bold('Assign files to packages'))
-
-    return assign_packages(broken_pathes, output)
-
-
-def check_temp_files(temp_path=DEFAULT_TMP_DIR, max_delay=3600):
-    ''' Checks if temporary files from previous run are still available
-        and if they aren't too old
-        @param temp_path is directory, where temporary files should be found
-        @param max_delay is maximum time difference (in seconds) when those files
-                are still considered fresh and useful
-        returns True, when files can be used, or False, when they don't
-        exists or they are too old
-    '''
-
-    if not os.path.exists(temp_path) or not os.path.isdir(temp_path):
-        return False
-
-    timestamp_path = os.path.join(temp_path, 'timestamp')
-    if not os.path.exists(timestamp_path) or not os.path.isfile(timestamp_path):
-        return False
-
-    try:
-        f = open(timestamp_path)
-        timestamp = int(f.readline())
-        f.close()
-    except:
-        timestamp = 0
-        return False
-
-    diff = int(time.time()) - timestamp
-    return max_delay > diff
-
-
 # Runs from here
 if __name__ == "__main__":
+    logger = logging.getLogger()
+    log_handler = logging.StreamHandler()
+    log_fmt = logging.Formatter('%(msg)s')
+    log_handler.setFormatter(log_fmt)
+    logger.addHandler(log_handler)
+    logger.setLevel(logging.WARNING)
+
     _libs_to_check = set()
 
     try:
@@ -694,10 +123,13 @@ if __name__ == "__main__":
                 sys.exit(0)
             elif key in ('-q', '--quiet'):
                 VERBOSITY = 0
+                logger.setLevel(logging.ERROR)
             elif key in ('-v', '--verbose'):
                 VERBOSITY = 2
+                logger.setLevel(logging.INFO)
             elif key in ('-d', '--debug'):
                 PRINT_DEBUG = True
+                logger.setLevel(logging.DEBUG)
             elif key in ('-p', '--pretend'):
                 PRETEND = True
             elif key == '--no-pretend':
@@ -713,7 +145,7 @@ if __name__ == "__main__":
 
         args = " " + " ".join(args)
     except getopt.GetoptError:
-        print_v(1, red('Unrecognized option\n'))
+        logging.info(red('Unrecognized option\n'))
         print_usage()
         sys.exit(2)
 
@@ -721,12 +153,12 @@ if __name__ == "__main__":
         nocolor()
 
     if os.getuid() != 0 and not PRETEND:
-        print_v(1, blue(' * ') + yellow('You are not root, adding --pretend to portage options'))
+        logger.warn(blue(' * ') + yellow('You are not root, adding --pretend to portage options'))
         PRETEND = True
     elif not PRETEND and IS_DEV and not NO_PRETEND:
-        print_v(1, blue(' * ') + yellow('This is a development version, so it may not work correctly'))
-        print_v(1, blue(' * ') + yellow('Adding --pretend to portage options anyway'))
-        print_v(1, blue(' * ') + 'If you\'re sure, you can add --no-pretend to revdep options')
+        logger.warn(blue(' * ') + yellow('This is a development version, so it may not work correctly'))
+        logger.warn(blue(' * ') + yellow('Adding --pretend to portage options anyway'))
+        logger.info(blue(' * ') + 'If you\'re sure, you can add --no-pretend to revdep options')
         PRETEND = True
 
 
@@ -738,18 +170,18 @@ if __name__ == "__main__":
     if USE_TMP_FILES and check_temp_files():
         libraries, la_libraries, libraries_links, binaries = read_cache()
         assigned = analyse(libraries=libraries, la_libraries=la_libraries, \
-                       libraries_links=libraries_links, binaries=binaries)
+                       libraries_links=libraries_links, binaries=binaries, _libs_to_check=_libs_to_check)
     else:
         assigned = analyse()
 
     if not assigned:
-        print_v(1, '\n' + bold('Your system is consistent'))
+        logger.warn('\n' + bold('Your system is consistent'))
         sys.exit(0)
 
     if EXACT:
         emerge_command = '=' + ' ='.join(assigned)
     else:
-        emerge_command = ' '.join(get_slotted_cps(assigned))
+        emerge_command = ' '.join(get_slotted_cps(assigned, logger))
     if PRETEND:
         args += ' --pretend'
     if VERBOSITY >= 2:
@@ -758,15 +190,11 @@ if __name__ == "__main__":
         args += ' --quiet'
 
     if len(emerge_command) == 0:
-        print_v(1, bold('\nThere is nothing to emerge. Exiting.'))
+        logger.warn(bold('\nThere is nothing to emerge. Exiting.'))
         sys.exit(0)
 
     emerge_command = args + ' --oneshot ' + emerge_command
 
-
-    #if PRETEND:
-    print_v(1, yellow('\nemerge') + bold(emerge_command))
-    #else:
-        #call_program(emerge_command.split())
+    logger.warn(yellow('\nemerge') + bold(emerge_command))
     os.system('emerge ' + emerge_command)
 

diff --git a/pym/gentoolkit/revdep_rebuild/revdep_rebuild.kdev4 b/pym/gentoolkit/revdep_rebuild/revdep_rebuild.kdev4
new file mode 100644
index 0000000..7c395ce
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/revdep_rebuild.kdev4
@@ -0,0 +1,3 @@
+[Project]
+Manager=KDevGenericManager
+Name=revdep_rebuild

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
new file mode 100644
index 0000000..dd8e572
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -0,0 +1,39 @@
+#!/usr/bin/python
+
+import subprocess
+
+
+# util. functions
+def call_program(args):
+    ''' Calls program with specified parameters and returns stdout '''
+    subp = subprocess.Popen(args, stdout=subprocess.PIPE, \
+                                stderr=subprocess.PIPE)
+    stdout, stderr = subp.communicate()
+    return stdout
+
+
+def scan(params, files, max_args):
+    ''' Calls scanelf with given params and files to scan.
+        @param params is list of parameters that should be passed into scanelf app.
+        @param files list of files to scan.
+        @param max_args number of files to process at once
+
+        When files count is greater CMD_MAX_ARGS, it'll be divided
+        into several parts
+
+        @return scanelf output (joined if was called several times)
+    '''
+    out = []
+    for i in range(0, len(files), max_args):
+        out += call_program(['scanelf'] + params + files[i:i+max_args]).strip().split('\n')
+    return out
+
+
+
+def exithandler(signum, frame):
+    sys.exit(1)
+
+
+
+if __name__ == '__main__':
+    print "There is nothing to run here."

diff --git a/pym/gentoolkit/revdep_rebuild/test.py b/pym/gentoolkit/revdep_rebuild/test.py
new file mode 100644
index 0000000..9f87f32
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/test.py
@@ -0,0 +1,7 @@
+#!/usr/bin/python
+
+import logging
+
+logging.basicConfig(format='%(msg)s', level=logging.DEBUG)
+#logging.basicConfig()
+logging.info('test')
\ No newline at end of file



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     ba2773480f8737e92dbbdc8c6f3e1a671200a35c
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Tue Feb 15 05:24:25 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=ba277348

Fixed bug from: http://bugs.gentoo.org/show_bug.cgi?id=353518

---
 pym/gentoolkit/revdep_rebuild/analyse.py        |    2 +-
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |   17 ++++++++++++++++-
 pym/gentoolkit/revdep_rebuild/stuff.py          |    7 +++++++
 3 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 004163e..c1c755b 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -131,7 +131,7 @@ def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=N
     else:
         #TODO: add partial cache (for ex. only libraries) when found for some reason
 
-        logger.info(green(' * ') + bold('Collecting system binaries and libraries'))
+        logger.warn(green(' * ') + bold('Collecting system binaries and libraries'))
         bin_dirs, lib_dirs = prepare_search_dirs(logger)
 
         masked_dirs, masked_files, ld = parse_revdep_config()

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
index f2fda2e..4ad5e58 100644
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -25,7 +25,7 @@ from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
 
 from analyse import analyse
-from stuff import exithandler
+from stuff import exithandler, get_masking_status
 from cache import check_temp_files, read_cache
 from assign import get_slotted_cps
 from settings import SETTINGS
@@ -155,6 +155,21 @@ if __name__ == "__main__":
         logger.warn('\n' + bold('Your system is consistent'))
         sys.exit(0)
 
+
+    has_masked = False
+    tmp = []
+    for a in assigned:
+        if get_masking_status(a):
+            has_masked = True
+            logger.warn('!!! ' + red('All ebuilds that could satisfy: ') + green(a) + red(' have been masked'))
+        else:
+            tmp.append(a)
+    assigned = tmp
+
+    if has_masked:
+        logger.info(red(' * ') + 'Unmask all ebuild listed above and call revdep-rebuild again or manually emerge given packages.')
+
+
     if SETTINGS['EXACT']:
         emerge_command = '=' + ' ='.join(assigned)
     else:

diff --git a/pym/gentoolkit/revdep_rebuild/stuff.py b/pym/gentoolkit/revdep_rebuild/stuff.py
index dd8e572..d153908 100644
--- a/pym/gentoolkit/revdep_rebuild/stuff.py
+++ b/pym/gentoolkit/revdep_rebuild/stuff.py
@@ -1,6 +1,7 @@
 #!/usr/bin/python
 
 import subprocess
+import portage
 
 
 # util. functions
@@ -34,6 +35,12 @@ def exithandler(signum, frame):
     sys.exit(1)
 
 
+def get_masking_status(ebuild):
+    try:
+        status = portage.getmaskingstatus(ebuild)
+    except KeyError:
+        status = ['deprecated']
+    return status
 
 if __name__ == '__main__':
     print "There is nothing to run here."



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     834fee88fe2cec331fed356015e7327b0f7ce271
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Tue Jan 18 06:18:42 2011 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=834fee88

Some fixes after file split. Removed unwanted files. Moved settings into module

---
 pym/gentoolkit/revdep_rebuild/analyse.py           |   18 +++---
 pym/gentoolkit/revdep_rebuild/assign.py            |    9 +--
 pym/gentoolkit/revdep_rebuild/cache.py             |   10 ++--
 pym/gentoolkit/revdep_rebuild/collect.py           |   26 ++++----
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py    |   63 ++++++-------------
 pym/gentoolkit/revdep_rebuild/revdep_rebuild.kdev4 |    3 -
 pym/gentoolkit/revdep_rebuild/settings.py          |   26 ++++++++
 pym/gentoolkit/revdep_rebuild/test.py              |    7 --
 8 files changed, 76 insertions(+), 86 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 5141f6f..004163e 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -1,17 +1,17 @@
 #!/usr/bin/python
 
+import os
+import re
 import platform
 import logging
 import glob
 from portage.output import bold, red, blue, yellow, green, nocolor
 
-from stuff import *
-from collect import *
+from stuff import scan
+from collect import prepare_search_dirs, parse_revdep_config, collect_libraries_from_dir, collect_binaries_from_dir
 from assign import assign_packages
-
-
-USE_TMP_FILES = True #if program should use temporary files from previous run
-CMD_MAX_ARGS = 1000 # number of maximum allowed files to be parsed at once
+from cache import save_cache
+from settings import SETTINGS
 
 
 
@@ -23,7 +23,7 @@ def prepare_checks(files_to_check, libraries, bits):
     dependencies = [] # list of lists of files (from file_to_check) that uses
                       # library (for dependencies[id] and libs[id] => id==id)
 
-    for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check, CMD_MAX_ARGS):
+    for line in scan(['-M', str(bits), '-nBF', '%F %n'], files_to_check, SETTINGS['CMD_MAX_ARGS']):
     #call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
         r = line.strip().split(' ')
         if len(r) < 2: # no dependencies?
@@ -143,7 +143,7 @@ def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=N
         libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs, logger)
         binaries = collect_binaries_from_dir(bin_dirs, masked_dirs, logger)
 
-        if USE_TMP_FILES:
+        if SETTINGS['USE_TMP_FILES']:
             save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
 
 
@@ -170,7 +170,7 @@ def analyse(logger=logging, libraries=None, la_libraries=None, libraries_links=N
 
     for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
         bits = int(av_bits[4:])
-        _libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, CMD_MAX_ARGS)
+        _libraries = scan(['-M', str(bits), '-BF', '%F'], libraries+libraries_links, SETTINGS['CMD_MAX_ARGS'])
         #call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
 
         found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits)

diff --git a/pym/gentoolkit/revdep_rebuild/assign.py b/pym/gentoolkit/revdep_rebuild/assign.py
index 836e792..6dcf6e3 100644
--- a/pym/gentoolkit/revdep_rebuild/assign.py
+++ b/pym/gentoolkit/revdep_rebuild/assign.py
@@ -6,7 +6,7 @@ import logging
 import portage
 from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
-
+from settings import SETTINGS
 
 
 def assign_packages(broken, logger=logging):
@@ -14,9 +14,9 @@ def assign_packages(broken, logger=logging):
         Broken is list of files
     '''
     assigned = set()
-    for group in os.listdir('/var/db/pkg'):
-        for pkg in os.listdir('/var/db/pkg/' + group):
-            f = '/var/db/pkg/' + group + '/' + pkg + '/CONTENTS'
+    for group in os.listdir(SETTINGS['PKG_DIR']):
+        for pkg in os.listdir(SETTINGS['PKG_DIR'] + group):
+            f = SETTINGS['PKG_DIR'] + group + '/' + pkg + '/CONTENTS'
             if os.path.exists(f):
                 try:
                     with open(f, 'r') as cnt:
@@ -71,7 +71,6 @@ def get_slotted_cps(cpvs, logger):
     cps = []
     for cpv in cpvs:
         parts = catpkgsplit(cpv)
-        print cpv
         cp = parts[0] + '/' + parts[1]
         try:
             slot = portdb.aux_get(cpv, ["SLOT"])

diff --git a/pym/gentoolkit/revdep_rebuild/cache.py b/pym/gentoolkit/revdep_rebuild/cache.py
index 5f7b932..421e22d 100644
--- a/pym/gentoolkit/revdep_rebuild/cache.py
+++ b/pym/gentoolkit/revdep_rebuild/cache.py
@@ -3,11 +3,11 @@
 import os
 import time
 import logging
+from portage.output import red
+from settings import SETTINGS
 
 
-DEFAULT_TMP_DIR = '/tmp/revdep-rebuild' #cache default location
-
-def read_cache(temp_path=DEFAULT_TMP_DIR):
+def read_cache(temp_path=SETTINGS['DEFAULT_TMP_DIR']):
     ''' Reads cache information needed by analyse function.
         This function does not checks if files exists nor timestamps,
         check_temp_files should be called first
@@ -29,7 +29,7 @@ def read_cache(temp_path=DEFAULT_TMP_DIR):
     return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
 
 
-def save_cache(logger=logging, to_save={}, temp_path=DEFAULT_TMP_DIR):
+def save_cache(logger=logging, to_save={}, temp_path=SETTINGS['DEFAULT_TMP_DIR']):
     ''' Tries to store caching information.
         @param logger
         @param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
@@ -53,7 +53,7 @@ def save_cache(logger=logging, to_save={}, temp_path=DEFAULT_TMP_DIR):
 
 
 
-def check_temp_files(temp_path=DEFAULT_TMP_DIR, max_delay=3600):
+def check_temp_files(temp_path=SETTINGS['DEFAULT_TMP_DIR'], max_delay=3600):
     ''' Checks if temporary files from previous run are still available
         and if they aren't too old
         @param temp_path is directory, where temporary files should be found

diff --git a/pym/gentoolkit/revdep_rebuild/collect.py b/pym/gentoolkit/revdep_rebuild/collect.py
index ca71d3d..4a0714b 100644
--- a/pym/gentoolkit/revdep_rebuild/collect.py
+++ b/pym/gentoolkit/revdep_rebuild/collect.py
@@ -7,12 +7,10 @@ import stat
 import logging
 import portage
 from portage.output import bold, red, blue, yellow, green, nocolor
+from settings import SETTINGS
 
-DEFAULT_LD_FILE = 'etc/ld.so.conf'
-DEFAULT_ENV_FILE = 'etc/profile.env'
 
-
-def parse_conf(conf_file=os.path.join(portage.root, DEFAULT_LD_FILE), visited=None, logger=logging):
+def parse_conf(conf_file=SETTINGS['DEFAULT_LD_FILE'], visited=None, logger=logging):
     ''' Parses supplied conf_file for libraries pathes.
         conf_file is file or files to parse
         visited is set of files already parsed
@@ -64,15 +62,15 @@ def prepare_search_dirs(logger=logging):
     bin_dirs = set(['/bin', '/usr/bin', ])
     lib_dirs = set(['/lib', '/usr/lib', ])
 
-    try:
-        with open(os.path.join(portage.root, DEFAULT_ENV_FILE), 'r') as f:
-            for line in f.readlines():
-                line = line.strip()
-                m = re.match("^export (ROOT)?PATH='([^']+)'", line)
-                if m is not None:
-                    bin_dirs = bin_dirs.union(set(m.group(2).split(':')))
-    except EnvironmentError:
-        logger.debug(yellow('Could not open file %s' % f))
+    #try:
+    with open(os.path.join(portage.root, SETTINGS['DEFAULT_ENV_FILE']), 'r') as f:
+        for line in f.readlines():
+            line = line.strip()
+            m = re.match("^export (ROOT)?PATH='([^']+)'", line)
+            if m is not None:
+                bin_dirs = bin_dirs.union(set(m.group(2).split(':')))
+    #except EnvironmentError:
+        #logger.debug(yellow('Could not open file %s' % f))
 
     lib_dirs = parse_conf(logger=logger)
     return (bin_dirs, lib_dirs)
@@ -87,7 +85,7 @@ def parse_revdep_config():
     masked_files = set()
 
     #TODO: remove hard-coded path
-    for f in os.listdir('/etc/revdep-rebuild/'):
+    for f in os.listdir(SETTINGS['REVDEP_CONFDIR']):
         for line in open(os.path.join('/etc/revdep-rebuild', f)):
             line = line.strip()
             if not line.startswith('#'): #first check for comment, we do not want to regex all lines

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
old mode 100755
new mode 100644
index c28b1b0..f2fda2e
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -25,42 +25,19 @@ from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
 
 from analyse import analyse
-from stuff import *
-from cache import *
+from stuff import exithandler
+from cache import check_temp_files, read_cache
 from assign import get_slotted_cps
+from settings import SETTINGS
 
 
 APP_NAME = sys.argv[0]
-VERSION = '0.1-r5'
-
+VERSION = '0.1-r6'
 
 __productname__ = "revdep-ng"
 
 
 
-# configuration variables
-DEFAULT_LD_FILE = 'etc/ld.so.conf'
-DEFAULT_ENV_FILE = 'etc/profile.env'
-
-
-# global variables
-PRINT_DEBUG = False      #program in debug mode
-
-PRETEND = False     #pretend only
-EXACT = False      #exact package version
-USE_TMP_FILES = True #if program should use temporary files from previous run
-DEFAULT_TMP_DIR = '/tmp/revdep-rebuild' #cache default location
-VERBOSITY = 1      #verbosity level; 0-quiet, 1-norm., 2-verbose
-
-IS_DEV = True       #True for dev. version, False for stable
-#used when IS_DEV is True, False forces to call emerge with --pretend
-# can be set True from the cli with the --no-pretend option
-NO_PRETEND = False
-
-CMD_MAX_ARGS = 1000 # number of maximum allowed files to be parsed at once
-
-
-
 def print_usage():
     print APP_NAME + ': (' + VERSION +')'
     print
@@ -122,26 +99,26 @@ if __name__ == "__main__":
                 print_usage()
                 sys.exit(0)
             elif key in ('-q', '--quiet'):
-                VERBOSITY = 0
                 logger.setLevel(logging.ERROR)
+                SETTINGS['VERBOSITY'] = 0
             elif key in ('-v', '--verbose'):
-                VERBOSITY = 2
                 logger.setLevel(logging.INFO)
+                SETTINGS['VERBOSITY'] = 2
             elif key in ('-d', '--debug'):
-                PRINT_DEBUG = True
                 logger.setLevel(logging.DEBUG)
+                SETTINGS['VERBOSITY'] = 3
             elif key in ('-p', '--pretend'):
-                PRETEND = True
+                SETTINGS['PRETEND'] = True
             elif key == '--no-pretend':
-                NO_PRETEND = True
+                SETTINGS['NO_PRETEND'] = True
             elif key in ('-e', '--exact'):
-                EXACT = True
+                SETTINGS['EXACT'] = True
             elif key in ('-C', '--nocolor', '--no-color'):
                 nocolor()
             elif key in ('-L', '--library', '--library='):
                 _libs_to_check = _libs_to_check.union(val.split(','))
             elif key in ('-i', '--ignore'):
-                USE_TMP_FILES = False
+                SETTINGS['USE_TMP_FILES'] = False
 
         args = " " + " ".join(args)
     except getopt.GetoptError:
@@ -152,14 +129,14 @@ if __name__ == "__main__":
     if not sys.stdout.isatty():
         nocolor()
 
-    if os.getuid() != 0 and not PRETEND:
+    if os.getuid() != 0 and not SETTINGS['PRETEND']:
         logger.warn(blue(' * ') + yellow('You are not root, adding --pretend to portage options'))
-        PRETEND = True
-    elif not PRETEND and IS_DEV and not NO_PRETEND:
+        SETTINGS['PRETEND'] = True
+    elif not SETTINGS['PRETEND'] and SETTINGS['IS_DEV'] and not SETTINGS['NO_PRETEND']:
         logger.warn(blue(' * ') + yellow('This is a development version, so it may not work correctly'))
         logger.warn(blue(' * ') + yellow('Adding --pretend to portage options anyway'))
         logger.info(blue(' * ') + 'If you\'re sure, you can add --no-pretend to revdep options')
-        PRETEND = True
+        SETTINGS['PRETEND'] = True
 
 
     signal.signal(signal.SIGINT, exithandler)
@@ -167,7 +144,7 @@ if __name__ == "__main__":
     signal.signal(signal.SIGPIPE, signal.SIG_DFL)
 
     analyze_cache = {}
-    if USE_TMP_FILES and check_temp_files():
+    if SETTINGS['USE_TMP_FILES'] and check_temp_files():
         libraries, la_libraries, libraries_links, binaries = read_cache()
         assigned = analyse(libraries=libraries, la_libraries=la_libraries, \
                        libraries_links=libraries_links, binaries=binaries, _libs_to_check=_libs_to_check)
@@ -178,15 +155,15 @@ if __name__ == "__main__":
         logger.warn('\n' + bold('Your system is consistent'))
         sys.exit(0)
 
-    if EXACT:
+    if SETTINGS['EXACT']:
         emerge_command = '=' + ' ='.join(assigned)
     else:
         emerge_command = ' '.join(get_slotted_cps(assigned, logger))
-    if PRETEND:
+    if SETTINGS['PRETEND']:
         args += ' --pretend'
-    if VERBOSITY >= 2:
+    if SETTINGS['VERBOSITY'] >= 2:
         args += ' --verbose'
-    elif VERBOSITY < 1:
+    elif SETTINGS['VERBOSITY'] < 1:
         args += ' --quiet'
 
     if len(emerge_command) == 0:

diff --git a/pym/gentoolkit/revdep_rebuild/revdep_rebuild.kdev4 b/pym/gentoolkit/revdep_rebuild/revdep_rebuild.kdev4
deleted file mode 100644
index 7c395ce..0000000
--- a/pym/gentoolkit/revdep_rebuild/revdep_rebuild.kdev4
+++ /dev/null
@@ -1,3 +0,0 @@
-[Project]
-Manager=KDevGenericManager
-Name=revdep_rebuild

diff --git a/pym/gentoolkit/revdep_rebuild/settings.py b/pym/gentoolkit/revdep_rebuild/settings.py
new file mode 100644
index 0000000..ea6b1ec
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/settings.py
@@ -0,0 +1,26 @@
+#!/usr/bin/python
+
+import os
+import portage
+
+SETTINGS = {
+        'DEFAULT_LD_FILE': os.path.join(portage.root, 'etc/ld.so.conf'),
+        'DEFAULT_ENV_FILE': os.path.join(portage.root, 'etc/profile.env'),
+        'REVDEP_CONFDIR': os.path.join(portage.root, 'etc/revdep-rebuild/'),
+        'PKG_DIR': os.path.join(portage.root, 'var/db/pkg/'),
+        'DEFAULT_TMP_DIR': '/tmp/revdep-rebuild', #cache default location
+
+
+        'USE_TMP_FILES': True, #if program should use temporary files from previous run
+        'CMD_MAX_ARGS': 1000, # number of maximum allowed files to be parsed at once
+
+        'PRETEND': False,     #pretend only
+        'EXACT': False,      #exact package version
+        'USE_TMP_FILES': True, #if program should use temporary files from previous run
+
+        'IS_DEV': True,       #True for dev. version, False for stable
+                #used when IS_DEV is True, False forces to call emerge with --pretend
+                # can be set True from the cli with the --no-pretend option
+        'NO_PRETEND': False,
+        'VERBOSITY': 1,
+    }

diff --git a/pym/gentoolkit/revdep_rebuild/test.py b/pym/gentoolkit/revdep_rebuild/test.py
deleted file mode 100644
index 9f87f32..0000000
--- a/pym/gentoolkit/revdep_rebuild/test.py
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/usr/bin/python
-
-import logging
-
-logging.basicConfig(format='%(msg)s', level=logging.DEBUG)
-#logging.basicConfig()
-logging.info('test')
\ No newline at end of file



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     bd038cff741ea9180de3eca2762da872ba1c1345
Author:     lis.slawek <lis.slawek <AT> 5234894e-44cd-11de-9a4c-a76526a193c6>
AuthorDate: Tue Nov 23 09:13:43 2010 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=bd038cff

Fixed checks for --library option

git-svn-id: http://genscripts.googlecode.com/svn/trunk/gentoolkit@489 5234894e-44cd-11de-9a4c-a76526a193c6

---
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
index f8f67d6..ebc0c3b 100755
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -99,8 +99,7 @@ def print_usage():
   -h, --help           Print this usage
   -i, --ignore         Ignore temporary files from previous runs (also won't create any)
   -L, --library NAME   Emerge existing packages that use the library with NAME
-      --library=NAME   NAME can be a full path to the library or a basic
-                       regular expression (man grep)
+      --library=NAME   NAME can be a full or partial library name
   -l, --no-ld-path     Do not set LD_LIBRARY_PATH
   -o, --no-order       Do not check the build order
                        (Saves time, but may cause breakage.)
@@ -420,7 +419,7 @@ def find_broken(found_libs, system_libraries, to_check):
     else:
         for tc in to_check:
             for f in found_libs:
-                if tc in f and f+'|' not in sl:
+                if tc in f:# and f+'|' not in sl:
                     broken.append(found_libs.index(f))
 
     return broken



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     71136316e79b7037da468d581374c3d013b6fa98
Author:     brian.dolbec <brian.dolbec <AT> 5234894e-44cd-11de-9a4c-a76526a193c6>
AuthorDate: Fri Nov  5 15:19:06 2010 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=71136316

Comment the NO_PRETEND variable better.
Fix a few minor grammar errors.

git-svn-id: http://genscripts.googlecode.com/svn/trunk/gentoolkit@478 5234894e-44cd-11de-9a4c-a76526a193c6

---
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |   12 +++++++-----
 1 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
index 544a86c..fb864da 100755
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -46,7 +46,9 @@ DEFAULT_TMP_DIR = '/tmp/revdep-rebuild' #cache default location
 VERBOSITY = 1      #verbosity level; 0-quiet, 1-norm., 2-verbose
 
 IS_DEV = True       #True for dev. version, False for stable
-NO_PRETEND = False  #used when IS_DEV is True, forces to call emerge from script
+#used when IS_DEV is True, False forces to call emerge with --pretend
+# can be set True from the cli with the --no-pretend option
+NO_PRETEND = False 
 
 
 
@@ -72,7 +74,7 @@ def print_v(verbosity, args):
 
 
 def exithandler(signum, frame):
-    print 'Signal catched!'
+    print 'Signal caught!'
     print 'Bye!'
     signal.signal(signal.SIGINT, signal.SIG_IGN)
     signal.signal(signal.SIGTERM, signal.SIG_IGN)
@@ -475,7 +477,7 @@ def get_best_match(cpv, cp):
     """
 
     slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])
-    print_v(1, yellow('Warn: ebuild ' + cpv + ' not found.'))
+    print_v(1, yellow('Warning: ebuild "' + cpv + '" not found.'))
     print_v(1, 'Looking for %s:%s' %(cp, slot))
     try:
         m = portdb.match('%s:%s' %(cp, slot))
@@ -568,7 +570,7 @@ def analyse(output=print_v, libraries=None, la_libraries=None, libraries_links=N
     """
 
     if libraries and la_libraries and libraries_links and binaries:
-        output(1, blue(' * ') + bold('Found cache, skipping collecting phase'))
+        output(1, blue(' * ') + bold('Found a valid cache, skipping collecting phase'))
     else:
         #TODO: add partial cache (for ex. only libraries) when found for some reason
 
@@ -680,7 +682,7 @@ if __name__ == "__main__":
         print_v(1, blue(' * ') + yellow('You are not root, adding --pretend to portage options'))
         PRETEND = True
     elif not PRETEND and IS_DEV and not NO_PRETEND:
-        print_v(1, blue(' * ') + yellow('This is dev. version, so it could not work correctly'))
+        print_v(1, blue(' * ') + yellow('This is a development version, so it may not work correctly'))
         print_v(1, blue(' * ') + yellow('Adding --pretend to portage options anyway'))
         print_v(1, blue(' * ') + 'If you\'re sure, you can add --no-pretend to revdep options')
         PRETEND = True



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     cac7bd60abddb8420eeeeb5563490f9b8ee9b188
Author:     brian.dolbec <brian.dolbec <AT> 5234894e-44cd-11de-9a4c-a76526a193c6>
AuthorDate: Fri Nov  5 05:26:11 2010 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=cac7bd60

fix a missing leading space so that any args are not attached to the emerge command itself.

git-svn-id: http://genscripts.googlecode.com/svn/trunk/gentoolkit@477 5234894e-44cd-11de-9a4c-a76526a193c6

---
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
index 23298f9..544a86c 100755
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -667,7 +667,7 @@ if __name__ == "__main__":
             elif key in ('-i', '--ignore'):
                 USE_TMP_FILES = False
 
-        args = " ".join(args)
+        args = " " + " ".join(args)
     except getopt.GetoptError:
         print_v(1, red('Unrecognized option\n'))
         print_usage()



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     a928c7509defc63c913ab61ef138cc59d44c38b6
Author:     lis.slawek <lis.slawek <AT> 5234894e-44cd-11de-9a4c-a76526a193c6>
AuthorDate: Thu Nov 18 11:16:57 2010 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=a928c750

Fixed scanning revdep config; minor fix in analyse function

git-svn-id: http://genscripts.googlecode.com/svn/trunk/gentoolkit@485 5234894e-44cd-11de-9a4c-a76526a193c6

---
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
index 0bc006e..f8f67d6 100755
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -210,9 +210,9 @@ def parse_revdep_config():
                     continue
                 m = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
                 if m is not None:
-                    s = m.group(1).split(' ')
+                    s = m.group(1).split()
                     for ss in s:
-                        search_dirs = masked_dirs.union(glob.glob(ss))
+                        search_dirs = search_dirs.union(glob.glob(ss))
                     continue
 
     return (masked_dirs, masked_files, search_dirs)
@@ -615,7 +615,7 @@ def analyse(output=print_v, libraries=None, la_libraries=None, libraries_links=N
     elif _bits.startswith('64'):
         bits = 64
 
-    for av_bits in glob.glob('/lib[0-9]*'):
+    for av_bits in glob.glob('/lib[0-9]*') or ('/lib32',):
         bits = int(av_bits[4:])
         _libraries = call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
 
@@ -740,6 +740,11 @@ if __name__ == "__main__":
         args += ' --verbose'
     elif VERBOSITY < 1:
         args += ' --quiet'
+
+    if len(emerge_command) == 0:
+        print_v(1, bold('\nThere is nothing to emerge. Exiting.'))
+        sys.exit(0)
+
     emerge_command = args + ' --oneshot ' + emerge_command
 
 



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     016a60ce9a134f1dba61bcbae6e0b5a286cf6c90
Author:     lis.slawek <lis.slawek <AT> 5234894e-44cd-11de-9a4c-a76526a193c6>
AuthorDate: Thu Nov 18 07:26:14 2010 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=016a60ce

Fixed problem with 32/64 bit libraries and binaries

git-svn-id: http://genscripts.googlecode.com/svn/trunk/gentoolkit@484 5234894e-44cd-11de-9a4c-a76526a193c6

---
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |   44 ++++++++++++++++++-----
 1 files changed, 35 insertions(+), 9 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
index fb864da..0bc006e 100755
--- a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -20,11 +20,12 @@ import stat
 import time
 import glob
 import portage
+import platform
 from portage import portdb
 from portage.output import bold, red, blue, yellow, green, nocolor
 
 APP_NAME = sys.argv[0]
-VERSION = '0.1-r2'
+VERSION = '0.1-r3'
 
 
 __productname__ = "revdep-ng"
@@ -342,14 +343,15 @@ def _match_str_in_list(lst, stri):
     return False
 
 
-def prepare_checks(files_to_check, libraries):
-    ''' Calls scanelf for all files_to_check, then returns found libraries and dependencies '''
+def prepare_checks(files_to_check, libraries, bits):
+    ''' Calls scanelf for all files_to_check, then returns found libraries and dependencies
+    '''
 
     libs = [] # libs found by scanelf
     dependencies = [] # list of lists of files (from file_to_check) that uses
                       # library (for dependencies[id] and libs[id] => id==id)
 
-    for line in call_program(['scanelf', '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
+    for line in call_program(['scanelf', '-M', str(bits), '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
         r = line.strip().split(' ')
         if len(r) < 2: # no dependencies?
             continue
@@ -368,6 +370,9 @@ def prepare_checks(files_to_check, libraries):
 def extract_dependencies_from_la(la, libraries, to_check):
     broken = []
     for f in la:
+        if not os.path.exists(f):
+            continue
+
         for line in open(f, 'r').readlines():
             line = line.strip()
             if line.startswith('dependency_libs='):
@@ -417,7 +422,6 @@ def find_broken(found_libs, system_libraries, to_check):
             for f in found_libs:
                 if tc in f and f+'|' not in sl:
                     broken.append(found_libs.index(f))
-        #print broken
 
     return broken
 
@@ -596,10 +600,32 @@ def analyse(output=print_v, libraries=None, la_libraries=None, libraries_links=N
     output(2,'Search for ' + str(len(binaries)+len(libraries)) + ' within ' + str(len(libraries)+len(libraries_links)))
     libs_and_bins = libraries+binaries
 
-    found_libs, dependencies = prepare_checks(libs_and_bins, libraries+libraries_links)
+    #l = []
+    #for line in call_program(['scanelf', '-M', '64', '-BF', '%F',] + libraries).strip().split('\n'):
+        #l.append(line)
+    #libraries = l
+
+    found_libs = []
+    dependencies = []
+
+
+    _bits, linkg = platform.architecture()
+    if _bits.startswith('32'):
+        bits = 32
+    elif _bits.startswith('64'):
+        bits = 64
+
+    for av_bits in glob.glob('/lib[0-9]*'):
+        bits = int(av_bits[4:])
+        _libraries = call_program(['scanelf', '-M', str(bits), '-BF', '%F',] + libraries+libraries_links).strip().split('\n')
+
+        found_libs, dependencies = prepare_checks(libs_and_bins, _libraries, bits)
+
+        broken = find_broken(found_libs, _libraries, _libs_to_check)
+        broken_la = extract_dependencies_from_la(la_libraries, _libraries, _libs_to_check)
 
-    broken = find_broken(found_libs, libraries+libraries_links, _libs_to_check)
-    broken_la = extract_dependencies_from_la(la_libraries, libraries+libraries_links, _libs_to_check)
+        bits /= 2
+        bits = int(bits)
 
     broken_pathes = main_checks(found_libs, broken, dependencies)
     broken_pathes += broken_la
@@ -646,7 +672,7 @@ if __name__ == "__main__":
         opts, args = getopt.getopt(sys.argv[1:], 'dehiklopqvCL:P', ['nocolor', 'debug', 'exact', 'help', 'ignore',\
             'keep-temp', 'library=', 'no-ld-path', 'no-order', 'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose'])
 
-        for key,val in opts:
+        for key, val in opts:
             if key in ('-h', '--help'):
                 print_usage()
                 sys.exit(0)



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     9ccb3af94c0b2ffc12e8c9b149f9894af5fa81a4
Author:     lis.slawek <lis.slawek <AT> 5234894e-44cd-11de-9a4c-a76526a193c6>
AuthorDate: Mon Oct 25 09:24:47 2010 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=9ccb3af9

Initial revision of revdep-rebuild python version

git-svn-id: http://genscripts.googlecode.com/svn/trunk/gentoolkit@471 5234894e-44cd-11de-9a4c-a76526a193c6

---
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |  723 +++++++++++++++++++++++
 1 files changed, 723 insertions(+), 0 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
new file mode 100755
index 0000000..23298f9
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -0,0 +1,723 @@
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
+
+
+# Author: Sławomir Lis <lis.slawek@gmail.com>
+# revdep-rebuild original author: Stanislav Brabec
+# revdep-rebuild original rewrite Author: Michael A. Smith
+# Current Maintainer: Paul Varner <fuzzyray@gentoo.org>
+
+# Creation date: 2010/10/17
+# License: BSD
+
+import subprocess
+import os
+import sys
+import re
+import getopt
+import signal
+import stat
+import time
+import glob
+import portage
+from portage import portdb
+from portage.output import bold, red, blue, yellow, green, nocolor
+
+APP_NAME = sys.argv[0]
+VERSION = '0.1-r2'
+
+
+__productname__ = "revdep-ng"
+
+
+
+# configuration variables
+DEFAULT_LD_FILE = 'etc/ld.so.conf'
+DEFAULT_ENV_FILE = 'etc/profile.env'
+
+
+# global variables
+PRINT_DEBUG = False      #program in debug mode
+
+PRETEND = False     #pretend only
+EXACT = False      #exact package version
+USE_TMP_FILES = True #if program should use temporary files from previous run
+DEFAULT_TMP_DIR = '/tmp/revdep-rebuild' #cache default location
+VERBOSITY = 1      #verbosity level; 0-quiet, 1-norm., 2-verbose
+
+IS_DEV = True       #True for dev. version, False for stable
+NO_PRETEND = False  #used when IS_DEV is True, forces to call emerge from script
+
+
+
+# util. functions
+def call_program(args):
+    ''' Calls program with specified parameters and returns stdout '''
+    subp = subprocess.Popen(args, stdout=subprocess.PIPE, \
+                                stderr=subprocess.PIPE)
+    stdout, stderr = subp.communicate()
+    return stdout
+
+
+def print_v(verbosity, args):
+    """Prints to stdout according to the verbosity level 
+    and the global VERBOSITY level
+    
+    @param verbosity: integer
+    @param args: string to print
+    """
+    if verbosity > VERBOSITY:
+        return
+    print args
+
+
+def exithandler(signum, frame):
+    print 'Signal catched!'
+    print 'Bye!'
+    signal.signal(signal.SIGINT, signal.SIG_IGN)
+    signal.signal(signal.SIGTERM, signal.SIG_IGN)
+    sys.exit(1)
+
+
+def print_usage():
+    print APP_NAME + ': (' + VERSION +')'
+    print
+    print 'This is free software; see the source for copying conditions.'
+    print
+    print 'Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]'
+    print
+    print 'Broken reverse dependency rebuilder, python implementation.'
+    print
+    print 'Available options:'
+    print '''
+  -C, --nocolor        Turn off colored output
+  -d, --debug          Print debug informations
+  -e, --exact          Emerge based on exact package version
+  -h, --help           Print this usage
+  -i, --ignore         Ignore temporary files from previous runs (also won't create any)
+  -L, --library NAME   Emerge existing packages that use the library with NAME
+      --library=NAME   NAME can be a full path to the library or a basic
+                       regular expression (man grep)
+  -l, --no-ld-path     Do not set LD_LIBRARY_PATH
+  -o, --no-order       Do not check the build order
+                       (Saves time, but may cause breakage.)
+  -p, --pretend        Do a trial run without actually emerging anything
+                       (also passed to emerge command)
+  -q, --quiet          Be less verbose (also passed to emerge command)
+  -v, --verbose        Be more verbose (also passed to emerge command)
+'''
+    print 'Calls emerge, options after -- are ignored by ' + APP_NAME
+    print 'and passed directly to emerge.'
+
+
+
+# functions
+def parse_conf(conf_file=None, visited=None):
+    ''' Parses supplied conf_file for libraries pathes.
+        conf_file is file or files to parse
+        visited is set of files already parsed
+    '''
+
+    if conf_file is None:
+        conf_file = os.path.join(portage.root, DEFAULT_LD_FILE)
+
+    lib_dirs = set()
+    to_parse = set()
+
+    if isinstance(conf_file, basestring):
+        conf_file = [conf_file]
+
+    for conf in conf_file:
+        try:
+            with open(conf) as f:
+                for line in f.readlines():
+                    line = line.strip()
+                    if line.startswith('#'):
+                        continue
+                    elif line.startswith('include'):
+                        include_line = line.split()[1:]
+                        for included in include_line:
+                            if not included.startswith('/'):
+                                path = os.path.join(os.path.dirname(conf), \
+                                                    included)
+                            else:
+                                path = included
+
+                            to_parse = to_parse.union(glob.glob(path))
+                    else:
+                        lib_dirs.add(line)
+        except EnvironmentError:
+            print_v(2, 'Error when parsing file %s' %conf)
+
+    if visited is None:
+        visited = set()
+
+    visited = visited.union(conf_file)
+    to_parse = to_parse.difference(visited)
+    if to_parse:
+        lib_dirs = lib_dirs.union(parse_conf(to_parse, visited))
+
+    return lib_dirs
+
+
+def prepare_search_dirs():
+    ''' Lookup for search dirs. Returns tuple with two lists,
+        (list_of_bin_dirs, list_of_lib_dirs)
+    '''
+
+    bin_dirs = set(['/bin', '/usr/bin', ])
+    lib_dirs = set(['/lib', '/usr/lib', ])
+
+    try:
+        with open(os.path.join(portage.root, DEFAULT_ENV_FILE), 'r') as f:
+            for line in f.readlines():
+                line = line.strip()
+                m = re.match("^export (ROOT)?PATH='([^']+)'", line)
+                if m is not None:
+                    bin_dirs = bin_dirs.union(set(m.group(2).split(':')))
+    except EnvironmentError:
+        print_v(2, 'Could not open file %s' % f)
+
+    lib_dirs = parse_conf()
+    return (bin_dirs, lib_dirs)
+
+
+def parse_revdep_config():
+    ''' Parses all files under /etc/revdep-rebuild/ and returns
+        tuple of: (masked_dirs, masked_files, search_dirs)'''
+
+    search_dirs = set()
+    masked_dirs = set()
+    masked_files = set()
+
+    for f in os.listdir('/etc/revdep-rebuild/'):
+        for line in open(os.path.join('/etc/revdep-rebuild', f)):
+            line = line.strip()
+            if not line.startswith('#'): #first check for comment, we do not want to regex all lines
+                m = re.match('LD_LIBRARY_MASK=\\"([^"]+)\\"', line)
+                if m is not None:
+                    s = m.group(1).split(' ')
+                    masked_files = masked_files.union(s)
+                    continue
+                m = re.match('SEARCH_DIRS_MASK=\\"([^"]+)\\"', line)
+                if m is not None:
+                    s = m.group(1).split(' ')
+                    for ss in s:
+                        masked_dirs = masked_dirs.union(glob.glob(ss))
+                    continue
+                m = re.match('SEARCH_DIRS=\\"([^"]+)\\"', line)
+                if m is not None:
+                    s = m.group(1).split(' ')
+                    for ss in s:
+                        search_dirs = masked_dirs.union(glob.glob(ss))
+                    continue
+
+    return (masked_dirs, masked_files, search_dirs)
+
+
+def collect_libraries_from_dir(dirs, mask):
+    ''' Collects all libraries from specified list of directories.
+        mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
+        Returns tuple composed of: list of libraries, list of symlinks, and toupe with pair
+        (symlink_id, library_id) for resolving dependencies
+    '''
+
+
+    found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
+    found_files = []
+    found_symlinks = []
+    found_la_files = [] # la libraries
+    symlink_pairs = []  # list of pairs symlink_id->library_id
+
+    for d in dirs:
+        if d in mask:
+            continue
+
+        try:
+            for l in os.listdir(d):
+                l = os.path.join(d, l)
+                if l in mask:
+                    continue
+
+                if os.path.isdir(l):
+                    if os.path.islink(l):
+                        #we do not want scan symlink-directories
+                        pass
+                    else:
+                        found_directories.append(l)
+                elif os.path.isfile(l):
+                    if l.endswith('.so') or '.so.' in l:
+                        if l in found_files or l in found_symlinks:
+                            continue
+
+                        if os.path.islink(l):
+                            found_symlinks.append(l)
+                            abs_path = os.path.realpath(l)
+                            if abs_path in found_files:
+                                i = found_files.index(abs_path)
+                            else:
+                                found_files.append(abs_path)
+                                i = len(found_files)-1
+                            symlink_pairs.append((len(found_symlinks)-1, i,))
+                        else:
+                            found_files.append(l)
+                        continue
+                    elif l.endswith('.la'):
+                        if l in found_la_files:
+                            continue
+
+                        found_la_files.append(l)
+                    else:
+                        # sometimes there are binaries in libs' subdir, for example in nagios
+                        if not os.path.islink(l):
+                            if l in found_files or l in found_symlinks:
+                                continue
+                            prv = os.stat(l)[stat.ST_MODE]
+                            if prv & stat.S_IXUSR == stat.S_IXUSR or \
+                                    prv & stat.S_IXGRP == stat.S_IXGRP or \
+                                    prv & stat.S_IXOTH == stat.S_IXOTH:
+                                found_files.append(l)
+        except:
+            pass
+
+
+    if found_directories:
+        f,a,l,p = collect_libraries_from_dir(found_directories, mask)
+        found_files+=f
+        found_la_files+=a
+        found_symlinks+=l
+        symlink_pairs+=p
+
+    return (found_files, found_la_files, found_symlinks, symlink_pairs)
+
+
+def collect_binaries_from_dir(dirs, mask):
+    ''' Collects all binaries from specified list of directories.
+        mask is list of pathes, that are ommited in scanning, can be eighter single file or entire directory
+        Returns list of binaries
+    '''
+
+    found_directories = []  # contains list of directories found; allow us to reduce number of fnc calls
+    found_files = []
+
+    for d in dirs:
+        if d in mask:
+            continue
+
+        try:
+            for l in os.listdir(d):
+                l = os.path.join(d, l)
+                if d in mask:
+                    continue
+
+                if os.path.isdir(l):
+                    if os.path.islink(l):
+                        #we do not want scan symlink-directories
+                        pass
+                    else:
+                        found_directories.append(l)
+                elif os.path.isfile(l):
+                    #we're looking for binaries, and with binaries we do not need links, thus we can optimize a bit
+                    if not os.path.islink(l):
+                        prv = os.stat(l)[stat.ST_MODE]
+                        if prv & stat.S_IXUSR == stat.S_IXUSR or \
+                                prv & stat.S_IXGRP == stat.S_IXGRP or \
+                                prv & stat.S_IXOTH == stat.S_IXOTH:
+                            found_files.append(l)
+        except:
+            pass
+
+    if found_directories:
+        found_files += collect_binaries_from_dir(found_directories, mask)
+
+    return found_files
+
+
+def _match_str_in_list(lst, stri):
+    for l in lst:
+        if stri.endswith(l):
+            return l
+    return False
+
+
+def prepare_checks(files_to_check, libraries):
+    ''' Calls scanelf for all files_to_check, then returns found libraries and dependencies '''
+
+    libs = [] # libs found by scanelf
+    dependencies = [] # list of lists of files (from file_to_check) that uses
+                      # library (for dependencies[id] and libs[id] => id==id)
+
+    for line in call_program(['scanelf', '-nBF', '%F %n',]+files_to_check).strip().split('\n'):
+        r = line.strip().split(' ')
+        if len(r) < 2: # no dependencies?
+            continue
+
+        deps = r[1].split(',')
+        for d in deps:
+            if d in libs:
+                i = libs.index(d)
+                dependencies[i].append(r[0])
+            else:
+                libs.append(d)
+                dependencies.append([r[0],])
+    return (libs, dependencies)
+
+
+def extract_dependencies_from_la(la, libraries, to_check):
+    broken = []
+    for f in la:
+        for line in open(f, 'r').readlines():
+            line = line.strip()
+            if line.startswith('dependency_libs='):
+                m = re.match("dependency_libs='([^']+)'", line)
+                if m is not None:
+                    for el in m.group(1).split(' '):
+                        el = el.strip()
+                        if len(el) < 1 or el.startswith('-'):
+                            continue
+
+                        if el in la or el in libraries:
+                            pass
+                        else:
+                            if to_check:
+                                _break = False
+                                for tc in to_check:
+                                    if tc in el:
+                                        _break = True
+                                        break
+                                if not _break:
+                                    continue
+
+                            print_v(1, yellow(' * ') + f + ' is broken (requires: ' + bold(el))
+                            broken.append(f)
+    return broken
+
+
+
+def find_broken(found_libs, system_libraries, to_check):
+    ''' Search for broken libraries.
+        Check if system_libraries contains found_libs, where
+        system_libraries is list of obsolute pathes and found_libs
+        is list of library names.
+    '''
+
+    # join libraries and looking at it as string is way too faster than for-jumping
+
+    broken = []
+    sl = '|'.join(system_libraries)
+
+    if not to_check:
+        for f in found_libs:
+            if f+'|' not in sl:
+                broken.append(found_libs.index(f))
+    else:
+        for tc in to_check:
+            for f in found_libs:
+                if tc in f and f+'|' not in sl:
+                    broken.append(found_libs.index(f))
+        #print broken
+
+    return broken
+
+
+def main_checks(found_libs, broken, dependencies):
+    ''' Checks for broken dependencies.
+        found_libs have to be the same as returned by prepare_checks
+        broken is list of libraries found by scanelf
+        dependencies is the value returned by prepare_checks
+    '''
+
+    broken_pathes = []
+
+    for b in broken:
+        f = found_libs[b]
+        print_v(1, 'Broken files that requires: ' + bold(f))
+        for d in dependencies[b]:
+            print_v(1, yellow(' * ') + d)
+            broken_pathes.append(d)
+    return broken_pathes
+
+
+def assign_packages(broken, output):
+    ''' Finds and returns packages that owns files placed in broken.
+        Broken is list of files
+    '''
+    assigned = set()
+    for group in os.listdir('/var/db/pkg'):
+        for pkg in os.listdir('/var/db/pkg/' + group):
+            f = '/var/db/pkg/' + group + '/' + pkg + '/CONTENTS'
+            if os.path.exists(f):
+                try:
+                    with open(f, 'r') as cnt:
+                        for line in cnt.readlines():
+                            m = re.match('^obj (/[^ ]+)', line)
+                            if m is not None:
+                                m = m.group(1)
+                                if m in broken:
+                                    found = group+'/'+pkg
+                                    if found not in assigned:
+                                        assigned.add(found)
+                                    print_v(1, '\t' + m + ' -> ' + bold(found))
+                except:
+                    output(1, red(' !! Failed to read ' + f))
+
+    return assigned
+
+
+def get_best_match(cpv, cp):
+    """Tries to find another version of the pkg with the same slot
+    as the deprecated installed version.  Failing that attempt to get any version
+    of the same app
+    
+    @param cpv: string
+    @param cp: string
+    @rtype tuple: ([cpv,...], SLOT)
+    """
+
+    slot = portage.db[portage.root]["vartree"].dbapi.aux_get(cpv, ["SLOT"])
+    print_v(1, yellow('Warn: ebuild ' + cpv + ' not found.'))
+    print_v(1, 'Looking for %s:%s' %(cp, slot))
+    try:
+        m = portdb.match('%s:%s' %(cp, slot))
+    except portage.exception.InvalidAtom:
+        m = None
+
+    if not m:
+        print_v(1, red('Could not find ebuild for %s:%s' %(cp, slot)))
+        slot = ['']
+        m = portdb.match(cp)
+        if not m:
+            print_v(1, red('Could not find ebuild for ' + cp))
+    return m, slot
+
+
+def get_slotted_cps(cpvs):
+    """Uses portage to reduce the cpv list into a cp:slot list and returns it
+    """
+    from portage.versions import catpkgsplit
+    from portage import portdb
+
+    cps = []
+    for cpv in cpvs:
+        parts = catpkgsplit(cpv)
+        cp = parts[0] + '/' + parts[1]
+        try:
+            slot = portdb.aux_get(cpv, ["SLOT"])
+        except KeyError:
+            m, slot = get_best_match(cpv, cp)
+            if not m:
+                print_v(1, red("Installed package: %s is no longer available" %cp))
+                continue
+
+        if slot[0]:
+            cps.append(cp + ":" + slot[0])
+        else:
+            cps.append(cp)
+
+    return cps
+
+
+def read_cache(temp_path=DEFAULT_TMP_DIR):
+    ''' Reads cache information needed by analyse function.
+        This function does not checks if files exists nor timestamps,
+        check_temp_files should be called first
+        @param temp_path: directory where all temp files should reside
+        @return tuple with values of: libraries, la_libraries, libraries_links, symlink_pairs, binaries
+    '''
+
+    ret = {'libraries':[], 'la_libraries':[], 'libraries_links':[], 'binaries':[]}
+    try:
+        for key,val in ret.iteritems():
+            f = open(os.path.join(temp_path, key))
+            for line in f.readlines():
+                val.append(line.strip())
+            #libraries.remove('\n')
+            f.close()
+    except EnvironmentError:
+        pass
+
+    return (ret['libraries'], ret['la_libraries'], ret['libraries_links'], ret['binaries'])
+
+
+def save_cache(to_save, temp_path=DEFAULT_TMP_DIR):
+    ''' Tries to store caching information.
+        @param to_save have to be dict with keys: libraries, la_libraries, libraries_links and binaries
+    '''
+
+    if not os.path.exists(temp_path):
+        os.makedirs(temp_path)
+
+    f = open(os.path.join(temp_path, 'timestamp'), 'w')
+    f.write(str(int(time.time())))
+    f.close()
+
+    for key,val in to_save.iteritems():
+        f = open(os.path.join(temp_path, key), 'w')
+        for line in val:
+            f.write(line + '\n')
+        f.close()
+
+
+def analyse(output=print_v, libraries=None, la_libraries=None, libraries_links=None, binaries=None):
+    """Main program body.  It will collect all info and determine the
+    pkgs needing rebuilding.
+
+    @param output: optional print/data gathering routine. Defaults to print_v
+            which prints to sys.stdout. Refer to print_v parameters for more detail.
+    @rtype list: list of pkgs that need rebuilding
+    """
+
+    if libraries and la_libraries and libraries_links and binaries:
+        output(1, blue(' * ') + bold('Found cache, skipping collecting phase'))
+    else:
+        #TODO: add partial cache (for ex. only libraries) when found for some reason
+
+        output(1, green(' * ') + bold('Collecting system binaries and libraries'))
+        bin_dirs, lib_dirs = prepare_search_dirs()
+
+        masked_dirs, masked_files, ld = parse_revdep_config()
+        lib_dirs = lib_dirs.union(ld)
+        bin_dirs = bin_dirs.union(ld)
+        masked_dirs = masked_dirs.union(set(['/lib/modules', '/lib32/modules', '/lib64/modules',]))
+
+        output(1, green(' * ') + bold('Collecting dynamic linking informations'))
+        libraries, la_libraries, libraries_links, symlink_pairs = collect_libraries_from_dir(lib_dirs, masked_dirs)
+        binaries = collect_binaries_from_dir(bin_dirs, masked_dirs)
+
+        if USE_TMP_FILES:
+            save_cache(to_save={'libraries':libraries, 'la_libraries':la_libraries, 'libraries_links':libraries_links, 'binaries':binaries})
+
+
+    output(2, 'Found '+ str(len(libraries)) + ' libraries (+' + str(len(libraries_links)) + ' symlinks) and ' + str(len(binaries)) + ' binaries')
+
+    output(1, green(' * ') + bold('Checking dynamic linking consistency'))
+    output(2,'Search for ' + str(len(binaries)+len(libraries)) + ' within ' + str(len(libraries)+len(libraries_links)))
+    libs_and_bins = libraries+binaries
+
+    found_libs, dependencies = prepare_checks(libs_and_bins, libraries+libraries_links)
+
+    broken = find_broken(found_libs, libraries+libraries_links, _libs_to_check)
+    broken_la = extract_dependencies_from_la(la_libraries, libraries+libraries_links, _libs_to_check)
+
+    broken_pathes = main_checks(found_libs, broken, dependencies)
+    broken_pathes += broken_la
+
+    output(1, green(' * ') + bold('Assign files to packages'))
+
+    return assign_packages(broken_pathes, output)
+
+
+def check_temp_files(temp_path=DEFAULT_TMP_DIR, max_delay=3600):
+    ''' Checks if temporary files from previous run are still available
+        and if they aren't too old
+        @param temp_path is directory, where temporary files should be found
+        @param max_delay is maximum time difference (in seconds) when those files
+                are still considered fresh and useful
+        returns True, when files can be used, or False, when they don't
+        exists or they are too old
+    '''
+
+    if not os.path.exists(temp_path) or not os.path.isdir(temp_path):
+        return False
+
+    timestamp_path = os.path.join(temp_path, 'timestamp')
+    if not os.path.exists(timestamp_path) or not os.path.isfile(timestamp_path):
+        return False
+
+    try:
+        f = open(timestamp_path)
+        timestamp = int(f.readline())
+        f.close()
+    except:
+        timestamp = 0
+        return False
+
+    diff = int(time.time()) - timestamp
+    return max_delay > diff
+
+
+# Runs from here
+if __name__ == "__main__":
+    _libs_to_check = set()
+
+    try:
+        opts, args = getopt.getopt(sys.argv[1:], 'dehiklopqvCL:P', ['nocolor', 'debug', 'exact', 'help', 'ignore',\
+            'keep-temp', 'library=', 'no-ld-path', 'no-order', 'pretend', 'no-pretend', 'no-progress', 'quiet', 'verbose'])
+
+        for key,val in opts:
+            if key in ('-h', '--help'):
+                print_usage()
+                sys.exit(0)
+            elif key in ('-q', '--quiet'):
+                VERBOSITY = 0
+            elif key in ('-v', '--verbose'):
+                VERBOSITY = 2
+            elif key in ('-d', '--debug'):
+                PRINT_DEBUG = True
+            elif key in ('-p', '--pretend'):
+                PRETEND = True
+            elif key == '--no-pretend':
+                NO_PRETEND = True
+            elif key in ('-e', '--exact'):
+                EXACT = True
+            elif key in ('-C', '--nocolor', '--no-color'):
+                nocolor()
+            elif key in ('-L', '--library', '--library='):
+                _libs_to_check = _libs_to_check.union(val.split(','))
+            elif key in ('-i', '--ignore'):
+                USE_TMP_FILES = False
+
+        args = " ".join(args)
+    except getopt.GetoptError:
+        print_v(1, red('Unrecognized option\n'))
+        print_usage()
+        sys.exit(2)
+
+    if not sys.stdout.isatty():
+        nocolor()
+
+    if os.getuid() != 0 and not PRETEND:
+        print_v(1, blue(' * ') + yellow('You are not root, adding --pretend to portage options'))
+        PRETEND = True
+    elif not PRETEND and IS_DEV and not NO_PRETEND:
+        print_v(1, blue(' * ') + yellow('This is dev. version, so it could not work correctly'))
+        print_v(1, blue(' * ') + yellow('Adding --pretend to portage options anyway'))
+        print_v(1, blue(' * ') + 'If you\'re sure, you can add --no-pretend to revdep options')
+        PRETEND = True
+
+
+    signal.signal(signal.SIGINT, exithandler)
+    signal.signal(signal.SIGTERM, exithandler)
+    signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+
+    analyze_cache = {}
+    if USE_TMP_FILES and check_temp_files():
+        libraries, la_libraries, libraries_links, binaries = read_cache()
+        assigned = analyse(libraries=libraries, la_libraries=la_libraries, \
+                       libraries_links=libraries_links, binaries=binaries)
+    else:
+        assigned = analyse()
+
+    if not assigned:
+        print_v(1, '\n' + bold('Your system is consistent'))
+        sys.exit(0)
+
+    if EXACT:
+        emerge_command = '=' + ' ='.join(assigned)
+    else:
+        emerge_command = ' '.join(get_slotted_cps(assigned))
+    if PRETEND:
+        args += ' --pretend'
+    if VERBOSITY >= 2:
+        args += ' --verbose'
+    elif VERBOSITY < 1:
+        args += ' --quiet'
+    emerge_command = args + ' --oneshot ' + emerge_command
+
+
+    #if PRETEND:
+    print_v(1, yellow('\nemerge') + bold(emerge_command))
+    #else:
+        #call_program(emerge_command.split())
+    os.system('emerge ' + emerge_command)
+



^ permalink raw reply related	[flat|nested] 115+ messages in thread
* [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-07-12 21:45 Paul Varner
  0 siblings, 0 replies; 115+ messages in thread
From: Paul Varner @ 2011-07-12 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     58860e21121ada2ec4538790b1e55f2719c910bc
Author:     brian.dolbec <brian.dolbec <AT> 5234894e-44cd-11de-9a4c-a76526a193c6>
AuthorDate: Sun Oct 24 19:44:19 2010 +0000
Commit:     Paul Varner <fuzzyray <AT> gentoo <DOT> org>
CommitDate: Tue Jul 12 21:29:00 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=58860e21

create a pkg for the new python revdep-rebuild.

git-svn-id: http://genscripts.googlecode.com/svn/trunk/gentoolkit@470 5234894e-44cd-11de-9a4c-a76526a193c6

---
 pym/gentoolkit/revdep_rebuild/__init__.py |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/__init__.py b/pym/gentoolkit/revdep_rebuild/__init__.py
new file mode 100644
index 0000000..edf9385
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/__init__.py
@@ -0,0 +1,4 @@
+#!/usr/bin/python
+#
+# Copyright 2003-2010 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2



^ permalink raw reply related	[flat|nested] 115+ messages in thread

end of thread, other threads:[~2015-05-27 17:27 UTC | newest]

Thread overview: 115+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-11 21:43 [gentoo-commits] proj/gentoolkit:gentoolkit commit in: pym/gentoolkit/revdep_rebuild/ Paul Varner
  -- strict thread matches above, loose matches on Subject: below --
2015-05-27 17:27 Mike Gilbert
2014-11-12 21:29 Paul Varner
2014-11-12  7:16 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-11-07 20:41 Slawek Lis
2014-10-30 18:56 Paul Varner
2014-08-28  7:37 Slawek Lis
2014-03-27  6:59 Slawek Lis
2014-03-26  8:21 Slawek Lis
2014-03-24  7:17 Slawek Lis
2014-03-24  7:17 Slawek Lis
2014-03-17  6:50 Slawek Lis
2014-03-17  6:50 Slawek Lis
2014-03-11 21:22 Paul Varner
2014-02-19  5:01 Brian Dolbec
2014-02-19  4:33 Brian Dolbec
2014-02-19  4:33 Brian Dolbec
2014-02-19  3:14 Brian Dolbec
2014-02-19  3:14 Brian Dolbec
2014-02-19  3:14 Brian Dolbec
2014-02-19  3:14 Brian Dolbec
2014-02-19  3:14 Brian Dolbec
2014-02-19  3:14 Brian Dolbec
2014-02-19  3:14 Brian Dolbec
2014-02-19  3:14 Brian Dolbec
2014-02-18 18:51 Brian Dolbec
2014-02-18 18:51 Brian Dolbec
2014-02-18 17:59 Brian Dolbec
2014-02-18 17:23 Brian Dolbec
2014-02-18  7:30 Brian Dolbec
2014-02-18  6:15 Brian Dolbec
2014-02-17 10:31 Slawek Lis
2014-02-17  8:50 Slawek Lis
2014-02-16 20:55 Brian Dolbec
2014-02-13 22:08 Paul Varner
2014-02-12 21:12 Paul Varner
2014-02-12 16:20 Brian Dolbec
2014-02-12 16:20 Brian Dolbec
2014-02-12 10:42 Brian Dolbec
2014-02-12 10:22 Brian Dolbec
2014-02-12 10:22 Brian Dolbec
2014-02-12 10:22 Brian Dolbec
2014-02-12 10:22 Brian Dolbec
2014-02-11 19:39 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11 18:49 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2014-02-11  8:40 Brian Dolbec
2012-11-09 14:16 Paul Varner
2012-03-19  6:50 Brian Dolbec
2012-03-04  7:41 Brian Dolbec
2012-03-02 17:47 Brian Dolbec
2011-10-10 17:36 Brian Dolbec
2011-10-10 16:09 Brian Dolbec
2011-07-14 18:29 Paul Varner
2011-07-14 18:29 Paul Varner
2011-07-14  2:32 Paul Varner
2011-07-14  1:44 Brian Dolbec
2011-07-14  1:44 Brian Dolbec
2011-07-13 20:06 Paul Varner
2011-07-13 16:01 Paul Varner
2011-07-13 15:35 Brian Dolbec
2011-07-13  5:53 Brian Dolbec
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner
2011-07-12 21:45 Paul Varner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox