Browse code

build.py: fix incremental build

Change-Id: If935d4f89f6090f0522d1a24facc56bd2542d14d
Reviewed-on: http://photon-jenkins.eng.vmware.com:8082/10992
Tested-by: gerrit-photon <photon-checkins@vmware.com>
Reviewed-by: Anish Swaminathan <anishs@vmware.com>

gerrit-photon authored on 2020/09/01 09:21:29
Showing 1 changed files
... ...
@@ -397,14 +397,24 @@ class CleanUp:
397 397
                 raise Exception("Not able to clean chroot")
398 398
 
399 399
     def clean_stage_for_incremental_build():
400
-        command = ["cd "+  configdict["photon-path"]+ ";test -z \"$$(git diff --name-only "\
401
-                + configdict["photon-build-param"].get("base-commit", "") + " @ | grep SPECS)\" || "\
402
-                + curDir + "/support/package-builder/SpecDeps.py  --spec-path SPECS/ -i remove-upward-deps -p \"$$(echo `git diff --name-only "\
403
-                + configdict["photon-build-param"].get("base-commit", "")+" @ | grep .spec | xargs -n1 basename 2>/dev/null` | tr ' ' :)\""]
400
+        #cd /root/photon;test -z "$(git diff --name-only 84562de @ | grep SPECS)" || \
401
+        #   /root/photon/support/package-builder/SpecDeps.py  --spec-path SPECS/
402
+        #                                                     -i remove-upward-deps \
403
+        #                                                     -p "$(echo `git diff --name-only 84562de @ | grep .spec | xargs -n1 basename 2>/dev/null` | tr ' ' :)"
404
+        command = "cd %s; \
405
+                   test -z \"$(git diff --name-only %s @ | grep SPECS)\" || \
406
+                   %s --spec-path SPECS/ \
407
+                      -i remove-upward-deps \
408
+                      -p \"$(echo `git diff --name-only %s @ | grep .spec | xargs -n1 basename 2>/dev/null` | tr ' ' :)\"" % (configdict["photon-path"],
409
+                                                                                                                              configdict["photon-build-param"]["base-commit"],
410
+                                                                                                                              "%s/support/package-builder/SpecDeps.py" % (curDir),
411
+                                                                                                                              configdict["photon-build-param"]["base-commit"])
404 412
         subprocess.Popen(command, shell=True).wait()
405 413
 
406
-        command = ["test -n \"$$(git diff --name-only @~1 @ | grep '^support/\(make\|package-builder\|pullpublishrpms\)')\" && " \
407
-                + "{ cd " + configdict["photon-path"] + "; echo 'Remove all staged RPMs'; /bin/rm -rf ./stage/RPMS; } ||:"]
414
+        #test -n "$(git diff --name-only @~1 @ | grep '^support/\(make\|package-builder\|pullpublishrpms\)')" && \
415
+        # { echo "Remove all staged RPMs"; $(RM) -rf $(PHOTON_RPMS_DIR); } ||:
416
+        command = "test -n \"$(git diff --name-only @~1 @ | grep '^support/\(make\|package-builder\|pullpublishrpms\)')\" && \
417
+                   { cd %s; echo \"Remove all staged RPMs\"; /bin/rm -rf ./stage/RPMS; } ||:" % (configdict["photon-path"])
408 418
         if subprocess.Popen(command, shell=True).wait() != 0:
409 419
             raise Exception("Not able to run clean_stage_for_incremental_build")
410 420
         return
... ...
@@ -979,6 +989,9 @@ def main():
979 979
     if 'INPUT_PHOTON_BUILD_NUMBER' in os.environ:
980 980
         configdict["photon-build-param"]["input-photon-build-number"]=os.environ['IMPUT_PHOTON_BUILD_NUMBER']
981 981
 
982
+    if 'BASE_COMMIT' in os.environ:
983
+        configdict["photon-build-param"]["base-commit"] = os.environ['BASE_COMMIT']
984
+
982 985
     if 'THREADS' in os.environ:
983 986
         configdict["photon-build-param"]["threads"] = int(os.environ['THREADS'])
984 987
 
... ...
@@ -990,6 +1003,7 @@ def main():
990 990
 
991 991
     if 'PHOTON_CACHE_PATH' in os.environ:
992 992
         configdict.setdefault("additional-path", {}).setdefault("photon-cache-path", os.environ['PHOTON_CACHE_PATH'])
993
+
993 994
     if 'PHOTON_SOURCES_PATH' in os.environ:
994 995
         configdict.setdefault('additional-path', {}).setdefault('photon-sources-path', os.environ["PHOTON_SOURCES_PATH"])
995 996
 
... ...
@@ -1004,6 +1018,7 @@ def main():
1004 1004
 
1005 1005
     if "DISTRIBUTED_BUILD_CONFIG" in os.environ:
1006 1006
         configdict["additional-path"]["distributed-build-option-file"] = os.environ["DISTRIBUTED_BUILD_CONFIG"]
1007
+
1007 1008
     if 'RPMCHECK' in os.environ:
1008 1009
         if os.environ['RPMCHECK']=="enable":
1009 1010
             configdict['photon-build-param']['rpm-check-flag'] = True