Browse code

Fixed OSS scripts generation to handle macros like kernel-release

Change-Id: I9d2fb5cfdbcecdaa6ca1e0a8fe05237e04659fcd
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1526
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: suezzelur <anishs@vmware.com>

dthaluru authored on 2016/10/18 08:49:16
Showing 4 changed files
... ...
@@ -18,15 +18,18 @@ class SerializableSpecObject(object):
18 18
         self.checksums={}
19 19
         self.listPatches=[]
20 20
         self.securityHardening=""
21
+        self.url=""
22
+        self.sourceurl=""
23
+        self.license=""
21 24
 
22 25
 class SerializableSpecObjectsUtils(object):
23
-    
26
+
24 27
     def __init__(self,logPath):
25 28
         self.mapSerializableSpecObjects={}
26 29
         self.mapPackageToSpec={}
27 30
         self.logger=Logger.getLogger("Serializable Spec objects", logPath )
28 31
         self.userDefinedMacros={}
29
-    
32
+
30 33
     def readSpecsAndConvertToSerializableObjects(self,specFilesPath):
31 34
         listSpecFiles=[]
32 35
         self.getListSpecFiles(listSpecFiles,specFilesPath)
... ...
@@ -47,19 +50,22 @@ class SerializableSpecObjectsUtils(object):
47 47
             specObj.listPatches=spec.getPatchNames()
48 48
             specObj.securityHardening=spec.getSecurityHardeningOption()
49 49
             specObj.isCheckAvailable=spec.isCheckAvailable()
50
+            specObj.license=spec.getLicense()
51
+            specObj.url=spec.getURL()
52
+            specObj.sourceurl=spec.getSourceURL()
50 53
             for specPkg in specObj.listPackages:
51 54
 	    	if specPkg in self.mapPackageToSpec:
52 55
 		    existingObj = self.mapSerializableSpecObjects[self.mapPackageToSpec[specPkg]]
53 56
 		    if self.compareVersions(existingObj,specObj) == 1:
54 57
 			skipUpdating = True
55
-			break;			
58
+			break;
56 59
             	specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg)
57 60
             	self.mapPackageToSpec[specPkg]=specName
58 61
                 if spec.getIsRPMPackage(specPkg):
59 62
                     specObj.listRPMPackages.append(specPkg)
60 63
 	    if skipUpdating == False:
61 64
                 self.mapSerializableSpecObjects[specName]=specObj
62
-    
65
+
63 66
     def getListSpecFiles(self,listSpecFiles,path):
64 67
         for dirEntry in os.listdir(path):
65 68
             dirEntryPath = os.path.join(path, dirEntry)
... ...
@@ -67,15 +73,15 @@ class SerializableSpecObjectsUtils(object):
67 67
                 listSpecFiles.append(dirEntryPath)
68 68
             elif os.path.isdir(dirEntryPath):
69 69
                 self.getListSpecFiles(listSpecFiles,dirEntryPath)
70
-    
70
+
71 71
     def getBuildRequiresForPackage(self, package):
72 72
         specName=self.getSpecName(package)
73 73
         return self.mapSerializableSpecObjects[specName].buildRequirePackages
74
-        
74
+
75 75
     def getRequiresAllForPackage(self, package):
76 76
         specName=self.getSpecName(package)
77 77
         return self.mapSerializableSpecObjects[specName].installRequiresAllPackages
78
-        
78
+
79 79
     def getRequiresForPackage(self, package):
80 80
         specName=self.getSpecName(package)
81 81
         if self.mapSerializableSpecObjects[specName].installRequiresPackages.has_key(package):
... ...
@@ -110,15 +116,15 @@ class SerializableSpecObjectsUtils(object):
110 110
     def getRelease(self, package):
111 111
         specName=self.getSpecName(package)
112 112
         return self.processData(self.mapSerializableSpecObjects[specName].release)
113
-        
113
+
114 114
     def getVersion(self, package):
115 115
         specName=self.getSpecName(package)
116 116
         return self.mapSerializableSpecObjects[specName].version
117
-        
117
+
118 118
     def getSpecFile(self, package):
119 119
         specName=self.getSpecName(package)
120 120
         return self.mapSerializableSpecObjects[specName].specFile
121
-        
121
+
122 122
     def getPatches(self, package):
