Skip to content

Commit

Permalink
[build]: generate build timestamp at the beginning and use it for the… (
Browse files Browse the repository at this point in the history
#2118)

* [build]: generate build timestamp at the beginning and use it for the rest of build

Signed-off-by: Guohan Lu <gulv@microsoft.com>
  • Loading branch information
lguohan authored Oct 5, 2018
1 parent 7cdf3cb commit 0a8e0c1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile.work
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ endif

OVERLAY_MODULE_CHECK := lsmod | grep "^overlay " > /dev/null 2>&1 || (echo "ERROR: Module 'overlay' not loaded. Try running 'sudo modprobe overlay'."; exit 1)

BUILD_TIMESTAMP := $(shell date +%Y%m%d\.%H%M%S)

DOCKER_RUN := docker run --rm=true --privileged \
-v $(PWD):/sonic \
-w /sonic \
Expand Down Expand Up @@ -88,6 +90,7 @@ SONIC_BUILD_INSTRUCTION := make \
-f slave.mk \
PLATFORM=$(PLATFORM) \
BUILD_NUMBER=$(BUILD_NUMBER) \
BUILD_TIMESTAMP=$(BUILD_TIMESTAMP) \
ENABLE_DHCP_GRAPH_SERVICE=$(ENABLE_DHCP_GRAPH_SERVICE) \
SHUTDOWN_BGP_ON_START=$(SHUTDOWN_BGP_ON_START) \
SONIC_ENABLE_PFCWD_ON_START=$(ENABLE_PFCWD_ON_START) \
Expand Down
3 changes: 1 addition & 2 deletions functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,11 @@ docker_try_rmi() {
}

sonic_get_version() {
DIRTY_SUFFIX="$(date +%Y%m%d\.%H%M%S)"
local describe=$(git describe --tags)
local latest_tag=$(git describe --tags --abbrev=0)
local branch_name=$(git rev-parse --abbrev-ref HEAD)
if [ -n "$(git status --untracked-files=no -s --ignore-submodules)" ]; then
local dirty="-dirty-$DIRTY_SUFFIX"
local dirty="-dirty-$BUILD_TIMESTAMP"
fi
BUILD_NUMBER=${BUILD_NUMBER:-0}
## Check if we are on tagged commit
Expand Down
2 changes: 2 additions & 0 deletions slave.mk
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ PROJECT_ROOT = $(shell pwd)
CONFIGURED_PLATFORM := $(shell [ -f .platform ] && cat .platform || echo generic)
PLATFORM_PATH = platform/$(CONFIGURED_PLATFORM)
export BUILD_NUMBER
export BUILD_TIMESTAMP
export CONFIGURED_PLATFORM

###############################################################################
Expand Down Expand Up @@ -133,6 +134,7 @@ $(info "ENABLE_SYSTEM_TELEMETRY" : "$(ENABLE_SYSTEM_TELEMETRY)")
$(info "SONIC_DEBUGGING_ON" : "$(SONIC_DEBUGGING_ON)")
$(info "SONIC_PROFILING_ON" : "$(SONIC_PROFILING_ON)")
$(info "KERNEL_PROCURE_METHOD" : "$(KERNEL_PROCURE_METHOD)")
$(info "BUILD_TIMESTAMP" : "$(BUILD_TIMESTAMP)")
$(info )

###############################################################################
Expand Down

0 comments on commit 0a8e0c1

Please sign in to comment.