From 65b9453349c5472ef738b2b95ccef480d3a1ac2c Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 3 Feb 2017 03:14:54 +0000 Subject: [PATCH 1/3] Allow build with local change for debug purpose --- build_image.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/build_image.sh b/build_image.sh index 5373b8da72c1..6dbf29a42b67 100755 --- a/build_image.sh +++ b/build_image.sh @@ -13,11 +13,12 @@ } ## Retrieval short version of Git revision hash for partition metadata -[ -z "$(git status --untracked-files=no -s --ignore-submodules)" ] || { - echo "Error: There is local changes not committed to git repo. Cannot get a revision hash for partition metadata." - exit 1 -} -GIT_REVISION=$(git rev-parse --short HEAD) +if [ -z "$(git status --untracked-files=no -s --ignore-submodules)" ]; then + GIT_REVISION=$(git rev-parse --short HEAD) +else + echo "Warning: There is local changes not committed to git repo. Cannot get a revision hash for partition metadata." + GIT_REVISION=$(git rev-parse --short HEAD)"_local_debug" +fi mkdir -p `dirname $OUTPUT_ONIE_IMAGE` sudo rm -f $OUTPUT_ONIE_IMAGE From 43e60777169f8e74fd4e025b85ac404007704782 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Fri, 3 Feb 2017 21:50:13 +0000 Subject: [PATCH 2/3] Modify according to CR comments --- Makefile | 1 + build_image.sh | 7 +++++-- slave.mk | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index b819d41cfb67..855efcdbf922 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,7 @@ DOCKER_BUILD = docker build --no-cache \ -f slave.mk \ PLATFORM=$(PLATFORM) \ SKU=$(SKU) \ + DEBUG_BUILD=$(DEBUG_BUILD) \ $@ sonic-slave-build : diff --git a/build_image.sh b/build_image.sh index 6dbf29a42b67..b73dd583aac9 100755 --- a/build_image.sh +++ b/build_image.sh @@ -15,8 +15,11 @@ ## Retrieval short version of Git revision hash for partition metadata if [ -z "$(git status --untracked-files=no -s --ignore-submodules)" ]; then GIT_REVISION=$(git rev-parse --short HEAD) -else - echo "Warning: There is local changes not committed to git repo. Cannot get a revision hash for partition metadata." +elif [ -z "$DEBUG_BUILD" ]; then + echo "Error: There are local changes not committed to git repo. Cannot get a revision hash for partition metadata." + exit 1 +else + echo "Warning: There are local changes not committed to git repo, revision hash won't be tracked. Never deploy this image for other than debugging purpose." GIT_REVISION=$(git rev-parse --short HEAD)"_local_debug" fi diff --git a/slave.mk b/slave.mk index 485f8ff9206c..30a63f497a94 100644 --- a/slave.mk +++ b/slave.mk @@ -316,7 +316,7 @@ $(addprefix $(TARGET_PATH)/, $(SONIC_INSTALLERS)) : $(TARGET_PATH)/% : .platform ) ./build_debian.sh "$(USERNAME)" "$(shell perl -e 'print crypt("$(PASSWORD)", "salt"),"\n"')" $(LOG) - TARGET_MACHINE=$($*_MACHINE) IMAGE_TYPE=$($*_IMAGE_TYPE) ./build_image.sh $(LOG) + TARGET_MACHINE=$($*_MACHINE) IMAGE_TYPE=$($*_IMAGE_TYPE) DEBUG_BUILD=$(DEBUG_BUILD) ./build_image.sh $(LOG) $(foreach docker, $($*_DOCKERS), \ rm $($(docker)_CONTAINER_NAME).sh From e2bbd8db272d70ef1736a72676adfb47059ba507 Mon Sep 17 00:00:00 2001 From: Taoyu Li Date: Thu, 9 Feb 2017 22:01:26 +0000 Subject: [PATCH 3/3] Modify according to CR comments --- Makefile | 2 +- build_image.sh | 2 +- rules/config | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 855efcdbf922..070c540509cf 100644 --- a/Makefile +++ b/Makefile @@ -31,7 +31,7 @@ DOCKER_BUILD = docker build --no-cache \ -f slave.mk \ PLATFORM=$(PLATFORM) \ SKU=$(SKU) \ - DEBUG_BUILD=$(DEBUG_BUILD) \ + DEBUG_BUILD=$(DEBUG_BUILD) \ $@ sonic-slave-build : diff --git a/build_image.sh b/build_image.sh index b73dd583aac9..0954e61b25f5 100755 --- a/build_image.sh +++ b/build_image.sh @@ -15,7 +15,7 @@ ## Retrieval short version of Git revision hash for partition metadata if [ -z "$(git status --untracked-files=no -s --ignore-submodules)" ]; then GIT_REVISION=$(git rev-parse --short HEAD) -elif [ -z "$DEBUG_BUILD" ]; then +elif [ ! "$DEBUG_BUILD" = "y" ]; then echo "Error: There are local changes not committed to git repo. Cannot get a revision hash for partition metadata." exit 1 else diff --git a/rules/config b/rules/config index d76477ce5adc..142a7c0d10f7 100644 --- a/rules/config +++ b/rules/config @@ -11,6 +11,10 @@ # Uncomment next line to enable: # SONIC_CONFIG_PRINT_DEPENDENCIES = y +# DEBUG_BUILD - enable building image with uncommitted local changes. +# Uncomment next line to enable: +# DEBUG_BUILD = y + # SONIC_CONFIG_BUILD_JOBS - set number of jobs for parallel build. # Corresponding -j argument will be passed to make command inside docker # container.