123 123
         specName=self.getSpecName(package)
124 124
         return self.mapSerializableSpecObjects[specName].listPatches
... ...
@@ -126,7 +132,7 @@ class SerializableSpecObjectsUtils(object):
126 126
     def getSources(self, package):
127 127
         specName=self.getSpecName(package)
128 128
         return self.mapSerializableSpecObjects[specName].listSources
129
-        
129
+
130 130
     def getSHA1(self, package, source):
131 131
         specName=self.getSpecName(package)
132 132
         return self.mapSerializableSpecObjects[specName].checksums.get(source)
... ...
@@ -154,7 +160,7 @@ class SerializableSpecObjectsUtils(object):
154 154
 	else:
155 155
 	    if int(self.getReleaseNum(existingObj.release)) > int(self.getReleaseNum(newObject.release)):
156 156
 		return 1;
157
-	    else: 
157
+	    else:
158 158
 	     	return -1;
159 159
 
160 160
     def getSpecName(self,package):
... ...
@@ -180,6 +186,30 @@ class SerializableSpecObjectsUtils(object):
180 180
         specName=self.getSpecName(package)
181 181
         return self.mapSerializableSpecObjects[specName].isCheckAvailable
182 182
 
183
+    def getListSpecs(self):
184
+        return self.mapSerializableSpecObjects.keys()
185
+
186
+    def getURL(self, package):
187
+        specName=self.getSpecName(package)
188
+        url = self.mapSerializableSpecObjects[specName].url
189
+        if url is None:
190
+            return None
191
+        return self.processData(url)
192
+
193
+    def getSourceURL(self, package):
194
+        specName=self.getSpecName(package)
195
+        sourceurl = self.mapSerializableSpecObjects[specName].sourceurl
196
+        if sourceurl is None:
197
+            return None
198
+        return self.processData(sourceurl)
199
+
200
+    def getLicense(self, package):
201
+        specName=self.getSpecName(package)
202
+        license = self.mapSerializableSpecObjects[specName].license
203
+        if license is None:
204
+            return None
205
+        return self.processData(license)
206
+
183 207
     def printAllObjects(self):
184 208
         listSpecs=self.mapSerializableSpecObjects.keys()
185 209
         for spec in listSpecs:
... ...
@@ -13,8 +13,8 @@ class SpecParser(object):
13 13
         self.packages={}
14 14
         self.specAdditionalContent=""
15 15
         self.globalSecurityHardening=""
16
-        
17
-    
16
+
17
+
18 18
     def readPkgNameFromPackageMacro(self,data,basePkgName=None):
19 19
         data=" ".join(data.split())
20 20
         pkgHeaderName=data.split(" ")
... ...
@@ -33,7 +33,7 @@ class SpecParser(object):
33 33
         if pkgName is None:
34 34
             return True, basePkgName
35 35
         return True, pkgName
36
-    
36
+
37 37
     def parseSpecFile(self,specfile):
38 38
         self.createDefaultPackage()
39 39
         currentPkg="default"
... ...
@@ -75,11 +75,11 @@ class SpecParser(object):
75 75
                 self.specAdditionalContent+=line+"\n"
76 76
             i=i+1
77 77
         specFile.close()
78
-    
78
+
79 79
     def createDefaultPackage(self):
80 80
         pkg = Package()
81 81
         self.packages["default"]=pkg
82
-    
82
+
83 83
     def readMacroFromFile(self,currentPos,lines):
84 84
         macro = rpmMacro()
85 85
         line = lines[currentPos]
... ...
@@ -96,7 +96,7 @@ class SpecParser(object):
96 96
 
97 97
         if currentPos+1 < len(lines) and self.isMacro(lines[currentPos+1]):
98 98
             return macro,currentPos
99
-            
99
+
100 100
         for j in range(currentPos+1,endPos):
101 101
             content = lines[j]
102 102
             if j+1 < endPos and self.isMacro(lines[j+1]):
... ...
@@ -104,7 +104,7 @@ class SpecParser(object):
104 104
             macro.content += content +'\n'
105 105
             macro.endposition=j
106 106
         return macro,endPos
107
-        
107
+
108 108
 
109 109
     def updateMacro(self,macro):
110 110
         if macro.macroName == "%clean":
