Esempio n. 1
0
    def __add_to_revdeps(self, package, revdeps):
        metadata_xml = os.path.join(self.package_path(package),
                                    ctx.const.metadata_xml)
        meta_doc = xmlext.parse(metadata_xml)

        try:
            pkg = xmlext.getNode(meta_doc, "Package")
        except:
            pkg = None

        if pkg is None:
            # If package info is broken or not available, skip it.
            ctx.ui.warning(
                _("Installation info for package \"{}\" is broken. "
                  "Reinstall it to fix this problem.").format(package))
            del self.installed_db[package]
            return

        deps = xmlext.getNode(pkg, 'RuntimeDependencies')
        if deps:
            for dep in xmlext.getTagByName(deps, 'Dependency'):
                revdep = revdeps.setdefault(xmlext.getNodeText(dep), {})
                revdep[package] = xmlext.toString(dep)

            for anydep in xmlext.getTagByName(deps, 'AnyDependency'):
                for dep in xmlext.getTagByName(anydep, 'Dependency'):
                    revdep = revdeps.setdefault(xmlext.getNodeText(dep), {})
                    revdep[package] = xmlext.toString(anydep)
Esempio n. 2
0
 def __generate_replaces(doc):
     replaces = []
     packages = xmlext.getTagByName(doc, "Package")
     for node in packages:
         if xmlext.getNodeText(node, "Replaces"):
             replaces.append(xmlext.getNodeText(node, "Name"))
     return replaces
Esempio n. 3
0
    def __generate_components(doc):
        groups = {}
        components = xmlext.getTagByName(doc, "Component")
        for comp in components:
            group = xmlext.getNodeText(comp, "Group")
            name = xmlext.getNodeText(comp, "Name")
            groups.setdefault(group, []).append(name)

        return groups
Esempio n. 4
0
    def __generate_packages(doc):
        components = {}
        packages = xmlext.getTagByName(doc, "Package")
        for pkg in packages:
            name = xmlext.getNodeText(pkg, "Name")
            partof = xmlext.getNodeText(pkg, "PartOf")
            components.setdefault(partof, []).append(name)

        return components
Esempio n. 5
0
    def __generate_sources(doc):
        components = {}
        specfile = xmlext.getTagByName(doc, "SpecFile")
        for spec in specfile:
            source = xmlext.getNode(spec, "Source")
            name = xmlext.getNodeText(source, "Name")
            partof = xmlext.getNodeText(source, "PartOf")
            components.setdefault(partof, []).append(name)

        return components
Esempio n. 6
0
    def _get_repos(self):
        repo_doc = self._get_doc()
        order = {}

        for r in xmlext.getTagByName(repo_doc, "Repo"):
            media = xmlext.getNodeText(r, "Media")
            name = xmlext.getNodeText(r, "Name")
            order.setdefault(media, []).append(name)

        return order
Esempio n. 7
0
    def get_status(self, repo_name):
        repo_doc = self._get_doc()
        for r in xmlext.getTagByName(repo_doc, "Repo"):
            if xmlext.getNodeText(r, "Name") == repo_name:
                status_node = xmlext.getNode(r, "Status")
                if status_node:
                    status = xmlext.getNodeText(status_node)
                    if status in ["active", "inactive"]:
                        return status

        return "inactive"
Esempio n. 8
0
    def __generate_revdeps(doc):
        revdeps = {}
        for node in xmlext.getTagByName(doc, "Package"):
            name = xmlext.getNodeText(node, 'Name')
            deps = xmlext.getNode(node, 'RuntimeDependencies')
            if deps:
                for dep in xmlext.getTagByName(deps, "Dependency"):
                    revdeps.setdefault(xmlext.getNodeText(dep), set()).add(
                        (name, xmlext.toString(dep)))

        return revdeps
Esempio n. 9
0
 def _set_i18n(tag, inst):
     try:
         for summary in xmlext.getTagByName(tag, "Summary"):
             inst.summary[xmlext.getNodeAttribute(
                 summary, "xml:lang")] = xmlext.getNodeText(summary)
         for desc in xmlext.getTagByName(tag, "Description"):
             inst.description[xmlext.getNodeAttribute(
                 desc, "xml:lang")] = xmlext.getNodeText(desc)
     except AttributeError as e:
         raise Error(
             _("translations.xml file is badly formed.: {}").format(e))
