2016-12-05 13:12:19 -06:00
|
|
|
###############################################################################
|
|
|
|
## Wrapper for starting make inside sonic-slave container
|
|
|
|
###############################################################################
|
2016-08-04 12:39:33 -05:00
|
|
|
|
2016-12-05 13:12:19 -06:00
|
|
|
SHELL = /bin/bash
|
2016-08-04 12:39:33 -05:00
|
|
|
|
2016-12-05 13:12:19 -06:00
|
|
|
USER := $(shell id -un)
|
|
|
|
PWD := $(shell pwd)
|
2016-10-31 23:50:59 -05:00
|
|
|
|
2016-12-05 13:12:19 -06:00
|
|
|
MAKEFLAGS += -B
|
2016-08-04 12:39:33 -05:00
|
|
|
|
2017-03-01 13:00:59 -06:00
|
|
|
SLAVE_TAG = $(shell shasum sonic-slave/Dockerfile | awk '{print substr($$1,0,11);}')
|
|
|
|
SLAVE_IMAGE = sonic-slave-$(USER)
|
|
|
|
|
2016-12-05 13:12:19 -06:00
|
|
|
DOCKER_RUN := docker run --rm=true --privileged \
|
|
|
|
-v $(PWD):/sonic \
|
2017-01-31 13:47:52 -06:00
|
|
|
-i$(SONIC_SLAVE_TTY)
|
2016-08-04 12:39:33 -05:00
|
|
|
|
2017-03-01 16:25:44 -06:00
|
|
|
DOCKER_BUILD = docker build --no-cache \
|
2016-12-05 13:12:19 -06:00
|
|
|
--build-arg user=$(USER) \
|
|
|
|
--build-arg uid=$(shell id -u) \
|
|
|
|
--build-arg guid=$(shell id -g) \
|
2017-04-05 18:14:41 -05:00
|
|
|
--build-arg hostname=$(shell echo $$HOSTNAME) \
|
2017-03-01 13:00:59 -06:00
|
|
|
-t $(SLAVE_IMAGE) \
|
|
|
|
sonic-slave && \
|
|
|
|
docker tag $(SLAVE_IMAGE):latest $(SLAVE_IMAGE):$(SLAVE_TAG)
|
2016-11-23 18:18:35 -06:00
|
|
|
|
2017-05-18 18:54:48 -05:00
|
|
|
|
|
|
|
MGMT_TAG = $(shell shasum sonic-mgmt/Dockerfile | awk '{print substr($$1,0,11);}')
|
|
|
|
MGMT_IMAGE = sonic-mgmt-$(USER)
|
|
|
|
|
|
|
|
DOCKER_MGMT_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 $(MGMT_IMAGE) \
|
|
|
|
sonic-mgmt && \
|
|
|
|
docker tag $(MGMT_IMAGE):latest $(MGMT_IMAGE):$(MGMT_TAG)
|
|
|
|
|
|
|
|
|
|
|
|
.PHONY: sonic-slave-build sonic-slave-bash sonic-mgmt-build
|
2016-09-27 13:42:35 -05:00
|
|
|
|
2016-12-05 13:12:19 -06:00
|
|
|
.DEFAULT_GOAL := all
|
2016-10-31 23:50:59 -05:00
|
|
|
|
2016-12-05 13:12:19 -06:00
|
|
|
%::
|
2017-03-01 13:00:59 -06:00
|
|
|
@docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \
|
|
|
|
{ echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \
|
|
|
|
$(DOCKER_BUILD) ; }
|
|
|
|
@$(DOCKER_RUN) $(SLAVE_IMAGE):$(SLAVE_TAG) make \
|
2016-12-05 13:12:19 -06:00
|
|
|
-C sonic \
|
|
|
|
-f slave.mk \
|
|
|
|
PLATFORM=$(PLATFORM) \
|
2017-04-05 18:14:41 -05:00
|
|
|
BUILD_NUMBER=$(BUILD_NUMBER) \
|
2017-02-22 19:21:03 -06:00
|
|
|
ENABLE_DHCP_GRAPH_SERVICE=$(ENABLE_DHCP_GRAPH_SERVICE) \
|
2017-05-30 18:17:03 -05:00
|
|
|
SONIC_ENABLE_SYNCD_RPC=$(ENABLE_SYNCD_RPC) \
|
2017-04-12 13:23:48 -05:00
|
|
|
PASSWORD=$(PASSWORD) \
|
|
|
|
USERNAME=$(USERNAME) \
|
2016-12-05 13:12:19 -06:00
|
|
|
$@
|
2016-08-04 12:39:33 -05:00
|
|
|
|
2016-12-05 13:12:19 -06:00
|
|
|
sonic-slave-build :
|
|
|
|
@$(DOCKER_BUILD)
|
2016-10-31 23:50:59 -05:00
|
|
|
|
2016-12-05 13:12:19 -06:00
|
|
|
sonic-slave-bash :
|
2017-03-01 13:00:59 -06:00
|
|
|
@docker inspect --type image $(SLAVE_IMAGE):$(SLAVE_TAG) &> /dev/null || \
|
|
|
|
{ echo Image $(SLAVE_IMAGE):$(SLAVE_TAG) not found. Building... ; \
|
|
|
|
$(DOCKER_BUILD) ; }
|
|
|
|
@$(DOCKER_RUN) -t $(SLAVE_IMAGE):$(SLAVE_TAG) bash
|
2017-05-18 18:54:48 -05:00
|
|
|
|
|
|
|
sonic-mgmt-build :
|
|
|
|
@$(DOCKER_MGMT_BUILD)
|