Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow build image with local changes for debug purpose #247

Merged
merged 3 commits into from
Feb 15, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

mkdir -p `dirname $OUTPUT_ONIE_IMAGE`
sudo rm -f $OUTPUT_ONIE_IMAGE
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 @@ -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
Expand Down