Beispiel #1
0
 def readSpecsAndConvertToSerializableObjects(self, specFilesPath):
     listSpecFiles = []
     self.getListSpecFiles(listSpecFiles, specFilesPath)
     for specFile in listSpecFiles:
         skipUpdating = False
         spec = Specutils(specFile)
         specName = spec.getBasePackageName()
         specObj = SerializableSpecObject()
         specObj.name = specName
         specObj.buildRequirePackages = spec.getBuildRequiresAllPackages()
         specObj.installRequiresAllPackages = spec.getRequiresAllPackages()
         specObj.listPackages = spec.getPackageNames()
         specObj.specFile = specFile
         specObj.version = spec.getVersion()
         specObj.release = spec.getRelease()
         specObj.listSources = spec.getSourceNames()
         specObj.checksums = spec.getChecksums()
         specObj.listPatches = spec.getPatchNames()
         specObj.securityHardening = spec.getSecurityHardeningOption()
         for specPkg in specObj.listPackages:
             if specPkg in self.mapPackageToSpec:
                 existingObj = self.mapSerializableSpecObjects[
                     self.mapPackageToSpec[specPkg]]
                 if self.compareVersions(existingObj, specObj) == 1:
                     skipUpdating = True
                     break
             specObj.installRequiresPackages[specPkg] = spec.getRequires(
                 specPkg)
             self.mapPackageToSpec[specPkg] = specName
         if skipUpdating == False:
             self.mapSerializableSpecObjects[specName] = specObj
Beispiel #2
0
    def readSpecsAndConvertToSerializableObjects(self,specFilesPath):
        listSpecFiles=[]
        self.getListSpecFiles(listSpecFiles,specFilesPath)
        for specFile in listSpecFiles:
            skipUpdating = False
            spec=Specutils(specFile)
            specName=spec.getBasePackageName()
            specObj=SerializableSpecObject()
            specObj.name=specName
            specObj.buildRequirePackages=spec.getBuildRequiresAllPackages()
            specObj.installRequiresAllPackages=spec.getRequiresAllPackages()
            specObj.listPackages=spec.getPackageNames()
            specObj.specFile=specFile
            specObj.version=spec.getVersion()
            specObj.release=spec.getRelease()
            specObj.listSources=spec.getSourceNames()
            specObj.checksums=spec.getChecksums()
            specObj.listPatches=spec.getPatchNames()
            specObj.securityHardening=spec.getSecurityHardeningOption()
            for specPkg in specObj.listPackages:
	    	if specPkg in self.mapPackageToSpec:
		    existingObj = self.mapSerializableSpecObjects[self.mapPackageToSpec[specPkg]]
		    if self.compareVersions(existingObj,specObj) == 1:
			skipUpdating = True
			break;			
            	specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg)
            	self.mapPackageToSpec[specPkg]=specName
                if spec.getIsRPMPackage(specPkg):
                    specObj.listRPMPackages.append(specPkg)
	    if skipUpdating == False:
                self.mapSerializableSpecObjects[specName]=specObj
Beispiel #3
0
 def readSpecsAndConvertToSerializableObjects(self, specFilesPath):
     listSpecFiles = []
     self.getListSpecFiles(listSpecFiles, specFilesPath)
     for specFile in listSpecFiles:
         spec = Specutils(specFile)
         specName = spec.getBasePackageName()
         specObj = SpecObject()
         specObj.name = specName
         specObj.buildRequiresAllPackages = spec.getBuildRequiresAllPackages(
         )
         specObj.extraBuildRequires = spec.getExtraBuildRequires()
         specObj.installRequiresAllPackages = spec.getRequiresAllPackages()
         specObj.checkBuildRequirePackages = spec.getCheckBuildRequiresAllPackages(
         )
         specObj.listPackages = spec.getPackageNames()
         specObj.specFile = specFile
         specObj.version = spec.getVersion()
         specObj.release = spec.getRelease()
         specObj.listSources = spec.getSourceNames()
         specObj.checksums = spec.getChecksums()
         specObj.specDefs = spec.getDefinitions()
         specObj.listPatches = spec.getPatchNames()
         specObj.securityHardening = spec.getSecurityHardeningOption()
         specObj.isCheckAvailable = spec.isCheckAvailable()
         specObj.license = spec.getLicense()
         specObj.url = spec.getURL()
         specObj.sourceurl = spec.getSourceURL()
         for specPkg in specObj.listPackages:
             specObj.installRequiresPackages[specPkg] = spec.getRequires(
                 specPkg)
             specObj.buildarch[specPkg] = spec.getBuildArch(specPkg)
             # TODO add multiversioning support
             self.mapPackageToSpec[specPkg] = specName
             if spec.getIsRPMPackage(specPkg):
                 specObj.listRPMPackages.append(specPkg)
         if specName in self.mapSpecObjects:
             self.mapSpecObjects[specName].append(specObj)
         else:
             self.mapSpecObjects[specName] = [specObj]
         self.mapSpecFileNameToSpecObj[os.path.basename(specFile)] = specObj
     for key, value in self.mapSpecObjects.items():
         if len(value) > 1:
             self.mapSpecObjects[key] = sorted(
                 value, key=lambda x: self.compareVersions(x), reverse=True)
