Change-Id: If581bcf04386052d5a787bcca4e50e8ff44212b3
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/4624
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Xiaolin Li <xiaolinl@vmware.com>
... | ... |
@@ -404,16 +404,16 @@ $(PHOTON_STAGE): |
404 | 404 |
generate-dep-lists: |
405 | 405 |
$(RMDIR) $(PHOTON_GENERATED_DATA_DIR) |
406 | 406 |
$(MKDIR) -p $(PHOTON_GENERATED_DATA_DIR) |
407 |
- @for f in $$(ls $(PHOTON_DATA_DIR)/build_install_options*.json) ; \ |
|
408 |
- do \ |
|
409 |
- cp $$f $(PHOTON_GENERATED_DATA_DIR); \ |
|
410 |
- echo "Generating the install time dependency list for " $$f; \ |
|
411 |
- cd $(PHOTON_SPECDEPS_DIR) && \ |
|
412 |
- $(PHOTON_SPECDEPS) \ |
|
407 |
+ cd $(PHOTON_SPECDEPS_DIR) && \ |
|
408 |
+ $(PHOTON_SPECDEPS) \ |
|
413 | 409 |
-s $(PHOTON_SPECS_DIR) \ |
414 | 410 |
-t $(PHOTON_STAGE) \ |
415 |
- --input-type=json --file $$f -d json -a $(PHOTON_DATA_DIR); \ |
|
416 |
- done |
|
411 |
+ -l $(PHOTON_LOGS_DIR) \ |
|
412 |
+ -p $(PHOTON_GENERATED_DATA_DIR) \ |
|
413 |
+ --input-type=json \ |
|
414 |
+ --file "$$(ls $(PHOTON_DATA_DIR)/build_install_options*.json)" \ |
|
415 |
+ -d json \ |
|
416 |
+ -a $(PHOTON_DATA_DIR) |
|
417 | 417 |
|
418 | 418 |
photon-docker-image: |
419 | 419 |
createrepo $(PHOTON_RPMS_DIR) |
... | ... |
@@ -617,22 +617,11 @@ check: packages |
617 | 617 |
generate-yaml-files: check-tools $(PHOTON_STAGE) $(PHOTON_PACKAGES) |
618 | 618 |
@echo "Generating yaml files for packages ..." |
619 | 619 |
@cd $(PHOTON_PKG_BUILDER_DIR) && \ |
620 |
- $(PHOTON_PACKAGE_BUILDER) -y \ |
|
621 |
- -b $(PHOTON_CHROOT_PATH) \ |
|
620 |
+ $(PHOTON_GENERATE_OSS_FILES) -y \ |
|
622 | 621 |
-s $(PHOTON_SPECS_DIR) \ |
623 |
- -r $(PHOTON_RPMS_DIR) \ |
|
624 | 622 |
-a $(PHOTON_SRPMS_DIR) \ |
625 |
- -x $(PHOTON_SRCS_DIR) \ |
|
626 |
- -p $(PHOTON_PUBLISH_RPMS_DIR) \ |
|
627 |
- -e $(PHOTON_PUBLISH_XRPMS_DIR) \ |
|
628 |
- -c $(PHOTON_PULLSOURCES_CONFIG) \ |
|
629 |
- -d $(PHOTON_DIST_TAG) \ |
|
630 |
- -n $(PHOTON_BUILD_NUMBER) \ |
|
631 |
- -v $(PHOTON_RELEASE_VERSION) \ |
|
632 |
- -g $(PHOTON_DATA_DIR)/pkg_build_options.json \ |
|
633 |
- $(PHOTON_RPMCHECK_OPTION) \ |
|
634 | 623 |
-l $(PHOTON_LOGS_DIR) \ |
635 |
- -j $(PHOTON_STAGE) \ |
|
624 |
+ -c $(PHOTON_PULLSOURCES_CONFIG) \ |
|
636 | 625 |
-f $(PHOTON_PKG_BLACKLIST_FILE) |
637 | 626 |
|
638 | 627 |
$(TOOLS_BIN): |
... | ... |
@@ -42,6 +42,7 @@ PHOTON_INSTALLER=$(PHOTON_INSTALLER_DIR)/photonInstaller.py |
42 | 42 |
PHOTON_SPECDEPS_DIR=$(SRCROOT)/support/package-builder |
43 | 43 |
PHOTON_SPECDEPS=$(PHOTON_SPECDEPS_DIR)/SpecDeps.py |
44 | 44 |
PHOTON_PACKAGE_BUILDER=$(PHOTON_PKG_BUILDER_DIR)/builder.py |
45 |
+PHOTON_GENERATE_OSS_FILES=$(PHOTON_PKG_BUILDER_DIR)/GenerateOSSFiles.py |
|
45 | 46 |
ifdef PHOTON_PULLSOURCES_CONFIG |
46 | 47 |
PHOTON_PULLSOURCES_CONFIG:=$(abspath $(PHOTON_PULLSOURCES_CONFIG)) |
47 | 48 |
else |
48 | 49 |
new file mode 100755 |
... | ... |
@@ -0,0 +1,221 @@ |
0 |
+#!/usr/bin/env python3 |
|
1 |
+ |
|
2 |
+import os |
|
3 |
+import json |
|
4 |
+import sys |
|
5 |
+import traceback |
|
6 |
+from Logger import Logger |
|
7 |
+from argparse import ArgumentParser |
|
8 |
+from constants import constants |
|
9 |
+from CommandUtils import CommandUtils |
|
10 |
+from SpecData import SPECS |
|
11 |
+ |
|
12 |
+ |
|
13 |
+ |
|
14 |
+def main(): |
|
15 |
+ usage = "Usage: %prog [options] <package name>" |
|
16 |
+ parser = ArgumentParser(usage) |
|
17 |
+ parser.add_argument("-s", "--spec-path", dest="specPath", default="../../SPECS") |
|
18 |
+ parser.add_argument("-l", "--log-path", dest="logPath", default="../../stage/LOGS") |
|
19 |
+ parser.add_argument("-a", "--source-rpm-path", dest="sourceRpmPath", default="../../stage/SRPMS") |
|
20 |
+ parser.add_argument("-j", "--output-dir", dest="outputDirPath", default="../../stage/") |
|
21 |
+ parser.add_argument("-c", "--pullsources-config", dest="pullsourcesConfig", default="pullsources.conf") |
|
22 |
+ parser.add_argument("-f", "--pkg-blacklist-file", dest="pkgBlacklistFile", default=None) |
|
23 |
+ parser.add_argument("-p", "--generate-pkg-list", dest="generatePkgList", default=False, action="store_true") |
|
24 |
+ parser.add_argument("-y", "--generate-yaml-files", dest="generateYamlFiles", default=False, action="store_true") |
|
25 |
+ |
|
26 |
+ options = parser.parse_args() |
|
27 |
+ errorFlag = False |
|
28 |
+ cmdUtils = CommandUtils() |
|
29 |
+ |
|
30 |
+ try: |
|
31 |
+ if not os.path.isdir(options.logPath): |
|
32 |
+ cmdUtils.runCommandInShell("mkdir -p " + options.logPath) |
|
33 |
+ logger = Logger.getLogger(options.logPath + "/generateYamlFiles") |
|
34 |
+ |
|
35 |
+ if options.generateYamlFiles: |
|
36 |
+ if (options.pkgBlacklistFile is not None and |
|
37 |
+ options.pkgBlacklistFile != "" and |
|
38 |
+ not os.path.isfile(options.pkgBlacklistFile)): |
|
39 |
+ logger.error("Given package blacklist file is not valid:" + options.pkgBlacklistFile) |
|
40 |
+ errorFlag = True |
|
41 |
+ |
|
42 |
+ if not os.path.isdir(options.specPath): |
|
43 |
+ logger.error("Given Specs Path is not a directory:" + options.specPath) |
|
44 |
+ errorFlag = True |
|
45 |
+ |
|
46 |
+ if not os.path.isdir(options.sourceRpmPath): |
|
47 |
+ logger.error("Given SRPM Path is not a directory:" + options.sourceRpmPath) |
|
48 |
+ errorFlag = True |
|
49 |
+ |
|
50 |
+ if options.generateYamlFiles and not os.path.isfile(options.pullsourcesConfig): |
|
51 |
+ logger.error("Given Source config file is not a valid file:" + options.pullsourcesConfig) |
|
52 |
+ errorFlag = True |
|
53 |
+ |
|
54 |
+ if errorFlag: |
|
55 |
+ logger.error("Found some errors. Please fix input options and re-run it.") |
|
56 |
+ sys.exit(1) |
|
57 |
+ |
|
58 |
+ if options.generateYamlFiles: |
|
59 |
+ if not os.path.isdir(options.outputDirPath): |
|
60 |
+ cmdUtils.runCommandInShell("mkdir -p "+options.outputDirPath) |
|
61 |
+ |
|
62 |
+ constants.setSpecPath(options.specPath) |
|
63 |
+ constants.setSourceRpmPath(options.sourceRpmPath) |
|
64 |
+ constants.setLogPath(options.logPath) |
|
65 |
+ constants.setPullSourcesConfig(options.pullsourcesConfig) |
|
66 |
+ constants.initialize() |
|
67 |
+ |
|
68 |
+ # parse SPECS folder |
|
69 |
+ SPECS() |
|
70 |
+ |
|
71 |
+ if options.generatePkgList: |
|
72 |
+ buildPackagesList(options.outputDirPath + "/packages_list.csv") |
|
73 |
+ elif options.generateYamlFiles: |
|
74 |
+ blackListPkgs = readBlackListPackages(options.pkgBlacklistFile) |
|
75 |
+ buildSourcesList(options.outputDirPath, blackListPkgs, logger) |
|
76 |
+ buildSRPMList(options.sourceRpmPath, options.outputDirPath, blackListPkgs, logger) |
|
77 |
+ |
|
78 |
+ except Exception as e: |
|
79 |
+ print("Caught Exception: "+str(e)) |
|
80 |
+ traceback.print_exc() |
|
81 |
+ sys.exit(1) |
|
82 |
+ |
|
83 |
+ sys.exit(0) |
|
84 |
+ |
|
85 |
+ |
|
86 |
+def buildPackagesList(csvFilename): |
|
87 |
+ csvFile = open(csvFilename, "w") |
|
88 |
+ csvFile.write("Package,Version,License,URL,Sources,Patches\n") |
|
89 |
+ listPackages = SPECS.getData().getListPackages() |
|
90 |
+ listPackages.sort() |
|
91 |
+ for package in listPackages: |
|
92 |
+ name = package |
|
93 |
+ version = SPECS.getData().getVersion(package) |
|
94 |
+ license = SPECS.getData().getLicense(package) |
|
95 |
+ listPatches = SPECS.getData().getPatches(package) |
|
96 |
+ url = SPECS.getData().getURL(package) |
|
97 |
+ listSourceNames = SPECS.getData().getSources(package) |
|
98 |
+ sources = "" |
|
99 |
+ patches = "" |
|
100 |
+ if listPatches is not None: |
|
101 |
+ patches = " ".join(listPatches) |
|
102 |
+ if listSourceNames is not None: |
|
103 |
+ sources = " ".join(listSourceNames) |
|
104 |
+ csvFile.write(name + "," + version + "," + license + "," + url + "," + sources + "," + patches + "\n") |
|
105 |
+ csvFile.close() |
|
106 |
+ |
|
107 |
+ |
|
108 |
+def readBlackListPackages(pkgBlackListFile): |
|
109 |
+ blackListPkgs = [] |
|
110 |
+ if pkgBlackListFile is not None and pkgBlackListFile != "": |
|
111 |
+ with open(pkgBlackListFile) as jsonFile: |
|
112 |
+ config = json.load(jsonFile) |
|
113 |
+ if 'packages' in config: |
|
114 |
+ blackListPkgs = config['packages'] |
|
115 |
+ return blackListPkgs |
|
116 |
+ |
|
117 |
+ |
|
118 |
+def buildSourcesList(yamlDir, blackListPkgs, logger, singleFile=True): |
|
119 |
+ cmdUtils = CommandUtils() |
|
120 |
+ yamlSourceDir = os.path.join(yamlDir, "yaml_sources") |
|
121 |
+ if not os.path.isdir(yamlSourceDir): |
|
122 |
+ cmdUtils.runCommandInShell("mkdir -p " + yamlSourceDir) |
|
123 |
+ if singleFile: |
|
124 |
+ yamlFile = open(yamlSourceDir + "/sources_list.yaml", "w") |
|
125 |
+ listPackages = SPECS.getData().getListPackages() |
|
126 |
+ listPackages.sort() |
|
127 |
+ import PullSources |
|
128 |
+ for package in listPackages: |
|
129 |
+ if package in blackListPkgs: |
|
130 |
+ continue |
|
131 |
+ ossname = package |
|
132 |
+ ossversion = SPECS.getData().getVersion(package) |
|
133 |
+ modified = False |
|
134 |
+ listPatches = SPECS.getData().getPatches(package) |
|
135 |
+ if listPatches is not None and len(listPatches) > 0: |
|
136 |
+ modified = True |
|
137 |
+ url = SPECS.getData().getSourceURL(package) |
|
138 |
+ if url is None: |
|
139 |
+ url = SPECS.getData().getURL(package) |
|
140 |
+ |
|
141 |
+ sourceName = None |
|
142 |
+ listSourceNames = SPECS.getData().getSources(package) |
|
143 |
+ if len(listSourceNames) > 0: |
|
144 |
+ sourceName = listSourceNames[0] |
|
145 |
+ sha1 = SPECS.getData().getSHA1(package, sourceName) |
|
146 |
+ if sha1 is not None: |
|
147 |
+ PullSources.get(sourceName, sha1, yamlSourceDir, |
|
148 |
+ constants.pullsourcesConfig, logger) |
|
149 |
+ |
|
150 |
+ if not singleFile: |
|
151 |
+ yamlFile = open(yamlSourceDir + "/" + ossname + "-" + ossversion + ".yaml", "w") |
|
152 |
+ yamlFile.write("vmwsource:" + ossname + ":" + ossversion + ":\n") |
|
153 |
+ yamlFile.write(" repository: VMWsource\n") |
|
154 |
+ yamlFile.write(" name: '" + ossname + "'\n") |
|
155 |
+ yamlFile.write(" version: '" + ossversion + "'\n") |
|
156 |
+ yamlFile.write(" url: " + str(url) + "\n") |
|
157 |
+ yamlFile.write(" license: UNKNOWN\n") |
|
158 |
+ if sourceName is not None: |
|
159 |
+ yamlFile.write(" vmwsource-distribution: " + str(sourceName) + "\n") |
|
160 |
+ if modified: |
|
161 |
+ yamlFile.write(" modified: true\n") |
|
162 |
+ yamlFile.write("\n") |
|
163 |
+ if not singleFile: |
|
164 |
+ yamlFile.close() |
|
165 |
+ |
|
166 |
+ if singleFile: |
|
167 |
+ yamlFile.close() |
|
168 |
+ logger.info("Generated source yaml files for all packages") |
|
169 |
+ |
|
170 |
+ |
|
171 |
+def buildSRPMList(srpmPath, yamlDir, blackListPkgs, logger, singleFile=True): |
|
172 |
+ cmdUtils = CommandUtils() |
|
173 |
+ yamlSrpmDir = os.path.join(yamlDir, "yaml_srpms") |
|
174 |
+ if not os.path.isdir(yamlSrpmDir): |
|
175 |
+ cmdUtils.runCommandInShell("mkdir -p " + yamlSrpmDir) |
|
176 |
+ if singleFile: |
|
177 |
+ yamlFile = open(yamlSrpmDir + "/srpm_list.yaml", "w") |
|
178 |
+ listPackages = SPECS.getData().getListPackages() |
|
179 |
+ listPackages.sort() |
|
180 |
+ for package in listPackages: |
|
181 |
+ if package in blackListPkgs: |
|
182 |
+ continue |
|
183 |
+ ossname = package |
|
184 |
+ ossversion = SPECS.getData().getVersion(package) |
|
185 |
+ ossrelease = SPECS.getData().getRelease(package) |
|
186 |
+ |
|
187 |
+ listFoundSRPMFiles = cmdUtils.findFile(ossname + "-" + ossversion + "-" + ossrelease + ".src.rpm", |
|
188 |
+ srpmPath) |
|
189 |
+ srpmName = None |
|
190 |
+ if len(listFoundSRPMFiles) == 1: |
|
191 |
+ srpmFullPath = listFoundSRPMFiles[0] |
|
192 |
+ srpmName = os.path.basename(srpmFullPath) |
|
193 |
+ cpcmd = "cp " + srpmFullPath + " " + yamlSrpmDir + "/" |
|
194 |
+ returnVal = cmdUtils.runCommandInShell(cpcmd) |
|
195 |
+ if not returnVal: |
|
196 |
+ logger.error("Copy SRPM File is failed for package:" + ossname) |
|
197 |
+ else: |
|
198 |
+ logger.error("SRPM file is not found:" + ossname) |
|
199 |
+ |
|
200 |
+ if not singleFile: |
|
201 |
+ yamlFile = open(yamlSrpmDir + "/" + ossname + "-" + ossversion + "-" + ossrelease + ".yaml", "w") |
|
202 |
+ |
|
203 |
+ yamlFile.write("baseos:" + ossname + ":" + ossversion + "-" + ossrelease + ":\n") |
|
204 |
+ yamlFile.write(" repository: BaseOS\n") |
|
205 |
+ yamlFile.write(" name: '" + ossname + "'\n") |
|
206 |
+ yamlFile.write(" version: '" + ossversion + "-" + ossrelease + "'\n") |
|
207 |
+ yamlFile.write(" baseos-style: rpm\n") |
|
208 |
+ yamlFile.write(" baseos-source: '" + str(srpmName) + "'\n") |
|
209 |
+ yamlFile.write(" baseos-osname: 'photon'\n") |
|
210 |
+ yamlFile.write("\n") |
|
211 |
+ if not singleFile: |
|
212 |
+ yamlFile.close() |
|
213 |
+ |
|
214 |
+ if singleFile: |
|
215 |
+ yamlFile.close() |
|
216 |
+ logger.info("Generated SRPM yaml files for all packages") |
|
217 |
+ |
|
218 |
+ |
|
219 |
+if __name__ == "__main__": |
|
220 |
+ main() |
0 | 221 |
deleted file mode 100644 |
... | ... |
@@ -1,16 +0,0 @@ |
1 |
-import commands |
|
2 |
- |
|
3 |
-class RepoQueryDependency(object): |
|
4 |
- def __init__(self, repoFile): |
|
5 |
- self.repo_file = repoFile |
|
6 |
- def getRequiresList(self,pkg): |
|
7 |
- cmd = ("repoquery -c " + self.repo_file + " -R -q " + pkg + |
|
8 |
- " | xargs repoquery -c " + self.repo_file + |
|
9 |
- " --whatprovides -q | sed 's/-[0-9]/ /g' | cut -f 1 -d ' ' | sort | uniq ") |
|
10 |
- status,output = commands.getstatusoutput(cmd) |
|
11 |
- if status == 0: |
|
12 |
- outList = output.split('\n') |
|
13 |
- if "" in outList: outList.remove("") |
|
14 |
- if "Options:" in outList: outList.remove("Options:") |
|
15 |
- if "Usage:" in outList: outList.remove("Usage:") |
|
16 |
- return outList |
... | ... |
@@ -8,6 +8,8 @@ from SpecUtils import Specutils |
8 | 8 |
from Logger import Logger |
9 | 9 |
from constants import constants |
10 | 10 |
|
11 |
+ |
|
12 |
+ |
|
11 | 13 |
class SerializableSpecObject(object): |
12 | 14 |
def __init__(self): |
13 | 15 |
self.listPackages = [] |
... | ... |
@@ -29,6 +31,7 @@ class SerializableSpecObject(object): |
29 | 29 |
self.license = "" |
30 | 30 |
self.specDefs = {} |
31 | 31 |
|
32 |
+ |
|
32 | 33 |
class SerializableSpecObjectsUtils(object): |
33 | 34 |
|
34 | 35 |
def __init__(self, logPath): |
... | ... |
@@ -71,7 +74,7 @@ class SerializableSpecObjectsUtils(object): |
71 | 71 |
self.mapPackageToSpec[specPkg] = specName |
72 | 72 |
if spec.getIsRPMPackage(specPkg): |
73 | 73 |
specObj.listRPMPackages.append(specPkg) |
74 |
- if skipUpdating == False: |
|
74 |
+ if not skipUpdating: |
|
75 | 75 |
self.mapSerializableSpecObjects[specName] = specObj |
76 | 76 |
|
77 | 77 |
def getListSpecFiles(self, listSpecFiles, path): |
... | ... |
@@ -135,10 +138,11 @@ class SerializableSpecObjectsUtils(object): |
135 | 135 |
specName = self.getSpecName(package) |
136 | 136 |
return self.mapSerializableSpecObjects[specName].listRPMPackages |
137 | 137 |
|
138 |
- def getReleaseNum(self, releaseVal): |
|
139 |
- id = releaseVal.find("%") |
|
140 |
- if id != -1: |
|
141 |
- return releaseVal[0:id] |
|
138 |
+ @staticmethod |
|
139 |
+ def getReleaseNum(releaseVal): |
|
140 |
+ releaseNum = releaseVal.find("%") |
|
141 |
+ if releaseNum != -1: |
|
142 |
+ return releaseVal[0:releaseNum] |
|
142 | 143 |
else: |
143 | 144 |
return releaseVal |
144 | 145 |
|
... | ... |
@@ -223,6 +227,7 @@ class SerializableSpecObjectsUtils(object): |
223 | 223 |
self.logger.info("security_hardening: " + specObj.securityHardening) |
224 | 224 |
self.logger.info("------------------------------------------------") |
225 | 225 |
|
226 |
+ |
|
226 | 227 |
class SPECS(object): |
227 | 228 |
__instance = None |
228 | 229 |
specData = None |
... | ... |
@@ -244,7 +249,7 @@ class SPECS(object): |
244 | 244 |
|
245 | 245 |
def initialize(self): |
246 | 246 |
# Preparse some files |
247 |
- #adding openjre8 version rpm macro |
|
247 |
+ # adding openjre8 version rpm macro |
|
248 | 248 |
if platform.machine() == "x86_64": |
249 | 249 |
spec = Specutils(constants.specPath + "/openjdk8/openjdk8.spec") |
250 | 250 |
else: |
... | ... |
@@ -252,16 +257,16 @@ class SPECS(object): |
252 | 252 |
java8version = spec.getVersion() |
253 | 253 |
constants.addMacro("JAVA8_VERSION", java8version) |
254 | 254 |
|
255 |
- #adding kernelversion rpm macro |
|
255 |
+ # adding kernelversion rpm macro |
|
256 | 256 |
spec = Specutils(constants.specPath + "/linux/linux.spec") |
257 | 257 |
kernelversion = spec.getVersion() |
258 | 258 |
constants.addMacro("KERNEL_VERSION", kernelversion) |
259 | 259 |
|
260 |
- #adding kernelrelease rpm macro |
|
260 |
+ # adding kernelrelease rpm macro |
|
261 | 261 |
kernelrelease = spec.getRelease() |
262 | 262 |
constants.addMacro("KERNEL_RELEASE", kernelrelease) |
263 | 263 |
|
264 |
- #adding kernelsubrelease rpm macro |
|
264 |
+ # adding kernelsubrelease rpm macro |
|
265 | 265 |
a, b, c = kernelversion.split(".") |
266 | 266 |
kernelsubrelease = ('%02d%02d%03d%03d' % (int(a), |
267 | 267 |
int(b), int(c), |
... | ... |
@@ -274,177 +279,79 @@ class SPECS(object): |
274 | 274 |
self.specData = SerializableSpecObjectsUtils(constants.logPath) |
275 | 275 |
self.specData.readSpecsAndConvertToSerializableObjects(constants.specPath) |
276 | 276 |
|
277 |
-# Little bit of duplication |
|
278 |
-# Used by SpecVerify and SpecDeps only |
|
279 |
-class SerializedSpecObjects(object): |
|
280 | 277 |
|
281 |
- def __init__(self, inputDataDir, stageDir): |
|
282 |
- self.mapSerializableSpecObjects = {} |
|
283 |
- self.mapPackageToSpec = {} |
|
284 |
- self.jsonFilesOutPath = stageDir + "/common/data/" |
|
285 |
- self.inputDataDir = inputDataDir |
|
278 |
+class SpecDependencyGenerator(object): |
|
286 | 279 |
|
287 |
- def findTotalRequires(self, allDeps, depQue, parent, displayOption): |
|
280 |
+ def findTotalRequires(self, mapDependencies, depQue, parent): |
|
288 | 281 |
while not depQue.empty(): |
289 | 282 |
specPkg = depQue.get() |
290 |
- specName = self.getSpecName(specPkg) |
|
291 |
- if specName is None: |
|
283 |
+ try: |
|
284 |
+ listRequiredPackages = SPECS.getData().getRequiresForPackage(specPkg) |
|
285 |
+ except Exception as e: |
|
286 |
+ print("Caught Exception:"+str(e)) |
|
292 | 287 |
print(specPkg + " is missing") |
293 |
- specObj = self.mapSerializableSpecObjects[specName] |
|
294 |
- for depPkg in specObj.installRequiresPackages[specPkg]: |
|
295 |
- if depPkg in allDeps: |
|
296 |
- if allDeps[depPkg] < allDeps[specPkg] + 1: |
|
297 |
- allDeps[depPkg] = allDeps[specPkg] + 1 |
|
288 |
+ |
|
289 |
+ for depPkg in listRequiredPackages: |
|
290 |
+ if depPkg in mapDependencies: |
|
291 |
+ if mapDependencies[depPkg] < mapDependencies[specPkg] + 1: |
|
292 |
+ mapDependencies[depPkg] = mapDependencies[specPkg] + 1 |
|
298 | 293 |
parent[depPkg] = specPkg |
299 |
- self.updateLevels(allDeps, depPkg, parent, allDeps[depPkg]) |
|
294 |
+ self.updateLevels(mapDependencies, depPkg, parent, mapDependencies[depPkg]) |
|
300 | 295 |
else: |
301 |
- allDeps[depPkg] = allDeps[specPkg] + 1 |
|
296 |
+ mapDependencies[depPkg] = mapDependencies[specPkg] + 1 |
|
302 | 297 |
parent[depPkg] = specPkg |
303 | 298 |
depQue.put(depPkg) |
304 | 299 |
|
305 |
- def findTotalWhoNeedsToBuild(self, depQue, whoBuildDeps, whoBuildDepSet, displayOption): |
|
300 |
+ def findTotalWhoNeedsToBuild(self, depQue, whoNeedsBuild): |
|
306 | 301 |
while not depQue.empty(): |
307 | 302 |
specPkg = depQue.get() |
308 |
- specName = self.getSpecName(specPkg) |
|
309 |
- spec = Specutils(self.getSpecFile(specPkg)) |
|
310 |
- RPMName = spec.getRPMName(specPkg) |
|
311 |
- debuginfoRPMName = spec.getDebuginfoRPMName(specPkg) |
|
312 |
- whoBuildDepSet.add(RPMName) |
|
313 |
- whoBuildDepSet.add(debuginfoRPMName) |
|
314 |
- if specName is None: |
|
315 |
- print(specPkg + " is missing") |
|
316 |
- if specPkg not in whoBuildDeps: |
|
317 |
- continue |
|
318 |
- for depPkg in whoBuildDeps[specPkg]: |
|
319 |
- depQue.put(depPkg) |
|
320 |
- |
|
321 |
- def printTree(self, allDeps, children, curParent, depth): |
|
303 |
+ listPackagesRequiredToBuild = SPECS.getData().getBuildRequiresForPackage(specPkg) |
|
304 |
+ for depPkg in listPackagesRequiredToBuild: |
|
305 |
+ depSpecPkg = SPECS.getData().getSpecName(depPkg) |
|
306 |
+ if depSpecPkg not in whoNeedsBuild: |
|
307 |
+ whoNeedsBuild.append(depSpecPkg) |
|
308 |
+ depQue.put(depSpecPkg) |
|
309 |
+ |
|
310 |
+ def printTree(self, children, curParent, depth): |
|
322 | 311 |
if curParent in children: |
323 | 312 |
for child in children[curParent]: |
324 |
- print("\t" * depth + child) |
|
325 |
- self.printTree(allDeps, children, child, depth + 1) |
|
313 |
+ print ("\t" * depth + child) |
|
314 |
+ self.printTree(children, child, depth + 1) |
|
326 | 315 |
|
327 |
- def get_all_package_names(self, jsonFilePath): |
|
328 |
- base_path = os.path.dirname(jsonFilePath) |
|
316 |
+ def getAllPackageNames(self, jsonFilePath): |
|
329 | 317 |
jsonData = open(jsonFilePath) |
330 | 318 |
option_list_json = json.load(jsonData) |
331 | 319 |
jsonData.close() |
332 | 320 |
packages = option_list_json["packages"] |
333 | 321 |
return packages |
334 | 322 |
|
335 |
- def updateLevels(self, allDeps, inPkg, parent, level): |
|
336 |
- specName = self.getSpecName(inPkg) |
|
337 |
- specObj = self.mapSerializableSpecObjects[specName] |
|
338 |
- for depPkg in specObj.installRequiresPackages[inPkg]: |
|
339 |
- # ignore circular deps within single spec file |
|
340 |
- if (depPkg in specObj.installRequiresPackages and |
|
341 |
- inPkg in specObj.installRequiresPackages[depPkg] and |
|
342 |
- self.getSpecName(depPkg) == specName): |
|
323 |
+ def updateLevels(self, mapDependencies, inPkg, parent, level): |
|
324 |
+ listPackages = SPECS.getData().getPackages(inPkg) |
|
325 |
+ for depPkg in SPECS.getData().getRequiresForPackage(inPkg): |
|
326 |
+ if depPkg in listPackages: |
|
343 | 327 |
continue |
344 |
- if depPkg in allDeps and allDeps[depPkg] < level + 1: |
|
345 |
- allDeps[depPkg] = level + 1 |
|
328 |
+ if depPkg in mapDependencies and mapDependencies[depPkg] < level + 1: |
|
329 |
+ mapDependencies[depPkg] = level + 1 |
|
346 | 330 |
parent[depPkg] = inPkg |
347 |
- self.updateLevels(allDeps, depPkg, parent, allDeps[depPkg]) |
|
331 |
+ self.updateLevels(mapDependencies, depPkg, parent, mapDependencies[depPkg]) |
|
348 | 332 |
|
349 |
- def readSpecsAndConvertToSerializableObjects(self, specFilesPath, inputType, |
|
350 |
- inputValue, displayOption): |
|
351 |
- children = {} |
|
352 |
- listSpecFiles = [] |
|
353 |
- whoNeedsList = [] |
|
354 |
- whoBuildDepSet = set() |
|
355 |
- # list of all RPMS not built from photon and that must be blindly copied. |
|
356 |
- independentRPMS = [] |
|
357 |
- whoBuildDeps = {} |
|
358 |
- allDeps = {} |
|
359 |
- parent = {} |
|
333 |
+ def calculateSpecDependency(self, inputPackages, mapDependencies, parent): |
|
360 | 334 |
depQue = queue.Queue() |
361 |
- packageFound = False |
|
362 |
- self.getListSpecFiles(listSpecFiles, specFilesPath) |
|
363 |
- for specFile in listSpecFiles: |
|
364 |
- spec = Specutils(specFile) |
|
365 |
- specName = spec.getBasePackageName() |
|
366 |
- specObj = SerializableSpecObject() |
|
367 |
- specObj.name = specName |
|
368 |
- specObj.buildRequirePackages = spec.getBuildRequiresAllPackages() |
|
369 |
- specObj.installRequiresAllPackages = spec.getRequiresAllPackages() |
|
370 |
- specObj.listPackages = spec.getPackageNames() |
|
371 |
- specObj.specFile = specFile |
|
372 |
- specObj.version = spec.getVersion() |
|
373 |
- specObj.release = spec.getRelease() |
|
374 |
- specObj.listSources = spec.getSourceNames() |
|
375 |
- specObj.listPatches = spec.getPatchNames() |
|
376 |
- specObj.securityHardening = spec.getSecurityHardeningOption() |
|
377 |
- for specPkg in specObj.listPackages: |
|
378 |
- specObj.installRequiresPackages[specPkg] = spec.getRequires(specPkg) |
|
379 |
- if inputType == "pkg" and inputValue == specPkg: |
|
380 |
- # all the first level dependencies to a dictionary and queue |
|
381 |
- packageFound = True |
|
382 |
- for depPkg in specObj.installRequiresPackages[specPkg]: |
|
383 |
- if depPkg not in allDeps: |
|
384 |
- allDeps[depPkg] = 0 |
|
385 |
- parent[depPkg] = "" |
|
386 |
- depQue.put(depPkg) |
|
387 |
- elif (inputType == "who-needs" and |
|
388 |
- inputValue in specObj.installRequiresPackages[specPkg]): |
|
389 |
- whoNeedsList.append(specPkg) |
|
390 |
- elif inputType == "who-needs-build": |
|
391 |
- for bdrq in specObj.buildRequirePackages: |
|
392 |
- if bdrq in whoBuildDeps: |
|
393 |
- whoBuildDeps[bdrq].add(specPkg) |
|
394 |
- else: |
|
395 |
- whoBuildDeps[bdrq] = set() |
|
396 |
- whoBuildDeps[bdrq].add(specPkg) |
|
397 |
- if inputValue == specPkg: |
|
398 |
- packageFound = True |
|
399 |
- for depPkg in specObj.listPackages: |
|
400 |
- depQue.put(depPkg) |
|
401 |
- |
|
402 |
- self.mapPackageToSpec[specPkg] = specName |
|
403 |
- self.mapSerializableSpecObjects[specName] = specObj |
|
404 |
- |
|
405 |
- # Generate dependencies for individual packages |
|
406 |
- if inputType == "pkg": |
|
407 |
- if packageFound == True: |
|
408 |
- self.findTotalRequires(allDeps, depQue, parent, displayOption) |
|
335 |
+ for pkg in inputPackages: |
|
336 |
+ if SPECS.getData().isRPMPackage(pkg): |
|
337 |
+ if pkg not in mapDependencies: |
|
338 |
+ mapDependencies[pkg] = 0 |
|
339 |
+ parent[pkg] = "" |
|
340 |
+ depQue.put(pkg) |
|
341 |
+ self.findTotalRequires(mapDependencies, depQue, parent) |
|
409 | 342 |
else: |
410 |
- print("No spec file builds a package named {}".format(inputValue)) |
|
411 |
- return |
|
412 |
- |
|
413 |
- # Generate dependencies for all packages in the given JSON input file |
|
414 |
- elif inputType == "json": |
|
415 |
- filePath = self.inputDataDir + "/" + inputValue |
|
416 |
- data = self.get_all_package_names(filePath) |
|
417 |
- for pkg in data: |
|
418 |
- if pkg not in allDeps: |
|
419 |
- spName = self.getSpecName(pkg) |
|
420 |
- if spName is not None: |
|
421 |
- allDeps[pkg] = 0 |
|
422 |
- parent[pkg] = "" |
|
423 |
- depQue.put(pkg) |
|
424 |
- self.findTotalRequires(allDeps, depQue, parent, displayOption) |
|
425 |
- else: |
|
426 |
- independentRPMS.append(pkg) |
|
427 |
- |
|
428 |
- #Generating the list of packages that requires the given input package at install time |
|
429 |
- elif inputType == "who-needs": |
|
430 |
- print(whoNeedsList) |
|
431 |
- return |
|
343 |
+ print("Could not find spec for "+pkg) |
|
432 | 344 |
|
433 |
- #Generating the list of packages that the modified package will affect at build time |
|
434 |
- elif inputType == "who-needs-build": |
|
435 |
- if packageFound == True: |
|
436 |
- self.findTotalWhoNeedsToBuild(depQue, whoBuildDeps, whoBuildDepSet, displayOption) |
|
437 |
- print(whoBuildDepSet) |
|
438 |
- else: |
|
439 |
- print("No spec file builds a package named {}".format(inputValue)) |
|
440 |
- return |
|
441 |
- |
|
442 |
- # construct the sorted list of all packages (sorted by dependency) |
|
345 |
+ def displayDependencies(self, displayOption, inputType, inputValue, allDeps, parent): |
|
346 |
+ children = {} |
|
443 | 347 |
sortedList = [] |
444 | 348 |
for elem in sorted(allDeps.items(), key=operator.itemgetter(1), reverse=True): |
445 | 349 |
sortedList.append(elem[0]) |
446 |
- sortedList.extend(independentRPMS) |
|
447 |
- |
|
448 | 350 |
# construct all children nodes |
449 | 351 |
if displayOption == "tree": |
450 | 352 |
for k, v in parent.iteritems(): |
... | ... |
@@ -456,95 +363,52 @@ class SerializedSpecObjects(object): |
456 | 456 |
if "" in children: |
457 | 457 |
for child in children[""]: |
458 | 458 |
print(child) |
459 |
- self.printTree(allDeps, children, child, 1) |
|
460 |
- for pkg in independentRPMS: |
|
461 |
- print(pkg) |
|
459 |
+ self.printTree(children, child, 1) |
|
462 | 460 |
print("*" * 18 + " {} ".format(len(sortedList)) + |
463 | 461 |
"packages in total " + "*" * 18) |
464 | 462 |
else: |
465 | 463 |
if inputType == "pkg" and len(children) > 0: |
466 |
- print("cyclic dependency detected, mappings:") |
|
467 |
- print(children) |
|
464 |
+ print ("cyclic dependency detected, mappings: \n", children) |
|
468 | 465 |
|
469 | 466 |
# To display a flat list of all packages |
470 | 467 |
elif displayOption == "list": |
471 |
- print(sortedList) |
|
468 |
+ print (sortedList) |
|
472 | 469 |
|
473 | 470 |
# To generate a new JSON file based on given input json file |
474 | 471 |
elif displayOption == "json" and inputType == "json": |
475 |
- d = {} |
|
476 |
- d['packages'] = sortedList |
|
477 |
- outFilePath = self.jsonFilesOutPath + inputValue |
|
478 |
- with open(outFilePath, 'w') as outfile: |
|
472 |
+ d = {'packages': sortedList} |
|
473 |
+ with open(inputValue, 'w') as outfile: |
|
479 | 474 |
json.dump(d, outfile) |
480 |
- return sortedList |
|
481 | 475 |
|
482 |
- def getListSpecFiles(self, listSpecFiles, path): |
|
483 |
- for dirEntry in os.listdir(path): |
|
484 |
- dirEntryPath = os.path.join(path, dirEntry) |
|
485 |
- if (os.path.isfile(dirEntryPath) and |
|
486 |
- dirEntryPath.endswith(".spec") and |
|
487 |
- os.path.basename(dirEntryPath) not in |
|
488 |
- constants.skipSpecsForArch.get(platform.machine(), [])): |
|
489 |
- listSpecFiles.append(dirEntryPath) |
|
490 |
- elif os.path.isdir(dirEntryPath): |
|
491 |
- self.getListSpecFiles(listSpecFiles, dirEntryPath) |
|
492 |
- |
|
493 |
- def getBuildRequiresForPackage(self, package): |
|
494 |
- specName = self.getSpecName(package) |
|
495 |
- return self.mapSerializableSpecObjects[specName].buildRequirePackages |
|
496 |
- |
|
497 |
- def getRequiresForPackage(self, package): |
|
498 |
- specName = self.getSpecName(package) |
|
499 |
- if package in self.mapSerializableSpecObjects[specName].installRequiresPackages: |
|
500 |
- return self.mapSerializableSpecObjects[specName].installRequiresPackages[package] |
|
501 |
- return None |
|
502 |
- |
|
503 |
- def getRelease(self, package): |
|
504 |
- specName = self.getSpecName(package) |
|
505 |
- return self.mapSerializableSpecObjects[specName].release |
|
506 |
- |
|
507 |
- def getVersion(self, package): |
|
508 |
- specName = self.getSpecName(package) |
|
509 |
- return self.mapSerializableSpecObjects[specName].version |
|
510 |
- |
|
511 |
- def getSpecFile(self, package): |
|
512 |
- specName = self.getSpecName(package) |
|
513 |
- return self.mapSerializableSpecObjects[specName].specFile |
|
514 |
- |
|
515 |
- def getPatches(self, package): |
|
516 |
- specName = self.getSpecName(package) |
|
517 |
- return self.mapSerializableSpecObjects[specName].listPatches |
|
518 |
- |
|
519 |
- def getSources(self, package): |
|
520 |
- specName = self.getSpecName(package) |
|
521 |
- return self.mapSerializableSpecObjects[specName].listSources |
|
522 |
- |
|
523 |
- def getPackages(self, package): |
|
524 |
- specName = self.getSpecName(package) |
|
525 |
- return self.mapSerializableSpecObjects[specName].listPackages |
|
476 |
+ return sortedList |
|
526 | 477 |
|
527 |
- def getSpecName(self, package): |
|
528 |
- if package in self.mapPackageToSpec: |
|
529 |
- specName = self.mapPackageToSpec[package] |
|
530 |
- if specName in self.mapSerializableSpecObjects: |
|
531 |
- return specName |
|
478 |
+ def process(self, inputType, inputValue, displayOption, outputFile=None): |
|
479 |
+ whoNeedsList = [] |
|
480 |
+ inputPackages = [] |
|
481 |
+ whoNeedsBuild = [] |
|
482 |
+ mapDependencies = {} |
|
483 |
+ parent = {} |
|
484 |
+ if inputType == "pkg" or inputType == "json": |
|
485 |
+ if inputType == "pkg": |
|
486 |
+ inputPackages.append(inputValue) |
|
532 | 487 |
else: |
533 |
- print("SpecDeps: Could not able to find " + package + " package from specs") |
|
534 |
- raise Exception("Invalid package:" + package) |
|
535 |
- else: |
|
536 |
- return None |
|
488 |
+ inputPackages = self.getAllPackageNames(inputValue) |
|
537 | 489 |
|
538 |
- def isRPMPackage(self, package): |
|
539 |
- if package in self.mapPackageToSpec: |
|
540 |
- specName = self.mapPackageToSpec[package] |
|
541 |
- if specName in self.mapSerializableSpecObjects: |
|
542 |
- return True |
|
543 |
- return False |
|
544 |
- |
|
545 |
- def getSecurityHardeningOption(self, package): |
|
546 |
- specName = self.getSpecName(package) |
|
547 |
- return self.mapSerializableSpecObjects[specName].securityHardening |
|
548 |
- |
|
549 |
- def getSpecDetails(self, name): |
|
550 |
- print(self.mapSerializableSpecObjects[name].installRequiresAllPackages) |
|
490 |
+ self.calculateSpecDependency(inputPackages, mapDependencies, parent) |
|
491 |
+ if outputFile is not None: |
|
492 |
+ return self.displayDependencies(displayOption, inputType, outputFile, mapDependencies, parent) |
|
493 |
+ else: |
|
494 |
+ return self.displayDependencies(displayOption, inputType, inputValue, mapDependencies, parent) |
|
495 |
+ elif inputType == "who-needs": |
|
496 |
+ for depPkg in SPECS.getData().mapPackageToSpec: |
|
497 |
+ if inputValue in SPECS.getData().getRequiresForPackage(depPkg): |
|
498 |
+ whoNeedsList.append(depPkg) |
|
499 |
+ print (whoNeedsList) |
|
500 |
+ return whoNeedsList |
|
501 |
+ elif inputType == "who-needs-build": |
|
502 |
+ depQue = queue.Queue() |
|
503 |
+ depQue.put(inputValue) |
|
504 |
+ self.findTotalWhoNeedsToBuild(depQue, whoNeedsBuild) |
|
505 |
+ print ("Following specs need to be build again") |
|
506 |
+ print (whoNeedsBuild) |
|
507 |
+ return whoNeedsBuild |
... | ... |
@@ -6,14 +6,19 @@ |
6 | 6 |
import sys |
7 | 7 |
import os |
8 | 8 |
from argparse import ArgumentParser |
9 |
-from SpecData import SerializedSpecObjects |
|
9 |
+import shutil |
|
10 |
+import traceback |
|
11 |
+from SpecData import SpecDependencyGenerator |
|
10 | 12 |
from jsonwrapper import JsonWrapper |
13 |
+from constants import constants |
|
14 |
+from CommandUtils import CommandUtils |
|
11 | 15 |
|
12 | 16 |
DEFAULT_INPUT_TYPE = "pkg" |
13 | 17 |
DEFAULT_DISPLAY_OPTION = "tree" |
14 | 18 |
SPEC_FILE_DIR = "../../SPECS" |
15 | 19 |
LOG_FILE_DIR = "../../stage/LOGS" |
16 | 20 |
|
21 |
+ |
|
17 | 22 |
def main(): |
18 | 23 |
usage = "Usage: %prog [options]" |
19 | 24 |
parser = ArgumentParser(usage) |
... | ... |
@@ -22,46 +27,58 @@ def main(): |
22 | 22 |
parser.add_argument("-f", "--file", dest="json_file", default="packages_minimal.json") |
23 | 23 |
parser.add_argument("-d", "--disp", dest="display_option", default=DEFAULT_DISPLAY_OPTION) |
24 | 24 |
parser.add_argument("-s", "--spec-dir", dest="spec_dir", default=SPEC_FILE_DIR) |
25 |
+ parser.add_argument("-l", "--log-dir", dest="log_dir", default=LOG_FILE_DIR) |
|
25 | 26 |
parser.add_argument("-t", "--stage-dir", dest="stage_dir", default="../../stage") |
26 |
- parser.add_argument("-a", "--input-data-dir", dest="input_data_dir", |
|
27 |
- default="../../common/data/") |
|
27 |
+ parser.add_argument("-a", "--input-data-dir", dest="input_data_dir", default="../../common/data/") |
|
28 |
+ parser.add_argument("-o", "--output-dir", dest="output_dir", default="../../stage/common/data") |
|
28 | 29 |
options = parser.parse_args() |
29 | 30 |
|
31 |
+ constants.setSpecPath(options.spec_dir) |
|
32 |
+ constants.setLogPath(options.log_dir) |
|
33 |
+ constants.initialize() |
|
34 |
+ |
|
35 |
+ cmdUtils = CommandUtils() |
|
36 |
+ |
|
37 |
+ if not os.path.isdir(options.output_dir): |
|
38 |
+ cmdUtils.runCommandInShell2("mkdir -p "+options.output_dir) |
|
39 |
+ |
|
30 | 40 |
if not options.input_data_dir.endswith('/'): |
31 | 41 |
options.input_data_dir += '/' |
32 | 42 |
try: |
33 |
- specDeps = SerializedSpecObjects(options.input_data_dir, options.stage_dir) |
|
34 |
- displayOption = options.display_option |
|
35 |
- abs_path = os.path.abspath(__file__) |
|
36 |
- dir_name = os.path.dirname(abs_path) |
|
37 |
- os.chdir(dir_name) |
|
43 |
+ specDeps = SpecDependencyGenerator() |
|
38 | 44 |
|
39 | 45 |
# To display/print package dependencies on console |
40 |
- if(options.input_type == "pkg" or |
|
41 |
- options.input_type == "who-needs" or |
|
42 |
- options.input_type == "who-needs-build"): |
|
43 |
- targetName = options.pkg |
|
44 |
- specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, |
|
45 |
- options.input_type, |
|
46 |
- targetName, displayOption) |
|
46 |
+ if (options.input_type == "pkg" or |
|
47 |
+ options.input_type == "who-needs" or |
|
48 |
+ options.input_type == "who-needs-build"): |
|
49 |
+ specDeps.process(options.input_type, options.pkg, options.display_option) |
|
50 |
+ |
|
47 | 51 |
elif options.input_type == "json": |
48 |
- # Generate the expanded package dependencies json file based on package_list_file |
|
49 |
- json_wrapper_option_list = JsonWrapper(options.json_file) |
|
50 |
- option_list_json = json_wrapper_option_list.read() |
|
51 |
- options_sorted = option_list_json.items() |
|
52 |
- for install_option in options_sorted: |
|
53 |
- if displayOption == "tree" and install_option[1]["title"] == "ISO Packages": |
|
54 |
- continue |
|
55 |
- specDeps.readSpecsAndConvertToSerializableObjects( |
|
56 |
- options.spec_dir, |
|
57 |
- options.input_type, install_option[1]["file"], |
|
58 |
- displayOption) |
|
59 |
- except Exception as _: |
|
52 |
+ list_json_files = options.json_file.split("\n") |
|
53 |
+ # Generate the expanded package dependencies json file based on package_list_file |
|
54 |
+ for json_file in list_json_files: |
|
55 |
+ shutil.copy2(json_file, options.output_dir) |
|
56 |
+ json_wrapper_option_list = JsonWrapper(json_file) |
|
57 |
+ option_list_json = json_wrapper_option_list.read() |
|
58 |
+ options_sorted = option_list_json.items() |
|
59 |
+ for install_option in options_sorted: |
|
60 |
+ output_file = None |
|
61 |
+ input_value = os.path.join(os.path.dirname(json_file), install_option[1]["file"]) |
|
62 |
+ if options.display_option == "tree" and install_option[1]["title"] == "ISO Packages": |
|
63 |
+ continue |
|
64 |
+ if options.display_option == "json": |
|
65 |
+ output_file = os.path.join(options.output_dir, install_option[1]["file"]) |
|
66 |
+ print ("Generating the install time dependency list for " + json_file) |
|
67 |
+ specDeps.process(options.input_type, input_value, options.display_option, output_file) |
|
68 |
+ except Exception as e: |
|
69 |
+ traceback.print_exc() |
|
70 |
+ sys.stderr.write(str(e)) |
|
60 | 71 |
sys.stderr.write("Failed to generate dependency lists from spec files\n") |
61 | 72 |
sys.exit(1) |
62 | 73 |
|
63 | 74 |
sys.stderr.write("Successfully generated dependency lists from spec files\n") |
64 | 75 |
sys.exit(0) |
65 | 76 |
|
77 |
+ |
|
66 | 78 |
if __name__ == "__main__": |
67 | 79 |
main() |
68 | 80 |
deleted file mode 100755 |
... | ... |
@@ -1,73 +0,0 @@ |
1 |
-#!/usr/bin/python2 |
|
2 |
-# |
|
3 |
-#Copyright (C) 2015 vmware inc. |
|
4 |
-# |
|
5 |
-#Author: Harish Udaiya Kumar <hudaiyakumar@vmware.com> |
|
6 |
-from SpecUtils import Specutils |
|
7 |
-from SpecData import SerializableSpecObject |
|
8 |
-from SpecData import SerializedSpecObjects |
|
9 |
-from RepoDeps import RepoQueryDependency |
|
10 |
-import sys |
|
11 |
-import os |
|
12 |
-from optparse import OptionParser |
|
13 |
- |
|
14 |
-DEFAULT_INPUT_TYPE = "json" |
|
15 |
-DEFAULT_DISPLAY_OPTION = "tree" |
|
16 |
-SPEC_FILE_DIR = "../../SPECS" |
|
17 |
-INPUT_DATA_DIR = "../../common/data" |
|
18 |
- |
|
19 |
-def reportMissing(pkg,specDepList, repoDepList, excludeList): |
|
20 |
- missingList = []; |
|
21 |
- if None != repoDepList: |
|
22 |
- for repoItem in repoDepList: |
|
23 |
- if repoItem not in excludeList and (None == specDepList or repoItem not in specDepList): |
|
24 |
- missingList.append(repoItem) |
|
25 |
- if missingList: |
|
26 |
- if len(pkg) <= 7: |
|
27 |
- print pkg, "missing\t\t->", missingList |
|
28 |
- else: |
|
29 |
- print pkg, "missing\t->", missingList |
|
30 |
- |
|
31 |
-def main(): |
|
32 |
- usage = os.path.basename(__file__) + "--input-type=[json/pkg] --pkg=[pkg_name] --file=<JSON_FILE_NAME> --repo-file=<photon>.repo" |
|
33 |
- parser = OptionParser(usage) |
|
34 |
- parser.add_option("-i", "--input-type", dest="input_type", default=DEFAULT_INPUT_TYPE) |
|
35 |
- parser.add_option("-p", "--pkg", dest="pkg") |
|
36 |
- parser.add_option("-f", "--file", dest="json_file", default="packages_full.json") |
|
37 |
- parser.add_option("-s", "--spec-dir", dest="spec_dir", default=SPEC_FILE_DIR) |
|
38 |
- parser.add_option("-a", "--input-data-dir", dest="input_data_dir", default=INPUT_DATA_DIR) |
|
39 |
- parser.add_option("-r", "--repo-file", dest = "repo_file", default="") |
|
40 |
- excludeList = ["bash","glibc","libgcc","pkg-config","filesystem"] |
|
41 |
- (options, args) = parser.parse_args() |
|
42 |
- |
|
43 |
- if(options.repo_file == ""): |
|
44 |
- print "Error! repo file not provided" |
|
45 |
- print usage |
|
46 |
- return |
|
47 |
- |
|
48 |
- if(False == options.input_data_dir.endswith('/')): |
|
49 |
- options.input_data_dir += '/' |
|
50 |
- |
|
51 |
- specDeps = SerializedSpecObjects(options.input_data_dir, "") |
|
52 |
- repoDeps = RepoQueryDependency(options.repo_file) |
|
53 |
- displayOption = None |
|
54 |
- abs_path = os.path.abspath(__file__) |
|
55 |
- dir_name = os.path.dirname(abs_path) |
|
56 |
- os.chdir(dir_name) |
|
57 |
- |
|
58 |
- if(options.input_type == "pkg"): |
|
59 |
- targetName = options.pkg |
|
60 |
- specDepList = specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, options.input_type, targetName, displayOption) |
|
61 |
- repoDepList = repoDeps.getRequiresList(targetName) |
|
62 |
- reportMissing(targetName,specDepList,repoDepList,excludeList) |
|
63 |
- elif(options.input_type == "json"): |
|
64 |
- filePath = options.input_data_dir + options.json_file |
|
65 |
- data = specDeps.get_all_package_names(filePath) |
|
66 |
- for pkg in data: |
|
67 |
- specDepList = specDeps.readSpecsAndConvertToSerializableObjects(options.spec_dir, "pkg" , pkg, displayOption) |
|
68 |
- repoDepList = repoDeps.getRequiresList(pkg) |
|
69 |
- reportMissing(pkg,specDepList,repoDepList,excludeList) |
|
70 |
- sys.exit(0) |
|
71 |
- |
|
72 |
-if __name__=="__main__": |
|
73 |
- main() |
... | ... |
@@ -53,11 +53,6 @@ def main(): |
53 | 53 |
parser.add_argument("-bd", "--publish-build-dependencies", dest="publishBuildDependencies", |
54 | 54 |
default=False) |
55 | 55 |
parser.add_argument("-pw", "--package-weights-path", dest="packageWeightsPath", default=None) |
56 |
- parser.add_argument("-y", "--generate-pkg-yaml-files", dest="generatePkgYamlFiles", |
|
57 |
- default=False, action="store_true") |
|
58 |
- parser.add_argument("-j", "--pkg-yaml-dir-path", dest="pkgYamlDirPath", |
|
59 |
- default="../../stage/") |
|
60 |
- parser.add_argument("-f", "--pkg-blacklist-file", dest="pkgBlacklistFile", default=None) |
|
61 | 56 |
parser.add_argument("-bt", "--build-type", dest="pkgBuildType", default="chroot") |
62 | 57 |
parser.add_argument("-F", "--kat-build", dest="katBuild", default=None) |
63 | 58 |
parser.add_argument("PackageName", nargs='?') |
... | ... |
@@ -109,14 +104,6 @@ def main(): |
109 | 109 |
logger.error("Given input Weights file is not a file:"+options.packageWeightsPath) |
110 | 110 |
errorFlag = True |
111 | 111 |
|
112 |
- if options.generatePkgYamlFiles: |
|
113 |
- if (options.pkgBlacklistFile is not None and |
|
114 |
- options.pkgBlacklistFile != "" and |
|
115 |
- not os.path.isfile(options.pkgBlacklistFile)): |
|
116 |
- logger.error("Given package blacklist file is not valid:"+ |
|
117 |
- options.pkgBlacklistFile) |
|
118 |
- errorFlag = True |
|
119 |
- |
|
120 | 112 |
if options.installPackage: |
121 | 113 |
if not options.PackageName: |
122 | 114 |
logger.error("Please provide package name") |
... | ... |
@@ -128,7 +115,6 @@ def main(): |
128 | 128 |
logger.error("Found some errors. Please fix input options and re-run it.") |
129 | 129 |
return False |
130 | 130 |
|
131 |
- |
|
132 | 131 |
if not os.path.isdir(options.rpmPath): |
133 | 132 |
cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/"+platform.machine()) |
134 | 133 |
cmdUtils.runCommandInShell("mkdir -p "+options.rpmPath+"/noarch") |
... | ... |
@@ -139,10 +125,6 @@ def main(): |
139 | 139 |
if not os.path.isdir(options.buildRootPath): |
140 | 140 |
cmdUtils.runCommandInShell("mkdir -p "+options.buildRootPath) |
141 | 141 |
|
142 |
- if options.generatePkgYamlFiles: |
|
143 |
- if not os.path.isdir(options.pkgYamlDirPath): |
|
144 |
- cmdUtils.runCommandInShell("mkdir -p "+options.pkgYamlDirPath) |
|
145 |
- |
|
146 | 142 |
logger.info("Source Path :"+options.sourcePath) |
147 | 143 |
logger.info("Spec Path :" + options.specPath) |
148 | 144 |
logger.info("Rpm Path :" + options.rpmPath) |
... | ... |
@@ -157,16 +139,31 @@ def main(): |
157 | 157 |
listBuildOptionPackages = get_packages_with_build_options(options.pkgBuildOptionFile) |
158 | 158 |
|
159 | 159 |
try: |
160 |
- constants.initialize(options) |
|
160 |
+ |
|
161 |
+ constants.setSpecPath(options.specPath) |
|
162 |
+ constants.setSourcePath(options.sourcePath) |
|
163 |
+ constants.setRpmPath(options.rpmPath) |
|
164 |
+ constants.setSourceRpmPath(options.sourceRpmPath) |
|
165 |
+ constants.setTopDirPath(options.topDirPath) |
|
166 |
+ constants.setLogPath(options.logPath) |
|
167 |
+ constants.setDist(options.dist) |
|
168 |
+ constants.setBuildNumber(options.buildNumber) |
|
169 |
+ constants.setReleaseVersion(options.releaseVersion) |
|
170 |
+ constants.setPrevPublishRPMRepo(options.publishRPMSPath) |
|
171 |
+ constants.setPrevPublishXRPMRepo(options.publishXRPMSPath) |
|
172 |
+ constants.setBuildRootPath(options.buildRootPath) |
|
173 |
+ constants.setPullSourcesConfig(options.pullsourcesConfig) |
|
174 |
+ constants.setInputRPMSPath(options.inputRPMSPath) |
|
175 |
+ constants.setRPMCheck(options.rpmCheck) |
|
176 |
+ constants.setRpmCheckStopOnError(options.rpmCheckStopOnError) |
|
177 |
+ constants.setPublishBuildDependencies(options.publishBuildDependencies) |
|
178 |
+ constants.setPackageWeightsPath(options.packageWeightsPath) |
|
179 |
+ constants.setKatBuild(options.katBuild) |
|
180 |
+ |
|
181 |
+ constants.initialize() |
|
161 | 182 |
# parse SPECS folder |
162 | 183 |
SPECS() |
163 |
- if package == "packages_list": |
|
164 |
- buildPackagesList(options.buildRootPath+"/../packages_list.csv") |
|
165 |
- elif options.generatePkgYamlFiles: |
|
166 |
- blackListPkgs = readBlackListPackages(options.pkgBlacklistFile) |
|
167 |
- buildSourcesList(options.pkgYamlDirPath, blackListPkgs, logger) |
|
168 |
- buildSRPMList(options.sourceRpmPath, options.pkgYamlDirPath, blackListPkgs, logger) |
|
169 |
- elif options.toolChainStage == "stage1": |
|
184 |
+ if options.toolChainStage == "stage1": |
|
170 | 185 |
pkgManager = PackageManager() |
171 | 186 |
pkgManager.buildToolChain() |
172 | 187 |
elif options.toolChainStage == "stage2": |
... | ... |
@@ -187,145 +184,17 @@ def main(): |
187 | 187 |
sys.exit(1) |
188 | 188 |
sys.exit(0) |
189 | 189 |
|
190 |
-def buildPackagesList(csvFilename): |
|
191 |
- csvFile = open(csvFilename, "w") |
|
192 |
- csvFile.write("Package,Version,License,URL,Sources,Patches\n") |
|
193 |
- listPackages = SPECS.getData().getListPackages() |
|
194 |
- listPackages.sort() |
|
195 |
- for package in listPackages: |
|
196 |
- name = package |
|
197 |
- version = SPECS.getData().getVersion(package) |
|
198 |
- license = SPECS.getData().getLicense(package) |
|
199 |
- listPatches = SPECS.getData().getPatches(package) |
|
200 |
- url = SPECS.getData().getURL(package) |
|
201 |
- listSourceNames = SPECS.getData().getSources(package) |
|
202 |
- sources = "" |
|
203 |
- patches = "" |
|
204 |
- if listPatches is not None: |
|
205 |
- patches = " ".join(listPatches) |
|
206 |
- if listSourceNames is not None: |
|
207 |
- sources = " ".join(listSourceNames) |
|
208 |
- csvFile.write(name+","+version+","+license+","+url+","+sources+","+patches+"\n") |
|
209 |
- csvFile.close() |
|
210 |
- |
|
211 |
-def readBlackListPackages(pkgBlackListFile): |
|
212 |
- blackListPkgs = [] |
|
213 |
- if pkgBlackListFile is not None and pkgBlackListFile != "": |
|
214 |
- with open(pkgBlackListFile) as jsonFile: |
|
215 |
- config = json.load(jsonFile) |
|
216 |
- if 'packages' in config: |
|
217 |
- blackListPkgs = config['packages'] |
|
218 |
- return blackListPkgs |
|
219 |
- |
|
220 |
-def buildSourcesList(yamlDir, blackListPkgs, logger, singleFile=True): |
|
221 |
- cmdUtils = CommandUtils() |
|
222 |
- yamlSourceDir = os.path.join(yamlDir, "yaml_sources") |
|
223 |
- if not os.path.isdir(yamlSourceDir): |
|
224 |
- cmdUtils.runCommandInShell("mkdir -p "+yamlSourceDir) |
|
225 |
- if singleFile: |
|
226 |
- yamlFile = open(yamlSourceDir+"/sources_list.yaml", "w") |
|
227 |
- listPackages = SPECS.getData().getListPackages() |
|
228 |
- listPackages.sort() |
|
229 |
- import PullSources |
|
230 |
- for package in listPackages: |
|
231 |
- if package in blackListPkgs: |
|
232 |
- continue |
|
233 |
- ossname = package |
|
234 |
- ossversion = SPECS.getData().getVersion(package) |
|
235 |
- modified = False |
|
236 |
- listPatches = SPECS.getData().getPatches(package) |
|
237 |
- if listPatches is not None and len(listPatches) > 0: |
|
238 |
- modified = True |
|
239 |
- url = SPECS.getData().getSourceURL(package) |
|
240 |
- if url is None: |
|
241 |
- url = SPECS.getData().getURL(package) |
|
242 |
- |
|
243 |
- sourceName = None |
|
244 |
- listSourceNames = SPECS.getData().getSources(package) |
|
245 |
- if len(listSourceNames) > 0: |
|
246 |
- sourceName = listSourceNames[0] |
|
247 |
- sha1 = SPECS.getData().getSHA1(package, sourceName) |
|
248 |
- if sha1 is not None: |
|
249 |
- PullSources.get(sourceName, sha1, yamlSourceDir, |
|
250 |
- constants.pullsourcesConfig, logger) |
|
251 |
- |
|
252 |
- if not singleFile: |
|
253 |
- yamlFile = open(yamlSourceDir+"/"+ossname+"-"+ossversion+".yaml", "w") |
|
254 |
- yamlFile.write("vmwsource:"+ossname+":"+ossversion+":\n") |
|
255 |
- yamlFile.write(" repository: VMWsource\n") |
|
256 |
- yamlFile.write(" name: '"+ossname+"'\n") |
|
257 |
- yamlFile.write(" version: '"+ossversion+"'\n") |
|
258 |
- yamlFile.write(" url: "+str(url)+"\n") |
|
259 |
- yamlFile.write(" license: UNKNOWN\n") |
|
260 |
- if sourceName is not None: |
|
261 |
- yamlFile.write(" vmwsource-distribution: "+str(sourceName)+"\n") |
|
262 |
- if modified: |
|
263 |
- yamlFile.write(" modified: true\n") |
|
264 |
- yamlFile.write("\n") |
|
265 |
- if not singleFile: |
|
266 |
- yamlFile.close() |
|
267 |
- |
|
268 |
- if singleFile: |
|
269 |
- yamlFile.close() |
|
270 |
- logger.info("Generated source yaml files for all packages") |
|
271 |
- |
|
272 |
-def buildSRPMList(srpmPath, yamlDir, blackListPkgs, logger, singleFile=True): |
|
273 |
- cmdUtils = CommandUtils() |
|
274 |
- yamlSrpmDir = os.path.join(yamlDir, "yaml_srpms") |
|
275 |
- if not os.path.isdir(yamlSrpmDir): |
|
276 |
- cmdUtils.runCommandInShell("mkdir -p "+yamlSrpmDir) |
|
277 |
- if singleFile: |
|
278 |
- yamlFile = open(yamlSrpmDir+"/srpm_list.yaml", "w") |
|
279 |
- listPackages = SPECS.getData().getListPackages() |
|
280 |
- listPackages.sort() |
|
281 |
- for package in listPackages: |
|
282 |
- if package in blackListPkgs: |
|
283 |
- continue |
|
284 |
- ossname = package |
|
285 |
- ossversion = SPECS.getData().getVersion(package) |
|
286 |
- ossrelease = SPECS.getData().getRelease(package) |
|
287 |
- |
|
288 |
- listFoundSRPMFiles = cmdUtils.findFile(ossname+"-"+ossversion+"-"+ossrelease+".src.rpm", |
|
289 |
- srpmPath) |
|
290 |
- srpmName = None |
|
291 |
- if len(listFoundSRPMFiles) == 1: |
|
292 |
- srpmFullPath = listFoundSRPMFiles[0] |
|
293 |
- srpmName = os.path.basename(srpmFullPath) |
|
294 |
- cpcmd = "cp "+ srpmFullPath +" "+yamlSrpmDir+"/" |
|
295 |
- returnVal = cmdUtils.runCommandInShell(cpcmd) |
|
296 |
- if not returnVal: |
|
297 |
- logger.error("Copy SRPM File is failed for package:"+ossname) |
|
298 |
- else: |
|
299 |
- logger.error("SRPM file is not found:" +ossname) |
|
300 |
- |
|
301 |
- if not singleFile: |
|
302 |
- yamlFile = open(yamlSrpmDir+"/"+ossname+"-"+ossversion+"-"+ossrelease+".yaml", "w") |
|
303 |
- |
|
304 |
- yamlFile.write("baseos:"+ossname+":"+ossversion+"-"+ossrelease+":\n") |
|
305 |
- yamlFile.write(" repository: BaseOS\n") |
|
306 |
- yamlFile.write(" name: '"+ossname+"'\n") |
|
307 |
- yamlFile.write(" version: '"+ossversion+"-"+ossrelease+"'\n") |
|
308 |
- yamlFile.write(" baseos-style: rpm\n") |
|
309 |
- yamlFile.write(" baseos-source: '"+str(srpmName)+"'\n") |
|
310 |
- yamlFile.write(" baseos-osname: 'photon'\n") |
|
311 |
- yamlFile.write("\n") |
|
312 |
- if not singleFile: |
|
313 |
- yamlFile.close() |
|
314 |
- |
|
315 |
- if singleFile: |
|
316 |
- yamlFile.close() |
|
317 |
- logger.info("Generated srpm yaml files for all packages") |
|
318 | 190 |
|
319 | 191 |
def buildAPackage(package, listBuildOptionPackages, pkgBuildOptionFile, |
320 | 192 |
buildThreads, pkgBuildType): |
321 |
- listPackages = [] |
|
322 |
- listPackages.append(package) |
|
193 |
+ listPackages = [package] |
|
323 | 194 |
pkgManager = PackageManager(pkgBuildType=pkgBuildType) |
324 | 195 |
if constants.rpmCheck: |
325 | 196 |
constants.setTestForceRPMS(listPackages[:]) |
326 | 197 |
pkgManager.buildPackages(listPackages, listBuildOptionPackages, pkgBuildOptionFile, |
327 | 198 |
buildThreads, pkgBuildType) |
328 | 199 |
|
200 |
+ |
|
329 | 201 |
def buildPackagesForAllSpecs(listBuildOptionPackages, pkgBuildOptionFile, logger, |
330 | 202 |
buildThreads, pkgInfoJsonFile, pkgBuildType): |
331 | 203 |
listPackages = SPECS.getData().getListPackages() |
... | ... |
@@ -338,12 +207,13 @@ def buildPackagesForAllSpecs(listBuildOptionPackages, pkgBuildOptionFile, logger |
338 | 338 |
pkgManager.buildPackages(listPackages, listBuildOptionPackages, pkgBuildOptionFile, |
339 | 339 |
buildThreads, pkgBuildType) |
340 | 340 |
|
341 |
- #Generating package info file which is required by installer |
|
341 |
+ # Generating package info file which is required by installer |
|
342 | 342 |
logger.info("Writing Package info to the file:"+pkgInfoJsonFile) |
343 | 343 |
pkgInfo = PackageInfo() |
344 | 344 |
pkgInfo.loadPackagesData() |
345 | 345 |
pkgInfo.writePkgListToFile(pkgInfoJsonFile) |
346 | 346 |
|
347 |
+ |
|
347 | 348 |
def get_packages_with_build_options(pkg_build_options_file): |
348 | 349 |
packages = [] |
349 | 350 |
if os.path.exists(pkg_build_options_file): |
... | ... |
@@ -357,6 +227,7 @@ def get_packages_with_build_options(pkg_build_options_file): |
357 | 357 |
|
358 | 358 |
return packages |
359 | 359 |
|
360 |
+ |
|
360 | 361 |
def get_all_package_names(build_install_option): |
361 | 362 |
base_path = os.path.dirname(build_install_option) |
362 | 363 |
jsonData = open(build_install_option) |
... | ... |
@@ -374,5 +245,6 @@ def get_all_package_names(build_install_option): |
374 | 374 |
|
375 | 375 |
return packages |
376 | 376 |
|
377 |
+ |
|
377 | 378 |
if __name__ == "__main__": |
378 | 379 |
main() |
... | ... |
@@ -18,6 +18,12 @@ class constants(object): |
18 | 18 |
packageWeightsPath = None |
19 | 19 |
dockerUnixSocket = "/var/run/docker.sock" |
20 | 20 |
userDefinedMacros = {} |
21 |
+ dist = None |
|
22 |
+ buildNumber = None |
|
23 |
+ releaseVersion = None |
|
24 |
+ katBuild = None |
|
25 |
+ testForceRPMS = [] |
|
26 |
+ tmpDirPath = "/dev/shm" |
|
21 | 27 |
|
22 | 28 |
noDepsPackageList = [ |
23 | 29 |
"texinfo", |
... | ... |
@@ -421,41 +427,103 @@ class constants(object): |
421 | 421 |
} |
422 | 422 |
|
423 | 423 |
@staticmethod |
424 |
- def initialize(options): |
|
425 |
- constants.specPath = options.specPath |
|
426 |
- constants.sourcePath = options.sourcePath |
|
427 |
- constants.rpmPath = options.rpmPath |
|
428 |
- constants.sourceRpmPath = options.sourceRpmPath |
|
429 |
- constants.topDirPath = options.topDirPath |
|
430 |
- constants.logPath = options.logPath |
|
431 |
- constants.prevPublishRPMRepo = options.publishRPMSPath |
|
432 |
- constants.prevPublishXRPMRepo = options.publishXRPMSPath |
|
433 |
- constants.buildRootPath = options.buildRootPath |
|
434 |
- constants.pullsourcesConfig = options.pullsourcesConfig |
|
435 |
- constants.inputRPMSPath = options.inputRPMSPath |
|
436 |
- constants.testForceRPMS = [] |
|
437 |
- constants.rpmCheck = options.rpmCheck |
|
438 |
- constants.rpmCheckStopOnError = options.rpmCheckStopOnError |
|
439 |
- constants.publishBuildDependencies = options.publishBuildDependencies |
|
440 |
- constants.packageWeightsPath = options.packageWeightsPath |
|
441 |
- constants.tmpDirPath = "/dev/shm" |
|
424 |
+ def setSpecPath(specPath): |
|
425 |
+ constants.specPath = specPath |
|
426 |
+ |
|
427 |
+ @staticmethod |
|
428 |
+ def setSourcePath(sourcePath): |
|
429 |
+ constants.sourcePath = sourcePath |
|
430 |
+ |
|
431 |
+ @staticmethod |
|
432 |
+ def setRpmPath(rpmPath): |
|
433 |
+ constants.rpmPath = rpmPath |
|
434 |
+ |
|
435 |
+ @staticmethod |
|
436 |
+ def setSourceRpmPath(sourceRpmPath): |
|
437 |
+ constants.sourceRpmPath = sourceRpmPath |
|
438 |
+ |
|
439 |
+ @staticmethod |
|
440 |
+ def setTopDirPath(topDirPath): |
|
441 |
+ constants.topDirPath = topDirPath |
|
442 |
+ |
|
443 |
+ @staticmethod |
|
444 |
+ def setLogPath(logPath): |
|
445 |
+ constants.logPath = logPath |
|
446 |
+ |
|
447 |
+ @staticmethod |
|
448 |
+ def setPrevPublishRPMRepo(prevPublishRPMRepo): |
|
449 |
+ constants.prevPublishRPMRepo = prevPublishRPMRepo |
|
450 |
+ |
|
451 |
+ @staticmethod |
|
452 |
+ def setPrevPublishXRPMRepo(prevPublishXRPMRepo): |
|
453 |
+ constants.prevPublishXRPMRepo = prevPublishXRPMRepo |
|
454 |
+ |
|
455 |
+ @staticmethod |
|
456 |
+ def setBuildRootPath(buildRootPath): |
|
457 |
+ constants.buildRootPath = buildRootPath |
|
458 |
+ |
|
459 |
+ @staticmethod |
|
460 |
+ def setPullSourcesConfig(pullSourcesConfig): |
|
461 |
+ constants.pullsourcesConfig = pullSourcesConfig |
|
462 |
+ |
|
463 |
+ @staticmethod |
|
464 |
+ def setInputRPMSPath(inputRPMSPath): |
|
465 |
+ constants.inputRPMSPath = inputRPMSPath |
|
466 |
+ |
|
467 |
+ @staticmethod |
|
468 |
+ def setRPMCheck(rpmCheck): |
|
469 |
+ constants.rpmCheck = rpmCheck |
|
470 |
+ |
|
471 |
+ @staticmethod |
|
472 |
+ def setRpmCheckStopOnError(rpmCheckStopOnError): |
|
473 |
+ constants.rpmCheckStopOnError = rpmCheckStopOnError |
|
474 |
+ |
|
475 |
+ @staticmethod |
|
476 |
+ def setPublishBuildDependencies(publishBuildDependencies): |
|
477 |
+ constants.publishBuildDependencies = publishBuildDependencies |
|
478 |
+ |
|
479 |
+ @staticmethod |
|
480 |
+ def setPackageWeightsPath(packageWeightsPath): |
|
481 |
+ constants.packageWeightsPath = packageWeightsPath |
|
482 |
+ |
|
483 |
+ @staticmethod |
|
484 |
+ def setDist(dist): |
|
485 |
+ constants.dist = dist |
|
486 |
+ |
|
487 |
+ @staticmethod |
|
488 |
+ def setBuildNumber(buildNumber): |
|
489 |
+ constants.buildNumber = buildNumber |
|
490 |
+ |
|
491 |
+ @staticmethod |
|
492 |
+ def setReleaseVersion(releaseVersion): |
|
493 |
+ constants.releaseVersion = releaseVersion |
|
494 |
+ |
|
495 |
+ @staticmethod |
|
496 |
+ def setKatBuild(katBuild): |
|
497 |
+ constants.katBuild = katBuild |
|
498 |
+ |
|
499 |
+ @staticmethod |
|
500 |
+ def initialize(): |
|
442 | 501 |
if constants.rpmCheck: |
443 | 502 |
constants.testLogger = Logger.getLogger("MakeCheckTest", constants.logPath) |
444 | 503 |
constants.addMacro("with_check", "1") |
445 | 504 |
else: |
446 | 505 |
constants.addMacro("with_check", "0") |
447 | 506 |
|
448 |
- #adding distribution rpm macro |
|
449 |
- constants.addMacro("dist", options.dist) |
|
507 |
+ # adding distribution rpm macro |
|
508 |
+ if constants.dist is not None: |
|
509 |
+ constants.addMacro("dist", constants.dist) |
|
450 | 510 |
|
451 |
- #adding buildnumber rpm macro |
|
452 |
- constants.addMacro("photon_build_number", options.buildNumber) |
|
511 |
+ # adding buildnumber rpm macro |
|
512 |
+ if constants.buildNumber is not None: |
|
513 |
+ constants.addMacro("photon_build_number", constants.buildNumber) |
|
453 | 514 |
|
454 |
- #adding releasenumber rpm macro |
|
455 |
- constants.addMacro("photon_release_version", options.releaseVersion) |
|
515 |
+ # adding releasenumber rpm macro |
|
516 |
+ if constants.releaseVersion is not None: |
|
517 |
+ constants.addMacro("photon_release_version", constants.releaseVersion) |
|
456 | 518 |
|
457 |
- if options.katBuild is not None: |
|
458 |
- constants.addMacro("kat_build", options.katBuild) |
|
519 |
+ if constants.katBuild is not None: |
|
520 |
+ constants.addMacro("kat_build", constants.katBuild) |
|
459 | 521 |
|
460 | 522 |
@staticmethod |
461 | 523 |
def setTestForceRPMS(listsPackages): |