... ...
@@ -126,15 +126,15 @@ class SpecParser(object):
126 126
             self.checkMacro=macro
127 127
             return True
128 128
         return False
129
-            
129
+
130 130
     def isMacro(self,line):
131 131
         return self.isPackageMacro(line) or self.isSpecMacro(line)
132
-    
132
+
133 133
     def isSpecMacro(self,line):
134 134
         if re.search('^'+'%clean',line) :
135 135
             return True
136 136
         elif re.search('^'+'%prep',line) :
137
-            return True            
137
+            return True
138 138
         elif re.search('^'+'%build',line) :
139 139
             return True
140 140
         elif re.search('^'+'%install',line) :
... ...
@@ -144,7 +144,7 @@ class SpecParser(object):
144 144
         elif re.search('^'+'%check',line) :
145 145
             return True
146 146
         return False
147
-    
147
+
148 148
     def isPackageMacro(self,line):
149 149
         line=line.strip()
150 150
 
... ...
@@ -159,7 +159,7 @@ class SpecParser(object):
159 159
         elif re.search('^'+'%package',line) :
160 160
             return True
161 161
         return False
162
-    
162
+
163 163
     def isPackageHeaders(self,line):
164 164
         if re.search('^'+'summary:',line,flags=re.IGNORECASE) :
165 165
             return True
... ...
@@ -243,7 +243,7 @@ class SpecParser(object):
243 243
                         compare="gt"
244 244
                     elif listContents[i+1] == "=":
245 245
                         compare="eq"
246
-                    
246
+
247 247
                 if compare is not None:
248 248
                     dpkg.package=listContents[i]
249 249
                     dpkg.compare=compare
... ...
@@ -310,7 +310,7 @@ class SpecParser(object):
310 310
                 pkg.buildrequires.extend(dpkg)
311 311
             if headerName == 'buildprovides':
312 312
                 pkg.buildprovides.extend(dpkg)
313
-                    
313
+
314 314
             return True
315 315
         return False
316 316
 
... ...
@@ -3,19 +3,19 @@ from StringUtils import StringUtils
3 3
 import os
4 4
 
5 5
 class Specutils(object):
6
-    
6
+
7 7
     def __init__(self,specfile):
8 8
         self.specfile=""
9 9
         self.spec = SpecParser()
10 10
         if self.isSpecFile(specfile):
11 11
             self.specfile=specfile
12 12
             self.spec.parseSpecFile(self.specfile)
13
-    
13
+
14 14
     def isSpecFile(self,specfile):
15 15
         if os.path.isfile(specfile) and specfile[-5:] == ".spec":
16 16
             return True
17 17
         return False
18
-    
18
+
19 19
     def getSourceNames(self):
20 20
         sourceNames=[]
21 21
         strUtils = StringUtils()
... ...
@@ -26,7 +26,7 @@ class Specutils(object):
26 26
             sourceName=strUtils.getFileNameFromURL(source)
27 27
             sourceNames.append(sourceName)
28 28
         return sourceNames
29
-    
29
+
30 30
     def getChecksums(self):
31 31
         pkg = self.spec.packages.get('default')
32 32
         return pkg.checksums
... ...
@@ -34,7 +34,7 @@ class Specutils(object):
34 34
     def getChecksumForSource(self,source):
35 35
         pkg = self.spec.packages.get('default')
36 36
         return pkg.checksums.get(source)
37
-    
37
+
38 38
     def getSourceURLs(self):
39 39
         sourceNames=[]
40 40
         strUtils = StringUtils()
... ...
@@ -55,14 +55,14 @@ class Specutils(object):
55 55
             patchName=strUtils.getFileNameFromURL(patch)
56 56
             patchNames.append(patchName)
57 57
         return patchNames
58
-    
58
+
59 59
     def getPackageNames(self):
60 60
         packageNames=[]
61 61
         for key in self.spec.packages.keys():
62 62
             pkg = self.spec.packages.get(key)
63 63
             packageNames.append(pkg.name)
64 64
         return packageNames
65
-    
65
+
66 66
     def getIsRPMPackage(self,pkgName):
67 67
         defaultPkgName=self.spec.packages['default'].name
68 68
         if pkgName == defaultPkgName:
... ...
@@ -108,23 +108,29 @@ class Specutils(object):
108 108
                 break
109 109
         return release
110 110
 
