Esempio n. 1
0
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()
Esempio n. 2
0
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()
Esempio n. 3
0
def buildSourcesList(specPath, sourcePath, yamlDir, logger, singleFile=True):
    strUtils = StringUtils()
    if singleFile:
        yamlFile = open(yamlDir + "sources_list.yaml", "w")
    lst = os.listdir(specPath)
    lst.sort()
    import PullSources
    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)
                    modified = len(spec.getPatchNames()) > 0
                    listSourceURLs = spec.getSourceURLs()
                    ossname = spec.getBasePackageName()
                    ossversion = spec.getVersion()
                    url = None
                    listSourceNames = spec.getSourceNames()
                    sourceName = None
                    if len(listSourceNames) > 0:
                        sourceName = listSourceNames[0]
                        sha1 = spec.getChecksumForSource(sourceName)
                        if sha1 is not None:
                            PullSources.get(sourceName, sha1, sourcePath,
                                            constants.pullsourcesConfig)

                    if len(listSourceURLs) > 0:
                        sourceURL = listSourceURLs[0]
                        if sourceURL.startswith(
                                "http") or sourceURL.startswith("ftp"):
                            url = sourceURL
                        else:
                            url = spec.getURL(ossname)
                    if not singleFile:
                        yamlFile = open(
                            yamlDir + "/" + ossname + "-" + ossversion +
                            ".yaml", "w")
                    yamlFile.write("vmwsource:" + ossname + ":" + ossversion +
                                   ":\n")
                    yamlFile.write("  repository: VMWsource\n")
                    yamlFile.write("  name: '" + ossname + "'\n")
                    yamlFile.write("  version: '" + ossversion + "'\n")
                    yamlFile.write("  url: " + str(url) + "\n")
                    yamlFile.write("  license: UNKNOWN\n")
                    if sourceName is not None:
                        yamlFile.write("  vmwsource-distribution: " +
                                       str(sourceName) + "\n")
                    if modified:
                        yamlFile.write("  modified: true\n")
                    yamlFile.write("\n")
                    if not singleFile:
                        yamlFile.close()
    if singleFile:
        yamlFile.close()
    logger.info("Generated source yaml files for all packages")
Esempio n. 4
0
def buildSourcesList(specPath,sourcePath, yamlDir, logger, singleFile=False):
    strUtils = StringUtils()
    if singleFile:
        yamlFile = open(yamlDir+"sources_list.yaml", "w")
    lst = os.listdir(specPath)
    lst.sort()
    import PullSources
    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)
                    modified = len(spec.getPatchNames()) > 0
                    listSourceURLs=spec.getSourceURLs()
                    ossname = spec.getBasePackageName()
                    ossversion = spec.getVersion()
                    url = None
                    listSourceNames = spec.getSourceNames()
                    sourceName = None
                    if len(listSourceNames) >0:
                        sourceName=listSourceNames[0]
                        sha1 = spec.getChecksumForSource(sourceName)                       
                        if sha1 is not None:
                            PullSources.get(sourceName, sha1, sourcePath, constants.pullsourcesConfig)

                    if len(listSourceURLs) > 0:
                        sourceURL = listSourceURLs[0]
                        if sourceURL.startswith("http") or sourceURL.startswith("ftp"):
                            url = sourceURL;
                        else:
                            url=spec.getURL(ossname)
                    if not singleFile:
                        yamlFile = open(yamlDir+"/"+ossname+"-"+ossversion+".yaml", "w")
                    yamlFile.write("vmwsource:"+ossname+":"+ossversion+":\n")
                    yamlFile.write("  repository: VMWsource\n")
                    yamlFile.write("  name: '"+ossname+"'\n")
                    yamlFile.write("  version: '"+ossversion+"'\n")
                    yamlFile.write("  url: "+str(url)+"\n")
                    yamlFile.write("  license: UNKNOWN\n")
                    if sourceName is not None:
                        yamlFile.write("  vmwsource-distribution: "+str(sourceName)+"\n")
                    if modified:
                        yamlFile.write("  modified: true\n")
                    yamlFile.write("\n")
                    if not singleFile:
                        yamlFile.close()
    if singleFile:
        yamlFile.close()
    logger.info("Generated source yaml files for all packages")
Esempio n. 5
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)
Esempio n. 6
0
def buildSourcesList(specPath, yamlDir, singleFile=False):
    strUtils = StringUtils()
    if singleFile:
        yamlFile = open(yamlDir + "sources_list.yaml", "w")
    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)
                    modified = len(spec.getPatchNames()) > 0
                    listSourceURLs = spec.getSourceURLs()
                    ossname = spec.getBasePackageName()
                    ossversion = spec.getVersion()
                    url = None
                    if len(listSourceURLs) > 0:
                        sourceURL = listSourceURLs[0]
                        if sourceURL.startswith(
                                "http") or sourceURL.startswith("ftp"):
                            url = sourceURL
                        else:
                            url = spec.getURL(ossname)
                    if not singleFile:
                        yamlFile = open(
                            yamlDir + ossname + "-" + ossversion + ".yaml",
                            "w")
                    yamlFile.write("vmwsource:" + ossname + ":" + ossversion +
                                   ":\n")
                    yamlFile.write("  repository: VMWsource\n")
                    yamlFile.write("  name: '" + ossname + "'\n")
                    yamlFile.write("  version: '" + ossversion + "'\n")
                    yamlFile.write("  url: " + str(url) + "\n")
                    yamlFile.write("  license: UNKNOWN\n")
                    if modified:
                        yamlFile.write("  modified: true\n")
                    yamlFile.write("\n")
                    if not singleFile:
                        yamlFile.close()
    if singleFile:
        yamlFile.close()
Esempio n. 7
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.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 buildSourcesList(specPath, yamlDir, singleFile=False):
    strUtils = StringUtils()
    if singleFile:
        yamlFile = open(yamlDir+"sources_list.yaml", "w")
    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)
                    modified = len(spec.getPatchNames()) > 0
                    listSourceURLs=spec.getSourceURLs()
                    ossname = spec.getBasePackageName()
                    ossversion = spec.getVersion()
                    url = None
                    if len(listSourceURLs) > 0:
                        sourceURL = listSourceURLs[0]
                        if sourceURL.startswith("http") or sourceURL.startswith("ftp"):
                            url = sourceURL;
                        else:
                            url=spec.getURL(ossname)
                    if not singleFile:
                        yamlFile = open(yamlDir+ossname+"-"+ossversion+".yaml", "w")
                    yamlFile.write("vmwsource:"+ossname+":"+ossversion+":\n")
                    yamlFile.write("  repository: VMWsource\n")
                    yamlFile.write("  name: '"+ossname+"'\n")
                    yamlFile.write("  version: '"+ossversion+"'\n")
                    yamlFile.write("  url: "+str(url)+"\n")
                    yamlFile.write("  license: UNKNOWN\n")
                    if modified:
                        yamlFile.write("  modified: true\n")
                    yamlFile.write("\n")
                    if not singleFile:
                        yamlFile.close()
    if singleFile:
        yamlFile.close()
Esempio n. 9
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)
Esempio n. 10
0
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
Esempio n. 11
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.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