Change-Id: Id0691dddfb2f0b883a0832531cda23ed84c5ea24
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/1817
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: suezzelur <anishs@vmware.com>
| ... | ... |
@@ -44,7 +44,7 @@ endif |
| 44 | 44 |
ifdef PHOTON_ENABLE_RPMCHECK |
| 45 | 45 |
PHOTON_RPMCHECK_OPTION := -u |
| 46 | 46 |
else |
| 47 |
-PHOTON_RPMCHECK_OPTION := |
|
| 47 |
+PHOTON_RPMCHECK_OPTION := |
|
| 48 | 48 |
endif |
| 49 | 49 |
|
| 50 | 50 |
TOOLS_BIN := $(SRCROOT)/tools/bin |
| ... | ... |
@@ -78,14 +78,13 @@ micro-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MICRO) |
| 78 | 78 |
packages-micro: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) generate-dep-lists |
| 79 | 79 |
@echo "Building all Micro RPMS..." |
| 80 | 80 |
@cd $(PHOTON_PKG_BUILDER_DIR) && \ |
| 81 |
- $(PHOTON_PACKAGE_BUILDER) -o full \ |
|
| 81 |
+ $(PHOTON_PACKAGE_BUILDER) \ |
|
| 82 | 82 |
-s $(PHOTON_SPECS_DIR) \ |
| 83 | 83 |
-r $(PHOTON_RPMS_DIR) \ |
| 84 | 84 |
-x $(PHOTON_SRCS_DIR) \ |
| 85 | 85 |
-b $(PHOTON_CHROOT_PATH) \ |
| 86 | 86 |
-l $(PHOTON_LOGS_DIR) \ |
| 87 | 87 |
-p $(PHOTON_PUBLISH_RPMS_DIR) \ |
| 88 |
- -j $(PHOTON_GENERATED_DATA_DIR)/$(MICRO_PACKAGE_LIST_FILE) \ |
|
| 89 | 88 |
-c $(PHOTON_BINTRAY_CONFIG) \ |
| 90 | 89 |
-d $(PHOTON_DIST_TAG) \ |
| 91 | 90 |
-n $(PHOTON_BUILD_NUMBER) \ |
| ... | ... |
@@ -141,14 +140,13 @@ live-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES_MINIMAL) minimal-iso |
| 141 | 141 |
packages-minimal: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) generate-dep-lists |
| 142 | 142 |
@echo "Building all RPMS..." |
| 143 | 143 |
@cd $(PHOTON_PKG_BUILDER_DIR) && \ |
| 144 |
- $(PHOTON_PACKAGE_BUILDER) -o full \ |
|
| 144 |
+ $(PHOTON_PACKAGE_BUILDER) \ |
|
| 145 | 145 |
-s $(PHOTON_SPECS_DIR) \ |
| 146 | 146 |
-r $(PHOTON_RPMS_DIR) \ |
| 147 | 147 |
-x $(PHOTON_SRCS_DIR) \ |
| 148 | 148 |
-b $(PHOTON_CHROOT_PATH) \ |
| 149 | 149 |
-l $(PHOTON_LOGS_DIR) \ |
| 150 | 150 |
-p $(PHOTON_PUBLISH_RPMS_DIR) \ |
| 151 |
- -j $(PHOTON_GENERATED_DATA_DIR)/$(MINIMAL_PACKAGE_LIST_FILE) \ |
|
| 152 | 151 |
-c $(PHOTON_BINTRAY_CONFIG) \ |
| 153 | 152 |
-d $(PHOTON_DIST_TAG) \ |
| 154 | 153 |
-n $(PHOTON_BUILD_NUMBER) \ |
| ... | ... |
@@ -198,8 +196,6 @@ src-iso: check $(PHOTON_STAGE) $(PHOTON_PACKAGES) |
| 198 | 198 |
-p $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \ |
| 199 | 199 |
-o $(PHOTON_STAGE)/common/data \ |
| 200 | 200 |
-s $(PHOTON_DATA_DIR) \ |
| 201 |
- -u $(PHOTON_DATA_DIR)/pkg_info.json\ |
|
| 202 |
- -z $(PHOTON_STAGE)/pkg_info.txt\ |
|
| 203 | 201 |
-f > \ |
| 204 | 202 |
$(PHOTON_LOGS_DIR)/sourceiso-installer.log 2>&1 |
| 205 | 203 |
|
| ... | ... |
@@ -213,12 +209,12 @@ imgtree: |
| 213 | 213 |
|
| 214 | 214 |
who-needs: |
| 215 | 215 |
@cd $(PHOTON_SPECDEPS_DIR) && \ |
| 216 |
- $(PHOTON_SPECDEPS) -s $(PHOTON_SPECS_DIR) -i who-needs -p $(pkg) |
|
| 216 |
+ $(PHOTON_SPECDEPS) -s $(PHOTON_SPECS_DIR) -i who-needs -p $(pkg) |
|
| 217 | 217 |
|
| 218 | 218 |
packages: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists |
| 219 | 219 |
@echo "Building all RPMS..." |
| 220 | 220 |
@cd $(PHOTON_PKG_BUILDER_DIR) && \ |
| 221 |
- $(PHOTON_PACKAGE_BUILDER) -o full \ |
|
| 221 |
+ $(PHOTON_PACKAGE_BUILDER) \ |
|
| 222 | 222 |
-s $(PHOTON_SPECS_DIR) \ |
| 223 | 223 |
-r $(PHOTON_RPMS_DIR) \ |
| 224 | 224 |
-a $(PHOTON_SRPMS_DIR) \ |
| ... | ... |
@@ -226,12 +222,11 @@ packages: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTA |
| 226 | 226 |
-b $(PHOTON_CHROOT_PATH) \ |
| 227 | 227 |
-l $(PHOTON_LOGS_DIR) \ |
| 228 | 228 |
-p $(PHOTON_PUBLISH_RPMS_DIR) \ |
| 229 |
- -j $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \ |
|
| 230 | 229 |
-c $(PHOTON_BINTRAY_CONFIG) \ |
| 231 | 230 |
-d $(PHOTON_DIST_TAG) \ |
| 232 | 231 |
-n $(PHOTON_BUILD_NUMBER) \ |
| 233 | 232 |
-v $(PHOTON_RELEASE_VERSION) \ |
| 234 |
- -w $(PHOTON_DATA_DIR)/pkg_info.json \ |
|
| 233 |
+ -w $(PHOTON_STAGE)/pkg_info.json \ |
|
| 235 | 234 |
-g $(PHOTON_DATA_DIR)/pkg_build_options.json \ |
| 236 | 235 |
$(PHOTON_RPMCHECK_OPTION) \ |
| 237 | 236 |
-t ${THREADS}
|
| ... | ... |
@@ -239,14 +234,13 @@ packages: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTA |
| 239 | 239 |
updated-packages: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists |
| 240 | 240 |
@echo "Building only updated RPMS..." |
| 241 | 241 |
@cd $(PHOTON_PKG_BUILDER_DIR) && \ |
| 242 |
- $(PHOTON_PACKAGE_BUILDER) -o full \ |
|
| 242 |
+ $(PHOTON_PACKAGE_BUILDER) \ |
|
| 243 | 243 |
-s $(PHOTON_SPECS_DIR) \ |
| 244 | 244 |
-r $(PHOTON_UPDATED_RPMS_DIR) \ |
| 245 | 245 |
-x $(PHOTON_SRCS_DIR) \ |
| 246 | 246 |
-b $(PHOTON_CHROOT_PATH) \ |
| 247 | 247 |
-l $(PHOTON_LOGS_DIR) \ |
| 248 | 248 |
-p $(PHOTON_PUBLISH_RPMS_DIR) \ |
| 249 |
- -j $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \ |
|
| 250 | 249 |
-c $(PHOTON_BINTRAY_CONFIG) \ |
| 251 | 250 |
-d $(PHOTON_DIST_TAG) \ |
| 252 | 251 |
-n $(PHOTON_BUILD_NUMBER) \ |
| ... | ... |
@@ -258,7 +252,7 @@ updated-packages: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) |
| 258 | 258 |
tool-chain-stage1: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists |
| 259 | 259 |
@echo "Building all RPMS..." |
| 260 | 260 |
@cd $(PHOTON_PKG_BUILDER_DIR) && \ |
| 261 |
- $(PHOTON_PACKAGE_BUILDER) -o full \ |
|
| 261 |
+ $(PHOTON_PACKAGE_BUILDER) \ |
|
| 262 | 262 |
-s $(PHOTON_SPECS_DIR) \ |
| 263 | 263 |
-r $(PHOTON_RPMS_DIR) \ |
| 264 | 264 |
-a $(PHOTON_SRPMS_DIR) \ |
| ... | ... |
@@ -266,7 +260,6 @@ tool-chain-stage1: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES |
| 266 | 266 |
-b $(PHOTON_CHROOT_PATH) \ |
| 267 | 267 |
-l $(PHOTON_LOGS_DIR) \ |
| 268 | 268 |
-p $(PHOTON_PUBLISH_RPMS_DIR) \ |
| 269 |
- -j $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \ |
|
| 270 | 269 |
-t ${THREADS} \
|
| 271 | 270 |
-c $(PHOTON_BINTRAY_CONFIG) \ |
| 272 | 271 |
-d $(PHOTON_DIST_TAG) \ |
| ... | ... |
@@ -278,7 +271,7 @@ tool-chain-stage1: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES |
| 278 | 278 |
tool-chain-stage2: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists |
| 279 | 279 |
@echo "Building all RPMS..." |
| 280 | 280 |
@cd $(PHOTON_PKG_BUILDER_DIR) && \ |
| 281 |
- $(PHOTON_PACKAGE_BUILDER) -o full \ |
|
| 281 |
+ $(PHOTON_PACKAGE_BUILDER) \ |
|
| 282 | 282 |
-s $(PHOTON_SPECS_DIR) \ |
| 283 | 283 |
-r $(PHOTON_RPMS_DIR) \ |
| 284 | 284 |
-a $(PHOTON_SRPMS_DIR) \ |
| ... | ... |
@@ -286,7 +279,6 @@ tool-chain-stage2: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES |
| 286 | 286 |
-b $(PHOTON_CHROOT_PATH) \ |
| 287 | 287 |
-l $(PHOTON_LOGS_DIR) \ |
| 288 | 288 |
-p $(PHOTON_PUBLISH_RPMS_DIR) \ |
| 289 |
- -j $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \ |
|
| 290 | 289 |
-t ${THREADS} \
|
| 291 | 290 |
-c $(PHOTON_BINTRAY_CONFIG) \ |
| 292 | 291 |
-d $(PHOTON_DIST_TAG) \ |
| ... | ... |
@@ -107,7 +107,7 @@ def create_additional_file_list_to_copy_in_iso(base_path, build_install_option): |
| 107 | 107 |
file_list = [] |
| 108 | 108 |
for install_option in options_sorted: |
| 109 | 109 |
if install_option[1].has_key("additional-files"):
|
| 110 |
- file_list = file_list + map(lambda filename: os.path.join(base_path, filename), install_option[1].get("additional-files"))
|
|
| 110 |
+ file_list = file_list + map(lambda filename: os.path.join(base_path, filename), install_option[1].get("additional-files"))
|
|
| 111 | 111 |
return file_list |
| 112 | 112 |
|
| 113 | 113 |
def get_live_cd_status_string(build_install_option): |
| ... | ... |
@@ -121,21 +121,6 @@ def get_live_cd_status_string(build_install_option): |
| 121 | 121 |
return "true" |
| 122 | 122 |
return "false" |
| 123 | 123 |
|
| 124 |
-def generate_pkginfo_text_file(list_rpms, pkg_info_json_file_path, pkg_info_text_file_path): |
|
| 125 |
- if not os.path.isfile(pkg_info_json_file_path): |
|
| 126 |
- return |
|
| 127 |
- pkg_info_json_file = open(pkg_info_json_file_path,'r') |
|
| 128 |
- data = json.load(pkg_info_json_file) |
|
| 129 |
- pkg_info_json_file.close() |
|
| 130 |
- list_lines = [] |
|
| 131 |
- list_lines.append("#%{name},%{version},%{release},%{arch},%{sourcerpm}\n")
|
|
| 132 |
- for rpm in list_rpms: |
|
| 133 |
- if data.has_key(rpm): |
|
| 134 |
- list_lines.append(data[rpm]["name"]+","+data[rpm]["version"]+","+data[rpm]["release"]+","+data[rpm]["arch"]+","+data[rpm]["sourcerpm"]+"\n") |
|
| 135 |
- pkg_info_text_file = open(pkg_info_text_file_path,'w') |
|
| 136 |
- pkg_info_text_file.writelines(list_lines) |
|
| 137 |
- pkg_info_text_file.close() |
|
| 138 |
- |
|
| 139 | 124 |
if __name__ == '__main__': |
| 140 | 125 |
usage = "Usage: %prog [options] <config file> <tools path>" |
| 141 | 126 |
parser = OptionParser(usage) |
| ... | ... |
@@ -153,8 +138,6 @@ if __name__ == '__main__': |
| 153 | 153 |
parser.add_option("-m", "--stage-path", dest="stage_path", default="../stage")
|
| 154 | 154 |
parser.add_option("-c", "--dracut-configuration", dest="dracut_configuration_file", default="../common/data/dracut_configuration.json")
|
| 155 | 155 |
parser.add_option("-s", "--json-data-path", dest="json_data_path", default="../stage/common/data/")
|
| 156 |
- parser.add_option("-u", "--pkginfo-json-file", dest="pkginfo_json_file", default="../common/data/pkg_info.json")
|
|
| 157 |
- parser.add_option("-z", "--pkginfo-txt-file", dest="pkginfo_txt_file", default="../stage/pkg_info.txt")
|
|
| 158 | 156 |
|
| 159 | 157 |
(options, args) = parser.parse_args() |
| 160 | 158 |
if options.iso_path or options.src_iso_path: |
| ... | ... |
@@ -262,7 +245,6 @@ if __name__ == '__main__': |
| 262 | 262 |
list_rpms = rpm_list.split(" ")
|
| 263 | 263 |
list_rpms = list(set(list_rpms)) |
| 264 | 264 |
list_rpms.sort() |
| 265 |
- generate_pkginfo_text_file(list_rpms, options.pkginfo_json_file, options.pkginfo_txt_file) |
|
| 266 | 265 |
|
| 267 | 266 |
# Cleaning up for vmdk |
| 268 | 267 |
if 'vmdk_install' in config and config['vmdk_install']: |
| ... | ... |
@@ -8,7 +8,7 @@ from constants import constants |
| 8 | 8 |
import shutil |
| 9 | 9 |
|
| 10 | 10 |
class PackageBuilder(object): |
| 11 |
- |
|
| 11 |
+ |
|
| 12 | 12 |
def __init__(self,mapPackageToCycles,listAvailableCyclicPackages,listBuildOptionPackages,pkgBuildOptionFile,logName=None,logPath=None): |
| 13 | 13 |
if logName is None: |
| 14 | 14 |
logName = "PackageBuilder" |
| ... | ... |
@@ -22,7 +22,7 @@ class PackageBuilder(object): |
| 22 | 22 |
self.listNodepsPackages = ["glibc","gmp","zlib","file","binutils","mpfr","mpc","gcc","ncurses","util-linux","groff","perl","texinfo","rpm","openssl","go"] |
| 23 | 23 |
self.listBuildOptionPackages=listBuildOptionPackages |
| 24 | 24 |
self.pkgBuildOptionFile=pkgBuildOptionFile |
| 25 |
- |
|
| 25 |
+ |
|
| 26 | 26 |
def prepareBuildRoot(self,chrootName,isToolChainPackage=False): |
| 27 | 27 |
chrootID=None |
| 28 | 28 |
try: |
| ... | ... |
@@ -42,7 +42,7 @@ class PackageBuilder(object): |
| 42 | 42 |
chrUtils.destroyChroot(chrootID) |
| 43 | 43 |
raise e |
| 44 | 44 |
return chrootID |
| 45 |
- |
|
| 45 |
+ |
|
| 46 | 46 |
def findPackageNameFromRPMFile(self,rpmfile): |
| 47 | 47 |
rpmfile=os.path.basename(rpmfile) |
| 48 | 48 |
releaseindex=rpmfile.rfind("-")
|
| ... | ... |
@@ -55,7 +55,7 @@ class PackageBuilder(object): |
| 55 | 55 |
return None |
| 56 | 56 |
packageName=rpmfile[0:versionindex] |
| 57 | 57 |
return packageName |
| 58 |
- |
|
| 58 |
+ |
|
| 59 | 59 |
def findInstalledPackages(self,chrootID): |
| 60 | 60 |
pkgUtils = PackageUtils(self.logName,self.logPath) |
| 61 | 61 |
listInstalledRPMs=pkgUtils.findInstalledRPMPackages(chrootID) |
| ... | ... |
@@ -65,7 +65,7 @@ class PackageBuilder(object): |
| 65 | 65 |
if packageName is not None: |
| 66 | 66 |
listInstalledPackages.append(packageName) |
| 67 | 67 |
return listInstalledPackages |
| 68 |
- |
|
| 68 |
+ |
|
| 69 | 69 |
def buildPackageThreadAPI(self,package,outputMap, threadName,): |
| 70 | 70 |
try: |
| 71 | 71 |
self.buildPackage(package) |
| ... | ... |
@@ -85,7 +85,7 @@ class PackageBuilder(object): |
| 85 | 85 |
break |
| 86 | 86 |
return packageIsAlreadyBuilt |
| 87 | 87 |
|
| 88 |
- def buildPackage(self,package): |
|
| 88 |
+ def buildPackage(self, package): |
|
| 89 | 89 |
#do not build if RPM is already built |
| 90 | 90 |
if self.checkIfPackageIsAlreadyBuilt(package): |
| 91 | 91 |
self.logger.info("Skipping building the package:"+package)
|
| ... | ... |
@@ -104,12 +104,12 @@ class PackageBuilder(object): |
| 104 | 104 |
if not os.path.isdir(destLogPath): |
| 105 | 105 |
cmdUtils = CommandUtils() |
| 106 | 106 |
cmdUtils.runCommandInShell("mkdir -p "+destLogPath)
|
| 107 |
- |
|
| 107 |
+ |
|
| 108 | 108 |
listInstalledPackages=self.findInstalledPackages(chrootID) |
| 109 | 109 |
self.logger.info("List of installed packages")
|
| 110 | 110 |
self.logger.info(listInstalledPackages) |
| 111 | 111 |
listDependentPackages=self.findBuildTimeRequiredPackages(package) |
| 112 |
- |
|
| 112 |
+ |
|
| 113 | 113 |
pkgUtils = PackageUtils(self.logName,self.logPath) |
| 114 | 114 |
if len(listDependentPackages) != 0: |
| 115 | 115 |
self.logger.info("Installing the build time dependent packages......")
|
| ... | ... |
@@ -129,16 +129,16 @@ class PackageBuilder(object): |
| 129 | 129 |
raise e |
| 130 | 130 |
if chrootID is not None: |
| 131 | 131 |
chrUtils.destroyChroot(chrootID) |
| 132 |
- |
|
| 133 |
- |
|
| 132 |
+ |
|
| 133 |
+ |
|
| 134 | 134 |
def findRunTimeRequiredRPMPackages(self,rpmPackage): |
| 135 | 135 |
listRequiredPackages=constants.specData.getRequiresForPackage(rpmPackage) |
| 136 | 136 |
return listRequiredPackages |
| 137 |
- |
|
| 137 |
+ |
|
| 138 | 138 |
def findBuildTimeRequiredPackages(self,package): |
| 139 | 139 |
listRequiredPackages=constants.specData.getBuildRequiresForPackage(package) |
| 140 | 140 |
return listRequiredPackages |
| 141 |
- |
|
| 141 |
+ |
|
| 142 | 142 |
def installPackage(self,pkgUtils,package,chrootID,destLogPath,listInstalledPackages): |
| 143 | 143 |
if package in listInstalledPackages: |
| 144 | 144 |
return |
| ... | ... |
@@ -3,42 +3,56 @@ from Logger import Logger |
| 3 | 3 |
from constants import constants |
| 4 | 4 |
import os.path |
| 5 | 5 |
from CommandUtils import CommandUtils |
| 6 |
+from PackageUtils import PackageUtils |
|
| 6 | 7 |
|
| 7 |
-class SourcePackageInfo(object): |
|
| 8 |
- sourcePkgList = {}
|
|
| 9 |
- logger = None |
|
| 8 |
+class PackageInfo(object): |
|
| 10 | 9 |
|
| 11 |
- |
|
| 12 |
- @staticmethod |
|
| 13 |
- def setLogging(logName=None,logPath=None): |
|
| 10 |
+ def __init__(self, logName=None, logPath=None): |
|
| 14 | 11 |
if logName is None: |
| 15 |
- logName = "SourcePackageInfo" |
|
| 12 |
+ logName = "PackageInfo" |
|
| 16 | 13 |
if logPath is None: |
| 17 | 14 |
logPath = constants.logPath |
| 18 |
- SourcePackageInfo.logger=Logger.getLogger(logName,logPath) |
|
| 19 |
- |
|
| 20 |
- @staticmethod |
|
| 21 |
- def loadPkgInfoFromFile(filePath): |
|
| 22 |
- SourcePackageInfo.logger.info("Loading source package list from the json file")
|
|
| 23 |
- if not os.path.isfile(filePath): |
|
| 24 |
- return |
|
| 25 |
- pkgInfoFile = open(filePath,'r') |
|
| 26 |
- SourcePackageInfo.sourcePkgList = json.load(pkgInfoFile) |
|
| 27 |
- pkgInfoFile.close() |
|
| 15 |
+ self.logName=logName |
|
| 16 |
+ self.logPath=logPath |
|
| 17 |
+ self.logger=Logger.getLogger(logName,logPath) |
|
| 18 |
+ self.pkgList = {}
|
|
| 28 | 19 |
|
| 29 |
- @staticmethod |
|
| 30 |
- def addSRPMData(packageName,version,release,arch,srpmFile): |
|
| 31 |
- listPkgAttributes={"name":packageName,"version":version,"release":release,"arch":arch,"sourcerpm":srpmFile}
|
|
| 32 |
- SourcePackageInfo.sourcePkgList[packageName]=listPkgAttributes |
|
| 33 |
- SourcePackageInfo.logger.info("Added source package to the list:"+packageName)
|
|
| 20 |
+ def loadPackagesData(self): |
|
| 21 |
+ listPackages = constants.specData.getListPackages() |
|
| 22 |
+ listPackages.sort() |
|
| 23 |
+ listRPMFiles = [] |
|
| 24 |
+ cmdUtils = CommandUtils() |
|
| 25 |
+ for package in listPackages: |
|
| 26 |
+ release = constants.specData.getRelease(package) |
|
| 27 |
+ version = constants.specData.getVersion(package) |
|
| 28 |
+ listRPMPackages = constants.specData.getRPMPackages(package) |
|
| 29 |
+ srpmFileName = package+"-"+version+"-"+release+".src.rpm" |
|
| 30 |
+ srpmFiles = cmdUtils.findFile(srpmFileName, constants.sourceRpmPath) |
|
| 31 |
+ srpmFile = None |
|
| 32 |
+ if len(srpmFiles) == 1: |
|
| 33 |
+ srpmFile = srpmFiles[0] |
|
| 34 |
+ debugrpmFileName = package+"-debuginfo-"+version+"-"+release+"*" |
|
| 35 |
+ debugrpmFiles = cmdUtils.findFile(debugrpmFileName, constants.rpmPath) |
|
| 36 |
+ debugrpmFile = None |
|
| 37 |
+ if len(debugrpmFiles) == 1: |
|
| 38 |
+ debugrpmFile = debugrpmFiles[0] |
|
| 39 |
+ pkgUtils = PackageUtils(self.logName,self.logPath) |
|
| 40 |
+ for rpmPkg in listRPMPackages: |
|
| 41 |
+ rpmFile = pkgUtils.findRPMFileForGivenPackage(rpmPkg) |
|
| 42 |
+ if rpmFile is not None: |
|
| 43 |
+ listRPMFiles.append(rpmFile) |
|
| 44 |
+ listPkgAttributes = {"sourcerpm":srpmFile, "rpm":rpmFile, "debugrpm":debugrpmFile}
|
|
| 45 |
+ self.pkgList[rpmPkg] = listPkgAttributes |
|
| 46 |
+ self.logger.debug("Added "+rpmPkg +" rpm package to the list")
|
|
| 47 |
+ else: |
|
| 48 |
+ self.logger.error("Missing rpm file for package:"+rpmPkg)
|
|
| 34 | 49 |
|
| 35 |
- @staticmethod |
|
| 36 |
- def writePkgListToFile(fileName): |
|
| 37 |
- SourcePackageInfo.logger.info("Writing source package list to the json file")
|
|
| 50 |
+ def writePkgListToFile(self, fileName): |
|
| 51 |
+ self.logger.info("Writing package list to the json file")
|
|
| 38 | 52 |
cmdUtils=CommandUtils() |
| 39 | 53 |
dirPath=os.path.basename(fileName) |
| 40 | 54 |
if not os.path.isdir(dirPath): |
| 41 | 55 |
cmdUtils.runCommandInShell("mkdir -p "+dirPath)
|
| 42 | 56 |
pkgInfoFile = open(fileName,'w+') |
| 43 |
- json.dump(SourcePackageInfo.sourcePkgList, pkgInfoFile,indent=4) |
|
| 57 |
+ json.dump(self.pkgList, pkgInfoFile, indent=4) |
|
| 44 | 58 |
pkgInfoFile.close() |
| ... | ... |
@@ -6,12 +6,11 @@ from constants import constants |
| 6 | 6 |
import re |
| 7 | 7 |
from time import sleep |
| 8 | 8 |
import PullSources |
| 9 |
-from PackageInfo import SourcePackageInfo |
|
| 10 | 9 |
import json |
| 11 | 10 |
import collections |
| 12 | 11 |
|
| 13 | 12 |
class PackageUtils(object): |
| 14 |
- |
|
| 13 |
+ |
|
| 15 | 14 |
def __init__(self,logName=None,logPath=None): |
| 16 | 15 |
if logName is None: |
| 17 | 16 |
self.logName = "PackageUtils" |
| ... | ... |
@@ -24,7 +23,7 @@ class PackageUtils(object): |
| 24 | 24 |
self.rpmBinary = "rpm" |
| 25 | 25 |
self.installRPMPackageOptions = "-Uvh" |
| 26 | 26 |
self.nodepsRPMPackageOptions = "--nodeps" |
| 27 |
- |
|
| 27 |
+ |
|
| 28 | 28 |
self.rpmbuildBinary = "rpmbuild" |
| 29 | 29 |
self.rpmbuildBuildallOption = "-ba --clean" |
| 30 | 30 |
self.rpmbuildNocheckOption = "--nocheck" |
| ... | ... |
@@ -36,7 +35,7 @@ class PackageUtils(object): |
| 36 | 36 |
self.packagesToInstallInAOneShot="" |
| 37 | 37 |
self.noDepsRPMFilesToInstallInAOneShot="" |
| 38 | 38 |
self.noDepsPackagesToInstallInAOneShot="" |
| 39 |
- |
|
| 39 |
+ |
|
| 40 | 40 |
def getRPMArch(self,rpmName): |
| 41 | 41 |
arch="" |
| 42 | 42 |
if rpmName.find("x86_64") != -1:
|
| ... | ... |
@@ -49,7 +48,7 @@ class PackageUtils(object): |
| 49 | 49 |
arch = self.getRPMArch(rpmName) |
| 50 | 50 |
rpmDestDir=rpmDir+"/"+arch |
| 51 | 51 |
return rpmDestDir |
| 52 |
- |
|
| 52 |
+ |
|
| 53 | 53 |
def copyRPM(self,rpmFile,destDir): |
| 54 | 54 |
cmdUtils = CommandUtils() |
| 55 | 55 |
rpmName=os.path.basename(rpmFile) |
| ... | ... |
@@ -60,11 +59,11 @@ class PackageUtils(object): |
| 60 | 60 |
cmdUtils.runCommandInShell("mkdir -p "+rpmDestDir)
|
| 61 | 61 |
shutil.copyfile(rpmFile, rpmDestPath) |
| 62 | 62 |
return rpmDestPath |
| 63 |
- |
|
| 63 |
+ |
|
| 64 | 64 |
def installRPM(self,package,chrootID,noDeps=False,destLogPath=None): |
| 65 | 65 |
# self.logger.info("Installing rpm for package:"+package)
|
| 66 | 66 |
# self.logger.debug("No deps:"+str(noDeps))
|
| 67 |
- |
|
| 67 |
+ |
|
| 68 | 68 |
rpmfile=self.findRPMFileForGivenPackage(package) |
| 69 | 69 |
if rpmfile is None: |
| 70 | 70 |
self.logger.error("No rpm file found for package:"+package)
|
| ... | ... |
@@ -78,7 +77,7 @@ class PackageUtils(object): |
| 78 | 78 |
else: |
| 79 | 79 |
self.rpmFilesToInstallInAOneShot += " " + rpmFile |
| 80 | 80 |
self.packagesToInstallInAOneShot += " " + package |
| 81 |
- |
|
| 81 |
+ |
|
| 82 | 82 |
def installRPMSInAOneShot(self,chrootID,destLogPath): |
| 83 | 83 |
chrootCmd=self.runInChrootCommand+" "+chrootID |
| 84 | 84 |
rpmInstallcmd=self.rpmBinary+" "+ self.installRPMPackageOptions |
| ... | ... |
@@ -104,8 +103,8 @@ class PackageUtils(object): |
| 104 | 104 |
if not returnVal: |
| 105 | 105 |
self.logger.error("Unable to install rpms")
|
| 106 | 106 |
raise Exception("RPM installation failed")
|
| 107 |
- |
|
| 108 |
- |
|
| 107 |
+ |
|
| 108 |
+ |
|
| 109 | 109 |
def copySourcesTobuildroot(self,listSourceFiles,package,destDir): |
| 110 | 110 |
cmdUtils = CommandUtils() |
| 111 | 111 |
for source in listSourceFiles: |
| ... | ... |
@@ -133,7 +132,7 @@ class PackageUtils(object): |
| 133 | 133 |
raise Exception("Multiple sources found")
|
| 134 | 134 |
self.logger.info("Copying... Source path :" + source + " Source filename: " + sourcePath[0])
|
| 135 | 135 |
shutil.copy2(sourcePath[0], destDir) |
| 136 |
- |
|
| 136 |
+ |
|
| 137 | 137 |
def copyAdditionalBuildFiles(self,listAdditionalFiles,chrootID): |
| 138 | 138 |
cmdUtils = CommandUtils() |
| 139 | 139 |
for additionalFile in listAdditionalFiles: |
| ... | ... |
@@ -144,7 +143,7 @@ class PackageUtils(object): |
| 144 | 144 |
shutil.copy(source, destDir) |
| 145 | 145 |
else: |
| 146 | 146 |
shutil.copytree(source, destDir) |
| 147 |
- |
|
| 147 |
+ |
|
| 148 | 148 |
def buildRPMSForGivenPackage(self,package,chrootID,listBuildOptionPackages,pkgBuildOptionFile,destLogPath=None): |
| 149 | 149 |
self.logger.info("Building rpm's for package:"+package)
|
| 150 | 150 |
|
| ... | ... |
@@ -152,13 +151,13 @@ class PackageUtils(object): |
| 152 | 152 |
listPatchFiles = constants.specData.getPatches(package) |
| 153 | 153 |
specFile = constants.specData.getSpecFile(package) |
| 154 | 154 |
specName = constants.specData.getSpecName(package) + ".spec" |
| 155 |
- |
|
| 155 |
+ |
|
| 156 | 156 |
chrootSourcePath=chrootID+constants.topDirPath+"/SOURCES/" |
| 157 | 157 |
chrootSpecPath=constants.topDirPath+"/SPECS/" |
| 158 | 158 |
chrootLogsFilePath=chrootID+constants.topDirPath+"/LOGS/"+package+".log" |
| 159 | 159 |
chrootCmd=self.runInChrootCommand+" "+chrootID |
| 160 | 160 |
shutil.copyfile(specFile, chrootID+chrootSpecPath+specName ) |
| 161 |
- |
|
| 161 |
+ |
|
| 162 | 162 |
# FIXME: some sources are located in SPECS/.. how to mount? |
| 163 | 163 |
# if os.geteuid()==0: |
| 164 | 164 |
self.copySourcesTobuildroot(listSourcesFiles,package,chrootSourcePath) |
| ... | ... |
@@ -180,7 +179,7 @@ class PackageUtils(object): |
| 180 | 180 |
macrolist = pkg[1]["macros"] |
| 181 | 181 |
for macro in macrolist: |
| 182 | 182 |
macros.append(str(macro.encode('utf-8')))
|
| 183 |
- |
|
| 183 |
+ |
|
| 184 | 184 |
self.copyAdditionalBuildFiles(listAdditionalFiles,chrootID) |
| 185 | 185 |
|
| 186 | 186 |
#Adding rpm macros |
| ... | ... |
@@ -200,26 +199,22 @@ class PackageUtils(object): |
| 200 | 200 |
shutil.copy2(chrootLogsFilePath, destLogPath) |
| 201 | 201 |
self.logger.info("RPM build is successful")
|
| 202 | 202 |
arch = self.getRPMArch(listRPMFiles[0]) |
| 203 |
- |
|
| 203 |
+ |
|
| 204 | 204 |
for rpmFile in listRPMFiles: |
| 205 |
- self.copyRPM(chrootID+"/"+rpmFile, constants.rpmPath) |
|
| 206 |
- |
|
| 205 |
+ rpmDestFilePath = self.copyRPM(chrootID+"/"+rpmFile, constants.rpmPath) |
|
| 206 |
+ |
|
| 207 | 207 |
for srpmFile in listSRPMFiles: |
| 208 |
- self.copyRPM(chrootID+"/"+srpmFile, constants.sourceRpmPath) |
|
| 209 |
- srpmName = os.path.basename(srpmFile) |
|
| 210 |
- package,version,release = self.findPackageInfoFromSourceRPMFile(srpmFile) |
|
| 211 |
- SourcePackageInfo.addSRPMData(package,version,release,arch,srpmName) |
|
| 208 |
+ srpmDestFile = self.copyRPM(chrootID+"/"+srpmFile, constants.sourceRpmPath) |
|
| 212 | 209 |
|
| 213 |
- |
|
| 214 | 210 |
def buildRPM(self,specFile,logFile,chrootCmd,package,macros): |
| 215 |
- |
|
| 211 |
+ |
|
| 216 | 212 |
rpmBuildcmd= self.rpmbuildBinary+" "+self.rpmbuildBuildallOption+" "+self.rpmbuildDistOption |
| 217 | 213 |
if not constants.rpmCheck: |
| 218 | 214 |
rpmBuildcmd+=" "+self.rpmbuildNocheckOption |
| 219 | 215 |
for macro in macros: |
| 220 | 216 |
rpmBuildcmd+=' --define \\\"%s\\\"' % macro |
| 221 | 217 |
rpmBuildcmd+=" "+specFile |
| 222 |
- |
|
| 218 |
+ |
|
| 223 | 219 |
cmdUtils = CommandUtils() |
| 224 | 220 |
self.logger.info("Building rpm....")
|
| 225 | 221 |
self.logger.info(rpmBuildcmd) |
| ... | ... |
@@ -227,7 +222,7 @@ class PackageUtils(object): |
| 227 | 227 |
if not returnVal: |
| 228 | 228 |
self.logger.error("Building rpm is failed "+specFile)
|
| 229 | 229 |
raise Exception("RPM Build failed")
|
| 230 |
- |
|
| 230 |
+ |
|
| 231 | 231 |
#Extracting rpms created from log file |
| 232 | 232 |
logfile=open(logFile,'r') |
| 233 | 233 |
fileContents=logfile.readlines() |
| ... | ... |
@@ -241,8 +236,8 @@ class PackageUtils(object): |
| 241 | 241 |
listRPMFiles.append(listcontents[1]) |
| 242 | 242 |
if (len(listcontents) == 2) and listcontents[1].strip()[-8:] == ".src.rpm" and listcontents[1].find("/SRPMS/") != -1:
|
| 243 | 243 |
listSRPMFiles.append(listcontents[1]) |
| 244 |
- return listRPMFiles,listSRPMFiles |
|
| 245 |
- |
|
| 244 |
+ return listRPMFiles,listSRPMFiles |
|
| 245 |
+ |
|
| 246 | 246 |
def findRPMFileForGivenPackage(self,package): |
| 247 | 247 |
cmdUtils = CommandUtils() |
| 248 | 248 |
version = constants.specData.getVersion(package) |
| ... | ... |
@@ -251,7 +246,7 @@ class PackageUtils(object): |
| 251 | 251 |
cmdUtils.findFile(package+"-"+version+"-"+release+".noarch.rpm",constants.rpmPath)], []) |
| 252 | 252 |
if constants.inputRPMSPath is not None: |
| 253 | 253 |
listFoundRPMFiles = sum([cmdUtils.findFile(package+"-"+version+"-"+release+".x86_64.rpm",constants.inputRPMSPath), |
| 254 |
- cmdUtils.findFile(package+"-"+version+"-"+release+".noarch.rpm",constants.inputRPMSPath)], listFoundRPMFiles) |
|
| 254 |
+ cmdUtils.findFile(package+"-"+version+"-"+release+".noarch.rpm",constants.inputRPMSPath)], listFoundRPMFiles) |
|
| 255 | 255 |
if len(listFoundRPMFiles) == 1 : |
| 256 | 256 |
return listFoundRPMFiles[0] |
| 257 | 257 |
if len(listFoundRPMFiles) == 0 : |
| ... | ... |
@@ -259,7 +254,7 @@ class PackageUtils(object): |
| 259 | 259 |
if len(listFoundRPMFiles) > 1 : |
| 260 | 260 |
self.logger.error("Found multiple rpm files for given package in rpm directory.Unable to determine the rpm file for package:"+package)
|
| 261 | 261 |
raise Exception("Multiple rpm files found")
|
| 262 |
- |
|
| 262 |
+ |
|
| 263 | 263 |
def findPackageNameFromRPMFile(self,rpmfile): |
| 264 | 264 |
rpmfile=os.path.basename(rpmfile) |
| 265 | 265 |
releaseindex=rpmfile.rfind("-")
|
| ... | ... |
@@ -271,7 +266,7 @@ class PackageUtils(object): |
| 271 | 271 |
self.logger.error("Invalid rpm file:"+rpmfile)
|
| 272 | 272 |
raise Exception("Invalid RPM")
|
| 273 | 273 |
packageName=rpmfile[0:versionindex] |
| 274 |
- return packageName |
|
| 274 |
+ return packageName |
|
| 275 | 275 |
|
| 276 | 276 |
def findPackageInfoFromRPMFile(self,rpmfile): |
| 277 | 277 |
rpmfile=os.path.basename(rpmfile) |
| ... | ... |
@@ -290,22 +285,6 @@ class PackageUtils(object): |
| 290 | 290 |
release=rpmfile[releaseindex+1:] |
| 291 | 291 |
return packageName,version,release |
| 292 | 292 |
|
| 293 |
- def findPackageInfoFromSourceRPMFile(self,sourcerpmfile): |
|
| 294 |
- sourcerpmfile=os.path.basename(sourcerpmfile) |
|
| 295 |
- sourcerpmfile=sourcerpmfile.replace(".src.rpm","")
|
|
| 296 |
- releaseindex=sourcerpmfile.rfind("-")
|
|
| 297 |
- if releaseindex == -1: |
|
| 298 |
- self.logger.error("Invalid source rpm file:"+sourcerpmfile)
|
|
| 299 |
- raise Exception("Invalid Source RPM")
|
|
| 300 |
- versionindex=sourcerpmfile[0:releaseindex].rfind("-")
|
|
| 301 |
- if versionindex == -1: |
|
| 302 |
- self.logger.error("Invalid source rpm file:"+sourcerpmfile)
|
|
| 303 |
- raise Exception("Invalid source RPM")
|
|
| 304 |
- packageName=sourcerpmfile[0:versionindex] |
|
| 305 |
- version=sourcerpmfile[versionindex+1:releaseindex] |
|
| 306 |
- release=sourcerpmfile[releaseindex+1:] |
|
| 307 |
- return packageName,version,release |
|
| 308 |
- |
|
| 309 | 293 |
def findInstalledRPMPackages(self, chrootID): |
| 310 | 294 |
cmd = self.rpmBinary+" "+self.queryRpmPackageOptions |
| 311 | 295 |
chrootCmd=self.runInChrootCommand+" "+chrootID |
| ... | ... |
@@ -53,16 +53,16 @@ class SerializableSpecObjectsUtils(object): |
| 53 | 53 |
specObj.url=spec.getURL() |
| 54 | 54 |
specObj.sourceurl=spec.getSourceURL() |
| 55 | 55 |
for specPkg in specObj.listPackages: |
| 56 |
- if specPkg in self.mapPackageToSpec: |
|
| 57 |
- existingObj = self.mapSerializableSpecObjects[self.mapPackageToSpec[specPkg]] |
|
| 58 |
- if self.compareVersions(existingObj,specObj) == 1: |
|
| 59 |
- skipUpdating = True |
|
| 60 |
- break; |
|
| 56 |
+ if specPkg in self.mapPackageToSpec: |
|
| 57 |
+ existingObj = self.mapSerializableSpecObjects[self.mapPackageToSpec[specPkg]] |
|
| 58 |
+ if self.compareVersions(existingObj,specObj) == 1: |
|
| 59 |
+ skipUpdating = True |
|
| 60 |
+ break; |
|
| 61 | 61 |
specObj.installRequiresPackages[specPkg]=spec.getRequires(specPkg) |
| 62 |
- self.mapPackageToSpec[specPkg]=specName |
|
| 62 |
+ self.mapPackageToSpec[specPkg]=specName |
|
| 63 | 63 |
if spec.getIsRPMPackage(specPkg): |
| 64 | 64 |
specObj.listRPMPackages.append(specPkg) |
| 65 |
- if skipUpdating == False: |
|
| 65 |
+ if skipUpdating == False: |
|
| 66 | 66 |
self.mapSerializableSpecObjects[specName]=specObj |
| 67 | 67 |
|
| 68 | 68 |
def getListSpecFiles(self,listSpecFiles,path): |
| ... | ... |
@@ -169,19 +169,19 @@ class SerializableSpecObjectsUtils(object): |
| 169 | 169 |
return specName |
| 170 | 170 |
self.logger.error("Could not able to find "+package+" package from specs")
|
| 171 | 171 |
raise Exception("Invalid package:"+package)
|
| 172 |
- |
|
| 172 |
+ |
|
| 173 | 173 |
def isRPMPackage(self,package): |
| 174 | 174 |
if self.mapPackageToSpec.has_key(package): |
| 175 | 175 |
specName=self.mapPackageToSpec[package] |
| 176 | 176 |
if self.mapSerializableSpecObjects.has_key(specName): |
| 177 | 177 |
return True |
| 178 | 178 |
return False |
| 179 |
- |
|
| 179 |
+ |
|
| 180 | 180 |
def getSecurityHardeningOption(self, package): |
| 181 | 181 |
specName=self.getSpecName(package) |
| 182 | 182 |
return self.mapSerializableSpecObjects[specName].securityHardening |
| 183 | 183 |
|
| 184 |
- def getListSpecs(self): |
|
| 184 |
+ def getListPackages(self): |
|
| 185 | 185 |
return self.mapSerializableSpecObjects.keys() |
| 186 | 186 |
|
| 187 | 187 |
def getURL(self, package): |
| ... | ... |
@@ -12,7 +12,7 @@ from SpecUtils import Specutils |
| 12 | 12 |
from StringUtils import StringUtils |
| 13 | 13 |
import collections |
| 14 | 14 |
import traceback |
| 15 |
-from PackageInfo import SourcePackageInfo |
|
| 15 |
+from PackageInfo import PackageInfo |
|
| 16 | 16 |
|
| 17 | 17 |
def main(): |
| 18 | 18 |
usage = "Usage: %prog [options] <package name>" |
| ... | ... |
@@ -23,9 +23,7 @@ def main(): |
| 23 | 23 |
parser.add_option("-i", "--install-package", dest="installPackage", default=False, action ="store_true")
|
| 24 | 24 |
parser.add_option("-p", "--publish-RPMS-path", dest="publishRPMSPath", default="../../stage/PUBLISHRPMS")
|
| 25 | 25 |
parser.add_option("-l", "--log-path", dest="logPath", default="../../stage/LOGS")
|
| 26 |
- parser.add_option("-o", "--build-option", dest="buildOption", default="full")
|
|
| 27 | 26 |
parser.add_option("-z", "--top-dir-path", dest="topDirPath", default="/usr/src/photon")
|
| 28 |
- parser.add_option("-j", "--json-file", dest="inputJSONFile", default="../../common/data/build_install_options_all.json")
|
|
| 29 | 27 |
parser.add_option("-b", "--build-root-path", dest="buildRootPath", default="/mnt")
|
| 30 | 28 |
parser.add_option("-t", "--threads", dest="buildThreads", default=1, type="int", help="Number of working threads")
|
| 31 | 29 |
parser.add_option("-m", "--tool-chain-stage", dest="toolChainStage", default="None")
|
| ... | ... |
@@ -36,7 +34,7 @@ def main(): |
| 36 | 36 |
parser.add_option("-v", "--release-version", dest="releaseVersion", default="NNNnNNN")
|
| 37 | 37 |
parser.add_option("-u", "--enable-rpmcheck", dest="rpmCheck", default=False, action ="store_true")
|
| 38 | 38 |
parser.add_option("-a", "--source-rpm-path", dest="sourceRpmPath", default="../../stage/SRPMS")
|
| 39 |
- parser.add_option("-w", "--pkginfo-file", dest="pkgInfoFile", default="../../common/data/pkg_info.json")
|
|
| 39 |
+ parser.add_option("-w", "--pkginfo-file", dest="pkgInfoFile", default="../../stage/pkg_info.json")
|
|
| 40 | 40 |
parser.add_option("-g", "--pkg-build-option-file", dest="pkgBuildOptionFile", default="../../common/data/pkg_build_options.json")
|
| 41 | 41 |
|
| 42 | 42 |
(options, args) = parser.parse_args() |
| ... | ... |
@@ -48,7 +46,7 @@ def main(): |
| 48 | 48 |
|
| 49 | 49 |
errorFlag=False |
| 50 | 50 |
package = None |
| 51 |
- pkgInfoJsonFile=options.pkgInfoFile |
|
| 51 |
+ pkgInfoJsonFile = options.pkgInfoFile |
|
| 52 | 52 |
if not os.path.isdir(options.sourcePath): |
| 53 | 53 |
logger.error("Given Sources Path is not a directory:"+options.sourcePath)
|
| 54 | 54 |
errorFlag = True |
| ... | ... |
@@ -65,9 +63,6 @@ def main(): |
| 65 | 65 |
logger.error("Given RPMS Path is missing noarch sub-directory:"+options.publishRPMSPath)
|
| 66 | 66 |
errorFlag = True |
| 67 | 67 |
|
| 68 |
- if not os.path.isfile(options.inputJSONFile) and not options.installPackage: |
|
| 69 |
- logger.error("Given JSON File is not a file:"+options.inputJSONFile)
|
|
| 70 |
- errorFlag = True |
|
| 71 | 68 |
if not os.path.isfile(options.pkgBuildOptionFile): |
| 72 | 69 |
logger.warning("Given JSON File is not a file:"+options.pkgBuildOptionFile)
|
| 73 | 70 |
|
| ... | ... |
@@ -103,19 +98,16 @@ def main(): |
| 103 | 103 |
logger.info("Log Path :" + options.logPath)
|
| 104 | 104 |
logger.info("Top Dir Path :" + options.topDirPath)
|
| 105 | 105 |
logger.info("Publish RPMS Path :" + options.publishRPMSPath)
|
| 106 |
- if not options.installPackage: |
|
| 107 |
- logger.info("JSON File :" + options.inputJSONFile)
|
|
| 108 |
- else: |
|
| 106 |
+ |
|
| 107 |
+ if options.installPackage: |
|
| 109 | 108 |
logger.info("Package to build:"+package)
|
| 110 | 109 |
|
| 111 | 110 |
listBuildOptionPackages = get_packages_with_build_options(options.pkgBuildOptionFile) |
| 112 | 111 |
|
| 113 | 112 |
try: |
| 114 | 113 |
constants.initialize(options) |
| 115 |
- SourcePackageInfo.setLogging() |
|
| 116 |
- SourcePackageInfo.loadPkgInfoFromFile(pkgInfoJsonFile) |
|
| 117 | 114 |
if package == "packages_list": |
| 118 |
- buildPackagesList(options.specPath, options.buildRootPath+"/../packages_list.csv") |
|
| 115 |
+ buildPackagesList(options.buildRootPath+"/../packages_list.csv") |
|
| 119 | 116 |
elif package == "sources_list": |
| 120 | 117 |
if not os.path.isdir("../../stage/yaml_sources"):
|
| 121 | 118 |
cmdUtils.runCommandInShell("mkdir -p ../../stage/yaml_sources")
|
| ... | ... |
@@ -133,7 +125,7 @@ def main(): |
| 133 | 133 |
elif options.installPackage: |
| 134 | 134 |
buildAPackage(package, listBuildOptionPackages, options.pkgBuildOptionFile, options.buildThreads) |
| 135 | 135 |
else: |
| 136 |
- buildPackagesFromGivenJSONFile(options.inputJSONFile, options.buildOption, listBuildOptionPackages, options.pkgBuildOptionFile, logger, options.buildThreads) |
|
| 136 |
+ buildPackagesForAllSpecs(listBuildOptionPackages, options.pkgBuildOptionFile, logger, options.buildThreads, pkgInfoJsonFile) |
|
| 137 | 137 |
except Exception as e: |
| 138 | 138 |
logger.error("Caught an exception")
|
| 139 | 139 |
logger.error(str(e)) |
| ... | ... |
@@ -141,26 +133,24 @@ def main(): |
| 141 | 141 |
traceback.print_exc() |
| 142 | 142 |
sys.exit(1) |
| 143 | 143 |
|
| 144 |
- logger.info("Writing Package info to the file:"+pkgInfoJsonFile)
|
|
| 145 |
- SourcePackageInfo.writePkgListToFile(pkgInfoJsonFile) |
|
| 146 | 144 |
sys.exit(0) |
| 147 | 145 |
|
| 148 | 146 |
def buildToolChain(buildThreads): |
| 149 | 147 |
pkgManager = PackageManager() |
| 150 | 148 |
pkgManager.buildToolChainPackages(buildThreads) |
| 151 | 149 |
|
| 152 |
-def buildPackagesList(specPath, csvFilename): |
|
| 150 |
+def buildPackagesList(csvFilename): |
|
| 153 | 151 |
csvFile = open(csvFilename, "w") |
| 154 | 152 |
csvFile.write("Package,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) |
|
| 153 |
+ listPackages = constants.specData.getListPackages() |
|
| 154 |
+ listPackages.sort() |
|
| 155 |
+ for package in listPackages: |
|
| 156 |
+ name = package |
|
| 157 |
+ version = constants.specData.getVersion(package) |
|
| 158 |
+ license = constants.specData.getLicense(package) |
|
| 159 |
+ listPatches = constants.specData.getPatches(package) |
|
| 160 |
+ url = constants.specData.getURL(package) |
|
| 161 |
+ listSourceNames = constants.specData.getSources(package) |
|
| 164 | 162 |
sources = "" |
| 165 | 163 |
patches = "" |
| 166 | 164 |
if listPatches is not None: |
| ... | ... |
@@ -174,25 +164,25 @@ def buildSourcesList(yamlDir, logger, singleFile=True): |
| 174 | 174 |
strUtils = StringUtils() |
| 175 | 175 |
if singleFile: |
| 176 | 176 |
yamlFile = open(yamlDir+"/sources_list.yaml", "w") |
| 177 |
- listSpecs = constants.specData.getListSpecs() |
|
| 178 |
- listSpecs.sort() |
|
| 177 |
+ listPackages = constants.specData.getListPackages() |
|
| 178 |
+ listPackages.sort() |
|
| 179 | 179 |
import PullSources |
| 180 |
- for spec in listSpecs: |
|
| 181 |
- ossname = spec |
|
| 182 |
- ossversion = constants.specData.getVersion(spec) |
|
| 180 |
+ for package in listPackages: |
|
| 181 |
+ ossname = package |
|
| 182 |
+ ossversion = constants.specData.getVersion(package) |
|
| 183 | 183 |
modified = False |
| 184 |
- listPatches = constants.specData.getPatches(spec) |
|
| 184 |
+ listPatches = constants.specData.getPatches(package) |
|
| 185 | 185 |
if listPatches is not None and len(listPatches) > 0 : |
| 186 | 186 |
modified = True |
| 187 |
- url = constants.specData.getSourceURL(spec) |
|
| 187 |
+ url = constants.specData.getSourceURL(package) |
|
| 188 | 188 |
if url is None: |
| 189 |
- url = constants.specData.getURL(spec) |
|
| 189 |
+ url = constants.specData.getURL(package) |
|
| 190 | 190 |
|
| 191 | 191 |
sourceName = None |
| 192 |
- listSourceNames = constants.specData.getSources(spec) |
|
| 192 |
+ listSourceNames = constants.specData.getSources(package) |
|
| 193 | 193 |
if len(listSourceNames) >0: |
| 194 | 194 |
sourceName=listSourceNames[0] |
| 195 |
- sha1 = constants.specData.getSHA1(spec, sourceName) |
|
| 195 |
+ sha1 = constants.specData.getSHA1(package, sourceName) |
|
| 196 | 196 |
if sha1 is not None: |
| 197 | 197 |
PullSources.get(sourceName, sha1, yamlDir, constants.pullsourcesConfig) |
| 198 | 198 |
|
| ... | ... |
@@ -220,13 +210,13 @@ def buildSRPMList(srpmPath, yamlDir, logger, singleFile=True): |
| 220 | 220 |
strUtils = StringUtils() |
| 221 | 221 |
if singleFile: |
| 222 | 222 |
yamlFile = open(yamlDir+"/srpm_list.yaml", "w") |
| 223 |
- listSpecs = constants.specData.getListSpecs() |
|
| 224 |
- listSpecs.sort() |
|
| 223 |
+ listPackages = constants.specData.getListPackages() |
|
| 224 |
+ listPackages.sort() |
|
| 225 | 225 |
cmdUtils = CommandUtils() |
| 226 |
- for spec in listSpecs: |
|
| 227 |
- ossname = spec |
|
| 228 |
- ossversion = constants.specData.getVersion(spec) |
|
| 229 |
- ossrelease = constants.specData.getRelease(spec) |
|
| 226 |
+ for package in listPackages: |
|
| 227 |
+ ossname = package |
|
| 228 |
+ ossversion = constants.specData.getVersion(package) |
|
| 229 |
+ ossrelease = constants.specData.getRelease(package) |
|
| 230 | 230 |
|
| 231 | 231 |
listFoundSRPMFiles = cmdUtils.findFile(ossname+"-"+ossversion+"-"+ossrelease+".src.rpm",srpmPath) |
| 232 | 232 |
srpmName = None |
| ... | ... |
@@ -264,17 +254,19 @@ def buildAPackage(package, listBuildOptionPackages, pkgBuildOptionFile, buildThr |
| 264 | 264 |
pkgManager = PackageManager() |
| 265 | 265 |
pkgManager.buildPackages(listPackages, listBuildOptionPackages, pkgBuildOptionFile, buildThreads) |
| 266 | 266 |
|
| 267 |
-def buildPackagesFromGivenJSONFile(inputJSONFile, buildOption, listBuildOptionPackages, pkgBuildOptionFile, logger, buildThreads): |
|
| 268 |
- listPackages = get_all_package_names(inputJSONFile) |
|
| 267 |
+def buildPackagesForAllSpecs(listBuildOptionPackages, pkgBuildOptionFile, logger, buildThreads, pkgInfoJsonFile): |
|
| 268 |
+ listPackages = constants.specData.getListPackages() |
|
| 269 | 269 |
|
| 270 |
- listPackagesToBuild=[] |
|
| 271 |
- for pkg in listPackages: |
|
| 272 |
- p = pkg.encode('utf-8')
|
|
| 273 |
- listPackagesToBuild.append(str(p)) |
|
| 274 | 270 |
logger.info("List of packages to build:")
|
| 275 |
- logger.info(listPackagesToBuild) |
|
| 271 |
+ logger.info(listPackages) |
|
| 276 | 272 |
pkgManager = PackageManager() |
| 277 |
- pkgManager.buildPackages(listPackagesToBuild, listBuildOptionPackages, pkgBuildOptionFile, buildThreads) |
|
| 273 |
+ pkgManager.buildPackages(listPackages, listBuildOptionPackages, pkgBuildOptionFile, buildThreads) |
|
| 274 |
+ |
|
| 275 |
+ #Generating package info file which is required by installer |
|
| 276 |
+ logger.info("Writing Package info to the file:"+pkgInfoJsonFile)
|
|
| 277 |
+ pkgInfo = PackageInfo() |
|
| 278 |
+ pkgInfo.loadPackagesData() |
|
| 279 |
+ pkgInfo.writePkgListToFile(pkgInfoJsonFile) |
|
| 278 | 280 |
|
| 279 | 281 |
def get_packages_with_build_options(pkg_build_options_file): |
| 280 | 282 |
packages = [] |