How to use the rebasehelper.results_store.results_store.get_old_build function in rebasehelper

To help you get started, we’ve selected a few rebasehelper examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rebase-helper / rebase-helper / rebasehelper / plugins / checkers / csmock.py View on Github external
def run_check(cls, results_dir, **kwargs):
        """Compares old and new RPMs using pkgdiff"""
        csmock_report = {}

        old_pkgs = results_store.get_old_build().get('srpm', None)
        new_pkgs = results_store.get_new_build().get('srpm', None)
        cls.results_dir = os.path.join(results_dir, cls.CMD)
        cls.prepare_results_dir()
        arguments = ['--force', '-a', '-r', 'fedora-rawhide-x86_64', '--base-srpm']
        if old_pkgs and new_pkgs:
            cmd = [cls.CMD]
            cmd.extend(arguments)
            cmd.append(old_pkgs)
            cmd.append(new_pkgs)
            cmd.extend(['-o', results_dir])
            output = io.StringIO()
            try:
                ProcessHelper.run_subprocess(cmd, output_file=output)
            except OSError:
                raise CheckerNotFoundError("Checker '{}' was not found or installed.".format(cls.name))
        csmock_report['error'] = PathHelper.find_all_files_current_dir(results_dir, '*.err')
github rebase-helper / rebase-helper / rebasehelper / plugins / checkers / rpminspect_srpm.py View on Github external
def run_check(cls, results_dir, **kwargs):
        cls.results_dir = os.path.join(results_dir, 'rpminspect-srpm')
        cls.prepare_results_dir()

        result = {'path': cls.get_checker_output_dir_short(), 'files': [], 'checks': {}}
        old_pkg = results_store.get_old_build()['srpm']
        new_pkg = results_store.get_new_build()['srpm']
        name = RpmHelper.split_nevra(os.path.basename(old_pkg))['name']
        outfile, pkg_data = cls.run_rpminspect(cls.results_dir, old_pkg, new_pkg)
        result['files'].append(os.path.basename(outfile))
        result['checks'][name] = pkg_data

        return result
github rebase-helper / rebase-helper / rebasehelper / plugins / checkers / rpminspect_rpm.py View on Github external
def run_check(cls, results_dir, **kwargs):
        cls.results_dir = os.path.join(results_dir, 'rpminspect-rpm')
        cls.prepare_results_dir()

        result = {'path': cls.get_checker_output_dir_short(), 'files': [], 'checks': {}}
        old_pkgs = results_store.get_old_build()['rpm']
        new_pkgs = results_store.get_new_build()['rpm']
        for old_pkg in old_pkgs:
            if 'debuginfo' in old_pkg:
                continue
            name = RpmHelper.split_nevra(os.path.basename(old_pkg))['name']
            found = [x for x in new_pkgs if RpmHelper.split_nevra(os.path.basename(x))['name'] == name]
            if not found:
                logger.warning('New version of package %s was not found!', name)
                continue
            new_pkg = found[0]
            outfile, pkg_data = cls.run_rpminspect(cls.results_dir, old_pkg, new_pkg)
            result['files'].append(os.path.basename(outfile))
            result['checks'][name] = pkg_data

        return result
github rebase-helper / rebase-helper / rebasehelper / plugins / checkers / sonamecheck.py View on Github external
def run_check(cls, results_dir, **kwargs):
        old_headers = [RpmHelper.get_header_from_rpm(x) for x in results_store.get_old_build().get('rpm', [])]
        new_headers = [RpmHelper.get_header_from_rpm(x) for x in results_store.get_new_build().get('rpm', [])]
        soname_changes: SonameChanges = collections.defaultdict(lambda: collections.defaultdict(list))
        for old in old_headers:
            new = [x for x in new_headers if x.name == old.name]
            if not new:
                logger.warning('New version of package %s was not found!', old.name)
                continue
            else:
                new = new[0]
            old_sonames = cls._get_sonames(old.provides)
            new_sonames = cls._get_sonames(new.provides)
            for old_soname in old_sonames:
                if old_soname in new_sonames:
                    new_sonames.remove(old_soname)
                    continue
                soname = [x for x in new_sonames if os.path.splitext(x)[0] == os.path.splitext(old_soname)[0]]
