Beispiel #1
0
	def _collectCopyFiles(self):
		
		files = []
		
		for entry in self.copyFiles:
			
			if not (isinstance(entry, str) or isinstance(entry, list)):
				print("Warning: invalid entry in copyFiles: \""+str(entry)+"\".")
				continue
			
			if isinstance(entry, str) or len(entry) == 1 or not entry[1]:
				
				src = entry if isinstance(entry, str) else entry[0]
				src = src.replace("\\", "/")
				
				if utils.is_absolute(src) and not src.startswith(self.projectPath):
					print("Warning: Src-only entries in copyFiles must be" \
						  " inside the project's directory. \""+src+"\"")
					continue
					
				if not utils.is_absolute(src):
					src = self.projectPath+"/"+src
					
				dst = src[len(self.projectPath)+1:]
				
				self._addEntryToCopyFiles(files, src, dst)
				
			elif isinstance(entry, list) and len(entry) == 2:
				
				src = compositor.completePath(entry[0], self.projectPath)
				dst = entry[1].replace("\\", "/")
				
				if not dst or utils.is_absolute(dst):
					if dst.startswith(self.projectPath):
						dst = dst[len(self.projectPath)+1:]
					else:
						print("Warning: Absolute filepath as dst in copyFiles \""+str(dst)+"\".")
						continue
						
				self._addEntryToCopyFiles(files, src, dst)
				
		self.copyFiles = files
Beispiel #2
0
    def read_resources( self, filename, baseuri ):
        """read_resources_rdf( filename, baseuri)
        Parse resources rdf file given by <filename>.
        Returns a dictionary with the resources as keys and a list of
        providers as values."""

        node = self.read_rdf( filename )
        resources = {} 
        try:
            main_node = node.children['rdf:Description']
            bag_node = main_node.children['rdf:Bag']
            for index in bag_node.children:
                res_node = bag_node.children[index]
                resource_list = []
                namenode = res_node.children['spi:name']
                resourcename = namenode.value
                provider_nodes = res_node.children['rdf:Bag']
                for key in provider_nodes.children:
                    provider_node = provider_nodes.children[key]
                    uri = provider_node.children['spi:uri'].value

                    if utils.is_absolute(uri):
                        pass
                    else:
                        uri = utils.normalize_uri( \
                                        os.path.join(baseuri, uri) )

                    name = provider_node.children["spi:name"].value
                    if provider_node.children.has_key("spi:epoch"):
                        epoch = provider_node.children["spi:epoch"].value
                    else:
                        epoch = None
                    version = provider_node.children["spi:version"].value
                    release = provider_node.children["spi:release"].value
                    resource_list.append( {"uri": uri,
                                           "epoch":epoch,
                                           "name": name,
                                           "version": version,
                                           "release": release,
                                           "resourcename": resourcename} )
                tmpdict = {}
                uniqlist = []
                for package in resource_list:
                    name = package['name']
                    if not tmpdict.has_key(name):
                        tmpdict[name] = True
                        uniqlist.append(package)
                resources[resourcename] = uniqlist

        except:
            raise

        return resources
Beispiel #3
0
    def read_latest( self, filename, baseuri ):
        topnode = self.read_rdf( filename )
        packagedict = {}
        
        if topnode.children == None:
            raise ex.spi_parse_error, filename
        try:
            firstnode = topnode.children["rdf:Description"]
            latest_nodes = firstnode.children[\
                "spi:package_list"].children["rdf:Bag"].children.values()
            protocol_regexp = re.compile("(^http:)|(^ftp:)|(^file:)")

            for node in latest_nodes:
                name = node.children["spi:name"].value
                if node.children.has_key("spi:epoch"):
                    epoch = node.children["spi:epoch"].value
                else:
                    epoch = None
                version = node.children["spi:version"].value
                release = node.children["spi:release"].value
                summary = node.children["spi:summary"].value
                resource = node.children["spi:resource"].attr["rdf:resource"]
                if utils.is_absolute(resource):
                    pass
                else:
                    resource = os.path.join(baseuri, resource)
                    resource = utils.normalize_uri(resource)

                obsoletes = []
                if node.children.has_key("spi:obsoletes"):
                    obs_node = node.children["spi:obsoletes"].children
                    if obs_node:
                        for li in obs_node["rdf:Bag"].children.values():
                            obsoletes.append(li.value)
                    
                packagedict[name] = {
                    "name": name,
                    "epoch":epoch,
                    "version": version,
                    "release": release,
                    "obsoletes": obsoletes,
                    "uri": resource,
                    "summary": summary}
        except KeyError:
            raise ex.spi_parse_error, filename
        except:
            raise

        return packagedict
Beispiel #4
0
    def read_resource( self, filename, baseuri ):
        """read_resource_rdf( filename, baseuri)
        Parse resource rdf file given by <filename>.
        Returns a list of dictionaries with the rdf-elements as keys."""

        node = self.read_rdf( filename )    
        try:
            resourcename = node.children["rdf:Description"].attr["rdf:ID"]
            provided_by_node = node.children["rdf:Description"].children[\
                "spi:provided_by"]
            alt_node = provided_by_node.children["rdf:Alt"]

            resource_list = []
            for resource_node in alt_node.children.values():
                uri = resource_node.children["spi:resource"].attr[\
                    "rdf:resource"]

                if utils.is_absolute(uri):
                    pass
                else:
                    uri = utils.normalize_uri( os.path.join(baseuri, uri) )

                name = resource_node.children["spi:name"].value
                if resource_node.children.has_key("spi:epoch"):
                    epoch = resource_node.children["spi:epoch"].value
                else:
                    epoch = None
                version = resource_node.children["spi:version"].value
                release = resource_node.children["spi:release"].value
                resource_list.append( {"uri": uri,
                                       "epoch":epoch,
                                       "name": name,
                                       "version": version,
                                       "release": release,
                                       "resourcename": resourcename} )

        except KeyError:
            raise ex.spi_parse_error, filename
        except:
            raise

        return resource_list
