#
# $Header$
-"""'analyse' is a flexible utility for Gentoo linux which can display various
-information about installed packages, such as the USE flags used and the
-packages that use them. It can also be used to help rebuild /etc/portage/package.*
-files in the event of corruption, and possibly more.
+"""'revdep-rebuild' scans libraries and binaries for missing shared library dependencies and attempts to fix them by re-emerging
+those broken binaries and shared libraries. It is useful when an upgraded package breaks other software packages that are
+dependent upon the upgraded package.
"""
from __future__ import print_function
unset GREP_OPTIONS
# Readonly variables:
-declare -r APP_NAME="${0##*/}" # The name of this application
+declare -r APP_NAME="revdep-rebuild" # # The name of this application
declare -r VERSION="svn"
declare -r OIFS="$IFS" # Save the IFS
declare -r ENV_FILE=0_env.rr # Contains environment variables
#!/usr/bin/python
+"""Analysis module"""
+
+from __future__ import print_function
+
import os
import re
import platform
from portage.output import bold, red, blue, yellow, green, nocolor
-from stuff import scan
-from collect import prepare_search_dirs, parse_revdep_config, collect_libraries_from_dir, collect_binaries_from_dir
-from assign import assign_packages
-from cache import save_cache
+from .stuff import scan
+from .collect import prepare_search_dirs, parse_revdep_config, collect_libraries_from_dir, collect_binaries_from_dir
+from .assign import assign_packages
+from .cache import save_cache
def prepare_checks(files_to_check, libraries, bits, cmd_max_args):
#!/usr/bin/python
+"""Assign module
+Functions used for determining the package the broken lib belongs to.
+"""
+
+from __future__ import print_function
+
import os
import re
#!/bin/bash
+"""Caching module
+Functions for reading, saving and verifying the data caches
+"""
+
+from __future__ import print_function
+
import os
import time
from portage.output import red
-from settings import DEFAULTS
+from .settings import DEFAULTS
def read_cache(temp_path=DEFAULTS['DEFAULT_TMP_DIR']):
ret = {'libraries':[], 'la_libraries':[], 'libraries_links':[], 'binaries':[]}
try:
- for key,val in ret.iteritems():
+ for key,val in list(ret.items()):
f = open(os.path.join(temp_path, key))
for line in f.readlines():
val.append(line.strip())
f.write(str(int(time.time())))
f.close()
- for key,val in to_save.iteritems():
+ for key,val in list(to_save.items()):
f = open(os.path.join(temp_path, key), 'w')
for line in val:
f.write(line + '\n')
if __name__ == '__main__':
print('Preparing cache ... ')
- from collect import *
+ from .collect import *
import logging
bin_dirs, lib_dirs = prepare_search_dirs()
"""Data collection module"""
+from __future__ import print_function
+
import re
import os
import glob
lib_dirs = set()
to_parse = set()
- if isinstance(conf_file, basestring):
+ if isinstance(conf_file, str):
conf_file = [conf_file]
for conf in conf_file:
# -*- 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>
+""" Rebuild module
-# Creation date: 2010/10/17
-# License: BSD
+Main program, cli parsing and api program control and operation
+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 __future__ import print_function
+
+import subprocess
import os
import sys
import getopt
import logging
from portage.output import bold, red, blue, yellow, green, nocolor
-from analyse import analyse
-from stuff import exithandler, get_masking_status
-from cache import check_temp_files, read_cache
-from assign import get_slotted_cps
-from settings import DEFAULTS
-from gentoolkit.revdep_rebuild import __version__
+from .analyse import analyse
+from .stuff import exithandler, get_masking_status
+from .cache import check_temp_files, read_cache
+from .assign import get_slotted_cps
+from .settings import DEFAULTS
+from . import __version__
APP_NAME = sys.argv[0]
def print_usage():
"""Outputs the help message"""
print( APP_NAME + ': (' + VERSION +')')
- print
+ print()
print('This is free software; see the source for copying conditions.')
- print
+ print()
print('Usage: ' + APP_NAME + ' [OPTIONS] [--] [EMERGE_OPTIONS]')
- print
+ print()
print('Broken reverse dependency rebuilder, python implementation.')
- print
+ print()
print('Available options:')
print('''
-C, --nocolor Turn off colored output
"""Default settings"""
+from __future__ import print_function
+
import os
import sys
"""Utilities submodule"""
+from __future__ import print_function
+
import subprocess
import portage
# util. functions
def call_program(args):
- ''' Calls program with specified parameters and returns stdout '''
+ ''' Calls program with specified parameters and returns stdout as a str object '''
subp = subprocess.Popen(args, stdout=subprocess.PIPE, \
stderr=subprocess.PIPE)
stdout, stderr = subp.communicate()
- return stdout
+ return str(stdout)
def scan(params, files, max_args):