Change-Id: Idcec436b45123c42373be218c32fc7d17ae75097
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1543
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: suezzelur <anishs@vmware.com>
| ... | ... |
@@ -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) |
| ... | ... |
@@ -46,19 +49,22 @@ class SerializableSpecObjectsUtils(object): |
| 46 | 46 |
specObj.checksums=spec.getChecksums() |
| 47 | 47 |
specObj.listPatches=spec.getPatchNames() |
| 48 | 48 |
specObj.securityHardening=spec.getSecurityHardeningOption() |
| 49 |
+ specObj.license=spec.getLicense() |
|
| 50 |
+ specObj.url=spec.getURL() |
|
| 51 |
+ specObj.sourceurl=spec.getSourceURL() |
|
| 49 | 52 |
for specPkg in specObj.listPackages: |
| 50 | 53 |
if specPkg in self.mapPackageToSpec: |
| 51 | 54 |
existingObj = self.mapSerializableSpecObjects[self.mapPackageToSpec[specPkg]] |
| 52 | 55 |
if self.compareVersions(existingObj,specObj) == 1: |
| 53 | 56 |
skipUpdating = True |
| 54 |
- break; |
|
| 57 |
+ break; |
|
| 55 | 58 |
specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg) |
| 56 | 59 |
self.mapPackageToSpec[specPkg]=specName |
| 57 | 60 |
if spec.getIsRPMPackage(specPkg): |
| 58 | 61 |
specObj.listRPMPackages.append(specPkg) |
| 59 | 62 |
if skipUpdating == False: |
| 60 | 63 |
self.mapSerializableSpecObjects[specName]=specObj |
| 61 |
- |
|
| 64 |
+ |
|
| 62 | 65 |
def getListSpecFiles(self,listSpecFiles,path): |
| 63 | 66 |
for dirEntry in os.listdir(path): |
| 64 | 67 |
dirEntryPath = os.path.join(path, dirEntry) |
| ... | ... |
@@ -66,15 +72,15 @@ class SerializableSpecObjectsUtils(object): |
| 66 | 66 |
listSpecFiles.append(dirEntryPath) |
| 67 | 67 |
elif os.path.isdir(dirEntryPath): |
| 68 | 68 |
self.getListSpecFiles(listSpecFiles,dirEntryPath) |
| 69 |
- |
|
| 69 |
+ |
|
| 70 | 70 |
def getBuildRequiresForPackage(self, package): |
| 71 | 71 |
specName=self.getSpecName(package) |
| 72 | 72 |
return self.mapSerializableSpecObjects[specName].buildRequirePackages |
| 73 |
- |
|
| 73 |
+ |
|
| 74 | 74 |
def getRequiresAllForPackage(self, package): |
| 75 | 75 |
specName=self.getSpecName(package) |
| 76 | 76 |
return self.mapSerializableSpecObjects[specName].installRequiresAllPackages |
| 77 |
- |
|
| 77 |
+ |
|
| 78 | 78 |
def getRequiresForPackage(self, package): |
| 79 | 79 |
specName=self.getSpecName(package) |
| 80 | 80 |
if self.mapSerializableSpecObjects[specName].installRequiresPackages.has_key(package): |
| ... | ... |
@@ -109,15 +115,15 @@ class SerializableSpecObjectsUtils(object): |
| 109 | 109 |
def getRelease(self, package): |
| 110 | 110 |
specName=self.getSpecName(package) |
| 111 | 111 |
return self.processData(self.mapSerializableSpecObjects[specName].release) |
| 112 |
- |
|
| 112 |
+ |
|
| 113 | 113 |
def getVersion(self, package): |
| 114 | 114 |
specName=self.getSpecName(package) |
| 115 | 115 |
return self.mapSerializableSpecObjects[specName].version |
| 116 |
- |
|
| 116 |
+ |
|
| 117 | 117 |
def getSpecFile(self, package): |
| 118 | 118 |
specName=self.getSpecName(package) |
| 119 | 119 |
return self.mapSerializableSpecObjects[specName].specFile |
| 120 |
- |
|
| 120 |
+ |
|
| 121 | 121 |
def getPatches(self, package): |
| 122 | 122 |
specName=self.getSpecName(package) |
| 123 | 123 |
return self.mapSerializableSpecObjects[specName].listPatches |
| ... | ... |
@@ -125,7 +131,7 @@ class SerializableSpecObjectsUtils(object): |
| 125 | 125 |
def getSources(self, package): |
| 126 | 126 |
specName=self.getSpecName(package) |
| 127 | 127 |
return self.mapSerializableSpecObjects[specName].listSources |
| 128 |
- |
|
| 128 |
+ |
|
| 129 | 129 |
def getSHA1(self, package, source): |
| 130 | 130 |
specName=self.getSpecName(package) |
| 131 | 131 |
return self.mapSerializableSpecObjects[specName].checksums.get(source) |
| ... | ... |
@@ -153,7 +159,7 @@ class SerializableSpecObjectsUtils(object): |
| 153 | 153 |
else: |
| 154 | 154 |
if int(self.getReleaseNum(existingObj.release)) > int(self.getReleaseNum(newObject.release)): |
| 155 | 155 |
return 1; |
| 156 |
- else: |
|
| 156 |
+ else: |
|
| 157 | 157 |
return -1; |
| 158 | 158 |
|
| 159 | 159 |
def getSpecName(self,package): |
| ... | ... |
@@ -175,6 +181,30 @@ class SerializableSpecObjectsUtils(object): |
| 175 | 175 |
specName=self.getSpecName(package) |
| 176 | 176 |
return self.mapSerializableSpecObjects[specName].securityHardening |
| 177 | 177 |
|
| 178 |
+ def getListSpecs(self): |
|
| 179 |
+ return self.mapSerializableSpecObjects.keys() |
|
| 180 |
+ |
|
| 181 |
+ def getURL(self, package): |
|
| 182 |
+ specName=self.getSpecName(package) |
|
| 183 |
+ url = self.mapSerializableSpecObjects[specName].url |
|
| 184 |
+ if url is None: |
|
| 185 |
+ return None |
|
| 186 |
+ return self.processData(url) |
|
| 187 |
+ |
|
| 188 |
+ def getSourceURL(self, package): |
|
| 189 |
+ specName=self.getSpecName(package) |
|
| 190 |
+ sourceurl = self.mapSerializableSpecObjects[specName].sourceurl |
|
| 191 |
+ if sourceurl is None: |
|
| 192 |
+ return None |
|
| 193 |
+ return self.processData(sourceurl) |
|
| 194 |
+ |
|
| 195 |
+ def getLicense(self, package): |
|
| 196 |
+ specName=self.getSpecName(package) |
|
| 197 |
+ license = self.mapSerializableSpecObjects[specName].license |
|
| 198 |
+ if license is None: |
|
| 199 |
+ return None |
|
| 200 |
+ return self.processData(license) |
|
| 201 |
+ |
|
| 178 | 202 |
def printAllObjects(self): |
| 179 | 203 |
listSpecs=self.mapSerializableSpecObjects.keys() |
| 180 | 204 |
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 |
|
| ... | ... |
@@ -215,14 +221,14 @@ def main(): |
| 215 | 215 |
print "packages",spec.getPackageNames() |
| 216 | 216 |
print "packages",spec.getRPMNames() |
| 217 | 217 |
print "sources",spec.getSourceNames() |
| 218 |
- print "patches",spec.getPatchNames() |
|
| 218 |
+ print "patches",spec.getPatchNames() |
|
| 219 | 219 |
print "requires",spec.getRequires('libltdl-devel')
|
| 220 | 220 |
print "requires",spec.getRequires('libtool')
|
| 221 |
- |
|
| 222 |
- print "provides",spec.getProvides('libtool')
|
|
| 221 |
+ |
|
| 222 |
+ print "provides",spec.getProvides('libtool')
|
|
| 223 | 223 |
print "all-requires",spec.getRequiresAllPackages() |
| 224 | 224 |
print "all-build-requires",spec.getBuildRequiresAllPackages() |
| 225 |
- |
|
| 225 |
+ |
|
| 226 | 226 |
if __name__ == '__main__': |
| 227 | 227 |
main() |
| 228 |
- |
|
| 228 |
+ |
| ... | ... |
@@ -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 |
| ... | ... |
@@ -45,7 +45,7 @@ def main(): |
| 45 | 45 |
cmdUtils.runCommandInShell("mkdir -p "+options.logPath)
|
| 46 | 46 |
|
| 47 | 47 |
logger=Logger.getLogger(options.logPath+"/Main") |
| 48 |
- |
|
| 48 |
+ |
|
| 49 | 49 |
errorFlag=False |
| 50 | 50 |
package = None |
| 51 | 51 |
pkgInfoJsonFile=options.pkgInfoFile |
| ... | ... |
@@ -64,39 +64,39 @@ def main(): |
| 64 | 64 |
if not os.path.isdir(options.publishRPMSPath+"/noarch"): |
| 65 | 65 |
logger.error("Given RPMS Path is missing noarch sub-directory:"+options.publishRPMSPath)
|
| 66 | 66 |
errorFlag = True |
| 67 |
- |
|
| 67 |
+ |
|
| 68 | 68 |
if not os.path.isfile(options.inputJSONFile) and not options.installPackage: |
| 69 | 69 |
logger.error("Given JSON File is not a file:"+options.inputJSONFile)
|
| 70 |
- errorFlag = True |
|
| 70 |
+ errorFlag = True |
|
| 71 | 71 |
if not os.path.isfile(options.pkgBuildOptionFile): |
| 72 | 72 |
logger.warning("Given JSON File is not a file:"+options.pkgBuildOptionFile)
|
| 73 |
- |
|
| 73 |
+ |
|
| 74 | 74 |
if options.inputRPMSPath is not None and not os.path.isdir(options.inputRPMSPath): |
| 75 | 75 |
logger.error("Given input RPMS Path is not a directory:"+options.publishRPMSPath)
|
| 76 | 76 |
errorFlag = True |
| 77 |
- |
|
| 77 |
+ |
|
| 78 | 78 |
if options.installPackage : |
| 79 | 79 |
if len(args) != 1: |
| 80 | 80 |
logger.error("Please provide package name")
|
| 81 | 81 |
errorFlag = True |
| 82 | 82 |
else: |
| 83 | 83 |
package=args[0] |
| 84 |
- |
|
| 84 |
+ |
|
| 85 | 85 |
if errorFlag: |
| 86 | 86 |
logger.error("Found some errors. Please fix input options and re-run it.")
|
| 87 | 87 |
return False |
| 88 |
- |
|
| 89 |
- |
|
| 88 |
+ |
|
| 89 |
+ |
|
| 90 | 90 |
if not os.path.isdir(options.rpmPath): |
| 91 | 91 |
cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/x86_64")
|
| 92 | 92 |
cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/noarch")
|
| 93 | 93 |
|
| 94 | 94 |
if not os.path.isdir(options.sourceRpmPath): |
| 95 | 95 |
cmdUtils.runCommandInShell("mkdir -p "+options.sourceRpmPath)
|
| 96 |
- |
|
| 96 |
+ |
|
| 97 | 97 |
if not os.path.isdir(options.buildRootPath): |
| 98 | 98 |
cmdUtils.runCommandInShell("mkdir -p "+options.buildRootPath)
|
| 99 |
- |
|
| 99 |
+ |
|
| 100 | 100 |
logger.info("Source Path :"+options.sourcePath)
|
| 101 | 101 |
logger.info("Spec Path :" + options.specPath)
|
| 102 | 102 |
logger.info("Rpm Path :" + options.rpmPath)
|
| ... | ... |
@@ -107,7 +107,7 @@ def main(): |
| 107 | 107 |
logger.info("JSON File :" + options.inputJSONFile)
|
| 108 | 108 |
else: |
| 109 | 109 |
logger.info("Package to build:"+package)
|
| 110 |
- |
|
| 110 |
+ |
|
| 111 | 111 |
listBuildOptionPackages = get_packages_with_build_options(options.pkgBuildOptionFile) |
| 112 | 112 |
|
| 113 | 113 |
try: |
| ... | ... |
@@ -119,11 +119,11 @@ def main(): |
| 119 | 119 |
elif package == "sources_list": |
| 120 | 120 |
if not os.path.isdir("../../stage/yaml_sources"):
|
| 121 | 121 |
cmdUtils.runCommandInShell("mkdir -p ../../stage/yaml_sources")
|
| 122 |
- buildSourcesList(options.specPath,"../../stage/yaml_sources", options.buildRootPath+"/../",logger) |
|
| 122 |
+ buildSourcesList('../../stage/yaml_sources',logger)
|
|
| 123 | 123 |
elif package == "srpms_list": |
| 124 | 124 |
if not os.path.isdir("../../stage/yaml_srpms"):
|
| 125 | 125 |
cmdUtils.runCommandInShell("mkdir -p ../../stage/yaml_srpms")
|
| 126 |
- buildSRPMList(options.specPath,options.sourceRpmPath,"../../stage/yaml_srpms",logger) |
|
| 126 |
+ buildSRPMList(options.sourceRpmPath,"../../stage/yaml_srpms",logger) |
|
| 127 | 127 |
elif options.toolChainStage == "stage1": |
| 128 | 128 |
pkgManager = PackageManager() |
| 129 | 129 |
pkgManager.buildToolChain() |
| ... | ... |
@@ -142,7 +142,7 @@ def main(): |
| 142 | 142 |
sys.exit(1) |
| 143 | 143 |
|
| 144 | 144 |
logger.info("Writing Package info to the file:"+pkgInfoJsonFile)
|
| 145 |
- SourcePackageInfo.writePkgListToFile(pkgInfoJsonFile) |
|
| 145 |
+ SourcePackageInfo.writePkgListToFile(pkgInfoJsonFile) |
|
| 146 | 146 |
sys.exit(0) |
| 147 | 147 |
|
| 148 | 148 |
def buildToolChain(buildThreads): |
| ... | ... |
@@ -152,127 +152,108 @@ def buildToolChain(buildThreads): |
| 152 | 152 |
def buildPackagesList(specPath, csvFilename): |
| 153 | 153 |
csvFile = open(csvFilename, "w") |
| 154 | 154 |
csvFile.write("Package,Version,License,URL,Sources,Patches\n")
|
| 155 |
- lst = os.listdir(specPath) |
|
| 156 |
- lst.sort() |
|
| 157 |
- for dirEntry in lst: |
|
| 158 |
- specDir = os.path.join(specPath, dirEntry) |
|
| 159 |
- if os.path.isdir(specDir): |
|
| 160 |
- for specEntry in os.listdir(specDir): |
|
| 161 |
- specFile = os.path.join(specDir, specEntry) |
|
| 162 |
- if os.path.isfile(specFile) and specFile.endswith(".spec"):
|
|
| 163 |
- spec=Specutils(specFile) |
|
| 164 |
- name=spec.getBasePackageName() |
|
| 165 |
- version=spec.getRPMVersion(name) |
|
| 166 |
- license=spec.getLicense(name) |
|
| 167 |
- url=spec.getURL(name) |
|
| 168 |
- ss=spec.getSourceURLs() |
|
| 169 |
- sources="" |
|
| 170 |
- for s in ss: |
|
| 171 |
- if (s.startswith("http") or s.startswith("ftp")):
|
|
| 172 |
- if sources != "": |
|
| 173 |
- sources += " " |
|
| 174 |
- sources += s |
|
| 175 |
- patches="" |
|
| 176 |
- ps=spec.getPatchNames() |
|
| 177 |
- for p in ps: |
|
| 178 |
- if patches != "": |
|
| 179 |
- patches += " " |
|
| 180 |
- patches += p |
|
| 181 |
- csvFile.write(name+","+version+","+license+","+url+","+sources+","+patches+"\n") |
|
| 155 |
+ listSpecs = constants.specData.getListSpecs() |
|
| 156 |
+ listSpecs.sort() |
|
| 157 |
+ for spec in listSpecs: |
|
| 158 |
+ name = spec |
|
| 159 |
+ version = constants.specData.getVersion(spec) |
|
| 160 |
+ license = constants.specData.getLicense(spec) |
|
| 161 |
+ listPatches = constants.specData.getPatches(spec) |
|
| 162 |
+ url = constants.specData.getURL(spec) |
|
| 163 |
+ listSourceNames = constants.specData.getSources(spec) |
|
| 164 |
+ sources = "" |
|
| 165 |
+ patches = "" |
|
| 166 |
+ if listPatches is not None: |
|
| 167 |
+ patches = " ".join(listPatches) |
|
| 168 |
+ if listSourceNames is not None: |
|
| 169 |
+ sources = " ".join(listSourceNames) |
|
| 170 |
+ csvFile.write(name+","+version+","+license+","+url+","+sources+","+patches+"\n") |
|
| 182 | 171 |
csvFile.close() |
| 183 | 172 |
|
| 184 |
-def buildSourcesList(specPath,sourcePath, yamlDir, logger, singleFile=True): |
|
| 173 |
+def buildSourcesList(yamlDir, logger, singleFile=True): |
|
| 185 | 174 |
strUtils = StringUtils() |
| 186 | 175 |
if singleFile: |
| 187 |
- yamlFile = open(yamlDir+"sources_list.yaml", "w") |
|
| 188 |
- lst = os.listdir(specPath) |
|
| 189 |
- lst.sort() |
|
| 176 |
+ yamlFile = open(yamlDir+"/sources_list.yaml", "w") |
|
| 177 |
+ listSpecs = constants.specData.getListSpecs() |
|
| 178 |
+ listSpecs.sort() |
|
| 190 | 179 |
import PullSources |
| 191 |
- for dirEntry in lst: |
|
| 192 |
- specDir = os.path.join(specPath, dirEntry) |
|
| 193 |
- if os.path.isdir(specDir): |
|
| 194 |
- for specEntry in os.listdir(specDir): |
|
| 195 |
- specFile = os.path.join(specDir, specEntry) |
|
| 196 |
- if os.path.isfile(specFile) and specFile.endswith(".spec"):
|
|
| 197 |
- spec=Specutils(specFile) |
|
| 198 |
- modified = len(spec.getPatchNames()) > 0 |
|
| 199 |
- listSourceURLs=spec.getSourceURLs() |
|
| 200 |
- ossname = spec.getBasePackageName() |
|
| 201 |
- ossversion = spec.getVersion() |
|
| 202 |
- url = None |
|
| 203 |
- listSourceNames = spec.getSourceNames() |
|
| 204 |
- sourceName = None |
|
| 205 |
- if len(listSourceNames) >0: |
|
| 206 |
- sourceName=listSourceNames[0] |
|
| 207 |
- sha1 = spec.getChecksumForSource(sourceName) |
|
| 208 |
- if sha1 is not None: |
|
| 209 |
- PullSources.get(sourceName, sha1, sourcePath, constants.pullsourcesConfig) |
|
| 210 |
- |
|
| 211 |
- if len(listSourceURLs) > 0: |
|
| 212 |
- sourceURL = listSourceURLs[0] |
|
| 213 |
- if sourceURL.startswith("http") or sourceURL.startswith("ftp"):
|
|
| 214 |
- url = sourceURL; |
|
| 215 |
- else: |
|
| 216 |
- url=spec.getURL(ossname) |
|
| 217 |
- if not singleFile: |
|
| 218 |
- yamlFile = open(yamlDir+"/"+ossname+"-"+ossversion+".yaml", "w") |
|
| 219 |
- yamlFile.write("vmwsource:"+ossname+":"+ossversion+":\n")
|
|
| 220 |
- yamlFile.write(" repository: VMWsource\n")
|
|
| 221 |
- yamlFile.write(" name: '"+ossname+"'\n")
|
|
| 222 |
- yamlFile.write(" version: '"+ossversion+"'\n")
|
|
| 223 |
- yamlFile.write(" url: "+str(url)+"\n")
|
|
| 224 |
- yamlFile.write(" license: UNKNOWN\n")
|
|
| 225 |
- if sourceName is not None: |
|
| 226 |
- yamlFile.write(" vmwsource-distribution: "+str(sourceName)+"\n")
|
|
| 227 |
- if modified: |
|
| 228 |
- yamlFile.write(" modified: true\n")
|
|
| 229 |
- yamlFile.write("\n")
|
|
| 230 |
- if not singleFile: |
|
| 231 |
- yamlFile.close() |
|
| 180 |
+ for spec in listSpecs: |
|
| 181 |
+ ossname = spec |
|
| 182 |
+ ossversion = constants.specData.getVersion(spec) |
|
| 183 |
+ modified = False |
|
| 184 |
+ listPatches = constants.specData.getPatches(spec) |
|
| 185 |
+ if listPatches is not None and len(listPatches) > 0 : |
|
| 186 |
+ modified = True |
|
| 187 |
+ url = constants.specData.getSourceURL(spec) |
|
| 188 |
+ if url is None: |
|
| 189 |
+ url = constants.specData.getURL(spec) |
|
| 190 |
+ |
|
| 191 |
+ sourceName = None |
|
| 192 |
+ listSourceNames = constants.specData.getSources(spec) |
|
| 193 |
+ if len(listSourceNames) >0: |
|
| 194 |
+ sourceName=listSourceNames[0] |
|
| 195 |
+ sha1 = constants.specData.getSHA1(spec, sourceName) |
|
| 196 |
+ if sha1 is not None: |
|
| 197 |
+ PullSources.get(sourceName, sha1, yamlDir, constants.pullsourcesConfig) |
|
| 198 |
+ |
|
| 199 |
+ if not singleFile: |
|
| 200 |
+ yamlFile = open(yamlDir+"/"+ossname+"-"+ossversion+".yaml", "w") |
|
| 201 |
+ yamlFile.write("vmwsource:"+ossname+":"+ossversion+":\n")
|
|
| 202 |
+ yamlFile.write(" repository: VMWsource\n")
|
|
| 203 |
+ yamlFile.write(" name: '"+ossname+"'\n")
|
|
| 204 |
+ yamlFile.write(" version: '"+ossversion+"'\n")
|
|
| 205 |
+ yamlFile.write(" url: "+str(url)+"\n")
|
|
| 206 |
+ yamlFile.write(" license: UNKNOWN\n")
|
|
| 207 |
+ if sourceName is not None: |
|
| 208 |
+ yamlFile.write(" vmwsource-distribution: "+str(sourceName)+"\n")
|
|
| 209 |
+ if modified: |
|
| 210 |
+ yamlFile.write(" modified: true\n")
|
|
| 211 |
+ yamlFile.write("\n")
|
|
| 212 |
+ if not singleFile: |
|
| 213 |
+ yamlFile.close() |
|
| 214 |
+ |
|
| 232 | 215 |
if singleFile: |
| 233 | 216 |
yamlFile.close() |
| 234 | 217 |
logger.info("Generated source yaml files for all packages")
|
| 235 | 218 |
|
| 236 |
-def buildSRPMList(specPath,srpmPath, yamlDir, logger, singleFile=True): |
|
| 219 |
+def buildSRPMList(srpmPath, yamlDir, logger, singleFile=True): |
|
| 237 | 220 |
strUtils = StringUtils() |
| 238 | 221 |
if singleFile: |
| 239 |
- yamlFile = open(yamlDir+"srpm_list.yaml", "w") |
|
| 240 |
- lst = os.listdir(specPath) |
|
| 241 |
- lst.sort() |
|
| 222 |
+ yamlFile = open(yamlDir+"/srpm_list.yaml", "w") |
|
| 223 |
+ listSpecs = constants.specData.getListSpecs() |
|
| 224 |
+ listSpecs.sort() |
|
| 242 | 225 |
cmdUtils = CommandUtils() |
| 243 |
- for dirEntry in lst: |
|
| 244 |
- specDir = os.path.join(specPath, dirEntry) |
|
| 245 |
- if os.path.isdir(specDir): |
|
| 246 |
- for specEntry in os.listdir(specDir): |
|
| 247 |
- specFile = os.path.join(specDir, specEntry) |
|
| 248 |
- if os.path.isfile(specFile) and specFile.endswith(".spec"):
|
|
| 249 |
- spec=Specutils(specFile) |
|
| 250 |
- ossname = spec.getBasePackageName() |
|
| 251 |
- ossversion = spec.getVersion() |
|
| 252 |
- ossrelease = spec.getRelease() |
|
| 253 |
- listFoundSRPMFiles = cmdUtils.findFile(ossname+"-"+ossversion+"-"+ossrelease+".src.rpm",srpmPath) |
|
| 254 |
- srpmName = None |
|
| 255 |
- if len(listFoundSRPMFiles) == 1: |
|
| 256 |
- srpmFullPath = listFoundSRPMFiles[0]; |
|
| 257 |
- srpmName = os.path.basename(srpmFullPath) |
|
| 258 |
- cpcmd = "cp "+ srpmFullPath +" "+yamlDir+"/" |
|
| 259 |
- returnVal = cmdUtils.runCommandInShell(cpcmd) |
|
| 260 |
- if not returnVal: |
|
| 261 |
- logger.error("Copy SRPM File is failed for package:"+ossname)
|
|
| 262 |
- else: |
|
| 263 |
- logger.error("SRPM file is not found:" +ossname)
|
|
| 264 |
- if not singleFile: |
|
| 265 |
- yamlFile = open(yamlDir+"/"+ossname+"-"+ossversion+"-"+ossrelease+".yaml", "w") |
|
| 266 |
- yamlFile.write("baseos:"+ossname+":"+ossversion+"-"+ossrelease+":\n")
|
|
| 267 |
- yamlFile.write(" repository: BaseOS\n")
|
|
| 268 |
- yamlFile.write(" name: '"+ossname+"'\n")
|
|
| 269 |
- yamlFile.write(" version: '"+ossversion+"-"+ossrelease+"'\n")
|
|
| 270 |
- yamlFile.write(" baseos-style: rpm\n")
|
|
| 271 |
- yamlFile.write(" baseos-source: '"+str(srpmName)+"'\n")
|
|
| 272 |
- yamlFile.write(" baseos-osname: 'photon'\n")
|
|
| 273 |
- yamlFile.write("\n")
|
|
| 274 |
- if not singleFile: |
|
| 275 |
- yamlFile.close() |
|
| 226 |
+ for spec in listSpecs: |
|
| 227 |
+ ossname = spec |
|
| 228 |
+ ossversion = constants.specData.getVersion(spec) |
|
| 229 |
+ ossrelease = constants.specData.getRelease(spec) |
|
| 230 |
+ |
|
| 231 |
+ listFoundSRPMFiles = cmdUtils.findFile(ossname+"-"+ossversion+"-"+ossrelease+".src.rpm",srpmPath) |
|
| 232 |
+ srpmName = None |
|
| 233 |
+ if len(listFoundSRPMFiles) == 1: |
|
| 234 |
+ srpmFullPath = listFoundSRPMFiles[0]; |
|
| 235 |
+ srpmName = os.path.basename(srpmFullPath) |
|
| 236 |
+ cpcmd = "cp "+ srpmFullPath +" "+yamlDir+"/" |
|
| 237 |
+ returnVal = cmdUtils.runCommandInShell(cpcmd) |
|
| 238 |
+ if not returnVal: |
|
| 239 |
+ logger.error("Copy SRPM File is failed for package:"+ossname)
|
|
| 240 |
+ else: |
|
| 241 |
+ logger.error("SRPM file is not found:" +ossname)
|
|
| 242 |
+ |
|
| 243 |
+ if not singleFile: |
|
| 244 |
+ yamlFile = open(yamlDir+"/"+ossname+"-"+ossversion+"-"+ossrelease+".yaml", "w") |
|
| 245 |
+ |
|
| 246 |
+ yamlFile.write("baseos:"+ossname+":"+ossversion+"-"+ossrelease+":\n")
|
|
| 247 |
+ yamlFile.write(" repository: BaseOS\n")
|
|
| 248 |
+ yamlFile.write(" name: '"+ossname+"'\n")
|
|
| 249 |
+ yamlFile.write(" version: '"+ossversion+"-"+ossrelease+"'\n")
|
|
| 250 |
+ yamlFile.write(" baseos-style: rpm\n")
|
|
| 251 |
+ yamlFile.write(" baseos-source: '"+str(srpmName)+"'\n")
|
|
| 252 |
+ yamlFile.write(" baseos-osname: 'photon'\n")
|
|
| 253 |
+ yamlFile.write("\n")
|
|
| 254 |
+ if not singleFile: |
|
| 255 |
+ yamlFile.close() |
|
| 256 |
+ |
|
| 276 | 257 |
if singleFile: |
| 277 | 258 |
yamlFile.close() |
| 278 | 259 |
logger.info("Generated srpm yaml files for all packages")
|
| ... | ... |
@@ -307,7 +288,7 @@ def get_packages_with_build_options(pkg_build_options_file): |
| 307 | 307 |
packages.append(str(p)) |
| 308 | 308 |
|
| 309 | 309 |
return packages |
| 310 |
- |
|
| 310 |
+ |
|
| 311 | 311 |
def get_all_package_names(build_install_option): |
| 312 | 312 |
base_path = os.path.dirname(build_install_option) |
| 313 | 313 |
jsonData = open(build_install_option) |