Beispiel #4
0
 def readSpecsAndConvertToSerializableObjects(self,specFilesPath):
     listSpecFiles=[]
     self.getListSpecFiles(listSpecFiles,specFilesPath)
     for specFile in listSpecFiles:
         spec=Specutils(specFile)
         specName=spec.getBasePackageName()
         specObj=SerializableSpecObject()
         specObj.name=specName
         specObj.buildRequirePackages=spec.getBuildRequiresAllPackages()
         specObj.installRequiresAllPackages=spec.getRequiresAllPackages()
         specObj.listPackages=spec.getPackageNames()
         specObj.specFile=specFile
         specObj.version=spec.getVersion()
         specObj.release=spec.getRelease()
         specObj.listSources=spec.getSourceNames()
         specObj.listPatches=spec.getPatchNames()
         specObj.securityHardening=spec.getSecurityHardeningOption()
         for specPkg in specObj.listPackages:
             specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg)
             self.mapPackageToSpec[specPkg]=specName
         self.mapSerializableSpecObjects[specName]=specObj
Beispiel #5
0
 def readSpecsAndConvertToSerializableObjects(self, specFilesPath):
     listSpecFiles = []
     self.getListSpecFiles(listSpecFiles, specFilesPath)
     for specFile in listSpecFiles:
         spec = Specutils(specFile)
         specName = spec.getBasePackageName()
         specObj = SerializableSpecObject()
         specObj.name = specName
         specObj.buildRequirePackages = spec.getBuildRequiresAllPackages()
         specObj.installRequiresAllPackages = spec.getRequiresAllPackages()
         specObj.listPackages = spec.getPackageNames()
         specObj.specFile = specFile
         specObj.version = spec.getVersion()
         specObj.release = spec.getRelease()
         specObj.listSources = spec.getSourceNames()
         specObj.listPatches = spec.getPatchNames()
         specObj.securityHardening = spec.getSecurityHardeningOption()
         for specPkg in specObj.listPackages:
             specObj.installRequiresPackages[specPkg] = spec.getRequires(
                 specPkg)
             self.mapPackageToSpec[specPkg] = specName
         self.mapSerializableSpecObjects[specName] = specObj
