1313# * SONIC_ENABLE_SYNCD_RPC: Enables rpc-based syncd builds.
1414# * USERNAME: Desired username -- default at rules/config
1515# * PASSWORD: Desired password -- default at rules/config
16- # * KEEP_SLAVE_ON: Keeps slave container up after building-process concludes.
16+ # * KEEP_SLAVE_ON: Keeps slave container up and active after building process concludes.
17+ # * Note that rm=true is still set, so once user quits from the docker
18+ # * session, the docker will be removed.
19+ # * Please note that with current Stretch build structure,
20+ # * user of KEEP_SLAVE_ON feature will have to be conscious
21+ # * about which docker to stay inside after build is done.
22+ # * - If user desires to stay inside Stretch docker, please issue
23+ # * make KEEP_SLAVE_ON=yes stretch
24+ # * - If user desires to stay inside Jessie docker, please issue
25+ # * (a successful "make stretch" may be needed before the following command)
26+ # * make NOSTRETCH=1 KEEP_SLAVE_ON=yes <any jessie target>
1727# * SOURCE_FOLDER: host path to be mount as /var/$(USER)/src, only effective when KEEP_SLAVE_ON=yes
1828# * SONIC_BUILD_JOBS: Specifying number of concurrent build job(s) to run
1929# * KERNEL_PROCURE_METHOD: Specifying method of obtaining kernel Debian package: download or build
@@ -48,7 +58,8 @@ SLAVE_IMAGE = sonic-slave-$(USER)
4858SLAVE_DIR = sonic-slave
4959endif
5060
51- INSMOD_OVERLAY := sudo modprobe overlay
61+ OVERLAY_MODULE_CHECK := lsmod | grep "^overlay " > /dev/null 2>&1 || (echo "ERROR: Module 'overlay' not loaded. Try running 'sudo modprobe overlay'."; exit 1)
62+
5263DOCKER_RUN := docker run --rm=true --privileged \
5364 -v $(PWD):/sonic \
5465 -w /sonic \
@@ -94,13 +105,13 @@ SONIC_BUILD_INSTRUCTION := make \
94105.DEFAULT_GOAL := all
95106
96107%::
108+ @$(OVERLAY_MODULE_CHECK)
97109 @docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \
98110 { echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \
99111 $(DOCKER_BASE_BUILD) ; }
100112 @docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \
101113 { echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \
102114 $(DOCKER_BUILD) ; }
103- @$(INSMOD_OVERLAY)
104115ifeq "$(KEEP_SLAVE_ON)" "yes"
105116 ifdef SOURCE_FOLDER
106117 @$(DOCKER_RUN) -v $(SOURCE_FOLDER):/var/$(USER)/src $(SLAVE_IMAGE):$(SLAVE_TAG) bash -c "$(SONIC_BUILD_INSTRUCTION) $@; /bin/bash"
@@ -116,13 +127,13 @@ sonic-slave-build :
116127 $(DOCKER_BUILD)
117128
118129sonic-slave-bash :
130+ @$(OVERLAY_MODULE_CHECK)
119131 @docker inspect --type image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) &> /dev/null || \
120132 { echo Image $(SLAVE_BASE_IMAGE):$(SLAVE_BASE_TAG) not found. Building... ; \
121133 $(DOCKER_BASE_BUILD) ; }
122134 @docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \
123135 { echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \
124136 $(DOCKER_BUILD) ; }
125- @$(INSMOD_OVERLAY)
126137 @$(DOCKER_RUN) -t $(SLAVE_IMAGE):$(SLAVE_TAG) bash
127138
128139showtag:
0 commit comments