How to use the rpmlint.pkg.getInstalledPkgs function in rpmlint

To help you get started, we’ve selected a few rpmlint 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 rpm-software-management / rpmlint / scripts / lint.py View on Github external
with Pkg.FakePkg(arg) as pkg:
                                runSpecChecks(pkg, arg)
                            specfiles_checked += 1
                        elif '/' in arg or arg.endswith('.rpm') or \
                                arg.endswith('.spm'):
                            pkgs.append(Pkg.Pkg(arg, extract_dir))
                        else:
                            raise OSError

                    elif stat.S_ISDIR(st[stat.ST_MODE]):
                        dirs.append(arg)
                        continue
                    else:
                        raise OSError
                except OSError:
                    ipkgs = Pkg.getInstalledPkgs(arg)
                    if not ipkgs:
                        print_warning(
                            '(none): E: no installed packages by name %s' % arg)
                    else:
                        ipkgs.sort(key=lambda x: locale.strxfrm(
                            x.header.sprintf('%{NAME}.%{ARCH}')))
                        pkgs.extend(ipkgs)
            except KeyboardInterrupt:
                if isfile:
                    arg = os.path.abspath(arg)
                print_warning(
                    '(none): E: interrupted, exiting while reading %s' % arg)
                sys.exit(2)
            except Exception as e:
                if isfile:
                    arg = os.path.abspath(arg)
github rpm-software-management / rpmlint / rpmlint / rpmdiff.py View on Github external
def __load_pkg(self, name):
        # FIXME: redo to try file/installed and proceed based on that, or pick
        # one of the selected first
        tmpdir = tempfile.gettempdir()
        try:
            if name.is_file():
                return Pkg(name, tmpdir)
        except TypeError:
            pass
        inst = getInstalledPkgs(name)
        if not inst:
            raise KeyError(f'No installed packages by name {name}')
        if len(inst) > 1:
            raise KeyError(f'More than one installed packages by name {name}')
        return inst[0]
github rpm-software-management / rpmlint / rpmlint / lint.py View on Github external
def _load_installed_rpms(self, packages):
        existing_packages = []
        for name in packages:
            pkg = getInstalledPkgs(name)
            if pkg:
                existing_packages.extend(pkg)
            else:
                print_warning(f'(none): E: there is no installed rpm "{name}".')
        return existing_packages