def run_check(cls, results_dir, **kwargs): """Compares old and new RPMs using abipkgdiff""" # Check if ABI changes occured cls.abi_changes = None cls.results_dir = os.path.join(results_dir, cls.NAME) os.makedirs(cls.results_dir) debug_old, rest_pkgs_old = cls._get_packages_for_abipkgdiff( results_store.get_build('old')) debug_new, rest_pkgs_new = cls._get_packages_for_abipkgdiff( results_store.get_build('new')) cmd = [cls.NAME] reports = {} for pkg in rest_pkgs_old: command = list(cmd) debug = cls._find_debuginfo(debug_old, pkg) if debug: command.append('--d1') command.append(debug) old_name = RpmHelper.split_nevra(os.path.basename(pkg))['name'] find = [ x for x in rest_pkgs_new if RpmHelper.split_nevra( os.path.basename(x))['name'] == old_name ] if not find: logger.warning('New version of package %s was not found!', old_name) continue new_pkg = find[0] debug = cls._find_debuginfo(debug_new, new_pkg) if debug: command.append('--d2') command.append(debug) command.append(pkg) command.append(new_pkg) logger.debug('Package name for ABI comparison %s', old_name) output = os.path.join(cls.results_dir, old_name + '.txt') try: ret_code = ProcessHelper.run_subprocess(command, output_file=output) except OSError: raise CheckerNotFoundError( "Checker '{}' was not found or installed.".format( cls.NAME)) if int(ret_code) & cls.ABIDIFF_ERROR and int( ret_code) & cls.ABIDIFF_USAGE_ERROR: raise RebaseHelperError( 'Execution of {} failed.\nCommand line is: {}'.format( cls.NAME, cmd)) reports[old_name] = int(ret_code) return dict(packages=cls.parse_abi_logs(reports), abi_changes=cls.abi_changes, path=cls.get_checker_output_dir_short())
def check_build_requires(spec): """ Check if all build dependencies are installed. If not, asks user they should be installed. If yes, it installs build dependencies using PolicyKit. :param spec: SpecFile object :return: """ req_pkgs = spec.get_requires() if not RpmHelper.all_packages_installed(req_pkgs): if ConsoleHelper.get_message('\nSome build dependencies are missing. Do you want to install them now'): if RpmHelper.install_build_dependencies(spec.get_path()) != 0: raise RebaseHelperError('Failed to install build dependencies')
def prepare(cls, spec, conf): """ Checks if all build dependencies are installed. If not, asks user whether they should be installed. If he agrees, installs build dependencies using PolicyKit. :param spec: SpecFile object """ req_pkgs = spec.get_requires() if not RpmHelper.all_packages_installed(req_pkgs): question = '\nSome build dependencies are missing. Do you want to install them now' if conf.non_interactive or ConsoleHelper.get_message(question): if RpmHelper.install_build_dependencies(spec.get_path(), assume_yes=conf.non_interactive) != 0: raise RebaseHelperError('Failed to install build dependencies')
def run_check(cls, result_dir): """Compares old and new RPMs using abipkgdiff""" debug_old, rest_pkgs_old = cls._get_packages_for_abipkgdiff( results_store.get_build('old')) debug_new, rest_pkgs_new = cls._get_packages_for_abipkgdiff( results_store.get_build('new')) cmd = [cls.CMD] reports = {} for pkg in rest_pkgs_old: command = list(cmd) debug = cls._find_debuginfo(debug_old, pkg) if debug: command.append('--d1') command.append(debug) old_name = RpmHelper.split_nevra(os.path.basename(pkg))['name'] find = [ x for x in rest_pkgs_new if RpmHelper.split_nevra( os.path.basename(x))['name'] == old_name ] if not find: logger.warning('New version of package %s was not found!', old_name) continue new_pkg = find[0] debug = cls._find_debuginfo(debug_new, new_pkg) if debug: command.append('--d2') command.append(debug) command.append(pkg) command.append(new_pkg) logger.debug('Package name for ABI comparison %s', old_name) output = os.path.join(cls.results_dir, result_dir, old_name + '-' + cls.log_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.' % old_name else: text = 'ABI of the compared binaries in package %s are not equal.' % old_name reports[output] = text return reports
def check_build_requires(spec): """ Check if all build dependencies are installed. If not, asks user they should be installed. If yes, it installs build dependencies using PolicyKit. :param spec: SpecFile object :return: """ req_pkgs = spec.get_requires() if not RpmHelper.all_packages_installed(req_pkgs): if ConsoleHelper.get_message( '\nSome build dependencies are missing. Do you want to install them now' ): if RpmHelper.install_build_dependencies(spec.get_path()) != 0: raise RebaseHelperError( 'Failed to install build dependencies')
def _find_debuginfo(cls, debug, pkg): name = RpmHelper.split_nevra(os.path.basename(pkg))['name'] debuginfo = '{}-debuginfo'.format(name) find = [ x for x in debug if RpmHelper.split_nevra(os.path.basename(x))['name'] == debuginfo ] if find: return find[0] srpm = RpmHelper.get_info_from_rpm(pkg, rpm.RPMTAG_SOURCERPM) debuginfo = '{}-debuginfo'.format(RpmHelper.split_nevra(srpm)['name']) find = [ x for x in debug if RpmHelper.split_nevra(os.path.basename(x))['name'] == debuginfo ] if find: return find[0] return None
def test_all_packages_installed_existing(self): assert RpmHelper.all_packages_installed(["glibc", "coreutils"]) is True
def test_is_package_installed_existing(self): assert RpmHelper.is_package_installed('glibc') is True assert RpmHelper.is_package_installed('coreutils') is True
def _get_rpms(cls, rpm_list): rpm_dict = {} for rpm_name in rpm_list: rpm_dict[RpmHelper.get_info_from_rpm(rpm_name, 'name')] = rpm_name return rpm_dict
def test_all_packages_installed_one_non_existing(self): assert RpmHelper.all_packages_installed( ['glibc', 'coreutils', 'non-existing-package']) is False
def _get_rpm_info(cls, name, packages): if packages is None: return None basic_package = sorted(packages)[0] return RpmHelper.get_info_from_rpm(basic_package, name)
def test_is_package_installed_non_existing(self): assert RpmHelper.is_package_installed('non-existing-package') is False assert RpmHelper.is_package_installed( 'another-non-existing-package') is False
def test_all_packages_installed_existing(self): assert RpmHelper.all_packages_installed(['glibc', 'coreutils']) is True
def test_is_package_installed_non_existing(self): assert RpmHelper.is_package_installed("non-existing-package") is False assert RpmHelper.is_package_installed("another-non-existing-package") is False
def test_is_package_installed_existing(self): assert RpmHelper.is_package_installed("glibc") is True assert RpmHelper.is_package_installed("coreutils") is True
def test_all_packages_installed_one_non_existing(self): assert RpmHelper.all_packages_installed(['glibc', 'coreutils', 'non-existing-package']) is False
def test_split_nevra(self, nevra, name, epoch, version, release, arch): assert RpmHelper.split_nevra(nevra) == dict(name=name, epoch=epoch, version=version, release=release, arch=arch)
def test_all_packages_installed_one_non_existing(self): assert RpmHelper.all_packages_installed(["glibc", "coreutils", "non-existing-package"]) is False