Beispiel #6
0
 def readSpecsAndConvertToSerializableObjects(self, specFilesPath):
     listSpecFiles = []
     self.getListSpecFiles(listSpecFiles, specFilesPath)
     for specFile in listSpecFiles:
         spec = Specutils(specFile)
         specName = spec.getBasePackageName()
         specObj = SpecObject()
         specObj.name = specName
         specObj.buildRequirePackages,specObj.specParseObjBuildRequirePackages = spec.getBuildRequiresAllPackages()
         specObj.installRequiresAllPackages,specObj.specParseObjInstallRequiresPackages = spec.getRequiresAllPackages()
         specObj.checkBuildRequirePackages,specObj.specParseObjCheckBuildRequirePackages = spec.getCheckBuildRequiresAllPackages()
         specObj.listPackages = spec.getPackageNames()
         specObj.specFile = specFile
         specObj.version = spec.getVersion()
         specObj.release = spec.getRelease()
         specObj.listSources = spec.getSourceNames()
         specObj.checksums = spec.getChecksums()
         specObj.specDefs = spec.getDefinitions()
         specObj.listPatches = spec.getPatchNames()
         specObj.securityHardening = spec.getSecurityHardeningOption()
         specObj.isCheckAvailable = spec.isCheckAvailable()
         specObj.license = spec.getLicense()
         specObj.url = spec.getURL()
         specObj.sourceurl = spec.getSourceURL()
         for specPkg in specObj.listPackages:
             specObj.installRequiresPackages[specPkg] = spec.getRequires(specPkg)
             self.mapPackageToSpec[specPkg] = specName
             if spec.getIsRPMPackage(specPkg):
                 specObj.listRPMPackages.append(specPkg)
         if specName in self.mapSpecObjects:
             self.mapSpecObjects[specName].append(specObj)
         else:
             self.mapSpecObjects[specName]=[specObj]
     for key, value in self.mapSpecObjects.items():
         if len(value) > 1:
             self.mapSpecObjects[key] = sorted(value,
                                               key=lambda x : self.compareVersions(x),
                                               reverse=True)
Beispiel #7
0
    def readSpecsAndConvertToSerializableObjects(self, specFilesPath,
                                                 inputType, inputValue,
                                                 displayOption):
        children = {}
        listSpecFiles = []
        whoNeedsList = []
        whoBuildDepSet = set()
        independentRPMS = [
        ]  # list of all RPMS not built from photon and that must be blindly copied.
        whoBuildDeps = {}
        allDeps = {}
        parent = {}
        depQue = Queue.Queue()
        packageFound = False
        self.getListSpecFiles(listSpecFiles, specFilesPath)
        for specFile in listSpecFiles:
            spec = Specutils(specFile)
            specName = spec.getBasePackageName()
            specObj = SerializableSpecObject()
            specObj.name = specName
            specObj.buildRequirePackages = spec.getBuildRequiresAllPackages()
            specObj.installRequiresAllPackages = spec.getRequiresAllPackages()
            specObj.listPackages = spec.getPackageNames()
            specObj.specFile = specFile
            specObj.version = spec.getVersion()
            specObj.release = spec.getRelease()
            specObj.listSources = spec.getSourceNames()
            specObj.listPatches = spec.getPatchNames()
            specObj.securityHardening = spec.getSecurityHardeningOption()
            for specPkg in specObj.listPackages:
                specObj.installRequiresPackages[specPkg] = spec.getRequires(
                    specPkg)
                if (
                        inputType == "pkg" and inputValue == specPkg
                ):  # all the first level dependencies to a dictionary and queue
                    packageFound = True
                    for depPkg in specObj.installRequiresPackages[specPkg]:
                        if False == allDeps.has_key(depPkg):
                            allDeps[depPkg] = 0
                            parent[depPkg] = ""
                            depQue.put(depPkg)
                elif (
                        inputType == "who-needs" and
                    (inputValue in specObj.installRequiresPackages[specPkg])):
                    whoNeedsList.append(specPkg)
                elif (inputType == "who-needs-build"):
                    for bdrq in specObj.buildRequirePackages:
                        if (whoBuildDeps.has_key(bdrq)):
                            whoBuildDeps[bdrq].add(specPkg)
                        else:
                            whoBuildDeps[bdrq] = set()
                            whoBuildDeps[bdrq].add(specPkg)
                    if (inputValue == specPkg):
                        packageFound = True
                        for depPkg in specObj.listPackages:
                            depQue.put(depPkg)

                self.mapPackageToSpec[specPkg] = specName
            self.mapSerializableSpecObjects[specName] = specObj

        # Generate dependencies for individual packages
        if (inputType == "pkg"):
            if (packageFound == True):
                self.findTotalRequires(allDeps, depQue, parent, displayOption)
            else:
                print "No spec file builds a package named", inputValue
                return

        # Generate dependencies for all packages in the given JSON input file
        elif (inputType == "json"):
            filePath = self.inputDataDir + "/" + inputValue
            data = self.get_all_package_names(filePath)
            for pkg in data:
                if False == allDeps.has_key(pkg):
                    spName = self.getSpecName(pkg)
                    if (spName != None):
                        allDeps[pkg] = 0
                        parent[pkg] = ""
                        depQue.put(pkg)
                        self.findTotalRequires(allDeps, depQue, parent,
                                               displayOption)
                    else:
                        independentRPMS.append(pkg)

        #Generating the list of packages that requires the given input package at install time
        elif (inputType == "who-needs"):
            print whoNeedsList
            return

        #Generating the list of packages that the modified package will affect at build time
        elif (inputType == "who-needs-build"):
            if (packageFound == True):
                self.findTotalWhoNeedsToBuild(depQue, whoBuildDeps,
                                              whoBuildDepSet, displayOption)
                print whoBuildDepSet
            else:
                print "No spec file builds a package named", inputValue
            return

        # construct the sorted list of all packages (sorted by dependency)
        sortedList = []
        for elem in sorted(allDeps.items(),
                           key=operator.itemgetter(1),
                           reverse=True):
            sortedList.append(elem[0])
        sortedList.extend(independentRPMS)

        # construct all children nodes
        if (displayOption == "tree"):
            for k, v in parent.iteritems():
                children.setdefault(v, []).append(k)
            if (inputType == "json"):
                print "Dependency Mappings for", inputValue, ":", "\n----------------------------------------------------", children
                print "----------------------------------------------------"
            if (children.has_key("")):
                for child in children[""]:
                    print child
                    self.printTree(allDeps, children, child, 1)
                for pkg in independentRPMS:
                    print pkg
                print "******************", len(
                    sortedList), "packages in total ******************"
            else:
                if (inputType == "pkg" and len(children) > 0):
                    print "cyclic dependency detected, mappings: \n", children

        # To display a flat list of all packages
        elif (displayOption == "list"):
            print sortedList

        # To generate a new JSON file based on given input json file
        elif (displayOption == "json" and inputType == "json"):
            d = {}
            d['packages'] = sortedList
            outFilePath = self.jsonFilesOutPath + inputValue
            with open(outFilePath, 'wb') as outfile:
                json.dump(d, outfile)
        return sortedList
