Browse code

Adding logic to build updated packages only

dthaluru authored on 2015/09/03 08:54:30
Showing 6 changed files
... ...
@@ -44,7 +44,7 @@ CONTAIN := $(TOOLS_BIN)/contain
44 44
 
45 45
 .PHONY : all iso clean photon-build-machine photon-vagrant-build photon-vagrant-local cloud-image \
46 46
 check check-docker check-bison check-g++ check-gawk check-createrepo check-vagrant check-packer check-packer-ovf-plugin check-sanity \
47
-clean-install clean-chroot
47
+clean-install clean-chroot build-updated-packages
48 48
 
49 49
 THREADS?=1
50 50
 
... ...
@@ -169,6 +169,22 @@ packages: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTA
169 169
 		-d $(PHOTON_DIST_TAG) \
170 170
                 -t ${THREADS}
171 171
 
172
+build-updated-packages: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
173
+	@echo "Building only updated RPMS..."
174
+	@cd $(PHOTON_PKG_BUILDER_DIR) && \
175
+        $(PHOTON_PACKAGE_BUILDER) -o full \
176
+                -s $(PHOTON_SPECS_DIR) \
177
+                -r $(PHOTON_RPMS_DIR) \
178
+                -x $(PHOTON_SRCS_DIR) \
179
+                -b $(PHOTON_CHROOT_PATH) \
180
+                -l $(PHOTON_LOGS_DIR) \
181
+                -p $(PHOTON_PUBLISH_RPMS_DIR) \
182
+                -j $(PHOTON_GENERATED_DATA_DIR)/$(FULL_PACKAGE_LIST_FILE) \
183
+		-c $(PHOTON_BINTRAY_CONFIG) \
184
+		-d $(PHOTON_DIST_TAG) \
185
+                -k $(PHOTON_INPUT_RPMS_DIR) \
186
+                -t ${THREADS}
187
+
172 188
 tool-chain-stage1: check $(PHOTON_STAGE) $(PHOTON_PUBLISH_RPMS) $(PHOTON_SOURCES) $(CONTAIN) generate-dep-lists
173 189
 	@echo "Building all RPMS..."
174 190
 	@cd $(PHOTON_PKG_BUILDER_DIR) && \
... ...
@@ -49,3 +49,4 @@ PHOTON_PACKER_TEMPLATES=$(SRCROOT)/support/packer-templates
49 49
 PHOTON_CHROOT_PATH:=$(PHOTON_STAGE)/photonroot
50 50
 PHOTON_FS_ROOT=/usr/src/photon
51 51
 PHOTON_DIST_TAG?=.ph1tp3
52
+PHOTON_INPUT_RPMS_DIR?=$(SRCROOT)/inputRPMS
... ...
@@ -41,6 +41,8 @@ class PackageManager(object):
41 41
         listRPMFiles=[]
42 42
         listDirectorys=[]
43 43
         listDirectorys.append(constants.rpmPath)
44
+        if constants.inputRPMSPath is not None:
45
+            listDirectorys.append(constants.inputRPMSPath)
44 46
         
45 47
         while len(listDirectorys) > 0:
46 48
             dirPath=listDirectorys.pop()
... ...
@@ -157,6 +157,7 @@ class PackageUtils(object):
157 157
         rpmBuildcmd+=" "+specFile
158 158
         
159 159
         cmdUtils = CommandUtils()
160
+        self.logger.info("Building rpm....")
160 161
         returnVal = cmdUtils.runCommandInShell(rpmBuildcmd, logFile, chrootCmd)
161 162
         if not returnVal:
162 163
             self.logger.error("Building rpm is failed "+specFile)
... ...
@@ -181,6 +182,9 @@ class PackageUtils(object):
181 181
         release = constants.specData.getRelease(package)
182 182
         listFoundRPMFiles = sum([cmdUtils.findFile(package+"-"+version+"-"+release+".x86_64.rpm",constants.rpmPath),
183 183
                             cmdUtils.findFile(package+"-"+version+"-"+release+".noarch.rpm",constants.rpmPath)], [])
184
+        if constants.inputRPMSPath is not None:
185
+            listFoundRPMFiles = sum([cmdUtils.findFile(package+"-"+version+"-"+release+".x86_64.rpm",constants.inputRPMSPath),
186
+                            cmdUtils.findFile(package+"-"+version+"-"+release+".noarch.rpm",constants.inputRPMSPath)], listFoundRPMFiles)    
184 187
         if len(listFoundRPMFiles) == 1 :
185 188
             return listFoundRPMFiles[0]
186 189
         if len(listFoundRPMFiles) == 0 :
... ...
@@ -237,8 +241,8 @@ class PackageUtils(object):
237 237
         chrootCmd=self.runInChrootCommand+" "+chrootID
238 238
         returnVal = cmdUtils.runCommandInShell(cpcmd, logFile)
239 239
         if not returnVal:
240
-             self.logger.error("Error during copying the file adjust gcc spec")
241
-             raise "Failed while copying adjust gcc spec file"
240
+            self.logger.error("Error during copying the file adjust gcc spec")
241
+            raise "Failed while copying adjust gcc spec file"
242 242
         returnVal = cmdUtils.runCommandInShell(cmd, logFile, chrootCmd)
243 243
         if returnVal:
244 244
             return
... ...
@@ -30,6 +30,7 @@ def main():
30 30
     parser.add_option("-m",  "--tool-chain-stage", dest="toolChainStage",  default="None")
31 31
     parser.add_option("-c",  "--pullsources-config", dest="pullsourcesConfig",  default="pullsources.conf")
32 32
     parser.add_option("-d",  "--dist", dest="dist",  default="")
33
+    parser.add_option("-k",  "--input-RPMS-path", dest="inputRPMSPath",   default=None)
33 34
 
34 35
     (options,  args) = parser.parse_args()
35 36
     cmdUtils=CommandUtils()
... ...
@@ -60,6 +61,10 @@ def main():
60 60
         logger.error("Given JSON File is not a file:"+options.inputJSONFile)
61 61
         errorFlag = True
62 62
         
63
+    if options.inputRPMSPath is not None and not os.path.isdir(options.inputRPMSPath):
64
+        logger.error("Given input RPMS Path is not a directory:"+options.publishRPMSPath)
65
+        errorFlag = True
66
+        
63 67
     if options.installPackage :
64 68
         if len(args) != 1:
65 69
             logger.error("Please provide package name")
... ...
@@ -11,6 +11,8 @@ class constants(object):
11 11
     buildRootPath="/mnt"
12 12
     prevPublishRPMRepo=""
13 13
     pullsourcesConfig=""
14
+    buildPatch=False
15
+    inputRPMSPath=""
14 16
     noDepsPackageList=["texinfo","bzip2","gettext","man-db","nspr","xz","bison","openjdk","go"]
15 17
     listToolChainPackages=["linux-api-headers", "glibc","zlib", "file",
16 18
         "binutils","gmp","mpfr", "mpc","gcc", "pkg-config", "ncurses", "bash", "bzip2", "sed","procps-ng","coreutils", "m4","grep",
... ...
@@ -60,6 +62,7 @@ class constants(object):
60 60
         constants.specData = SerializableSpecObjectsUtils(constants.logPath)
61 61
         constants.specData.readSpecsAndConvertToSerializableObjects(constants.specPath)
62 62
         constants.pullsourcesConfig = options.pullsourcesConfig
63
+        constants.inputRPMSPath=options.inputRPMSPath
63 64
         
64 65
 
65 66