예제 #1
0
    def add_aliases(self, artifact, aliases):
        """
        Adds alias artifacts for given main artifact

        artifact -- main Artifact for which aliases are being provided
        aliases -- list of alternate Artifact representations
        """
        artifact.validate(allow_backref=False)
        wild_groups = self.__count_wildcard_groups(artifact.get_rpm_str())
        main = artifact.get_xml_element(root_element_name="artifactGlob")
        elems = [main]
        aelem = Element("aliases")
        for alias in aliases:
            alias.validate(allow_empty=False, allow_wildcards=False)
            backrefs = self.__count_backreferences(alias.get_rpm_str())
            if backrefs > wild_groups:
                raise ArtifactValidationException("Number of backrefenreces "
                                                  "is higher than wildcard "
                                                  "groups.")
            aelem.append(alias.get_xml_element(root_element_name="alias"))
        elems.append(aelem)
        self.__add_config("artifactManagement", "rule", content=elems)
예제 #2
0
    def add_compat_versions(self, artifact, versions):
        """
        Change where on filesystem given artifact is installed

        artifact -- Artifact to be modified
        versions -- list of compat versions for given artifact
        """
        artifact.validate(allow_backref=False)
        wild_groups = self.__count_wildcard_groups(artifact.get_rpm_str(artifact.version))
        main = artifact.get_xml_element(root_element_name="artifactGlob")
        elems = [main]
        velem = Element("versions")
        for version in versions:
            backrefs = self.__count_backreferences(version)
            if backrefs > wild_groups:
                raise ArtifactValidationException("Number of backrefenreces "
                                                  "is higher than wildcard "
                                                  "groups.")
            ve = SubElement(velem, "version")
            ve.text = version
        elems.append(velem)
        self.__add_config("artifactManagement", "rule", content=elems)
예제 #3
0
    def add_package_mapping(self, artifact, package, optional=False):
        """
        Change which package given artifact belongs to

        artifact -- Artifact to be modified
        package -- subpackage name where artifact belongs
        """
        artifact.validate(allow_backref=False)
        wild_groups = self.__count_wildcard_groups(artifact.get_rpm_str())
        main = artifact.get_xml_element(root_element_name="artifactGlob")
        backrefs = self.__count_backreferences(package)
        if backrefs > wild_groups:
            raise ArtifactValidationException("Number of backrefenreces "
                                              "is higher than wildcard "
                                              "groups.")
        elems = [main]
        if optional:
            opt = Element("optional")
            opt.text = "true"
            elems.append(opt)
        target = Element("targetPackage")
        target.text = package
        elems.append(target)
        self.__add_config("artifactManagement", "rule", content=elems)
예제 #4
0
    def add_file_mapping(self, artifact, paths):
        """
        Change where on filesystem given artifact is installed

        artifact -- Artifact to be modified
        paths -- list of paths for given artifact
        """
        artifact.validate(allow_backref=False)
        wild_groups = self.__count_wildcard_groups(artifact.get_rpm_str())
        main = artifact.get_xml_element(root_element_name="artifactGlob")
        elems = [main]
        felem = Element("files")
        if not [path for path in paths if not os.path.isabs(path)]:
            raise XMvnConfigException("At least one path must be relative")
        for path in paths:
            backrefs = self.__count_backreferences(path)
            if backrefs > wild_groups:
                raise ArtifactValidationException("Number of backrefenreces "
                                                  "is higher than wildcard "
                                                  "groups.")
            pe = SubElement(felem, "file")
            pe.text = path
        elems.append(felem)
        self.__add_config("artifactManagement", "rule", content=elems)