def run_check(cls, results_dir): """ Compares old and new RPMs using pkgdiff """ results_dict = {} for tag in settings.CHECKER_TAGS: results_dict[tag] = [] cls.results_dir = results_dir # Only S (size), M(mode) and 5 (checksum) are now important not_catched_flags = ['T', 'F', 'G', 'U', 'V', 'L', 'D', 'N'] old_pkgs = cls._get_rpms(OutputLogger.get_build('old').get('rpm', None)) new_pkgs = cls._get_rpms(OutputLogger.get_build('new').get('rpm', None)) for key, value in six.iteritems(old_pkgs): cmd = [cls.CMD] # TODO modify to online command for x in not_catched_flags: cmd.extend(['-i', x]) cmd.append(value) # We would like to build correct old package against correct new packages cmd.append(new_pkgs[key]) output = StringIO() ret_code = ProcessHelper.run_subprocess(cmd, output=output) results_dict = cls._analyze_logs(output, results_dict) results_dict = cls.update_added_removed(results_dict) # TODO Check for changed files and # remove them from 'removed' and 'added' #cls._unpack_rpm(old_pkgs) #cls._unpack_rpm(new_pkgs) #cls._find_file_diffs(old_pkgs, new_pkgs) return results_dict
def run_check(cls, results_dir): """ Compares old and new RPMs using pkgdiff """ results_dict = {} for tag in settings.CHECKER_TAGS: results_dict[tag] = [] cls.results_dir = results_dir # Only S (size), M(mode) and 5 (checksum) are now important not_catched_flags = ['T', 'F', 'G', 'U', 'V', 'L', 'D', 'N'] old_pkgs = cls._get_rpms(OutputLogger.get_build('old').get('rpm', None)) new_pkgs = cls._get_rpms(OutputLogger.get_build('new').get('rpm', None)) for key, value in six.iteritems(old_pkgs): cmd = [cls.CMD] # TODO modify to online command for x in not_catched_flags: cmd.extend(['-i', x]) cmd.append(value) # We would like to build correct old package against correct new packages cmd.append(new_pkgs[key]) output = StringIO() ProcessHelper.run_subprocess(cmd, output=output) results_dict = cls._analyze_logs(output, results_dict) results_dict = cls.update_added_removed(results_dict) results_dict = dict((k, v) for k, v in six.iteritems(results_dict) if v) text = [] for key, val in six.iteritems(results_dict): text.append('Following files were %s:\n%s' % (key, '\n'.join(val))) return text
def run_check(cls, result_dir): """Compares old and new RPMs using pkgdiff""" debug_old, rest_pkgs_old = cls._get_packages_for_abipkgdiff(OutputLogger.get_build('old')) debug_new, rest_pkgs_new = cls._get_packages_for_abipkgdiff(OutputLogger.get_build('new')) cmd = [cls.CMD] if debug_old is None: logger.warning("Package doesn't contain any debug package") return None try: cmd.append('--d1') cmd.append(debug_old[0]) except IndexError: logger.error('Debuginfo package not found for old package.') return None try: cmd.append('--d2') cmd.append(debug_new[0]) except IndexError: logger.error('Debuginfo package not found for new package.') return None reports = {} for pkg in rest_pkgs_old: command = list(cmd) # Package can be <letters><numbers>-<letters>-<and_whatever> regexp = r'^(\w*)(-\D+)?.*$' reg = re.compile(regexp) matched = reg.search(os.path.basename(pkg)) if matched: file_name = matched.group(1) command.append(pkg) find = [x for x in rest_pkgs_new if os.path.basename(x).startswith(file_name)] command.append(find[0]) package_name = os.path.basename(os.path.basename(pkg)) logger.debug('Package name for ABI comparision %s', package_name) regexp_name = r'(\w-)*(\D+)*' reg_name = re.compile(regexp_name) matched = reg_name.search(os.path.basename(pkg)) logger.debug('Found matches %s', matched.groups()) if matched: package_name = matched.group(0) + cls.log_name else: package_name = package_name + '-' + cls.log_name output = os.path.join(cls.results_dir, result_dir, package_name) try: ret_code = ProcessHelper.run_subprocess(command, output=output) except OSError: raise CheckerNotFoundError("Checker '%s' was not found or installed." % cls.CMD) if int(ret_code) & settings.ABIDIFF_ERROR and int(ret_code) & settings.ABIDIFF_USAGE_ERROR: raise RebaseHelperError('Execution of %s failed.\nCommand line is: %s' % (cls.CMD, cmd)) if int(ret_code) == 0: text = 'ABI of the compared binaries in package %s are equal.' % package_name else: text = 'ABI of the compared binaries in package %s are not equal.' % package_name reports[output] = text else: logger.debug("Rebase-helper did not find a package name in '%s'", package_name) return reports
def run_check(cls, results_dir): """ Compares old and new RPMs using pkgdiff """ cls.results_dir = results_dir cls.pkgdiff_results_full_path = os.path.join(cls.results_dir, cls.pkgdiff_results_filename) versions = ['old', 'new'] cmd = [cls.CMD] for version in versions: old = OutputLogger.get_build(version) if old: file_name = cls._create_xml(version, input_structure=old) cmd.append(file_name) cmd.append('-extra-info') cmd.append(cls.results_dir) cmd.append('-report-path') cmd.append(cls.pkgdiff_results_full_path) ret_code = ProcessHelper.run_subprocess(cmd, output=ProcessHelper.DEV_NULL) """ From pkgdiff source code: ret_code 0 means unchanged ret_code 1 means Changed other return codes means error """ if int(ret_code) != 0 and int(ret_code) != 1: raise RebaseHelperError('Execution of %s failed.\nCommand line is: %s', cls.CMD, cmd) OutputLogger.set_info_text('Result HTML page from pkgdiff is store in: ', cls.pkgdiff_results_full_path) results_dict = cls.process_xml_results(cls.results_dir) text = [] for key, val in six.iteritems(results_dict): text.append('Following files were %s:\n%s' % (key, '\n'.join(val))) return text
def print_summary(cls, path): """ Function is used for printing summary informations :return: """ # First of all we would like to print all # summary information OutputLogger.set_info_text("Summary output is also available in log:", path) logger.info('\n') for key, value in six.iteritems(OutputLogger.get_summary_info()): logger.info("%s %s\n", key, value) try: LoggerHelper.add_file_handler(logger_output, path) except (OSError, IOError): raise RebaseHelperError("Can not create results file '%s'", path) type_pkgs = ['old', 'new'] cls.print_patches(OutputLogger.get_patches(), '\nSummary information about patches:') for pkg in type_pkgs: type_pkg = OutputLogger.get_build(pkg) if type_pkg: cls.print_rpms(type_pkg, pkg.capitalize()) cls.print_build_logs(type_pkg, pkg.capitalize()) cls.print_pkgdiff_tool()
def print_summary(cls, path): """ Function is used for printing summary informations :return: """ for key, value in six.iteritems(OutputLogger.get_summary_info()): logger.info("%s %s\n", key, value) try: LoggerHelper.add_file_handler(logger_report, path) except (OSError, IOError): raise RebaseHelperError("Can not create results file '%s'" % path) type_pkgs = ['old', 'new'] if OutputLogger.get_patches(): cls.print_patches(OutputLogger.get_patches(), '\nSummary information about patches:') for pkg in type_pkgs: type_pkg = OutputLogger.get_build(pkg) if type_pkg: cls.print_rpms(type_pkg, pkg.capitalize()) cls.print_build_logs(type_pkg, pkg.capitalize()) cls.print_pkgdiff_tool()
def test_base_output_builds_new(self): """ Test Output logger new builds :return: """ build_results = OutputLogger.get_build('new') assert build_results == self.new_rpm_data
def test_base_output_builds_old(self): """ Test Output logger old builds :return: """ build_results = OutputLogger.get_build('old') assert build_results == self.old_rpm_data
def run_check(cls, results_dir): """ Compares old and new RPMs using pkgdiff """ cls.results_dir = results_dir debug_old, rest_pkgs_old = cls._get_packages_for_abipkgdiff(OutputLogger.get_build('old')) debug_new, rest_pkgs_new = cls._get_packages_for_abipkgdiff(OutputLogger.get_build('new')) cmd = [cls.CMD] cmd.append('--d1') cmd.append(debug_old[0]) cmd.append('--d2') cmd.append(debug_new[0]) text = [] for pkg in rest_pkgs_old: command = list(cmd) # Package can be <letters><numbers>-<letters>-<and_whatever> regexp = r'^(\w*)(-\D+)?.*$' reg = re.compile(regexp) matched = reg.search(os.path.basename(pkg)) if matched: file_name = matched.group(1) command.append(pkg) find = [x for x in rest_pkgs_new if os.path.basename(x).startswith(file_name)] command.append(find[0]) package_name = os.path.basename(os.path.basename(pkg)) logger.debug('Package name for ABI comparision %s', package_name) regexp_name = r'(\w-)*(\D+)*' reg_name = re.compile(regexp_name) matched = reg_name.search(os.path.basename(pkg)) logger.debug('Found matches %s', matched.groups()) if matched: package_name = matched.group(0) + cls.log_name else: package_name = package_name + '-' + cls.log_name output = os.path.join(results_dir, package_name) ret_code = ProcessHelper.run_subprocess(command, output=output) if int(ret_code) & settings.ABIDIFF_ERROR and int(ret_code) & settings.ABIDIFF_USAGE_ERROR: raise RebaseHelperError('Execution of %s failed.\nCommand line is: %s', cls.CMD, cmd) if int(ret_code) == 0: text.append('ABI of the compared binaries in package %s are equal.' % package_name) else: text.append('ABI of the compared binaries in package %s are not equal. See file %s' % (package_name, output)) else: logger.debug("Rebase-helper did not find a package name in '%s'", package_name) return text
def run_check(cls, results_dir): """ Compares old and new RPMs using pkgdiff :param results_dir result dir where are stored results """ cls.results_dir = results_dir cls.pkgdiff_results_full_path = os.path.join(cls.results_dir, cls.pkgdiff_results_filename) cmd = [cls.CMD] cmd.append('-hide-unchanged') for version in ['old', 'new']: old = OutputLogger.get_build(version) if old: file_name = cls._create_xml(version, input_structure=old) cmd.append(file_name) cmd.append('-extra-info') cmd.append(cls.results_dir) cmd.append('-report-path') cmd.append(cls.pkgdiff_results_full_path) try: ret_code = ProcessHelper.run_subprocess(cmd, output=ProcessHelper.DEV_NULL) except OSError: raise CheckerNotFoundError("Checker '%s' was not found or installed." % cls.CMD) """ From pkgdiff source code: ret_code 0 means unchanged ret_code 1 means Changed other return codes means error """ if int(ret_code) != 0 and int(ret_code) != 1: raise RebaseHelperError('Execution of %s failed.\nCommand line is: %s' % (cls.CMD, cmd)) results_dict = cls.process_xml_results(cls.results_dir) text = [] for key, val in six.iteritems(results_dict): if val: text.append('Following files were %s:\n%s' % (key, '\n'.join(val))) pkgdiff_report = os.path.join(cls.results_dir, 'report-' + cls.pkgdiff_results_filename + '.log') try: with open(pkgdiff_report, "w") as f: f.writelines(text) except IOError: raise RebaseHelperError("Unable to write result from %s to '%s'" % (cls.CMD, pkgdiff_report)) return {pkgdiff_report: None}
def get_new_build_logs(self): result = {} result['build_ref'] = {} for version in ['old', 'new']: result['build_ref'][version] = OutputLogger.get_build(version) return result