111
-    def getLicense(self, pkgName):
111
+    def getLicense(self):
112 112
         licenseInfo=None
113
-        for key in self.spec.packages.keys():
114
-            pkg = self.spec.packages.get(key)
115
-            if pkg.name == pkgName:
116
-                licenseInfo=pkg.license
117
-                break
118
-        return licenseInfo
113
+        pkg = self.spec.packages.get('default')
114
+        if pkg is None:
115
+            return None
116
+        return pkg.license
119 117
 
120
-    def getURL(self, pkgName):
121
-        url=None
122
-        for key in self.spec.packages.keys():
123
-            pkg = self.spec.packages.get(key)
124
-            if pkg.name == pkgName:
125
-                url=pkg.URL
126
-                break
127
-        return url
118
+    def getURL(self):
119
+        pkg = self.spec.packages.get('default')
120
+        if pkg is None:
121
+            return None
122
+        return pkg.URL
123
+
124
+    def getSourceURL(self):
125
+        pkg = self.spec.packages.get('default')
126
+        if pkg is None:
127
+            return None
128
+        if len(pkg.sources) == 0:
129
+            return None
130
+        sourceURL = pkg.sources[0]
131
+        if sourceURL.startswith("http") or sourceURL.startswith("ftp"):
132
+            return sourceURL
133
+        return None
128 134
 
129 135
     def getBuildArch(self, pkgName):
130 136
         buildArch="x86_64"
... ...
@@ -134,7 +140,7 @@ class Specutils(object):
134 134
                 buildArch=pkg.buildarch
135 135
                 break
136 136
         return buildArch
137
-    
137
+
138 138
     def getRequiresAllPackages(self):
139 139
         depedentPackages=[]
140 140
         for key in self.spec.packages.keys():
... ...
@@ -147,7 +153,7 @@ class Specutils(object):
147 147
             if pkgName in depedentPackages:
148 148
                 depedentPackages.remove(pkgName)
149 149
         return depedentPackages
150
-    
150
+
151 151
     def getBuildRequiresAllPackages(self):
152 152
         depedentPackages=[]
153 153
         for key in self.spec.packages.keys():
... ...
@@ -160,8 +166,8 @@ class Specutils(object):
160 160
             if pkgName in depedentPackages:
161 161
                 depedentPackages.remove(pkgName)
162 162
         return depedentPackages
163
-    
164
-    
163
+
164
+
165 165
     def getRequires(self,pkgName):
166 166
         dependentPackages=[]
167 167
         for key in self.spec.packages.keys():
... ...
@@ -179,7 +185,7 @@ class Specutils(object):
179 179
                 for dpkg in pkg.buildrequires:
180 180
                     dependentPackages.append(dpkg.package)
181 181
         return dependentPackages
182
-        
182
+
183 183
     def getProvides(self,packageName):
184 184
         depedentPackages=[]
185 185
         defaultPkgName=self.spec.packages['default'].name
... ...
@@ -194,19 +200,19 @@ class Specutils(object):
194 194
         else:
195 195
             print "package not found"
196 196
         return depedentPackages
197
-    
197
+
198 198
     def getVersion(self):
199 199
         pkg = self.spec.packages.get('default')
200 200
         return pkg.version
201
-    
201
+
202 202
     def getRelease(self):
203 203
         pkg = self.spec.packages.get('default')
204 204
         return pkg.release
205
-    
205
+
206 206
     def getBasePackageName(self):
207 207
         pkg = self.spec.packages.get('default')
208 208
         return pkg.name
209
-        
209
+
210 210
     def getSecurityHardeningOption(self):
211 211
         return self.spec.globalSecurityHardening
212 212
 
... ...
@@ -221,14 +227,14 @@ def main():
221 221
     print "packages",spec.getPackageNames()
222 222
     print "packages",spec.getRPMNames()
223 223
     print "sources",spec.getSourceNames()
224
-    print "patches",spec.getPatchNames()  
224
+    print "patches",spec.getPatchNames()
225 225
     print "requires",spec.getRequires('libltdl-devel')
226 226
     print "requires",spec.getRequires('libtool')
227
-    
228
-    print "provides",spec.getProvides('libtool')  
227
+
228
+    print "provides",spec.getProvides('libtool')
229 229
     print "all-requires",spec.getRequiresAllPackages()