Beispiel #8
0
	def readSpecsAndConvertToSerializableObjects(self, specFilesPath, inputType, inputValue, displayOption):
		children = {}
		listSpecFiles=[]
		whoNeedsList=[]
		independentRPMS=[] # list of all RPMS not built from photon and that must be blindly copied.
		allDeps={}
		parent={}
		depQue = Queue.Queue()
		packageFound = False
		self.getListSpecFiles(listSpecFiles,specFilesPath)
		for specFile in listSpecFiles:
			spec=Specutils(specFile)
			specName=spec.getBasePackageName()
			specObj=SerializableSpecObject()
			specObj.name=specName
			specObj.buildRequirePackages=spec.getBuildRequiresAllPackages()
			specObj.installRequiresAllPackages=spec.getRequiresAllPackages()
			specObj.listPackages=spec.getPackageNames()
			specObj.specFile=specFile
			specObj.version=spec.getVersion()
			specObj.release=spec.getRelease()
			specObj.listSources=spec.getSourceNames()
			specObj.listPatches=spec.getPatchNames()
			specObj.securityHardening=spec.getSecurityHardeningOption()
			for specPkg in specObj.listPackages:
				specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg)
				if (inputType == "pkg" and inputValue == specPkg): # all the first level dependencies to a dictionary and queue 
					packageFound = True
					for depPkg in specObj.installRequiresPackages[specPkg]:
						if False == allDeps.has_key(depPkg):
							allDeps[depPkg] = 0
							parent[depPkg] = ""
							depQue.put(depPkg)
				if (inputType == "who-needs" and (inputValue in specObj.installRequiresPackages[specPkg])):
					whoNeedsList.append(specPkg)
				self.mapPackageToSpec[specPkg]=specName
			self.mapSerializableSpecObjects[specName]=specObj		
	    
		# Generate dependencies for individual packages
		if (inputType == "pkg"):
			if (packageFound == True):
				self.findTotalRequires(allDeps, depQue, parent, displayOption)
			else:
				print "No spec file builds a package named",inputValue
				return

		# Generate dependencies for all packages in the given JSON input file
		elif (inputType == "json"):
			filePath = self.inputDataDir +"/"+ inputValue
			data = self.get_all_package_names(filePath)
			for pkg in data:
				if False == allDeps.has_key(pkg):
					spName = self.getSpecName(pkg)
					if(spName != None):			
						allDeps[pkg] = 0 
						parent[pkg] = ""
						depQue.put(pkg)
						self.findTotalRequires(allDeps, depQue, parent, displayOption)
					else:
						independentRPMS.append(pkg); 

		#Generating the list of packages that requires the given input package at install time
		elif (inputType == "who-needs"):
			print whoNeedsList
			return

		# construct the sorted list of all packages (sorted by dependency)
		sortedList = []
		for elem in sorted(allDeps.items(), key=operator.itemgetter(1), reverse=True):
			sortedList.append(elem[0])
		sortedList.extend(independentRPMS)

	    # construct all children nodes
		if (displayOption == "tree"):
			for k, v in parent.iteritems():
				children.setdefault(v, []).append(k)
			if(inputType == "json"):
				print "Dependency Mappings for", inputValue, ":", "\n----------------------------------------------------",children
				print "----------------------------------------------------"				
			if (children.has_key("")):
				for child in children[""]:
					print child
					self.printTree(allDeps, children, child, 1)
				for pkg in independentRPMS:
					print pkg
				print "******************",len(sortedList), "packages in total ******************"
			else:
				if (inputType == "pkg" and len(children) > 0):
					print "cyclic dependency detected, mappings: \n",children 

		# To display a flat list of all packages
		elif(displayOption == "list"):
			print sortedList

		# To generate a new JSON file based on given input json file
		elif(displayOption == "json" and inputType == "json"):
			d = {}
			d['packages'] = sortedList
			outFilePath = self.jsonFilesOutPath + inputValue
			with open(outFilePath, 'wb') as outfile:
				json.dump(d, outfile)		
