public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-02-15  5:34 Sławek Lis
  0 siblings, 0 replies; 15+ messages in thread
From: Sławek Lis @ 2011-02-15  5:34 UTC (permalink / raw
  To: gentoo-commits

commit:     d8b5a025e19c154fef9977b6e33cd4d03b08ff85
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Tue Feb 15 05:24:25 2011 +0000
Commit:     Sławek Lis <lis.slawek <AT> gmail <DOT> com>
CommitDate: Tue Feb 15 05:24:25 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=d8b5a025

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-25 15:13 Brian Dolbec
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2011-04-25 15:13 UTC (permalink / raw
  To: gentoo-commits

commit:     ad4df499d1a87b94dc5f74f7f76be07ab26f013f
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Apr 24 22:18:27 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Apr 24 22:18:27 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=ad4df499

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-25 15:13 Brian Dolbec
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2011-04-25 15:13 UTC (permalink / raw
  To: gentoo-commits

commit:     3eb9f6755720847305d628770ac82f7a89a8661b
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Sun Apr 24 22:24:01 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun Apr 24 22:24:01 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=3eb9f675

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-25 15:13 Brian Dolbec
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2011-04-25 15:13 UTC (permalink / raw
  To: gentoo-commits

commit:     8a83c1932eef3a025700f7d230a37b4fe0883794
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 06:18:44 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Apr 25 06:18:44 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=8a83c193

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-25 15:13 Brian Dolbec
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2011-04-25 15:13 UTC (permalink / raw
  To: gentoo-commits

commit:     00e17176b0052f5b6a2376c2b3a9864c11eff680
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:05:43 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Apr 25 07:05:43 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=00e17176

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-25 15:13 Brian Dolbec
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2011-04-25 15:13 UTC (permalink / raw
  To: gentoo-commits

commit:     47027d1da9df4aafe291ef7f6035a7ccf089c2ab
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:04:33 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Apr 25 07:04:33 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=47027d1d

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-25 15:13 Brian Dolbec
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2011-04-25 15:13 UTC (permalink / raw
  To: gentoo-commits

commit:     47e678415a0c61d3eee2a9b30605b05949ac94c4
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:03:20 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Apr 25 07:03:20 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=47e67841

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-25 15:13 Brian Dolbec
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2011-04-25 15:13 UTC (permalink / raw
  To: gentoo-commits

commit:     9511938f41d56768087d726dff7cf019c9ef3ce6
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:22:11 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Apr 25 07:22:11 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=9511938f

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-25 15:13 Brian Dolbec
  0 siblings, 0 replies; 15+ messages in thread
From: Brian Dolbec @ 2011-04-25 15:13 UTC (permalink / raw
  To: gentoo-commits

commit:     abebde73d86ca78117121466e33d3747fdbf4ef9
Author:     dol-sen <brian.dolbec <AT> gmail <DOT> com>
AuthorDate: Mon Apr 25 07:23:55 2011 +0000
Commit:     Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Apr 25 07:23:55 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=abebde73

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-26  9:08 Sławek Lis
  0 siblings, 0 replies; 15+ messages in thread
From: Sławek Lis @ 2011-04-26  9:08 UTC (permalink / raw
  To: gentoo-commits

commit:     8e0ca4b5aa041e760446d862b28007eff228be4d
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Tue Apr 26 07:08:24 2011 +0000
Commit:     Sławek Lis <lis.slawek <AT> gmail <DOT> com>
CommitDate: Tue Apr 26 07:08:24 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=8e0ca4b5

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-27  4:53 Sławek Lis
  0 siblings, 0 replies; 15+ messages in thread
From: Sławek Lis @ 2011-04-27  4:53 UTC (permalink / raw
  To: gentoo-commits

commit:     ade3a26d6ac1003bd221cb3611567d175de5cf8b
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Wed Apr 27 04:21:03 2011 +0000
Commit:     Sławek Lis <lis.slawek <AT> gmail <DOT> com>
CommitDate: Wed Apr 27 04:21:03 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=ade3a26d

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2011-04-28  9:47 Sławek Lis
  0 siblings, 0 replies; 15+ messages in thread
From: Sławek Lis @ 2011-04-28  9:47 UTC (permalink / raw
  To: gentoo-commits

commit:     350ab06e0d40942519bc686cc0ef099bcd8cba52
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Thu Apr 28 09:41:35 2011 +0000
Commit:     Sławek Lis <lis.slawek <AT> gmail <DOT> com>
CommitDate: Thu Apr 28 09:41:35 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=350ab06e

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] 15+ messages in thread

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2012-10-02  6:42 Sławek Lis
  0 siblings, 0 replies; 15+ messages in thread
From: Sławek Lis @ 2012-10-02  6:42 UTC (permalink / raw
  To: gentoo-commits

commit:     bb34f3532d586186a009a08c0e40c9d5fda91fb5
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Tue Oct  2 06:44:01 2012 +0000
Commit:     Sławek Lis <lis.slawek <AT> gmail <DOT> com>
CommitDate: Tue Oct  2 06:44:01 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=bb34f353

Cleanup in revdep-rebuild file; improved multi-core analyzing (speedup on multi-core cpu to about 60% original time)

---
 pym/gentoolkit/revdep_rebuild/analyse.py        |    5 +
 pym/gentoolkit/revdep_rebuild/rebuild.py        |    9 ++-
 pym/gentoolkit/revdep_rebuild/revdep-rebuild.py |   17 ++++
 pym/gentoolkit/revdep_rebuild/runner.py         |  114 +++++++++++++++++++++++
 4 files changed, 144 insertions(+), 1 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index d94365e..1b7372c 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -21,6 +21,11 @@ def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
 	dependencies = [] # list of lists of files (from file_to_check) that uses
 					  # library (for dependencies[id] and libs[id] => id==id)
 
+
+#	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'], 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(' ')

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 834170e..3d9ce82 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -170,9 +170,11 @@ def rebuild(logger, assigned, settings):
 def main(settings=None, logger=None):
 
 	if settings is None:
-		print("NO Input settings, using defaults...")
+#		print("NO Input settings, using defaults...")
 		settings = DEFAULTS.copy()
 
+	parse_options()
+	
 	if logger is None:
 		logger = init_logger(settings)
 
@@ -237,3 +239,8 @@ def main(settings=None, logger=None):
 	success = rebuild(logger, assigned, settings)
 	logger.debug("rebuild return code = %i" %success)
 	return success
+
+
+if __name__ == '__main__':
+	main()
+

diff --git a/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
new file mode 100755
index 0000000..2619ee0
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/revdep-rebuild.py
@@ -0,0 +1,17 @@
+#!/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()

diff --git a/pym/gentoolkit/revdep_rebuild/runner.py b/pym/gentoolkit/revdep_rebuild/runner.py
new file mode 100644
index 0000000..24411a5
--- /dev/null
+++ b/pym/gentoolkit/revdep_rebuild/runner.py
@@ -0,0 +1,114 @@
+# -*- coding: utf-8 -*-
+
+import threading
+import subprocess
+
+
+class ProcessRunner(threading.Thread):
+    '''
+    ProcessRunner is class designed to run arbitrary command
+    in background (separate thread). It's replacement for old 
+    stuff.call_program function.
+    
+    When called program is finished, its output can be accessed
+    through .stdout and .stderr fields
+    '''
+    
+    def __init__(self, args, autorun=True):
+        '''
+        @param args - program name and its arguments
+        @param autorun - if True, then automatically starts new thread
+        ''' 
+
+        threading.Thread.__init__(self)
+        self.args = args
+        self.lock = threading.Lock()
+        self.stdout = ''
+        self.stderr = ''
+        
+        if autorun:
+            self.start()
+            
+        
+        
+    def run(self):
+        self.lock.acquire()
+        
+        subp = subprocess.Popen(self.args, stdout=subprocess.PIPE, \
+                                stderr=subprocess.PIPE)
+        self.stdout, self.stderr = subp.communicate()
+        self.lock.release()
+        
+        
+    def is_ready(self):
+        ''' Checks whether current command is finished '''
+        return not self.lock.locked()
+    
+    
+    def wait(self):
+        ''' Waits until called program finishes '''
+        self.lock.acquire()
+        self.lock.release()
+
+
+
+
+class ScanRunner(threading.Thread):
+    '''
+    ScanRunner is a class for calling scanelf in separate 
+    thread, so several instances could be called at a time,
+    and then all results could be consolidated.
+    
+    Consolidated output is available through .out
+    '''   
+    
+    def __init__(self, params, files, max_args, autorun=True):
+        '''
+        @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
+        @param autorun automatically start new thread
+
+        When files count is greater CMD_MAX_ARGS, then scanelf will be called
+        several times.
+        '''
+        
+        threading.Thread.__init__(self)
+        self.params = params
+        self.files = files
+        self.max_args = max_args
+        
+        self.out = []
+        self.lock = threading.Lock()
+        
+        if autorun:
+            self.start()
+            
+            
+    def run(self):
+        self.lock.acquire()
+        
+        process_pool = []
+        for i in range(0, len(self.files), self.max_args):
+            process_pool.append(ProcessRunner(['scanelf'] + self.params + self.files[i:i+self.max_args]))
+                
+        while process_pool:
+            p = process_pool.pop()
+            p.wait()
+            self.out += p.stdout.strip().split('\n')
+            
+        self.lock.release()
+        
+        
+    def is_ready(self):
+        ''' Checks whether scanning is finished '''
+        return not self.lock.locked()
+    
+    
+    def wait(self):
+        ''' Waits until all scanning instances are finished '''
+        self.lock.acquire()
+        self.lock.release()
+        
+        
+        
\ No newline at end of file


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

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2012-10-02  7:35 Sławek Lis
  0 siblings, 0 replies; 15+ messages in thread
From: Sławek Lis @ 2012-10-02  7:35 UTC (permalink / raw
  To: gentoo-commits

commit:     59d7a464c995965e254f6940e2e5fc52161fe1f5
Author:     Slawek <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Tue Oct  2 07:37:56 2012 +0000
Commit:     Sławek Lis <lis.slawek <AT> gmail <DOT> com>
CommitDate: Tue Oct  2 07:37:56 2012 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=59d7a464

Minor fix in rebuild (parsing options)

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

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index 3d9ce82..cfceacc 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -173,8 +173,6 @@ def main(settings=None, logger=None):
 #		print("NO Input settings, using defaults...")
 		settings = DEFAULTS.copy()
 
-	parse_options()
-	
 	if logger is None:
 		logger = init_logger(settings)
 
@@ -242,5 +240,5 @@ def main(settings=None, logger=None):
 
 
 if __name__ == '__main__':
-	main()
+	main(rebuild.parse_options())
 


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

* [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/
@ 2013-09-30  5:35 slis
  0 siblings, 0 replies; 15+ messages in thread
From: slis @ 2013-09-30  5:35 UTC (permalink / raw
  To: gentoo-commits

commit:     6282695a77af21bd60a31d182575c5a12a1a359b
Author:     slis <lis.slawek <AT> gmail <DOT> com>
AuthorDate: Mon Sep 30 05:36:25 2013 +0000
Commit:     slis <lis.slawek <AT> gmail <DOT> com>
CommitDate: Mon Sep 30 05:36:25 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/gentoolkit.git;a=commit;h=6282695a

Fixed multilib support

---
 pym/gentoolkit/revdep_rebuild/analyse.py | 136 +++++++++++++++++++++++--------
 pym/gentoolkit/revdep_rebuild/rebuild.py |   2 +-
 2 files changed, 105 insertions(+), 33 deletions(-)

diff --git a/pym/gentoolkit/revdep_rebuild/analyse.py b/pym/gentoolkit/revdep_rebuild/analyse.py
index 1b7372c..e630bc9 100644
--- a/pym/gentoolkit/revdep_rebuild/analyse.py
+++ b/pym/gentoolkit/revdep_rebuild/analyse.py
@@ -20,13 +20,14 @@ def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
 	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)
+	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'], files_to_check, cmd_max_args):
+	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?
@@ -38,12 +39,34 @@ def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
 				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):
+	import os
+
+	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(' ')
+		filename = os.path.realpath(filename)
+		needed = needed.split(',')
+		bits = bits[8:] # 8: -> strlen('ELFCLASS')
+		if not soname:
+			soname = sfilename
+		
+		try:
+			scanned_files[bits][soname] = (filename, needed)
+		except KeyError:
+			scanned_files[bits] = {}
+			scanned_files[bits][soname] = (filename, needed)
+	return scanned_files
+
+
+
 def extract_dependencies_from_la(la, libraries, to_check, logger):
 	broken = []
 
@@ -98,7 +121,7 @@ def find_broken(found_libs, system_libraries, to_check):
 	# join libraries and looking at it as string is way too faster than for-jumping
 
 	broken = []
-	sl = '|'.join(system_libraries)
+	sl = '|'.join(system_libraries) + '|'
 
 	if not to_check:
 		for f in found_libs:
@@ -113,6 +136,25 @@ def find_broken(found_libs, system_libraries, to_check):
 	return broken
 
 
+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:
+						try:
+							broken_libs[bits][l] = set([soname])
+						except KeyError:
+							broken_libs = {bits: {l: set([soname])}}
+
+	return broken_libs
+
+
 def main_checks(found_libs, broken, dependencies, logger):
 	''' Checks for broken dependencies.
 		found_libs have to be the same as returned by prepare_checks
@@ -131,6 +173,18 @@ def main_checks(found_libs, broken, dependencies, logger):
 	return broken_pathes
 
 
+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 n in needed:
+				fp = scanned_files[bits][n][0]
+				logger.info(yellow(' * ') + n  + ' (' + fp + ')')
+				broken_pathes.append(fp)
+	return broken_pathes
+
+
 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
@@ -169,56 +223,74 @@ 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.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 ' + str(len(binaries)+len(libraries)) + ' within ' + str(len(libraries)+len(libraries_links)))
-	libs_and_bins = libraries+binaries
+	
+	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
+
+	logger.warn(green(' * ') + bold('Assign files to packages'))
+
+	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
 
-	found_libs = []
-	dependencies = []
+	## 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
+	#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
+	#_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:])
+	#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
+		##_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)
+		#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)
+		#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)
-	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, settings)
+	#return assign_packages(broken_pathes, logger, settings)
 
 
 

diff --git a/pym/gentoolkit/revdep_rebuild/rebuild.py b/pym/gentoolkit/revdep_rebuild/rebuild.py
index cfceacc..a943902 100644
--- a/pym/gentoolkit/revdep_rebuild/rebuild.py
+++ b/pym/gentoolkit/revdep_rebuild/rebuild.py
@@ -240,5 +240,5 @@ def main(settings=None, logger=None):
 
 
 if __name__ == '__main__':
-	main(rebuild.parse_options())
+	main(parse_options())
 


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

end of thread, other threads:[~2013-09-30  5:35 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-26  9:08 [gentoo-commits] proj/gentoolkit:revdep-rebuild commit in: pym/gentoolkit/revdep_rebuild/ Sławek Lis
  -- strict thread matches above, loose matches on Subject: below --
2013-09-30  5:35 slis
2012-10-02  7:35 Sławek Lis
2012-10-02  6:42 Sławek Lis
2011-04-28  9:47 Sławek Lis
2011-04-27  4:53 Sławek Lis
2011-04-25 15:13 Brian Dolbec
2011-04-25 15:13 Brian Dolbec
2011-04-25 15:13 Brian Dolbec
2011-04-25 15:13 Brian Dolbec
2011-04-25 15:13 Brian Dolbec
2011-04-25 15:13 Brian Dolbec
2011-04-25 15:13 Brian Dolbec
2011-04-25 15:13 Brian Dolbec
2011-02-15  5:34 Sławek Lis

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