230 230
     print "all-build-requires",spec.getBuildRequiresAllPackages()
231
-    
231
+
232 232
 if __name__ == '__main__':
233 233
     main()
234
-    
234
+
... ...
@@ -5,7 +5,7 @@ import os.path
5 5
 from CommandUtils import CommandUtils
6 6
 from Logger import Logger
7 7
 from constants import constants
8
-from PackageManager import PackageManager 
8
+from PackageManager import PackageManager
9 9
 import json
10 10
 import sys
11 11
 from SpecUtils import Specutils
... ...
@@ -46,7 +46,7 @@ def main():
46 46
         cmdUtils.runCommandInShell("mkdir -p "+options.logPath)
47 47
 
48 48
     logger=Logger.getLogger(options.logPath+"/Main")
49
-    
49
+
50 50
     errorFlag=False
51 51
     package = None
52 52
     pkgInfoJsonFile=options.pkgInfoFile
... ...
@@ -65,39 +65,39 @@ def main():
65 65
     if not os.path.isdir(options.publishRPMSPath+"/noarch"):
66 66
         logger.error("Given RPMS Path is missing noarch sub-directory:"+options.publishRPMSPath)
67 67
         errorFlag = True
68
-    
68
+
69 69
     if not os.path.isfile(options.inputJSONFile) and not options.installPackage:
70 70
         logger.error("Given JSON File is not a file:"+options.inputJSONFile)
71
-        errorFlag = True    
71
+        errorFlag = True
72 72
     if not os.path.isfile(options.pkgBuildOptionFile):
73 73
         logger.warning("Given JSON File is not a file:"+options.pkgBuildOptionFile)
74
-        
74
+
75 75
     if options.inputRPMSPath is not None and not os.path.isdir(options.inputRPMSPath):
76 76
         logger.error("Given input RPMS Path is not a directory:"+options.publishRPMSPath)
77 77
         errorFlag = True
78
-        
78
+
79 79
     if options.installPackage :
80 80
         if len(args) != 1:
81 81
             logger.error("Please provide package name")
82 82
             errorFlag = True
83 83
         else:
84 84
             package=args[0]
85
-        
85
+
86 86
     if errorFlag:
87 87
         logger.error("Found some errors. Please fix input options and re-run it.")
88 88
         return False
89
-    
90
-    
89
+
90
+
91 91
     if not os.path.isdir(options.rpmPath):
92 92
         cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/x86_64")
93 93
         cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/noarch")
94 94
 
95 95
     if not os.path.isdir(options.sourceRpmPath):
96 96
         cmdUtils.runCommandInShell("mkdir -p "+options.sourceRpmPath)
97
-    
97
+
98 98
     if not os.path.isdir(options.buildRootPath):
99 99
         cmdUtils.runCommandInShell("mkdir -p "+options.buildRootPath)
100
-    
100
+
101 101
     logger.info("Source Path :"+options.sourcePath)
102 102
     logger.info("Spec Path :" + options.specPath)
103 103
     logger.info("Rpm Path :" + options.rpmPath)
... ...
@@ -109,7 +109,7 @@ def main():
109 109
         logger.info("JSON File :" + options.inputJSONFile)
110 110
     else:
111 111
         logger.info("Package to build:"+package)
112
-    
112
+
113 113
     listBuildOptionPackages = get_packages_with_build_options(options.pkgBuildOptionFile)
114 114
 
115 115
     try:
... ...
@@ -121,11 +121,11 @@ def main():
121 121
         elif package == "sources_list":
122 122
             if not os.path.isdir("../../stage/yaml_sources"):
123 123
                 cmdUtils.runCommandInShell("mkdir -p ../../stage/yaml_sources")
124
-            buildSourcesList(options.specPath,"../../stage/yaml_sources", options.buildRootPath+"/../",logger)
124
+            buildSourcesList('../../stage/yaml_sources',logger)
125 125
         elif package == "srpms_list":
126 126
             if not os.path.isdir("../../stage/yaml_srpms"):
127 127
                 cmdUtils.runCommandInShell("mkdir -p ../../stage/yaml_srpms")
128
-            buildSRPMList(options.specPath,options.sourceRpmPath,"../../stage/yaml_srpms",logger)
128
+            buildSRPMList(options.sourceRpmPath,"../../stage/yaml_srpms",logger)
129 129
         elif options.toolChainStage == "stage1":