Beispiel #9
0
    def readSpecsAndConvertToSerializableObjects(self, specFilesPath, inputType, inputValue, displayOption):
		children = {}
		listSpecFiles=[]
		whoNeedsList=[]
		allDeps={}
		parent={}
		depQue = Queue.Queue()
		packageFound = False
		self.getListSpecFiles(listSpecFiles,specFilesPath)
		for specFile in listSpecFiles:
			spec=Specutils(specFile)
			specName=spec.getBasePackageName()
			specObj=SerializableSpecObject()
			specObj.name=specName
			specObj.buildRequirePackages=spec.getBuildRequiresAllPackages()
			specObj.installRequiresAllPackages=spec.getRequiresAllPackages()
			specObj.listPackages=spec.getPackageNames()
			specObj.specFile=specFile
			specObj.version=spec.getVersion()
			specObj.release=spec.getRelease()
			specObj.listSources=spec.getSourceNames()
			specObj.listPatches=spec.getPatchNames()
			specObj.securityHardening=spec.getSecurityHardeningOption()
			for specPkg in specObj.listPackages:
				specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg)
				if( inputType == "pkg" and inputValue == specPkg): # all all the first level dependencies to a dictionary and queue 
				    packageFound = True
				    for depPkg in specObj.installRequiresPackages[specPkg]:
					if False == allDeps.has_key(depPkg):
								allDeps[depPkg] = 0
								parent[depPkg] = ""
								depQue.put(depPkg)
				if (inputType == "who-needs"):
					if (inputValue in specObj.installRequiresPackages[specPkg]):
						whoNeedsList.append(specPkg)
				self.mapPackageToSpec[specPkg]=specName
			self.mapSerializableSpecObjects[specName]=specObj		
		if (inputType == "pkg"):
			if (packageFound == True):
				self.findTotalRequires(allDeps, depQue, parent, displayOption)
			else:
				print "No spec file builds a package named",pkgName
  	  			return
		elif (inputType == "json"):
			filePath = self.inputDataDir +"/"+ inputValue
			data = self.get_all_package_names(filePath)
			#print data
			for pkg in data:
				if False == allDeps.has_key(pkg):
					allDeps[pkg] = 0 
					parent[pkg] = ""
					depQue.put(pkg)
					self.findTotalRequires(allDeps, depQue, parent, displayOption)
		elif (inputType == "who-needs"):
			print whoNeedsList
		# construct the sorted list of all packages (sorted by dependency)
		sortedList = []
		for elem in sorted(allDeps.items(), key=operator.itemgetter(1), reverse=True):
			sortedList.append(elem[0])
		# construct all children nodes
		if (displayOption == "tree"):
			#print "parent:" ,parent
			for k, v in parent.iteritems():
				children.setdefault(v, []).append(k)
			if(inputType == "json"):
				print "Dependency Mappings:\n", children
			if (children.has_key("")):
				for child in children[""]:
					print child
					self.printTree(allDeps, children, child, 1)
			else:
				if (inputType == "pkg" and len(children) > 0):
					print "cyclic dependency mappings: \n",children
		elif(displayOption == "list"):
			print sortedList
		elif(displayOption == "json" and inputType == "json"):
			d = {}
			d['packages'] = sortedList
			outFilePath = self.jsonFilesOutPath + inputValue
			with open(outFilePath, 'wb') as outfile:
    				json.dump(d, outfile)		