Esempio n. 10
0
    def __generate_revdeps(doc):
        revdeps = {}

        for spec in xmlext.getTagByName(doc, "SpecFile"):
            src = xmlext.getNode(spec, "Source")
            name = xmlext.getNodeText(src, "Name")
            deps = xmlext.getNode(src, "BuildDependencies")
            if deps:
                for dep in xmlext.getTagByName(deps, "Dependency"):
                    revdeps.setdefault(xmlext.getNodeText(dep), set()).add(
                        (name, xmlext.toString(dep)))

        return revdeps
Esempio n. 11
0
    def get_isa_packages(isa):
        repodb = inary.db.repodb.RepoDB()

        packages = set()
        for repo in repodb.list_repos():
            doc = repodb.get_repo_doc(repo)
            for package in xmlext.getTagByName(doc, "Package"):
                if xmlext.getNodeText(package, "IsA"):
                    for node in xmlext.getTagByName(package, "IsA"):
                        if xmlext.getNodeText(node) == isa:
                            packages.add(xmlext.getNodeText(package, "Name"))

        return list(packages)
Esempio n. 12
0
    def __generate_sources(doc):
        sources = {}
        pkgstosrc = {}
        for spec in xmlext.getTagByName(doc, "SpecFile"):
            src = xmlext.getNode(spec, "Source")
            src_name = xmlext.getNodeText(src, "Name")
            compressed_data = gzip.zlib.compress(
                xmlext.toString(spec).encode('utf-8'))
            sources[src_name] = compressed_data

            for package in xmlext.getTagByName(spec, "Package"):
                pkgstosrc[xmlext.getNodeText(package, "Name")] = src_name

        return sources, pkgstosrc
Esempio n. 13
0
    def read_translations(self, path):
        if not os.path.exists(path):
            return

        doc = xmlext.parse(path)

        if xmlext.getNodeText(xmlext.getNode(doc, "Source"),
                              "Name") == self.source.name:
            # Set source package translations
            self._set_i18n(xmlext.getNode(doc, "Source"), self.source)

        for pak in xmlext.getTagByName(doc, "Package"):
            for inst in self.packages:
                if inst.name == xmlext.getNodeText(pak, "Name"):
                    self._set_i18n(pak, inst)
                    break
Esempio n. 14
0
    def remove(self, repo_name):
        repo_doc = self._get_doc()
        for r in xmlext.getChildElts(repo_doc):
            if xmlext.getNodeText(r, "Name") == repo_name:
                xmlext.removeChild(r, repo_doc)

        self._update(repo_doc)
Esempio n. 15
0
    def get_rev_deps(self, name, repo=None):
        try:
            rvdb = self.rvdb.get_item(name, repo)
        except BaseException:  # FIXME: what exception could we catch here, replace with that.
            return []

        rev_deps = []

        for pkg, dep in rvdb:
            node = xmlext.parseString(dep)
            dependency = inary.analyzer.dependency.Dependency()
            dependency.package = xmlext.getNodeText(node)

            if xmlext.getAttributeList(node):
                if xmlext.getNodeAttribute(node, "version"):
                    dependency.__dict__["version"] = xmlext.getNodeAttribute(
                        node, "version")
                elif xmlext.getNodeAttribute(node, "release"):
                    dependency.__dict__["release"] = xmlext.getNodeAttribute(
                        node, "release")
                else:
                    pass  # FIXME: ugly
            rev_deps.append((pkg, dependency))

        return rev_deps
Esempio n. 16
0
    def __get_last_date(meta_doc):
        history = xmlext.getNode(meta_doc, 'History')
        update = xmlext.getNode(history, 'Update')

        date = xmlext.getNodeText(update, 'Date')

        return date
Esempio n. 17
0
def domodules(filepath):
    doc = xmlext.parse(filepath)
    for item in xmlext.getAllNodes("File"):
        path = xmlext.getNodeText(item, "Path")
        if path.startswith("lib/modules/"):
            kernelVersion = path.split("/")[2]
            subprocess.call(["/sbin/depmod", "-a", kernelVersion])
            return
Esempio n. 18
0
    def __generate_groups(doc):
        groups = {}
        group = xmlext.getTagByName(doc, "Group")
        for gr in group:
            name = xmlext.getNodeText(gr, "Name")
            groups[name] = xmlext.toString(gr)

        return groups
Esempio n. 19
0
    def __generate_components(doc):
        components = {}
        component = xmlext.getTagByName(doc, "Component")
        for comp in component:
            name = xmlext.getNodeText(comp, "Name")
            components[name] = xmlext.toString(comp)

        return components