130 130
             pkgManager = PackageManager()
131 131
             pkgManager.buildToolChain()
... ...
@@ -144,7 +144,7 @@ def main():
144 144
         sys.exit(1)
145 145
 
146 146
     logger.info("Writing Package info to the file:"+pkgInfoJsonFile)
147
-    SourcePackageInfo.writePkgListToFile(pkgInfoJsonFile)   
147
+    SourcePackageInfo.writePkgListToFile(pkgInfoJsonFile)
148 148
     sys.exit(0)
149 149
 
150 150
 def buildToolChain(buildThreads):
... ...
@@ -154,127 +154,108 @@ def buildToolChain(buildThreads):
154 154
 def buildPackagesList(specPath, csvFilename):
155 155
     csvFile = open(csvFilename, "w")
156 156
     csvFile.write("Package,Version,License,URL,Sources,Patches\n")
157
-    lst = os.listdir(specPath)
158
-    lst.sort()
159
-    for dirEntry in lst:
160
-        specDir = os.path.join(specPath, dirEntry)
161
-        if os.path.isdir(specDir):
162
-            for specEntry in os.listdir(specDir):
163
-                specFile = os.path.join(specDir, specEntry)
164
-                if os.path.isfile(specFile) and specFile.endswith(".spec"):
165
-                    spec=Specutils(specFile)
166
-                    name=spec.getBasePackageName()
167
-                    version=spec.getRPMVersion(name)
168
-                    license=spec.getLicense(name)
169
-                    url=spec.getURL(name)
170
-                    ss=spec.getSourceURLs()
171
-                    sources=""
172
-                    for s in ss:
173
-                        if (s.startswith("http") or s.startswith("ftp")):
174
-                            if sources != "":
175
-                                sources += " "
176
-                            sources += s
177
-                    patches=""
178
-                    ps=spec.getPatchNames()
179
-                    for p in ps:
180
-                        if patches != "":
181
-                            patches += " "
182
-                        patches += p
183
-                    csvFile.write(name+","+version+","+license+","+url+","+sources+","+patches+"\n")
157
+    listSpecs =  constants.specData.getListSpecs()
158
+    listSpecs.sort()
159
+    for spec in listSpecs:
160
+        name = spec
161
+        version = constants.specData.getVersion(spec)
162
+        license = constants.specData.getLicense(spec)
163
+        listPatches = constants.specData.getPatches(spec)
164
+        url = constants.specData.getURL(spec)
165
+        listSourceNames = constants.specData.getSources(spec)
166
+        sources = ""
167
+        patches = ""
168
+        if listPatches is not None:
169
+            patches = " ".join(listPatches)
170
+        if listSourceNames is not None:
171
+            sources = " ".join(listSourceNames)
172
+        csvFile.write(name+","+version+","+license+","+url+","+sources+","+patches+"\n")
184 173
     csvFile.close()
185 174
 
186
-def buildSourcesList(specPath,sourcePath, yamlDir, logger, singleFile=True):
175
+def buildSourcesList(yamlDir, logger, singleFile=True):
187 176
     strUtils = StringUtils()
188 177
     if singleFile:
189
-        yamlFile = open(yamlDir+"sources_list.yaml", "w")
190
-    lst = os.listdir(specPath)
191
-    lst.sort()
178
+        yamlFile = open(yamlDir+"/sources_list.yaml", "w")
179
+    listSpecs =  constants.specData.getListSpecs()
180
+    listSpecs.sort()
192 181
     import PullSources