Beispiel #5
0
    def read_package_short( self, filename, baseuri ):
        node = self.read_rdf( filename )
        dict = {}
        
        if node.children == None:
            raise ex.spi_parse_error, filename
            
        try:
            uri = node.children["rdf:Description"].attr["rdf:about"]

            if utils.is_absolute(uri):
                    pass
            else:
                uri = utils.normalize_uri( os.path.join(baseuri, uri) )

            dict["uri"] = uri
            description = node.children["rdf:Description"].children
            if node.children.has_key("spi:epoch"):
                dict["epoch"] = description["spi:epoch"].value
            dict["name"] = description["spi:name"].value
            dict["version"] = description["spi:version"].value
            dict["release"] = description["spi:release"].value

            obsoletes = []
            if description.has_key("spi:obsoletes"):
                obs_node = description["spi:obsoletes"].children
                if obs_node:
                    for li in obs_node["rdf:Bag"].children.values():
                        obsoletes.append(li.value)

            dict["obsoletes"] = obsoletes

        except KeyError:
            raise ex.spi_parse_error, uri
        except:
            raise

        return dict
Beispiel #6
0
    def read_package( self, filename, baseuri ):
        """read_package_rdf(filename)
        Parse package rdf file given by <filename>. Returns a dictionary with
        the rdf-elements as keys."""
        node = self.read_rdf( filename )

        try:
            description_node = node.children["rdf:Description"]
            if description_node.children.has_key("spi:epoch"):
                epoch = description_node.children["spi:epoch"].value
            else:
                epoch = None
            if description_node.children.has_key("spi:serial"):
                serial = description_node.children["spi:serial"].value
            else:
                serial = None
            version = description_node.children["spi:version"].value
            release = description_node.children["spi:release"].value
            arch = description_node.children["spi:arch"].value
            opsys = description_node.children["spi:os"].value
            group = description_node.children["spi:group"].value
            name = description_node.children["spi:name"].value
            pkg_uri = description_node.attr["rdf:about"]
            desc = description_node.children["spi:description"].value
            summary = description_node.children["spi:summary"].value
            distribution = description_node.children["spi:distribution"].value
            vendor = description_node.children["spi:vendor"].value
            copyright = description_node.children["spi:copyright"].value
            build_date = description_node.children["spi:build_date"].value
            size = description_node.children["spi:size"].value
            md5sum = description_node.children["spi:md5sum"].value

            if( utils.is_absolute(pkg_uri) ):
                pass
            else:
                pkg_uri = utils.normalize_uri( os.path.join(baseuri, pkg_uri) )

            sig_uri = description_node.children["spi:signature"].attr[\
                "rdf:resource"]
            
            if( utils.is_absolute(sig_uri) ):
                pass
            else:
                sig_uri = utils.normalize_uri( os.path.join(baseuri, sig_uri) )

            #requires = [] # a list containing all requirements
            requires_node = description_node.children["spi:requires"]

            requires_list = []
            if requires_node.children != None:
                requires_node = node.children["rdf:Description"].children[\
                        "spi:requires"].children["rdf:Bag"]
                if requires_node.children != None:
                    for require_node in requires_node.children.values():
                        requirement = require_node.children[\
                            "spi:requirement"].value
                        resource_uri = require_node.children[\
                            "spi:resource"].attr["rdf:resource"]

                        if utils.is_absolute(resource_uri):
                            pass
                        else:
                            resource_uri = utils.normalize_uri(
                                os.path.join(baseuri, resource_uri) )

                        requirement = split_requirement( requirement )
                        requires_list.append( {"name": requirement[0],
                                               "operator": requirement[1],
                                               "epoch": requirement[2],
                                               "version": requirement[3],
                                               "release": requirement[4],
                                               "uri": resource_uri} )
            conflicts = []
            if description_node.children.has_key( "spi:conflicts" ):
                conflicts_node = description_node.children["spi:conflicts"]
                if conflicts_node.children:
                    nodes = conflicts_node.children[\
                        "rdf:Bag"].children.values()
                    for node in nodes:
                        conflict = split_requirement( node.value)
                        conflicts.append({"name": conflict[0],
                                         "flag": conflict[1],
                                         "epoch": conflict[2],
                                         "version": conflict[3],
                                         "release": conflict[4]})
                else:
                    if conflicts_node.value:
                        conflict = split_requirement( conflicts_node.value)
                        conflicts.append({"name": conflict[0],
                                         "flag": conflict[1],
                                         "epoch": conflict[2],
                                         "version": conflict[3],
                                         "release": conflict[4]})
        except KeyError:
            raise ex.spi_parse_error, filename
        except:
            raise
        return {"name":name,
                "epoch":epoch,
                "serial":serial,
                "version":version,
                "release":release,
                "group":group,
                "arch": arch,
                "os": opsys,
                "uri": pkg_uri,
                "signature": sig_uri,
                "requirements": requires_list,
                "conflicts": conflicts,
                "summary": summary,
                "description": desc,
                "distribution": distribution,
                "vendor": vendor,
                "copyright": copyright,
                "build_date": build_date,
                "size": size,
                "md5sum": md5sum,}