Beispiel #10
0
    def readSpecsAndConvertToSerializableObjects(self, specFilesPath, inputType, inputValue, displayOption):
		children = {}
		listSpecFiles=[]
		whoNeedsList=[]
		allDeps={}
		parent={}
		depQue = Queue.Queue()
		packageFound = False
		self.getListSpecFiles(listSpecFiles,specFilesPath)
		for specFile in listSpecFiles:
			spec=Specutils(specFile)
			specName=spec.getBasePackageName()
			specObj=SerializableSpecObject()
			specObj.name=specName
			specObj.buildRequirePackages=spec.getBuildRequiresAllPackages()
			specObj.installRequiresAllPackages=spec.getRequiresAllPackages()
			specObj.listPackages=spec.getPackageNames()
			specObj.specFile=specFile
			specObj.version=spec.getVersion()
			specObj.release=spec.getRelease()
			specObj.listSources=spec.getSourceNames()
			specObj.listPatches=spec.getPatchNames()
			specObj.securityHardening=spec.getSecurityHardeningOption()
			for specPkg in specObj.listPackages:
				specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg)
				if( inputType == "pkg" and inputValue == specPkg): # all all the first level dependencies to a dictionary and queue 
				    packageFound = True
				    for depPkg in specObj.installRequiresPackages[specPkg]:
					if False == allDeps.has_key(depPkg):
								allDeps[depPkg] = 0
								parent[depPkg] = ""
								depQue.put(depPkg)
				if (inputType == "who-needs"):
					if (inputValue in specObj.installRequiresPackages[specPkg]):
						whoNeedsList.append(specPkg)
				self.mapPackageToSpec[specPkg]=specName
			self.mapSerializableSpecObjects[specName]=specObj		
		if (inputType == "pkg"):
			if (packageFound == True):
				self.findTotalRequires(allDeps, depQue, parent, displayOption)
			else:
				print "No spec file builds a package named",inputValue
  	  			return
		elif (inputType == "json"):
			filePath = self.inputDataDir +"/"+ inputValue
			data = self.get_all_package_names(filePath)
			#print data
			for pkg in data:
				if False == allDeps.has_key(pkg):
					allDeps[pkg] = 0 
					parent[pkg] = ""
					depQue.put(pkg)
					self.findTotalRequires(allDeps, depQue, parent, displayOption)
		elif (inputType == "who-needs"):
			print whoNeedsList
		# construct the sorted list of all packages (sorted by dependency)
		sortedList = []
		for elem in sorted(allDeps.items(), key=operator.itemgetter(1), reverse=True):
			sortedList.append(elem[0])
		# construct all children nodes
		if (displayOption == "tree"):
			#print "parent:" ,parent
			for k, v in parent.iteritems():
				children.setdefault(v, []).append(k)
			if(inputType == "json"):
				print "Dependency Mappings:\n", children
			if (children.has_key("")):
				for child in children[""]:
					print child
					self.printTree(allDeps, children, child, 1)
			else:
				if (inputType == "pkg" and len(children) > 0):
					print "cyclic dependency mappings: \n",children
		elif(displayOption == "list"):
			print sortedList
		elif(displayOption == "json" and inputType == "json"):
			d = {}
			d['packages'] = sortedList
			outFilePath = self.jsonFilesOutPath + inputValue
			with open(outFilePath, 'wb') as outfile:
    				json.dump(d, outfile)