193
-    for dirEntry in lst:
194
-        specDir = os.path.join(specPath, dirEntry)
195
-        if os.path.isdir(specDir):
196
-            for specEntry in os.listdir(specDir):
197
-                specFile = os.path.join(specDir, specEntry)
198
-                if os.path.isfile(specFile) and specFile.endswith(".spec"):
199
-                    spec=Specutils(specFile)
200
-                    modified = len(spec.getPatchNames()) > 0
201
-                    listSourceURLs=spec.getSourceURLs()
202
-                    ossname = spec.getBasePackageName()
203
-                    ossversion = spec.getVersion()
204
-                    url = None
205
-                    listSourceNames = spec.getSourceNames()
206
-                    sourceName = None
207
-                    if len(listSourceNames) >0:
208
-                        sourceName=listSourceNames[0]
209
-                        sha1 = spec.getChecksumForSource(sourceName)                       
210
-                        if sha1 is not None:
211
-                            PullSources.get(sourceName, sha1, sourcePath, constants.pullsourcesConfig)
212
-
213
-                    if len(listSourceURLs) > 0:
214
-                        sourceURL = listSourceURLs[0]
215
-                        if sourceURL.startswith("http") or sourceURL.startswith("ftp"):
216
-                            url = sourceURL;
217
-                        else:
218
-                            url=spec.getURL(ossname)
219
-                    if not singleFile:
220
-                        yamlFile = open(yamlDir+"/"+ossname+"-"+ossversion+".yaml", "w")
221
-                    yamlFile.write("vmwsource:"+ossname+":"+ossversion+":\n")
222
-                    yamlFile.write("  repository: VMWsource\n")
223
-                    yamlFile.write("  name: '"+ossname+"'\n")
224
-                    yamlFile.write("  version: '"+ossversion+"'\n")
225
-                    yamlFile.write("  url: "+str(url)+"\n")
226
-                    yamlFile.write("  license: UNKNOWN\n")
227
-                    if sourceName is not None:
228
-                        yamlFile.write("  vmwsource-distribution: "+str(sourceName)+"\n")
229
-                    if modified:
230
-                        yamlFile.write("  modified: true\n")
231
-                    yamlFile.write("\n")
232
-                    if not singleFile:
233
-                        yamlFile.close()
182
+    for spec in listSpecs:
183
+        ossname = spec
184
+        ossversion = constants.specData.getVersion(spec)
185
+        modified = False
186
+        listPatches = constants.specData.getPatches(spec)
187
+        if listPatches is not None and len(listPatches) > 0 :
188
+            modified = True
189
+        url = constants.specData.getSourceURL(spec)
190
+        if url is None:
191
+            url = constants.specData.getURL(spec)
192
+
193
+        sourceName = None
194
+        listSourceNames = constants.specData.getSources(spec)
195
+        if len(listSourceNames) >0:
196
+            sourceName=listSourceNames[0]
197
+            sha1 = constants.specData.getSHA1(spec, sourceName)
198
+            if sha1 is not None:
199
+                PullSources.get(sourceName, sha1, yamlDir, constants.pullsourcesConfig)
200
+
201
+        if not singleFile:
202
+            yamlFile = open(yamlDir+"/"+ossname+"-"+ossversion+".yaml", "w")
203
+        yamlFile.write("vmwsource:"+ossname+":"+ossversion+":\n")
204
+        yamlFile.write("  repository: VMWsource\n")
205
+        yamlFile.write("  name: '"+ossname+"'\n")
206
+        yamlFile.write("  version: '"+ossversion+"'\n")
207
+        yamlFile.write("  url: "+str(url)+"\n")
208
+        yamlFile.write("  license: UNKNOWN\n")
209
+        if sourceName is not None:
210
+            yamlFile.write("  vmwsource-distribution: "+str(sourceName)+"\n")
211
+        if modified:
212
+            yamlFile.write("  modified: true\n")
213
+        yamlFile.write("\n")
214
+        if not singleFile:
215
+            yamlFile.close()
216
+
234 217
     if singleFile:
235 218
         yamlFile.close()
236 219
     logger.info("Generated source yaml files for all packages")
237 220
 
238
-def buildSRPMList(specPath,srpmPath, yamlDir, logger, singleFile=True):
221
+def buildSRPMList(srpmPath, yamlDir, logger, singleFile=True):
239 222
     strUtils = StringUtils()
240 223
     if singleFile:
241
-        yamlFile = open(yamlDir+"srpm_list.yaml", "w")
242
-    lst = os.listdir(specPath)
243
-    lst.sort()
224
+        yamlFile = open(yamlDir+"/srpm_list.yaml", "w")
225
+    listSpecs =  constants.specData.getListSpecs()
226
+    listSpecs.sort()
244 227
     cmdUtils = CommandUtils()
