Esempio n. 1
0
    def print_what_provides(self, rpms):
        output = ""
        versions = self.list_module_version_all()
        for version in versions:
            nevras = version.artifacts()
            for nevra in nevras:
                subj = Subject(nevra)
                nevra_obj = list(
                    subj.get_nevra_possibilities(hawkey.FORM_NEVRA))[0]
                if nevra_obj.name not in rpms:
                    continue

                profiles = []
                for profile in version.profiles:
                    if nevra_obj.name in version.rpms(profile):
                        profiles.append(profile)

                lines = {
                    "Module": version.full_version,
                    "Profiles": " ".join(profiles),
                    "Repo": version.repo.id,
                    "Summary": version.summary()
                }

                table = self.create_simple_table(lines)

                output += "{}\n".format(self.base.output.term.bold(nevra))
                output += "{}\n\n".format(table.toString())

        logger.info(output[:-2])
Esempio n. 2
0
 def profile_nevra_objects(self, profile):
     result = []
     rpms = set(self.rpms(profile))
     for nevra in self.artifacts():
         subj = Subject(nevra)
         nevra_obj = list(subj.get_nevra_possibilities(
             hawkey.FORM_NEVRA))[0]
         if nevra_obj.name not in rpms:
             continue
         result.append(nevra_obj)
     return result
Esempio n. 3
0
def get_source_packages(packages):
    """
    Return the unique set of source package names
    """
    source_packages = set()
    for pkg in packages:
        # Get the source RPM NEVRA without the trailing ".rpm"
        subject = Subject(pkg.rpm_sourcerpm[:-4])

        # Now get just the source RPM name
        nevras = subject.get_nevra_possibilities(forms=[hawkey.FORM_NEVRA])
        for nevra in nevras:
            source_packages.add(nevra.name)

    return source_packages
Esempio n. 4
0
    def nevra(self):
        """
        Takes a package filename and returns its NEVRA
        """
        filename = os.path.basename(self.path)
        if not filename.endswith(".rpm"):
            raise ValueError("File name doesn't end with '.rpm': {}".format(self.path))

        # @TODO: construct NEVRA from rpm header
        subject = Subject(filename)
        nevras = subject.get_nevra_possibilities(forms=[hawkey.FORM_NEVRA])
        for nevra in nevras:
            # For some reason `nevra.release` contains also the architecture
            return "{N}-{E}:{V}-{RA}".format(N=nevra.name, E=nevra.epoch or 0,
                                             V=nevra.version, RA=nevra.release)
Esempio n. 5
0
def splitFilename(filename):
    """
    Pass in a standard style rpm fullname

    Return a name, version, release, epoch, arch, e.g.::
        foo-1.0-1.i386.rpm returns foo, 1.0, 1, i386
    """

    if filename[-4:] == '.rpm':
        filename = filename[:-4]

    subject = Subject(filename)
    possible_nevra = list(subject.get_nevra_possibilities(forms=FORM_NEVRA))
    if possible_nevra:
        nevra = possible_nevra[0]
    else:
        return None, None, None, None, None

    return nevra.name, nevra.version, nevra.release, nevra.epoch, nevra.arch