def buildPackagesList(specPath, csvFilename): csvFile = open(csvFilename, "w") csvFile.write("Package,Version,License,URL,Sources,Patches\n") lst = os.listdir(specPath) lst.sort() for dirEntry in lst: specDir = os.path.join(specPath, dirEntry) if os.path.isdir(specDir): for specEntry in os.listdir(specDir): specFile = os.path.join(specDir, specEntry) if os.path.isfile(specFile) and specFile.endswith(".spec"): spec = Specutils(specFile) name = spec.getBasePackageName() version = spec.getRPMVersion(name) license = spec.getLicense(name) url = spec.getURL(name) ss = spec.getSourceURLs() sources = "" for s in ss: if (s.startswith("http") or s.startswith("ftp")): if sources != "": sources += " " sources += s patches = "" ps = spec.getPatchNames() for p in ps: if patches != "": patches += " " patches += p csvFile.write(name + "," + version + "," + license + "," + url + "," + sources + "," + patches + "\n") csvFile.close()
def buildPackagesList(specPath, csvFilename): csvFile = open(csvFilename, "w") csvFile.write("Package,Version,License,URL,Sources,Patches\n") lst = os.listdir(specPath) lst.sort() for dirEntry in lst: specDir = os.path.join(specPath, dirEntry) if os.path.isdir(specDir): for specEntry in os.listdir(specDir): specFile = os.path.join(specDir, specEntry) if os.path.isfile(specFile) and specFile.endswith(".spec"): spec=Specutils(specFile) name=spec.getBasePackageName() version=spec.getRPMVersion(name) license=spec.getLicense(name) url=spec.getURL(name) ss=spec.getSourceURLs() sources="" for s in ss: if (s.startswith("http") or s.startswith("ftp")): if sources != "": sources += " " sources += s patches="" ps=spec.getPatchNames() for p in ps: if patches != "": patches += " " patches += p csvFile.write(name+","+version+","+license+","+url+","+sources+","+patches+"\n") csvFile.close()
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)
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.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: 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 not skipUpdating: self.mapSerializableSpecObjects[specName] = specObj
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)
def buildPackageList(specPath): print "Package,Version,License,URL,Sources,Patches" lst = os.listdir(specPath) lst.sort() for dirEntry in lst: specDir = os.path.join(specPath, dirEntry) if os.path.isdir(specDir): for specEntry in os.listdir(specDir): specFile = os.path.join(specDir, specEntry) if os.path.isfile(specFile) and specFile.endswith(".spec"): spec = Specutils(specFile) name = spec.getPackageNames()[0] version = spec.getRPMVersion(name) license = spec.getLicense(name) url = spec.getURL(name) source = spec.getSourceURLs()[0] patches = "" ps = spec.getPatchNames() for p in ps: if patches != "": patches += " " patches += p print name + "," + version + "," + license + "," + url + "," + source + "," + patches
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.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: 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 not skipUpdating: self.mapSerializableSpecObjects[specName] = specObj