245
-    for dirEntry in lst:
246
-        specDir = os.path.join(specPath, dirEntry)
247
-        if os.path.isdir(specDir):
248
-            for specEntry in os.listdir(specDir):
249
-                specFile = os.path.join(specDir, specEntry)
250
-                if os.path.isfile(specFile) and specFile.endswith(".spec"):
251
-                    spec=Specutils(specFile)
252
-                    ossname = spec.getBasePackageName()
253
-                    ossversion = spec.getVersion()
254
-                    ossrelease = spec.getRelease()
255
-                    listFoundSRPMFiles = cmdUtils.findFile(ossname+"-"+ossversion+"-"+ossrelease+".src.rpm",srpmPath)
256
-                    srpmName = None
257
-                    if len(listFoundSRPMFiles) == 1:
258
-                        srpmFullPath = listFoundSRPMFiles[0];
259
-                        srpmName = os.path.basename(srpmFullPath)
260
-                        cpcmd = "cp "+ srpmFullPath +" "+yamlDir+"/"
261
-                        returnVal = cmdUtils.runCommandInShell(cpcmd)
262
-                        if not returnVal:
263
-                            logger.error("Copy SRPM File is failed for package:"+ossname)
264
-                    else:
265
-                         logger.error("SRPM file is not found:" +ossname)
266
-                    if not singleFile:
267
-                        yamlFile = open(yamlDir+"/"+ossname+"-"+ossversion+"-"+ossrelease+".yaml", "w")
268
-                    yamlFile.write("baseos:"+ossname+":"+ossversion+"-"+ossrelease+":\n")
269
-                    yamlFile.write("  repository: BaseOS\n")
270
-                    yamlFile.write("  name: '"+ossname+"'\n")
271
-                    yamlFile.write("  version: '"+ossversion+"-"+ossrelease+"'\n")
272
-                    yamlFile.write("  baseos-style: rpm\n")
273
-                    yamlFile.write("  baseos-source: '"+str(srpmName)+"'\n")
274
-                    yamlFile.write("  baseos-osname: 'photon'\n")
275
-                    yamlFile.write("\n")
276
-                    if not singleFile:
277
-                        yamlFile.close()
228
+    for spec in listSpecs:
229
+        ossname = spec
230
+        ossversion = constants.specData.getVersion(spec)
231
+        ossrelease = constants.specData.getRelease(spec)
232
+
233
+        listFoundSRPMFiles = cmdUtils.findFile(ossname+"-"+ossversion+"-"+ossrelease+".src.rpm",srpmPath)
234
+        srpmName = None
235
+        if len(listFoundSRPMFiles) == 1:
236
+            srpmFullPath = listFoundSRPMFiles[0];
237
+            srpmName = os.path.basename(srpmFullPath)
238
+            cpcmd = "cp "+ srpmFullPath +" "+yamlDir+"/"
239
+            returnVal = cmdUtils.runCommandInShell(cpcmd)
240
+            if not returnVal:
241
+                logger.error("Copy SRPM File is failed for package:"+ossname)
242
+        else:
243
+             logger.error("SRPM file is not found:" +ossname)
244
+
245
+        if not singleFile:
246
+            yamlFile = open(yamlDir+"/"+ossname+"-"+ossversion+"-"+ossrelease+".yaml", "w")
247
+
248
+        yamlFile.write("baseos:"+ossname+":"+ossversion+"-"+ossrelease+":\n")
249
+        yamlFile.write("  repository: BaseOS\n")
250
+        yamlFile.write("  name: '"+ossname+"'\n")
251
+        yamlFile.write("  version: '"+ossversion+"-"+ossrelease+"'\n")
252
+        yamlFile.write("  baseos-style: rpm\n")
253
+        yamlFile.write("  baseos-source: '"+str(srpmName)+"'\n")
254
+        yamlFile.write("  baseos-osname: 'photon'\n")
255
+        yamlFile.write("\n")
256
+        if not singleFile:
257
+            yamlFile.close()
258
+
278 259
     if singleFile:
279 260
         yamlFile.close()
280 261
     logger.info("Generated srpm yaml files for all packages")
... ...
@@ -313,7 +294,7 @@ def get_packages_with_build_options(pkg_build_options_file):
313 313
             packages.append(str(p))
314 314
 
315 315
     return packages
316
-    
316
+
317 317
 def get_all_package_names(build_install_option):
318 318
     base_path = os.path.dirname(build_install_option)
319 319
     jsonData = open(build_install_option)