Skip to content

Commit

Permalink
Allow build image with local changes for debug purpose (#247)
Browse files Browse the repository at this point in the history
* Allow build with local change for debug purpose
Uncomment DEBUG_BUILD = y in rule.mk/config to enable local build
  • Loading branch information
taoyl-ms authored Feb 15, 2017
1 parent 7e9f6b4 commit f5b2dcc
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ DOCKER_BUILD = docker build --no-cache \
-f slave.mk \
PLATFORM=$(PLATFORM) \
SKU=$(SKU) \
DEBUG_BUILD=$(DEBUG_BUILD) \
$@

sonic-slave-build :
Expand Down
12 changes: 8 additions & 4 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@
}

## 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."
if [ -z "$(git status --untracked-files=no -s --ignore-submodules)" ]; then
GIT_REVISION=$(git rev-parse --short HEAD)
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
}
GIT_REVISION=$(git rev-parse --short HEAD)
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

if [ "$IMAGE_TYPE" = "onie" ]; then
echo "Build ONIE installer"
Expand Down
4 changes: 4 additions & 0 deletions rules/config
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,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
Expand Down

0 comments on commit f5b2dcc

Please sign in to comment.