github rebase-helper / rebase-helper / rebasehelper / plugins / checkers / rpmdiff.py View on Github external
def run_check(cls, results_dir, **kwargs):
        """Compares old and new RPMs using rpmdiff"""
        results_dict: Dict[str, List[str]] = {}

        for tag in cls.CHECKER_TAGS:
            results_dict[tag] = []

        cls.results_dir = os.path.join(results_dir, cls.name)
        cls.prepare_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(results_store.get_old_build().get('rpm', None))
        new_pkgs = cls._get_rpms(results_store.get_new_build().get('rpm', None))
        for key, value in old_pkgs.items():
            if 'debuginfo' in key or 'debugsource' in key:
                # skip debug{info,source} packages
                continue
            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
            try:
                cmd.append(new_pkgs[key])
            except KeyError:
                logger.warning('New version of package %s was not found!', key)
                continue
github rebase-helper / rebase-helper / rebasehelper / plugins / checkers / pkgdiff.py View on Github external
def fill_dictionary(cls, result_dir, old_version=None, new_version=None):
        """
        Parsed files.xml and symbols.xml and fill dictionary
        :param result_dir: where should be stored file for pkgdiff
        :param old_version: old version of package
        :param new_version: new version of package
        :return:
        """
        XML_FILES = ['files.xml', 'symbols.xml']
        if old_version is None:
            old_version = results_store.get_old_build().get('version')
            if old_version == '':
                old_version = cls._get_rpm_info('version', results_store.get_old_build()['rpm'])
        if new_version is None:
            new_version = results_store.get_new_build().get('version')
            if new_version == '':
                new_version = cls._get_rpm_info('version', results_store.get_new_build()['rpm'])

        for tag in cls.CHECKER_TAGS:
            cls.results_dict[tag] = []
        for file_name in [os.path.join(result_dir, x) for x in XML_FILES]:
            logger.verbose('Processing %s file.', file_name)
            try:
                with open(file_name, "r") as f:
                    lines = ['']
                    lines.extend(f.readlines())
                    lines.append('')
                    pkgdiff_tree = ElementTree.fromstringlist(lines)
                    for tag in cls.CHECKER_TAGS:
github rebase-helper / rebase-helper / rebasehelper / plugins / checkers / pkgdiff.py View on Github external
def fill_dictionary(cls, result_dir, old_version=None, new_version=None):
        """
        Parsed files.xml and symbols.xml and fill dictionary
        :param result_dir: where should be stored file for pkgdiff
        :param old_version: old version of package
        :param new_version: new version of package
        :return:
        """
        XML_FILES = ['files.xml', 'symbols.xml']
        if old_version is None:
            old_version = results_store.get_old_build().get('version')
            if old_version == '':
                old_version = cls._get_rpm_info('version', results_store.get_old_build()['rpm'])
        if new_version is None:
            new_version = results_store.get_new_build().get('version')
            if new_version == '':
                new_version = cls._get_rpm_info('version', results_store.get_new_build()['rpm'])

        for tag in cls.CHECKER_TAGS:
            cls.results_dict[tag] = []
        for file_name in [os.path.join(result_dir, x) for x in XML_FILES]:
            logger.verbose('Processing %s file.', file_name)
            try:
                with open(file_name, "r") as f:
                    lines = ['']
                    lines.extend(f.readlines())
                    lines.append('')
github rebase-helper / rebase-helper / rebasehelper / plugins / output_tools / __init__.py View on Github external
def print_cli_summary(cls, app):
        """Outputs a summary of a rebase-helper run.

        Args:
            app: Application instance.
        """
        cls.print_patches_cli()
        result = results_store.get_result_message()

        cls.print_important_checkers_output()

        logger_summary.heading('\nAvailable logs:')
        logger_summary.info('%s:\n%s', 'Debug log', cls.prepend_results_dir_name(app,
                                                                                 os.path.join(LOGS_DIR, DEBUG_LOG)))
        if results_store.get_old_build() is not None:
            logger_summary.info('%s:\n%s', 'Old build logs and (S)RPMs',
                                cls.prepend_results_dir_name(app, OLD_BUILD_DIR))
        if results_store.get_new_build() is not None:
            logger_summary.info('%s:\n%s', 'New build logs and (S)RPMs',
                                cls.prepend_results_dir_name(app, NEW_BUILD_DIR))
        logger_summary.info('')

        logger_summary.heading('%s:', 'Rebased sources')
        logger_summary.info("%s", cls.prepend_results_dir_name(app, os.path.relpath(app.rebased_sources_dir,
                                                                                    app.results_dir)))

        patch = results_store.get_changes_patch()
        if 'changes_patch' in patch:
            logger_summary.heading('%s:', 'Generated patch')
            logger_summary.info("%s\n", cls.prepend_results_dir_name(app, os.path.basename(patch['changes_patch'])))