-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Makefile: make new step "make stretch" optional #1936
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,147 +1,20 @@ | ||
############################################################################### | ||
## Wrapper for starting make inside sonic-slave container | ||
# | ||
# Supported parameters: | ||
# | ||
# * PLATFORM: Specific platform we wish to build images for. | ||
# * BUILD_NUMBER: Desired version-number to pass to the building-system. | ||
# * ENABLE_DHCP_GRAPH_SERVICE: Enables get-graph service to fetch minigraph files | ||
# through http. | ||
# * SHUTDOWN_BGP_ON_START: Sets admin-down state for all bgp peerings after restart. | ||
# * ENABLE_PFCWD_ON_START: Enable PFC Watchdog (PFCWD) on server-facing ports | ||
# * by default for TOR switch. | ||
# * SONIC_ENABLE_SYNCD_RPC: Enables rpc-based syncd builds. | ||
# * USERNAME: Desired username -- default at rules/config | ||
# * PASSWORD: Desired password -- default at rules/config | ||
# * KEEP_SLAVE_ON: Keeps slave container up after building-process concludes. | ||
# * SOURCE_FOLDER: host path to be mount as /var/$(USER)/src, only effective when KEEP_SLAVE_ON=yes | ||
# * SONIC_BUILD_JOBS: Specifying number of concurrent build job(s) to run | ||
# * KERNEL_PROCURE_METHOD: Specifying method of obtaining kernel Debian package: download or build | ||
# | ||
############################################################################### | ||
# SONiC make file | ||
|
||
SHELL = /bin/bash | ||
|
||
USER := $(shell id -un) | ||
PWD := $(shell pwd) | ||
|
||
ifeq ($(USER), root) | ||
$(error Add your user account to docker group and use your user account to make. root or sudo are not supported!) | ||
endif | ||
|
||
# Remove lock file in case previous run was forcefully stopped | ||
$(shell rm -f .screen) | ||
|
||
MAKEFLAGS += -B | ||
|
||
ifeq ($(BLDENV), stretch) | ||
SLAVE_BASE_TAG = $(shell sha1sum sonic-slave-stretch/Dockerfile | awk '{print substr($$1,0,11);}') | ||
SLAVE_TAG = $(shell cat sonic-slave-stretch/Dockerfile.user sonic-slave-stretch/Dockerfile | sha1sum | awk '{print substr($$1,0,11);}') | ||
SLAVE_BASE_IMAGE = sonic-slave-stretch-base | ||
SLAVE_IMAGE = sonic-slave-stretch-$(USER) | ||
SLAVE_DIR = sonic-slave-stretch | ||
else | ||
SLAVE_BASE_TAG = $(shell sha1sum sonic-slave/Dockerfile | awk '{print substr($$1,0,11);}') | ||
SLAVE_TAG = $(shell cat sonic-slave/Dockerfile.user sonic-slave/Dockerfile | sha1sum | awk '{print substr($$1,0,11);}') | ||
SLAVE_BASE_IMAGE = sonic-slave-base | ||
SLAVE_IMAGE = sonic-slave-$(USER) | ||
SLAVE_DIR = sonic-slave | ||
endif | ||
|
||
INSMOD_OVERLAY := sudo modprobe overlay | ||
DOCKER_RUN := docker run --rm=true --privileged \ | ||
-v $(PWD):/sonic \ | ||
-w /sonic \ | ||
-e "http_proxy=$(http_proxy)" \ | ||
-e "https_proxy=$(https_proxy)" \ | ||
-i$(if $(TERM),t,) | ||
|
||
DOCKER_BASE_BUILD = docker build --no-cache \ | ||
-t $(SLAVE_BASE_IMAGE) \ | ||
--build-arg http_proxy=$(http_proxy) \ | ||
--build-arg https_proxy=$(https_proxy) \ | ||
$(SLAVE_DIR) && \ | ||
docker tag $(SLAVE_BASE_IMAGE):latest $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) | ||
|
||
DOCKER_BUILD = docker build --no-cache \ | ||
--build-arg user=$(USER) \ | ||
--build-arg uid=$(shell id -u) \ | ||
--build-arg guid=$(shell id -g) \ | ||
--build-arg hostname=$(shell echo $$HOSTNAME) \ | ||
-t $(SLAVE_IMAGE) \ | ||
-f $(SLAVE_DIR)/Dockerfile.user \ | ||
$(SLAVE_DIR) && \ | ||
docker tag $(SLAVE_IMAGE):latest $(SLAVE_IMAGE):$(SLAVE_TAG) | ||
|
||
SONIC_BUILD_INSTRUCTION := make \ | ||
-f slave.mk \ | ||
PLATFORM=$(PLATFORM) \ | ||
BUILD_NUMBER=$(BUILD_NUMBER) \ | ||
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) \ | ||
ENABLE_SYNCD_RPC=$(ENABLE_SYNCD_RPC) \ | ||
PASSWORD=$(PASSWORD) \ | ||
USERNAME=$(USERNAME) \ | ||
SONIC_BUILD_JOBS=$(SONIC_BUILD_JOBS) \ | ||
KERNEL_PROCURE_METHOD=$(KERNEL_PROCURE_METHOD) \ | ||
HTTP_PROXY=$(http_proxy) \ | ||
HTTPS_PROXY=$(https_proxy) \ | ||
SONIC_ENABLE_SYSTEM_TELEMETRY=$(ENABLE_SYSTEM_TELEMETRY) | ||
|
||
.PHONY: sonic-slave-build sonic-slave-bash init reset | ||
|
||
.DEFAULT_GOAL := all | ||
NOSTRETCH ?= 0 | ||
|
||
%:: | ||
@docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \ | ||
{ echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \ | ||
$(DOCKER_BASE_BUILD) ; } | ||
@docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \ | ||
{ echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \ | ||
$(DOCKER_BUILD) ; } | ||
@$(INSMOD_OVERLAY) | ||
ifeq "$(KEEP_SLAVE_ON)" "yes" | ||
ifdef SOURCE_FOLDER | ||
@$(DOCKER_RUN) -v $(SOURCE_FOLDER):/var/$(USER)/src $(SLAVE_IMAGE):$(SLAVE_TAG) bash -c "$(SONIC_BUILD_INSTRUCTION) $@; /bin/bash" | ||
else | ||
@$(DOCKER_RUN) $(SLAVE_IMAGE):$(SLAVE_TAG) bash -c "$(SONIC_BUILD_INSTRUCTION) $@; /bin/bash" | ||
endif | ||
else | ||
@$(DOCKER_RUN) $(SLAVE_IMAGE):$(SLAVE_TAG) $(SONIC_BUILD_INSTRUCTION) $@ | ||
@echo "+++ --- Making $@ --- +++" | ||
ifeq ($(NOSTRETCH), 0) | ||
BLDENV=stretch make -f Makefile.work stretch | ||
endif | ||
make -f Makefile.work $@ | ||
|
||
sonic-slave-build : | ||
$(DOCKER_BASE_BUILD) | ||
$(DOCKER_BUILD) | ||
|
||
sonic-slave-bash : | ||
@docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \ | ||
{ echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \ | ||
$(DOCKER_BASE_BUILD) ; } | ||
@docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \ | ||
{ echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \ | ||
$(DOCKER_BUILD) ; } | ||
@$(INSMOD_OVERLAY) | ||
@$(DOCKER_RUN) -t $(SLAVE_IMAGE):$(SLAVE_TAG) bash | ||
|
||
showtag: | ||
@echo $(SLAVE_IMAGE):$(SLAVE_TAG) | ||
@echo $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) | ||
|
||
init : | ||
@git submodule update --init --recursive | ||
@git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' | ||
stretch: | ||
@echo "+++ Making $@ +++" | ||
ifeq ($(NOSTRETCH), 0) | ||
BLDENV=stretch make -f Makefile.work stretch | ||
endif | ||
|
||
reset : | ||
@echo && echo -n "Warning! All local changes will be lost. Proceed? [y/N]: " | ||
@read ans && \ | ||
if [ $$ans == y ]; then \ | ||
git clean -xfdf; \ | ||
git reset --hard; \ | ||
git submodule foreach --recursive git clean -xfdf; \ | ||
git submodule foreach --recursive git reset --hard; \ | ||
git submodule update --init --recursive;\ | ||
else \ | ||
echo "Reset aborted"; \ | ||
fi | ||
clean reset init configure : | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
showtag should be here too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. okey dokey :-) |
||
@echo "+++ Making $@ +++" | ||
make -f Makefile.work $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
############################################################################### | ||
## Wrapper for starting make inside sonic-slave container | ||
# | ||
# Supported parameters: | ||
# | ||
# * PLATFORM: Specific platform we wish to build images for. | ||
# * BUILD_NUMBER: Desired version-number to pass to the building-system. | ||
# * ENABLE_DHCP_GRAPH_SERVICE: Enables get-graph service to fetch minigraph files | ||
# through http. | ||
# * SHUTDOWN_BGP_ON_START: Sets admin-down state for all bgp peerings after restart. | ||
# * ENABLE_PFCWD_ON_START: Enable PFC Watchdog (PFCWD) on server-facing ports | ||
# * by default for TOR switch. | ||
# * SONIC_ENABLE_SYNCD_RPC: Enables rpc-based syncd builds. | ||
# * USERNAME: Desired username -- default at rules/config | ||
# * PASSWORD: Desired password -- default at rules/config | ||
# * KEEP_SLAVE_ON: Keeps slave container up after building-process concludes. | ||
# * SOURCE_FOLDER: host path to be mount as /var/$(USER)/src, only effective when KEEP_SLAVE_ON=yes | ||
# * SONIC_BUILD_JOBS: Specifying number of concurrent build job(s) to run | ||
# * KERNEL_PROCURE_METHOD: Specifying method of obtaining kernel Debian package: download or build | ||
# | ||
############################################################################### | ||
|
||
SHELL = /bin/bash | ||
|
||
USER := $(shell id -un) | ||
PWD := $(shell pwd) | ||
|
||
ifeq ($(USER), root) | ||
$(error Add your user account to docker group and use your user account to make. root or sudo are not supported!) | ||
endif | ||
|
||
# Remove lock file in case previous run was forcefully stopped | ||
$(shell rm -f .screen) | ||
|
||
MAKEFLAGS += -B | ||
|
||
ifeq ($(BLDENV), stretch) | ||
SLAVE_BASE_TAG = $(shell sha1sum sonic-slave-stretch/Dockerfile | awk '{print substr($$1,0,11);}') | ||
SLAVE_TAG = $(shell cat sonic-slave-stretch/Dockerfile.user sonic-slave-stretch/Dockerfile | sha1sum | awk '{print substr($$1,0,11);}') | ||
SLAVE_BASE_IMAGE = sonic-slave-stretch-base | ||
SLAVE_IMAGE = sonic-slave-stretch-$(USER) | ||
SLAVE_DIR = sonic-slave-stretch | ||
else | ||
SLAVE_BASE_TAG = $(shell sha1sum sonic-slave/Dockerfile | awk '{print substr($$1,0,11);}') | ||
SLAVE_TAG = $(shell cat sonic-slave/Dockerfile.user sonic-slave/Dockerfile | sha1sum | awk '{print substr($$1,0,11);}') | ||
SLAVE_BASE_IMAGE = sonic-slave-base | ||
SLAVE_IMAGE = sonic-slave-$(USER) | ||
SLAVE_DIR = sonic-slave | ||
endif | ||
|
||
INSMOD_OVERLAY := sudo modprobe overlay | ||
DOCKER_RUN := docker run --rm=true --privileged \ | ||
-v $(PWD):/sonic \ | ||
-w /sonic \ | ||
-e "http_proxy=$(http_proxy)" \ | ||
-e "https_proxy=$(https_proxy)" \ | ||
-i$(if $(TERM),t,) | ||
|
||
DOCKER_BASE_BUILD = docker build --no-cache \ | ||
-t $(SLAVE_BASE_IMAGE) \ | ||
--build-arg http_proxy=$(http_proxy) \ | ||
--build-arg https_proxy=$(https_proxy) \ | ||
$(SLAVE_DIR) && \ | ||
docker tag $(SLAVE_BASE_IMAGE):latest $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) | ||
|
||
DOCKER_BUILD = docker build --no-cache \ | ||
--build-arg user=$(USER) \ | ||
--build-arg uid=$(shell id -u) \ | ||
--build-arg guid=$(shell id -g) \ | ||
--build-arg hostname=$(shell echo $$HOSTNAME) \ | ||
-t $(SLAVE_IMAGE) \ | ||
-f $(SLAVE_DIR)/Dockerfile.user \ | ||
$(SLAVE_DIR) && \ | ||
docker tag $(SLAVE_IMAGE):latest $(SLAVE_IMAGE):$(SLAVE_TAG) | ||
|
||
SONIC_BUILD_INSTRUCTION := make \ | ||
-f slave.mk \ | ||
PLATFORM=$(PLATFORM) \ | ||
BUILD_NUMBER=$(BUILD_NUMBER) \ | ||
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) \ | ||
ENABLE_SYNCD_RPC=$(ENABLE_SYNCD_RPC) \ | ||
PASSWORD=$(PASSWORD) \ | ||
USERNAME=$(USERNAME) \ | ||
SONIC_BUILD_JOBS=$(SONIC_BUILD_JOBS) \ | ||
KERNEL_PROCURE_METHOD=$(KERNEL_PROCURE_METHOD) \ | ||
HTTP_PROXY=$(http_proxy) \ | ||
HTTPS_PROXY=$(https_proxy) \ | ||
SONIC_ENABLE_SYSTEM_TELEMETRY=$(ENABLE_SYSTEM_TELEMETRY) | ||
|
||
.PHONY: sonic-slave-build sonic-slave-bash init reset | ||
|
||
.DEFAULT_GOAL := all | ||
|
||
%:: | ||
@docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \ | ||
{ echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \ | ||
$(DOCKER_BASE_BUILD) ; } | ||
@docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \ | ||
{ echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \ | ||
$(DOCKER_BUILD) ; } | ||
@$(INSMOD_OVERLAY) | ||
ifeq "$(KEEP_SLAVE_ON)" "yes" | ||
ifdef SOURCE_FOLDER | ||
@$(DOCKER_RUN) -v $(SOURCE_FOLDER):/var/$(USER)/src $(SLAVE_IMAGE):$(SLAVE_TAG) bash -c "$(SONIC_BUILD_INSTRUCTION) $@; /bin/bash" | ||
else | ||
@$(DOCKER_RUN) $(SLAVE_IMAGE):$(SLAVE_TAG) bash -c "$(SONIC_BUILD_INSTRUCTION) $@; /bin/bash" | ||
endif | ||
else | ||
@$(DOCKER_RUN) $(SLAVE_IMAGE):$(SLAVE_TAG) $(SONIC_BUILD_INSTRUCTION) $@ | ||
endif | ||
|
||
sonic-slave-build : | ||
$(DOCKER_BASE_BUILD) | ||
$(DOCKER_BUILD) | ||
|
||
sonic-slave-bash : | ||
@docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \ | ||
{ echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \ | ||
$(DOCKER_BASE_BUILD) ; } | ||
@docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \ | ||
{ echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \ | ||
$(DOCKER_BUILD) ; } | ||
@$(INSMOD_OVERLAY) | ||
@$(DOCKER_RUN) -t $(SLAVE_IMAGE):$(SLAVE_TAG) bash | ||
|
||
showtag: | ||
@echo $(SLAVE_IMAGE):$(SLAVE_TAG) | ||
@echo $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) | ||
|
||
init : | ||
@git submodule update --init --recursive | ||
@git submodule foreach --recursive '[ -f .git ] && echo "gitdir: $$(realpath --relative-to=. $$(cut -d" " -f2 .git))" > .git' | ||
|
||
reset : | ||
@echo && echo -n "Warning! All local changes will be lost. Proceed? [y/N]: " | ||
@read ans && \ | ||
if [ $$ans == y ]; then \ | ||
git clean -xfdf; \ | ||
git reset --hard; \ | ||
git submodule foreach --recursive git clean -xfdf; \ | ||
git submodule foreach --recursive git reset --hard; \ | ||
git submodule update --init --recursive;\ | ||
else \ | ||
echo "Reset aborted"; \ | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you add {if endif}, so that we can override the behavior, for example, NOSTRETCH=1 make will not make stretch target implicitly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. Done. Thanks.