Esempio n. 20
0
    def __get_version(meta_doc):
        history = xmlext.getNode(meta_doc, 'History')
        update = xmlext.getNode(history, 'Update')

        version = xmlext.getNodeText(update, 'Version')
        release = xmlext.getNodeAttribute(update, 'release')

        return version, release, None
Esempio n. 21
0
    def __generate_packages(doc):
        pdict = {}

        for x in xmlext.getTagByName(doc, "Package"):
            name = xmlext.getNodeText(x, "Name")
            compressed_data = gzip.zlib.compress(
                xmlext.toString(x).encode('utf-8'))
            pdict[name] = compressed_data
        return pdict
Esempio n. 22
0
    def __generate_sources(doc):
        pdict = {}

        for x in xmlext.getTagByName(doc, "SpecFile"):
            source = xmlext.getNode(x, "Source")
            name = xmlext.getNodeText(source, "Name")
            compressed_data = gzip.zlib.compress(
                xmlext.toString(x).encode('utf-8'))
            pdict[name] = compressed_data
        return pdict
Esempio n. 23
0
    def __generate_obsoletes(doc):
        distribution = xmlext.getNode(doc, "Distribution")
        obsoletes = distribution and xmlext.getNode(distribution, "Obsoletes")
        src_repo = xmlext.getNode(doc, "SpecFile") is not None

        if not obsoletes or src_repo:
            return []
        return [
            xmlext.getNodeText(x)
            for x in xmlext.getTagByName(obsoletes, "Package")
        ]
Esempio n. 24
0
    def set_status(self, repo_name, status):
        repo_doc = self._get_doc()
        for r in xmlext.getTagByName(repo_doc, "Repo"):
            if xmlext.getNodeText(r, "Name") == repo_name:
                status_node = xmlext.getNode(r, "Status")
                if status_node:
                    xmlext.removeChild(status_node, r)
                    xmlext.addText(r, "Status", status)
                else:
                    xmlext.addText(r, "Status", status)

        self._update(repo_doc)
Esempio n. 25
0
    def __make_dependency(depStr):

        node = xmlext.parseString(depStr)

        dependency = inary.analyzer.dependency.Dependency()
        dependency.package = xmlext.getNodeText(node)

        if xmlext.getAttributeList(node):
            if xmlext.getNodeAttribute(node, "version"):
                dependency.__dict__["version"] = xmlext.getNodeAttribute(
                    node, "version")
            elif xmlext.getNodeAttribute(node, "release"):
                dependency.__dict__["release"] = xmlext.getNodeAttribute(
                    node, "release")
            else:
                pass  #FIXME: ugly
        return dependency
Esempio n. 26
0
def doinfo(filepath, remove=False):
    # install-info is broken with i18n :(
    os.environ["LC_ALL"] = "C"

    doc = xmlext.parse(filepath)
    for item in xmlext.getAllNodes(doc, "File"):
        path = xmlext.getNodeText(item, "Path")
        if path.startswith("usr/share/info") and path.endswith(
            (".info", ".info.gz")):
            if remove:
                subprocess.call([
                    "install-info", "--delete",
                    "/%s" % path, "/usr/share/info/dir"
                ])
            else:
                subprocess.call(
                    ["install-info",
                     "/%s" % path, "/usr/share/info/dir"])
Esempio n. 27
0
 def decode(self, node, errs, where=""):
     # flags, tag name, instance attribute
     assert self.tag != ''
     nodes = xmlext.getAllNodes(node, self.tag)
     if not nodes:
         if self.req == mandatory:
             errs.append(where + ': ' +
                         _("At least one '{}' tag should have local text."
                           ).format(self.tag))
     else:
         for node in nodes:
             lang = xmlext.getNodeAttribute(node, 'xml:lang')
             c = xmlext.getNodeText(node)
             if not c:
                 errs.append(where + ': ' +
                             _("'{0}' language of tag '{1}' is empty."
                               ).format(lang, self.tag))
             # FIXME: check for dups and 'en'
             if not lang:
                 lang = 'en'
             self[lang] = str(c)
Esempio n. 28
0
 def __get_install_tar_hash(meta_doc):
     package = xmlext.getNode(meta_doc, 'Package')
     hash = xmlext.getNodeText(package, 'InstallTarHash')
     return hash
Esempio n. 29
0
    def __get_distro_release(meta_doc):
        distro = xmlext.getNodeText(meta_doc, 'Distribution')
        release = xmlext.getNodeText(meta_doc, 'DistributionRelease')

        return distro, release
Esempio n. 30
0
    def __get_summary(meta_doc):
        summary = xmlext.getNodeText(meta_doc, 'Summary')

        return summary