Change-Id: Id47e9d23d562eae01635def5c4c9830489ac2d3a
Reviewed-on: http://photon-jenkins.eng.vmware.com/1069
Reviewed-by: suezzelur <anishs@vmware.com>
Tested-by: suezzelur <anishs@vmware.com>
| ... | ... |
@@ -8,10 +8,10 @@ |
| 8 | 8 |
class Action(object): |
| 9 | 9 |
|
| 10 | 10 |
def do_action(self, params): |
| 11 |
- raise NameError('Abstract method, this should be implemented in the child class')
|
|
| 11 |
+ raise NameError('Abstract method, this should be implemented in the child class')
|
|
| 12 | 12 |
|
| 13 | 13 |
def hide(self, params): |
| 14 |
- raise NameError('Abstract method, this should be implemented in the child class')
|
|
| 14 |
+ raise NameError('Abstract method, this should be implemented in the child class')
|
|
| 15 | 15 |
|
| 16 | 16 |
|
| 17 | 17 |
|
| ... | ... |
@@ -7,9 +7,9 @@ enabled = True |
| 7 | 7 |
|
| 8 | 8 |
def execute(name, ks_config, config, root): |
| 9 | 9 |
|
| 10 |
- if ks_config: |
|
| 11 |
- if 'partitions' in ks_config: |
|
| 12 |
- partitions = ks_config['partitions'] |
|
| 13 |
- else: |
|
| 14 |
- partitions = commons.default_partitions |
|
| 15 |
- config['disk'] = commons.partition_disk(ks_config['disk'], partitions) |
|
| 10 |
+ if ks_config: |
|
| 11 |
+ if 'partitions' in ks_config: |
|
| 12 |
+ partitions = ks_config['partitions'] |
|
| 13 |
+ else: |
|
| 14 |
+ partitions = commons.default_partitions |
|
| 15 |
+ config['disk'] = commons.partition_disk(ks_config['disk'], partitions) |
| ... | ... |
@@ -10,7 +10,7 @@ def execute(name, ks_config, config, root): |
| 10 | 10 |
if ks_config and 'postinstall' in ks_config: |
| 11 | 11 |
config['postinstall'] = ks_config['postinstall'] |
| 12 | 12 |
if 'postinstall' not in config: |
| 13 |
- return |
|
| 13 |
+ return |
|
| 14 | 14 |
# run the script in the chroot environment |
| 15 | 15 |
script = config['postinstall'] |
| 16 | 16 |
|
| ... | ... |
@@ -20,6 +20,6 @@ def execute(name, ks_config, config, root): |
| 20 | 20 |
hosts_file = os.path.join(root, 'etc/hosts') |
| 21 | 21 |
|
| 22 | 22 |
with open(hostname_file, 'wb') as outfile: |
| 23 |
- outfile.write(hostname) |
|
| 23 |
+ outfile.write(hostname) |
|
| 24 | 24 |
|
| 25 | 25 |
commons.replace_string_in_file(hosts_file, r'127\.0\.0\.1\s+localhost\s*\Z', '127.0.0.1\tlocalhost\n127.0.0.1\t' + hostname) |
| ... | ... |
@@ -22,217 +22,217 @@ class SerializableSpecObject(object): |
| 22 | 22 |
|
| 23 | 23 |
class SerializedSpecObjects(object): |
| 24 | 24 |
|
| 25 |
- def __init__(self, inputDataDir, stageDir): |
|
| 26 |
- self.mapSerializableSpecObjects={}
|
|
| 27 |
- self.mapPackageToSpec={}
|
|
| 28 |
- self.jsonFilesOutPath = stageDir + "/common/data/" |
|
| 29 |
- self.inputDataDir = inputDataDir |
|
| 30 |
- |
|
| 31 |
- def findTotalRequires(self, allDeps, depQue, parent, displayOption): |
|
| 32 |
- while not depQue.empty(): |
|
| 33 |
- specPkg = depQue.get() |
|
| 34 |
- specName = self.getSpecName(specPkg) |
|
| 35 |
- specObj = self.mapSerializableSpecObjects[specName] |
|
| 36 |
- for depPkg in specObj.installRequiresPackages[specPkg]: |
|
| 37 |
- if True == allDeps.has_key(depPkg): |
|
| 38 |
- if(allDeps[depPkg] < allDeps[specPkg] + 1): |
|
| 39 |
- allDeps[depPkg] = allDeps[specPkg] + 1 |
|
| 40 |
- parent[depPkg] = specPkg |
|
| 41 |
- self.updateLevels(allDeps, depPkg, parent, allDeps[depPkg]) |
|
| 42 |
- else: |
|
| 43 |
- allDeps[depPkg] = allDeps[specPkg] + 1 |
|
| 44 |
- parent[depPkg] = specPkg |
|
| 45 |
- depQue.put(depPkg) |
|
| 46 |
- |
|
| 47 |
- def printTree(self, allDeps, children, curParent , depth): |
|
| 48 |
- if (children.has_key(curParent)): |
|
| 49 |
- for child in children[curParent]: |
|
| 50 |
- print "\t" * depth, child |
|
| 51 |
- self.printTree(allDeps, children, child, depth+1) |
|
| 52 |
- |
|
| 53 |
- def get_all_package_names(self, jsonFilePath): |
|
| 54 |
- base_path = os.path.dirname(jsonFilePath) |
|
| 55 |
- jsonData = open(jsonFilePath) |
|
| 56 |
- option_list_json = json.load(jsonData) |
|
| 57 |
- jsonData.close() |
|
| 58 |
- packages = option_list_json["packages"] |
|
| 59 |
- return packages |
|
| 25 |
+ def __init__(self, inputDataDir, stageDir): |
|
| 26 |
+ self.mapSerializableSpecObjects={}
|
|
| 27 |
+ self.mapPackageToSpec={}
|
|
| 28 |
+ self.jsonFilesOutPath = stageDir + "/common/data/" |
|
| 29 |
+ self.inputDataDir = inputDataDir |
|
| 30 |
+ |
|
| 31 |
+ def findTotalRequires(self, allDeps, depQue, parent, displayOption): |
|
| 32 |
+ while not depQue.empty(): |
|
| 33 |
+ specPkg = depQue.get() |
|
| 34 |
+ specName = self.getSpecName(specPkg) |
|
| 35 |
+ specObj = self.mapSerializableSpecObjects[specName] |
|
| 36 |
+ for depPkg in specObj.installRequiresPackages[specPkg]: |
|
| 37 |
+ if True == allDeps.has_key(depPkg): |
|
| 38 |
+ if(allDeps[depPkg] < allDeps[specPkg] + 1): |
|
| 39 |
+ allDeps[depPkg] = allDeps[specPkg] + 1 |
|
| 40 |
+ parent[depPkg] = specPkg |
|
| 41 |
+ self.updateLevels(allDeps, depPkg, parent, allDeps[depPkg]) |
|
| 42 |
+ else: |
|
| 43 |
+ allDeps[depPkg] = allDeps[specPkg] + 1 |
|
| 44 |
+ parent[depPkg] = specPkg |
|
| 45 |
+ depQue.put(depPkg) |
|
| 46 |
+ |
|
| 47 |
+ def printTree(self, allDeps, children, curParent , depth): |
|
| 48 |
+ if (children.has_key(curParent)): |
|
| 49 |
+ for child in children[curParent]: |
|
| 50 |
+ print "\t" * depth, child |
|
| 51 |
+ self.printTree(allDeps, children, child, depth+1) |
|
| 52 |
+ |
|
| 53 |
+ def get_all_package_names(self, jsonFilePath): |
|
| 54 |
+ base_path = os.path.dirname(jsonFilePath) |
|
| 55 |
+ jsonData = open(jsonFilePath) |
|
| 56 |
+ option_list_json = json.load(jsonData) |
|
| 57 |
+ jsonData.close() |
|
| 58 |
+ packages = option_list_json["packages"] |
|
| 59 |
+ return packages |
|
| 60 | 60 |
|
| 61 |
- def updateLevels(self, allDeps, inPkg, parent, level): |
|
| 62 |
- specName = self.getSpecName(inPkg) |
|
| 63 |
- specObj = self.mapSerializableSpecObjects[specName] |
|
| 64 |
- for depPkg in specObj.installRequiresPackages[inPkg]: |
|
| 65 |
- if (allDeps.has_key(depPkg) and allDeps[depPkg] < level + 1): |
|
| 66 |
- allDeps[depPkg] = level + 1 |
|
| 67 |
- parent[depPkg] = inPkg |
|
| 68 |
- self.updateLevels(allDeps, depPkg, parent, allDeps[depPkg]) |
|
| 69 |
- |
|
| 70 |
- def readSpecsAndConvertToSerializableObjects(self, specFilesPath, inputType, inputValue, displayOption): |
|
| 71 |
- children = {}
|
|
| 72 |
- listSpecFiles=[] |
|
| 73 |
- whoNeedsList=[] |
|
| 74 |
- independentRPMS=[] # list of all RPMS not built from photon and that must be blindly copied. |
|
| 75 |
- allDeps={}
|
|
| 76 |
- parent={}
|
|
| 77 |
- depQue = Queue.Queue() |
|
| 78 |
- packageFound = False |
|
| 79 |
- self.getListSpecFiles(listSpecFiles,specFilesPath) |
|
| 80 |
- for specFile in listSpecFiles: |
|
| 81 |
- spec=Specutils(specFile) |
|
| 82 |
- specName=spec.getBasePackageName() |
|
| 83 |
- specObj=SerializableSpecObject() |
|
| 84 |
- specObj.name=specName |
|
| 85 |
- specObj.buildRequirePackages=spec.getBuildRequiresAllPackages() |
|
| 86 |
- specObj.installRequiresAllPackages=spec.getRequiresAllPackages() |
|
| 87 |
- specObj.listPackages=spec.getPackageNames() |
|
| 88 |
- specObj.specFile=specFile |
|
| 89 |
- specObj.version=spec.getVersion() |
|
| 90 |
- specObj.release=spec.getRelease() |
|
| 91 |
- specObj.listSources=spec.getSourceNames() |
|
| 92 |
- specObj.listPatches=spec.getPatchNames() |
|
| 93 |
- specObj.securityHardening=spec.getSecurityHardeningOption() |
|
| 94 |
- for specPkg in specObj.listPackages: |
|
| 95 |
- specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg) |
|
| 96 |
- if (inputType == "pkg" and inputValue == specPkg): # all the first level dependencies to a dictionary and queue |
|
| 97 |
- packageFound = True |
|
| 98 |
- for depPkg in specObj.installRequiresPackages[specPkg]: |
|
| 99 |
- if False == allDeps.has_key(depPkg): |
|
| 100 |
- allDeps[depPkg] = 0 |
|
| 101 |
- parent[depPkg] = "" |
|
| 102 |
- depQue.put(depPkg) |
|
| 103 |
- if (inputType == "who-needs" and (inputValue in specObj.installRequiresPackages[specPkg])): |
|
| 104 |
- whoNeedsList.append(specPkg) |
|
| 105 |
- self.mapPackageToSpec[specPkg]=specName |
|
| 106 |
- self.mapSerializableSpecObjects[specName]=specObj |
|
| 107 |
- |
|
| 108 |
- # Generate dependencies for individual packages |
|
| 109 |
- if (inputType == "pkg"): |
|
| 110 |
- if (packageFound == True): |
|
| 111 |
- self.findTotalRequires(allDeps, depQue, parent, displayOption) |
|
| 112 |
- else: |
|
| 113 |
- print "No spec file builds a package named",inputValue |
|
| 114 |
- return |
|
| 61 |
+ def updateLevels(self, allDeps, inPkg, parent, level): |
|
| 62 |
+ specName = self.getSpecName(inPkg) |
|
| 63 |
+ specObj = self.mapSerializableSpecObjects[specName] |
|
| 64 |
+ for depPkg in specObj.installRequiresPackages[inPkg]: |
|
| 65 |
+ if (allDeps.has_key(depPkg) and allDeps[depPkg] < level + 1): |
|
| 66 |
+ allDeps[depPkg] = level + 1 |
|
| 67 |
+ parent[depPkg] = inPkg |
|
| 68 |
+ self.updateLevels(allDeps, depPkg, parent, allDeps[depPkg]) |
|
| 69 |
+ |
|
| 70 |
+ def readSpecsAndConvertToSerializableObjects(self, specFilesPath, inputType, inputValue, displayOption): |
|
| 71 |
+ children = {}
|
|
| 72 |
+ listSpecFiles=[] |
|
| 73 |
+ whoNeedsList=[] |
|
| 74 |
+ independentRPMS=[] # list of all RPMS not built from photon and that must be blindly copied. |
|
| 75 |
+ allDeps={}
|
|
| 76 |
+ parent={}
|
|
| 77 |
+ depQue = Queue.Queue() |
|
| 78 |
+ packageFound = False |
|
| 79 |
+ self.getListSpecFiles(listSpecFiles,specFilesPath) |
|
| 80 |
+ for specFile in listSpecFiles: |
|
| 81 |
+ spec=Specutils(specFile) |
|
| 82 |
+ specName=spec.getBasePackageName() |
|
| 83 |
+ specObj=SerializableSpecObject() |
|
| 84 |
+ specObj.name=specName |
|
| 85 |
+ specObj.buildRequirePackages=spec.getBuildRequiresAllPackages() |
|
| 86 |
+ specObj.installRequiresAllPackages=spec.getRequiresAllPackages() |
|
| 87 |
+ specObj.listPackages=spec.getPackageNames() |
|
| 88 |
+ specObj.specFile=specFile |
|
| 89 |
+ specObj.version=spec.getVersion() |
|
| 90 |
+ specObj.release=spec.getRelease() |
|
| 91 |
+ specObj.listSources=spec.getSourceNames() |
|
| 92 |
+ specObj.listPatches=spec.getPatchNames() |
|
| 93 |
+ specObj.securityHardening=spec.getSecurityHardeningOption() |
|
| 94 |
+ for specPkg in specObj.listPackages: |
|
| 95 |
+ specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg) |
|
| 96 |
+ if (inputType == "pkg" and inputValue == specPkg): # all the first level dependencies to a dictionary and queue |
|
| 97 |
+ packageFound = True |
|
| 98 |
+ for depPkg in specObj.installRequiresPackages[specPkg]: |
|
| 99 |
+ if False == allDeps.has_key(depPkg): |
|
| 100 |
+ allDeps[depPkg] = 0 |
|
| 101 |
+ parent[depPkg] = "" |
|
| 102 |
+ depQue.put(depPkg) |
|
| 103 |
+ if (inputType == "who-needs" and (inputValue in specObj.installRequiresPackages[specPkg])): |
|
| 104 |
+ whoNeedsList.append(specPkg) |
|
| 105 |
+ self.mapPackageToSpec[specPkg]=specName |
|
| 106 |
+ self.mapSerializableSpecObjects[specName]=specObj |
|
| 107 |
+ |
|
| 108 |
+ # Generate dependencies for individual packages |
|
| 109 |
+ if (inputType == "pkg"): |
|
| 110 |
+ if (packageFound == True): |
|
| 111 |
+ self.findTotalRequires(allDeps, depQue, parent, displayOption) |
|
| 112 |
+ else: |
|
| 113 |
+ print "No spec file builds a package named",inputValue |
|
| 114 |
+ return |
|
| 115 | 115 |
|
| 116 |
- # Generate dependencies for all packages in the given JSON input file |
|
| 117 |
- elif (inputType == "json"): |
|
| 118 |
- filePath = self.inputDataDir +"/"+ inputValue |
|
| 119 |
- data = self.get_all_package_names(filePath) |
|
| 120 |
- for pkg in data: |
|
| 121 |
- if False == allDeps.has_key(pkg): |
|
| 122 |
- spName = self.getSpecName(pkg) |
|
| 123 |
- if(spName != None): |
|
| 124 |
- allDeps[pkg] = 0 |
|
| 125 |
- parent[pkg] = "" |
|
| 126 |
- depQue.put(pkg) |
|
| 127 |
- self.findTotalRequires(allDeps, depQue, parent, displayOption) |
|
| 128 |
- else: |
|
| 129 |
- independentRPMS.append(pkg); |
|
| 116 |
+ # Generate dependencies for all packages in the given JSON input file |
|
| 117 |
+ elif (inputType == "json"): |
|
| 118 |
+ filePath = self.inputDataDir +"/"+ inputValue |
|
| 119 |
+ data = self.get_all_package_names(filePath) |
|
| 120 |
+ for pkg in data: |
|
| 121 |
+ if False == allDeps.has_key(pkg): |
|
| 122 |
+ spName = self.getSpecName(pkg) |
|
| 123 |
+ if(spName != None): |
|
| 124 |
+ allDeps[pkg] = 0 |
|
| 125 |
+ parent[pkg] = "" |
|
| 126 |
+ depQue.put(pkg) |
|
| 127 |
+ self.findTotalRequires(allDeps, depQue, parent, displayOption) |
|
| 128 |
+ else: |
|
| 129 |
+ independentRPMS.append(pkg); |
|
| 130 | 130 |
|
| 131 |
- #Generating the list of packages that requires the given input package at install time |
|
| 132 |
- elif (inputType == "who-needs"): |
|
| 133 |
- print whoNeedsList |
|
| 134 |
- return |
|
| 131 |
+ #Generating the list of packages that requires the given input package at install time |
|
| 132 |
+ elif (inputType == "who-needs"): |
|
| 133 |
+ print whoNeedsList |
|
| 134 |
+ return |
|
| 135 | 135 |
|
| 136 |
- # construct the sorted list of all packages (sorted by dependency) |
|
| 137 |
- sortedList = [] |
|
| 138 |
- for elem in sorted(allDeps.items(), key=operator.itemgetter(1), reverse=True): |
|
| 139 |
- sortedList.append(elem[0]) |
|
| 140 |
- sortedList.extend(independentRPMS) |
|
| 136 |
+ # construct the sorted list of all packages (sorted by dependency) |
|
| 137 |
+ sortedList = [] |
|
| 138 |
+ for elem in sorted(allDeps.items(), key=operator.itemgetter(1), reverse=True): |
|
| 139 |
+ sortedList.append(elem[0]) |
|
| 140 |
+ sortedList.extend(independentRPMS) |
|
| 141 | 141 |
|
| 142 |
- # construct all children nodes |
|
| 143 |
- if (displayOption == "tree"): |
|
| 144 |
- for k, v in parent.iteritems(): |
|
| 145 |
- children.setdefault(v, []).append(k) |
|
| 146 |
- if(inputType == "json"): |
|
| 147 |
- print "Dependency Mappings for", inputValue, ":", "\n----------------------------------------------------",children |
|
| 148 |
- print "----------------------------------------------------" |
|
| 149 |
- if (children.has_key("")):
|
|
| 150 |
- for child in children[""]: |
|
| 151 |
- print child |
|
| 152 |
- self.printTree(allDeps, children, child, 1) |
|
| 153 |
- for pkg in independentRPMS: |
|
| 154 |
- print pkg |
|
| 155 |
- print "******************",len(sortedList), "packages in total ******************" |
|
| 156 |
- else: |
|
| 157 |
- if (inputType == "pkg" and len(children) > 0): |
|
| 158 |
- print "cyclic dependency detected, mappings: \n",children |
|
| 142 |
+ # construct all children nodes |
|
| 143 |
+ if (displayOption == "tree"): |
|
| 144 |
+ for k, v in parent.iteritems(): |
|
| 145 |
+ children.setdefault(v, []).append(k) |
|
| 146 |
+ if(inputType == "json"): |
|
| 147 |
+ print "Dependency Mappings for", inputValue, ":", "\n----------------------------------------------------",children |
|
| 148 |
+ print "----------------------------------------------------" |
|
| 149 |
+ if (children.has_key("")):
|
|
| 150 |
+ for child in children[""]: |
|
| 151 |
+ print child |
|
| 152 |
+ self.printTree(allDeps, children, child, 1) |
|
| 153 |
+ for pkg in independentRPMS: |
|
| 154 |
+ print pkg |
|
| 155 |
+ print "******************",len(sortedList), "packages in total ******************" |
|
| 156 |
+ else: |
|
| 157 |
+ if (inputType == "pkg" and len(children) > 0): |
|
| 158 |
+ print "cyclic dependency detected, mappings: \n",children |
|
| 159 | 159 |
|
| 160 |
- # To display a flat list of all packages |
|
| 161 |
- elif(displayOption == "list"): |
|
| 162 |
- print sortedList |
|
| 160 |
+ # To display a flat list of all packages |
|
| 161 |
+ elif(displayOption == "list"): |
|
| 162 |
+ print sortedList |
|
| 163 | 163 |
|
| 164 |
- # To generate a new JSON file based on given input json file |
|
| 165 |
- elif(displayOption == "json" and inputType == "json"): |
|
| 166 |
- d = {}
|
|
| 167 |
- d['packages'] = sortedList |
|
| 168 |
- outFilePath = self.jsonFilesOutPath + inputValue |
|
| 169 |
- with open(outFilePath, 'wb') as outfile: |
|
| 170 |
- json.dump(d, outfile) |
|
| 171 |
- |
|
| 172 |
- def getListSpecFiles(self,listSpecFiles,path): |
|
| 173 |
- for dirEntry in os.listdir(path): |
|
| 174 |
- dirEntryPath = os.path.join(path, dirEntry) |
|
| 175 |
- if os.path.isfile(dirEntryPath) and dirEntryPath.endswith(".spec"):
|
|
| 176 |
- listSpecFiles.append(dirEntryPath) |
|
| 177 |
- elif os.path.isdir(dirEntryPath): |
|
| 178 |
- self.getListSpecFiles(listSpecFiles,dirEntryPath) |
|
| 164 |
+ # To generate a new JSON file based on given input json file |
|
| 165 |
+ elif(displayOption == "json" and inputType == "json"): |
|
| 166 |
+ d = {}
|
|
| 167 |
+ d['packages'] = sortedList |
|
| 168 |
+ outFilePath = self.jsonFilesOutPath + inputValue |
|
| 169 |
+ with open(outFilePath, 'wb') as outfile: |
|
| 170 |
+ json.dump(d, outfile) |
|
| 171 |
+ |
|
| 172 |
+ def getListSpecFiles(self,listSpecFiles,path): |
|
| 173 |
+ for dirEntry in os.listdir(path): |
|
| 174 |
+ dirEntryPath = os.path.join(path, dirEntry) |
|
| 175 |
+ if os.path.isfile(dirEntryPath) and dirEntryPath.endswith(".spec"):
|
|
| 176 |
+ listSpecFiles.append(dirEntryPath) |
|
| 177 |
+ elif os.path.isdir(dirEntryPath): |
|
| 178 |
+ self.getListSpecFiles(listSpecFiles,dirEntryPath) |
|
| 179 | 179 |
|
| 180 |
- def getBuildRequiresForPackage(self, package): |
|
| 181 |
- specName=self.getSpecName(package) |
|
| 182 |
- return self.mapSerializableSpecObjects[specName].buildRequirePackages |
|
| 180 |
+ def getBuildRequiresForPackage(self, package): |
|
| 181 |
+ specName=self.getSpecName(package) |
|
| 182 |
+ return self.mapSerializableSpecObjects[specName].buildRequirePackages |
|
| 183 | 183 |
|
| 184 |
- def getRequiresForPackage(self, package): |
|
| 185 |
- specName=self.getSpecName(package) |
|
| 186 |
- if self.mapSerializableSpecObjects[specName].installRequiresPackages.has_key(package): |
|
| 187 |
- return self.mapSerializableSpecObjects[specName].installRequiresPackages[package] |
|
| 188 |
- return None |
|
| 184 |
+ def getRequiresForPackage(self, package): |
|
| 185 |
+ specName=self.getSpecName(package) |
|
| 186 |
+ if self.mapSerializableSpecObjects[specName].installRequiresPackages.has_key(package): |
|
| 187 |
+ return self.mapSerializableSpecObjects[specName].installRequiresPackages[package] |
|
| 188 |
+ return None |
|
| 189 | 189 |
|
| 190 |
- def getRelease(self, package): |
|
| 191 |
- specName=self.getSpecName(package) |
|
| 192 |
- return self.mapSerializableSpecObjects[specName].release |
|
| 190 |
+ def getRelease(self, package): |
|
| 191 |
+ specName=self.getSpecName(package) |
|
| 192 |
+ return self.mapSerializableSpecObjects[specName].release |
|
| 193 | 193 |
|
| 194 |
- def getVersion(self, package): |
|
| 195 |
- specName=self.getSpecName(package) |
|
| 196 |
- return self.mapSerializableSpecObjects[specName].version |
|
| 194 |
+ def getVersion(self, package): |
|
| 195 |
+ specName=self.getSpecName(package) |
|
| 196 |
+ return self.mapSerializableSpecObjects[specName].version |
|
| 197 | 197 |
|
| 198 |
- def getSpecFile(self, package): |
|
| 199 |
- specName=self.getSpecName(package) |
|
| 200 |
- return self.mapSerializableSpecObjects[specName].specFile |
|
| 198 |
+ def getSpecFile(self, package): |
|
| 199 |
+ specName=self.getSpecName(package) |
|
| 200 |
+ return self.mapSerializableSpecObjects[specName].specFile |
|
| 201 | 201 |
|
| 202 |
- def getPatches(self, package): |
|
| 203 |
- specName=self.getSpecName(package) |
|
| 204 |
- return self.mapSerializableSpecObjects[specName].listPatches |
|
| 202 |
+ def getPatches(self, package): |
|
| 203 |
+ specName=self.getSpecName(package) |
|
| 204 |
+ return self.mapSerializableSpecObjects[specName].listPatches |
|
| 205 | 205 |
|
| 206 |
- def getSources(self, package): |
|
| 207 |
- specName=self.getSpecName(package) |
|
| 208 |
- return self.mapSerializableSpecObjects[specName].listSources |
|
| 206 |
+ def getSources(self, package): |
|
| 207 |
+ specName=self.getSpecName(package) |
|
| 208 |
+ return self.mapSerializableSpecObjects[specName].listSources |
|
| 209 | 209 |
|
| 210 |
- def getPackages(self, package): |
|
| 211 |
- specName=self.getSpecName(package) |
|
| 212 |
- return self.mapSerializableSpecObjects[specName].listPackages |
|
| 210 |
+ def getPackages(self, package): |
|
| 211 |
+ specName=self.getSpecName(package) |
|
| 212 |
+ return self.mapSerializableSpecObjects[specName].listPackages |
|
| 213 | 213 |
|
| 214 |
- def getSpecName(self,package): |
|
| 215 |
- if self.mapPackageToSpec.has_key(package): |
|
| 216 |
- specName=self.mapPackageToSpec[package] |
|
| 217 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
| 218 |
- return specName |
|
| 219 |
- else: |
|
| 220 |
- print "SpecDeps: Could not able to find " + package + " package from specs" |
|
| 221 |
- raise Exception("Invalid package:" + package)
|
|
| 222 |
- else: |
|
| 223 |
- return None |
|
| 214 |
+ def getSpecName(self,package): |
|
| 215 |
+ if self.mapPackageToSpec.has_key(package): |
|
| 216 |
+ specName=self.mapPackageToSpec[package] |
|
| 217 |
+ if self.mapSerializableSpecObjects.has_key(specName): |
|
| 218 |
+ return specName |
|
| 219 |
+ else: |
|
| 220 |
+ print "SpecDeps: Could not able to find " + package + " package from specs" |
|
| 221 |
+ raise Exception("Invalid package:" + package)
|
|
| 222 |
+ else: |
|
| 223 |
+ return None |
|
| 224 | 224 |
|
| 225 |
- def isRPMPackage(self,package): |
|
| 226 |
- if self.mapPackageToSpec.has_key(package): |
|
| 227 |
- specName=self.mapPackageToSpec[package] |
|
| 228 |
- if self.mapSerializableSpecObjects.has_key(specName): |
|
| 229 |
- return True |
|
| 230 |
- return False |
|
| 225 |
+ def isRPMPackage(self,package): |
|
| 226 |
+ if self.mapPackageToSpec.has_key(package): |
|
| 227 |
+ specName=self.mapPackageToSpec[package] |
|
| 228 |
+ if self.mapSerializableSpecObjects.has_key(specName): |
|
| 229 |
+ return True |
|
| 230 |
+ return False |
|
| 231 | 231 |
|
| 232 |
- def getSecurityHardeningOption(self, package): |
|
| 233 |
- specName=self.getSpecName(package) |
|
| 234 |
- return self.mapSerializableSpecObjects[specName].securityHardening |
|
| 232 |
+ def getSecurityHardeningOption(self, package): |
|
| 233 |
+ specName=self.getSpecName(package) |
|
| 234 |
+ return self.mapSerializableSpecObjects[specName].securityHardening |
|
| 235 | 235 |
|
| 236 |
- def getSpecDetails(self, name): |
|
| 237 |
- print self.mapSerializableSpecObjects[name].installRequiresAllPackages |
|
| 236 |
+ def getSpecDetails(self, name): |
|
| 237 |
+ print self.mapSerializableSpecObjects[name].installRequiresAllPackages |
|
| 238 | 238 |
|
| ... | ... |
@@ -18,39 +18,39 @@ LOG_FILE_DIR = "../../stage/LOGS" |
| 18 | 18 |
|
| 19 | 19 |
|
| 20 | 20 |
def main(): |
| 21 |
- usage = os.path.basename(__file__) + "--input-type=[json/pkg/who-needs] --pkg=[pkg_name] --file=<JSON_FILE_NAME> --disp=[tree/list/json]" |
|
| 22 |
- parser = OptionParser(usage) |
|
| 23 |
- parser.add_option("-i", "--input-type", dest="input_type", default=DEFAULT_INPUT_TYPE)
|
|
| 24 |
- parser.add_option("-p", "--pkg", dest="pkg")
|
|
| 25 |
- parser.add_option("-f", "--file", dest="json_file", default="packages_minimal.json")
|
|
| 26 |
- parser.add_option("-d", "--disp", dest="display_option", default=DEFAULT_DISPLAY_OPTION)
|
|
| 27 |
- parser.add_option("-s", "--spec-dir", dest="spec_dir", default=SPEC_FILE_DIR)
|
|
| 28 |
- parser.add_option("-t", "--stage-dir", dest="stage_dir", default="../../stage")
|
|
| 29 |
- parser.add_option("-a", "--input-data-dir", dest="input_data_dir", default="../../common/data/")
|
|
| 30 |
- (options, args) = parser.parse_args() |
|
| 31 |
- |
|
| 32 |
- if(False == options.input_data_dir.endswith('/')):
|
|
| 33 |
- options.input_data_dir += '/' |
|
| 34 |
- |
|
| 35 |
- specDeps = SerializedSpecObjects(options.input_data_dir, options.stage_dir) |
|
| 36 |
- displayOption = options.display_option |
|
| 37 |
- abs_path = os.path.abspath(__file__) |
|
| 38 |
- dir_name = os.path.dirname(abs_path) |
|
| 39 |
- os.chdir(dir_name) |
|
| 40 |
- |
|
| 41 |
- if(options.input_type == "pkg" or options.input_type == "who-needs"): # To display/print package dependencies on console |
|
| 42 |
- targetName = options.pkg |
|
| 43 |
- specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, targetName, displayOption) |
|
| 44 |
- elif(options.input_type == "json"):# Generate the expanded package dependencies json file based on package_list_file |
|
| 45 |
- json_wrapper_option_list = JsonWrapper(options.json_file) |
|
| 46 |
- option_list_json = json_wrapper_option_list.read() |
|
| 47 |
- options_sorted = option_list_json.items() |
|
| 48 |
- for install_option in options_sorted: |
|
| 49 |
- if displayOption == "tree" and install_option[1]["title"] == "ISO Packages": |
|
| 50 |
- continue |
|
| 51 |
- specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, install_option[1]["file"], displayOption) |
|
| 52 |
- |
|
| 53 |
- sys.exit(0) |
|
| 21 |
+ usage = os.path.basename(__file__) + "--input-type=[json/pkg/who-needs] --pkg=[pkg_name] --file=<JSON_FILE_NAME> --disp=[tree/list/json]" |
|
| 22 |
+ parser = OptionParser(usage) |
|
| 23 |
+ parser.add_option("-i", "--input-type", dest="input_type", default=DEFAULT_INPUT_TYPE)
|
|
| 24 |
+ parser.add_option("-p", "--pkg", dest="pkg")
|
|
| 25 |
+ parser.add_option("-f", "--file", dest="json_file", default="packages_minimal.json")
|
|
| 26 |
+ parser.add_option("-d", "--disp", dest="display_option", default=DEFAULT_DISPLAY_OPTION)
|
|
| 27 |
+ parser.add_option("-s", "--spec-dir", dest="spec_dir", default=SPEC_FILE_DIR)
|
|
| 28 |
+ parser.add_option("-t", "--stage-dir", dest="stage_dir", default="../../stage")
|
|
| 29 |
+ parser.add_option("-a", "--input-data-dir", dest="input_data_dir", default="../../common/data/")
|
|
| 30 |
+ (options, args) = parser.parse_args() |
|
| 31 |
+ |
|
| 32 |
+ if(False == options.input_data_dir.endswith('/')):
|
|
| 33 |
+ options.input_data_dir += '/' |
|
| 34 |
+ |
|
| 35 |
+ specDeps = SerializedSpecObjects(options.input_data_dir, options.stage_dir) |
|
| 36 |
+ displayOption = options.display_option |
|
| 37 |
+ abs_path = os.path.abspath(__file__) |
|
| 38 |
+ dir_name = os.path.dirname(abs_path) |
|
| 39 |
+ os.chdir(dir_name) |
|
| 40 |
+ |
|
| 41 |
+ if(options.input_type == "pkg" or options.input_type == "who-needs"): # To display/print package dependencies on console |
|
| 42 |
+ targetName = options.pkg |
|
| 43 |
+ specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, targetName, displayOption) |
|
| 44 |
+ elif(options.input_type == "json"):# Generate the expanded package dependencies json file based on package_list_file |
|
| 45 |
+ json_wrapper_option_list = JsonWrapper(options.json_file) |
|
| 46 |
+ option_list_json = json_wrapper_option_list.read() |
|
| 47 |
+ options_sorted = option_list_json.items() |
|
| 48 |
+ for install_option in options_sorted: |
|
| 49 |
+ if displayOption == "tree" and install_option[1]["title"] == "ISO Packages": |
|
| 50 |
+ continue |
|
| 51 |
+ specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, install_option[1]["file"], displayOption) |
|
| 52 |
+ |
|
| 53 |
+ sys.exit(0) |
|
| 54 | 54 |
|
| 55 | 55 |
if __name__=="__main__": |
| 56 | 56 |
main() |
| ... | ... |
@@ -138,17 +138,17 @@ class Specutils(object): |
| 138 | 138 |
for dpkg in pkg.requires: |
| 139 | 139 |
dependentPackages.append(dpkg.package) |
| 140 | 140 |
#if (pkgName == "mono-extras"): |
| 141 |
- # print "4given packages:", self.spec.packages |
|
| 141 |
+ # print "4given packages:", self.spec.packages |
|
| 142 | 142 |
# print "4given dep packages: ", dependentPackages |
| 143 | 143 |
return dependentPackages |
| 144 | 144 |
|
| 145 | 145 |
def getBuildRequiresAllPackages(self): |
| 146 |
- |
|
| 146 |
+ |
|
| 147 | 147 |
depedentPackages=[] |
| 148 | 148 |
for key in self.spec.packages.keys(): |
| 149 | 149 |
pkg = self.spec.packages.get(key) |
| 150 | 150 |
#if(pkg.name == "mono"): |
| 151 |
- #print "build dendent packages len 4 mono-devel:", len(pkg.buildrequires) |
|
| 151 |
+ #print "build dendent packages len 4 mono-devel:", len(pkg.buildrequires) |
|
| 152 | 152 |
for dpkg in pkg.buildrequires: |
| 153 | 153 |
depedentPackages.append(dpkg.package) |
| 154 | 154 |
depedentPackages=list(set(depedentPackages)) |
| ... | ... |
@@ -166,8 +166,8 @@ class Specutils(object): |
| 166 | 166 |
for key in self.spec.packages.keys(): |
| 167 | 167 |
pkg = self.spec.packages.get(key) |
| 168 | 168 |
if pkg.name == pkgName: |
| 169 |
- #if( pkgName == "mono-devel"): |
|
| 170 |
- #print "dendent packages len 4 mono-devel:", len(pkg.requires), pkg.requires[0].package |
|
| 169 |
+ #if( pkgName == "mono-devel"): |
|
| 170 |
+ #print "dendent packages len 4 mono-devel:", len(pkg.requires), pkg.requires[0].package |
|
| 171 | 171 |
for dpkg in pkg.requires: |
| 172 | 172 |
dependentPackages.append(dpkg.package) |
| 173 | 173 |
return dependentPackages |
| ... | ... |
@@ -177,8 +177,8 @@ class Specutils(object): |
| 177 | 177 |
for key in self.spec.packages.keys(): |
| 178 | 178 |
pkg = self.spec.packages.get(key) |
| 179 | 179 |
if pkg.name == pkgName: |
| 180 |
- #if( pkgName == "mono-devel"): |
|
| 181 |
- #print "build dendent packages len 4 mono-devel:", len(pkg.buildrequires), pkg.buildrequires[0].package |
|
| 180 |
+ #if( pkgName == "mono-devel"): |
|
| 181 |
+ #print "build dendent packages len 4 mono-devel:", len(pkg.buildrequires), pkg.buildrequires[0].package |
|
| 182 | 182 |
for dpkg in pkg.buildrequires: |
| 183 | 183 |
dependentPackages.append(dpkg.package) |
| 184 | 184 |
return dependentPackages |
| ... | ... |
@@ -14,8 +14,8 @@ class StringUtils(object): |
| 14 | 14 |
return inputstring[index+1:] |
| 15 | 15 |
|
| 16 | 16 |
def getSpecNameFromPackageName(self, pkgName): |
| 17 |
- id = pkgName.rfind("-")
|
|
| 18 |
- if (id != -1): |
|
| 19 |
- return pkgName[0:id]; |
|
| 20 |
- else: |
|
| 21 |
- return pkgName; |
|
| 17 |
+ id = pkgName.rfind("-")
|
|
| 18 |
+ if (id != -1): |
|
| 19 |
+ return pkgName[0:id]; |
|
| 20 |
+ else: |
|
| 21 |
+ return pkgName; |
| ... | ... |
@@ -30,13 +30,13 @@ class ThreadPool(object): |
| 30 | 30 |
@staticmethod |
| 31 | 31 |
def addWorkerThread(workerThreadName): |
| 32 | 32 |
workerThread = WorkerThread.WorkerThread( |
| 33 |
- ThreadPool.statusEvent, |
|
| 34 |
- workerThreadName, |
|
| 35 |
- ThreadPool.mapPackageToCycle, |
|
| 36 |
- ThreadPool.listAvailableCyclicPackages, |
|
| 37 |
- ThreadPool.logger, |
|
| 38 |
- ThreadPool.listBuildOptionPackages, |
|
| 39 |
- ThreadPool.pkgBuildOptionFile) |
|
| 33 |
+ ThreadPool.statusEvent, |
|
| 34 |
+ workerThreadName, |
|
| 35 |
+ ThreadPool.mapPackageToCycle, |
|
| 36 |
+ ThreadPool.listAvailableCyclicPackages, |
|
| 37 |
+ ThreadPool.logger, |
|
| 38 |
+ ThreadPool.listBuildOptionPackages, |
|
| 39 |
+ ThreadPool.pkgBuildOptionFile) |
|
| 40 | 40 |
ThreadPool.mapWorkerThreads[workerThreadName]=workerThread |
| 41 | 41 |
|
| 42 | 42 |
@staticmethod |