2016-09-01 05:26:17 +02:00
|
|
|
##
|
|
|
|
## This file is part of the coreboot project.
|
|
|
|
##
|
|
|
|
## Copyright (C) 2016 Google, Inc.
|
|
|
|
##
|
|
|
|
## This program is free software; you can redistribute it and/or modify
|
|
|
|
## it under the terms of the GNU General Public License as published by
|
|
|
|
## the Free Software Foundation; version 2 of the License.
|
|
|
|
##
|
|
|
|
## This program is distributed in the hope that it will be useful,
|
|
|
|
## but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
## GNU General Public License for more details.
|
|
|
|
##
|
|
|
|
export top=$(abspath $(CURDIR)/../..)
|
|
|
|
export crossgcc_version=$(shell $(top)/util/crossgcc/buildgcc --version | grep 'cross toolchain' | sed 's/^.*\sv//' | sed 's/\s.*$$//')
|
2016-12-31 01:00:19 +01:00
|
|
|
export DOCKER:=$(shell $(SHELL) -c "command -v docker")
|
|
|
|
|
2016-12-31 22:59:29 +01:00
|
|
|
# Local port to forward to the jenkins image for the test server
|
|
|
|
export COREBOOT_JENKINS_PORT?=49151
|
|
|
|
|
|
|
|
# Local cache directory - for storing files shared with the docker image
|
|
|
|
export COREBOOT_JENKINS_CACHE_DIR?=/srv/docker/coreboot-builder/cache
|
|
|
|
|
|
|
|
# Local ccache directory
|
|
|
|
export COREBOOT_JENKINS_CCACHE_DIR?=/srv/docker/coreboot-builder/ccache
|
|
|
|
|
|
|
|
# Name of the jenkins container
|
|
|
|
export COREBOOT_JENKINS_CONTAINER?=coreboot_jenkins
|
|
|
|
|
2016-12-31 01:00:19 +01:00
|
|
|
# Version of the jenkins / sdk container
|
|
|
|
export COREBOOT_CONTAINER_VERSION?=$(crossgcc_version)
|
|
|
|
|
|
|
|
# Commit id to build from
|
|
|
|
export DOCKER_COMMIT?=$(shell git log -n 1 --pretty=%h)
|
2016-09-01 05:26:17 +02:00
|
|
|
|
2017-10-20 12:17:34 +02:00
|
|
|
# SDK architecture
|
|
|
|
export COREBOOT_CROSSGCC_PARAM?=all_without_gdb
|
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
test-docker:
|
2016-09-01 05:26:17 +02:00
|
|
|
$(if $(DOCKER),,\
|
|
|
|
$(warning Docker command not found. Please install docker) \
|
|
|
|
$(warning https://docs.docker.com/engine/installation ) \
|
|
|
|
$(error halting))
|
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
test-docker-login: test-docker
|
2016-09-01 05:26:17 +02:00
|
|
|
$(if $(shell if [ ! -f ~/.docker/config.json ]; then \
|
|
|
|
echo "docker authentication file not found"; fi), \
|
|
|
|
$(error Docker authentication file not found. Run 'docker login'))
|
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
coreboot-sdk: test-docker
|
2016-12-31 01:00:19 +01:00
|
|
|
@echo "Building coreboot SDK $(crossgcc_version) from commit $(DOCKER_COMMIT)"
|
|
|
|
cat coreboot-sdk/Dockerfile | \
|
|
|
|
sed "s/{{DOCKER_COMMIT}}/$(DOCKER_COMMIT)/" | \
|
|
|
|
sed "s/{{SDK_VERSION}}/$(COREBOOT_CONTAINER_VERSION)/" | \
|
2017-10-20 12:17:34 +02:00
|
|
|
sed "s/{{CROSSGCC_PARAM}}/$(COREBOOT_CROSSGCC_PARAM)/" | \
|
2016-12-31 01:00:19 +01:00
|
|
|
$(DOCKER) build -t coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) -
|
2016-09-01 05:26:17 +02:00
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
upload-coreboot-sdk: test-docker-login
|
2016-12-31 01:00:19 +01:00
|
|
|
$(DOCKER) push coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION)
|
2016-09-01 05:26:17 +02:00
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
coreboot-jenkins-node: test-docker
|
2016-12-31 01:00:19 +01:00
|
|
|
cat coreboot-jenkins-node/Dockerfile | \
|
|
|
|
sed "s/{{SDK_VERSION}}/$(COREBOOT_CONTAINER_VERSION)/" | \
|
|
|
|
sed "s|{{SSH_KEY}}|$$(cat coreboot-jenkins-node/authorized_keys)|" | \
|
|
|
|
$(DOCKER) build -t coreboot/coreboot-jenkins-node:$(COREBOOT_CONTAINER_VERSION) -
|
2016-09-01 05:26:17 +02:00
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
upload-coreboot-jenkins-node: test-docker-login
|
2016-12-31 01:00:19 +01:00
|
|
|
$(DOCKER) push coreboot/coreboot-jenkins-node:$(COREBOOT_CONTAINER_VERSION)
|
2016-09-01 05:26:17 +02:00
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
docker-killall: test-docker
|
2016-12-31 00:12:30 +01:00
|
|
|
@if [ -n "$$($(DOCKER) ps | grep 'coreboot')" ]; then \
|
|
|
|
$(DOCKER) kill $$($(DOCKER) ps | grep 'coreboot' | cut -f1 -d ' '); \
|
|
|
|
fi
|
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
clean-coreboot-containers: docker-killall
|
2016-12-31 22:59:29 +01:00
|
|
|
@if [ -n "$$($(DOCKER) ps -a | grep 'coreboot')" ]; then \
|
|
|
|
$(DOCKER) rm $$($(DOCKER) ps -a | grep 'coreboot' | sed 's|\s.*$$||'); \
|
|
|
|
fi
|
2016-09-01 05:26:17 +02:00
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
clean-coreboot-images: docker-killall
|
2016-12-31 22:59:29 +01:00
|
|
|
@if [ -n "$$($(DOCKER) images | grep 'coreboot')" ]; then \
|
|
|
|
$(DOCKER) rmi $$($(DOCKER) images | grep coreboot | sed 's|^\S\+\s\+\S\+\s\+||' | sed 's|\s.*$$||'); \
|
|
|
|
fi
|
|
|
|
|
|
|
|
docker-clean: clean-coreboot-containers
|
|
|
|
@$(MAKE) clean-coreboot-images
|
|
|
|
|
|
|
|
docker-cleanall:
|
|
|
|
@if [ -n "$$($(DOCKER) ps -a | grep -v "CONTAINER")" ]; then \
|
|
|
|
$(DOCKER) kill $$($(DOCKER) ps -a | grep -v "CONTAINER" | sed 's|\s.*$$||'); \
|
|
|
|
$(DOCKER) rm $$($(DOCKER) ps -a | grep -v "CONTAINER" | sed 's|\s.*$$||'); \
|
|
|
|
fi
|
|
|
|
@if [ -n "$$($(DOCKER) images | grep -v "REPOSITORY")" ]; then \
|
|
|
|
$(DOCKER) rmi $$($(DOCKER) images | grep -v "REPOSITORY" | tr -s ' ' | cut -f3 -d ' '); \
|
|
|
|
fi
|
2016-09-01 05:26:17 +02:00
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
docker-build-coreboot: test-docker
|
2016-09-01 05:26:17 +02:00
|
|
|
$(DOCKER) run -u root -it -v $(top):/home/coreboot/coreboot \
|
2016-12-31 01:00:19 +01:00
|
|
|
--rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \
|
2016-09-01 05:26:17 +02:00
|
|
|
/bin/bash -c "cd /home/coreboot/coreboot && \
|
|
|
|
make clean && \
|
|
|
|
make $(BUILD_CMD)"
|
|
|
|
@echo "Enter root password to chown files to $$(whoami):$$(id -gn $$(whoami))"
|
|
|
|
@echo "Exiting now will leave built files owned by root"
|
|
|
|
sudo chown -R $$(whoami):$$(id -gn $$(whoami)) $(top)
|
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
docker-abuild: test-docker
|
2016-09-01 05:26:17 +02:00
|
|
|
$(DOCKER) run -u root -it -v $(top):/home/coreboot/coreboot \
|
2016-12-31 01:00:19 +01:00
|
|
|
--rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \
|
2016-09-01 05:26:17 +02:00
|
|
|
/bin/bash -c "cd /home/coreboot/coreboot && \
|
|
|
|
make clean && \
|
|
|
|
util/abuild/abuild $(ABUILD_ARGS)"
|
|
|
|
@echo "Enter root password to chown files to $$(whoami):$$(id -gn $$(whoami))"
|
|
|
|
@echo "Exiting now will leave built files owned by root"
|
|
|
|
sudo chown -R $$(whoami):$$(id -gn $$(whoami)) $(top)
|
|
|
|
|
2016-12-31 22:59:29 +01:00
|
|
|
docker-what-jenkins-does: test-docker
|
|
|
|
$(DOCKER) run -u root -it -v $(top):/home/coreboot/coreboot \
|
|
|
|
--rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \
|
|
|
|
/bin/bash -c "cd /home/coreboot/coreboot && \
|
|
|
|
make clean && make what-jenkins-does CPUS=$(CPUS)"
|
|
|
|
|
|
|
|
docker-jenkins-server: test-docker
|
|
|
|
@if [ ! -d "$(COREBOOT_JENKINS_CACHE_DIR)" ]; then \
|
|
|
|
printf "\nError: %s does not exist.\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
|
|
|
|
printf "Please run:\nsudo mkdir -p %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
|
|
|
|
false; \
|
|
|
|
fi
|
|
|
|
@if ! touch "$(COREBOOT_JENKINS_CACHE_DIR)/testfile" 2>/dev/null; then \
|
|
|
|
printf "\nError: Cannot create file in %s." "$(COREBOOT_JENKINS_CACHE_DIR)"; \
|
|
|
|
printf "Please run:\nsudo chown -R $(whoami):$(whoami) %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)"; \
|
|
|
|
else \
|
|
|
|
rm -f "$(COREBOOT_JENKINS_CACHE_DIR)/testfile"; \
|
|
|
|
fi
|
|
|
|
@if [ ! -d "$(COREBOOT_JENKINS_CCACHE_DIR)" ]; then \
|
|
|
|
printf "\nError: %s does not exist.\n" "$(COREBOOT_JENKINS_CCACHE_DIR)"; \
|
|
|
|
printf "Please run:\nsudo mkdir -p %s\n\n" "$(COREBOOT_JENKINS_CCACHE_DIR)"; \
|
|
|
|
false; \
|
|
|
|
fi
|
|
|
|
@if ! touch "$(COREBOOT_JENKINS_CCACHE_DIR)/testfile" 2>/dev/null; then \
|
|
|
|
printf "\nError: Cannot create file in %s." "$(COREBOOT_JENKINS_CCACHE_DIR)"; \
|
|
|
|
printf 'Please run:\nsudo chown -R $$(whoami):$$(whoami) %s\n\n' "$(COREBOOT_JENKINS_CCACHE_DIR)"; \
|
|
|
|
else \
|
|
|
|
rm -f "$(COREBOOT_JENKINS_CCACHE_DIR)/testfile"; \
|
|
|
|
fi
|
|
|
|
$(DOCKER) run -d --privileged --restart=always \
|
|
|
|
-p $(COREBOOT_JENKINS_PORT):49151 \
|
|
|
|
-v $(COREBOOT_JENKINS_CACHE_DIR):/data/cache \
|
|
|
|
-v $(COREBOOT_JENKINS_CCACHE_DIR):/home/coreboot/.ccache \
|
|
|
|
--name=$(COREBOOT_JENKINS_CONTAINER) \
|
|
|
|
coreboot/coreboot-jenkins-node:$(COREBOOT_CONTAINER_VERSION)
|
|
|
|
|
|
|
|
docker-jenkins-shell: test-docker
|
|
|
|
@if [ ! -d $(COREBOOT_JENKINS_CACHE_DIR) ]; then printf "\nError: %s does not exist.\nPlease run:\nsudo mkdir -p %s\n\n" "$(COREBOOT_JENKINS_CACHE_DIR)" "$(COREBOOT_JENKINS_CACHE_DIR)"; false; fi
|
|
|
|
@if [ ! -d $(COREBOOT_JENKINS_CCACHE_DIR) ]; then printf "\nError: %s does not exist.\nPlease run:\nsudo mkdir -p %s\n\n" "$(COREBOOT_JENKINS_CCACHE_DIR)" "$(COREBOOT_JENKINS_CCACHE_DIR)"; false; fi
|
|
|
|
$(DOCKER) run -u root -it --privileged \
|
|
|
|
--entrypoint="/bin/bash" \
|
|
|
|
-p $(COREBOOT_JENKINS_PORT):49151 \
|
|
|
|
-v $(top):/home/coreboot/coreboot \
|
|
|
|
-v $(COREBOOT_JENKINS_CACHE_DIR):/data/cache \
|
|
|
|
-v $(COREBOOT_JENKINS_CCACHE_DIR):/home/coreboot/.ccache \
|
|
|
|
--name=$(COREBOOT_JENKINS_CONTAINER) \
|
|
|
|
--rm coreboot/coreboot-jenkins-node:$(COREBOOT_CONTAINER_VERSION)
|
|
|
|
|
|
|
|
docker-shell: USER=coreboot
|
|
|
|
docker-shell: test-docker
|
|
|
|
$(DOCKER) run -u $(USER) -it \
|
|
|
|
-w /home/coreboot/coreboot \
|
|
|
|
-v $(top):/home/coreboot/coreboot \
|
|
|
|
--rm coreboot/coreboot-sdk:$(COREBOOT_CONTAINER_VERSION) \
|
|
|
|
/bin/bash -l
|
|
|
|
|
2016-09-01 05:26:17 +02:00
|
|
|
help:
|
|
|
|
@echo "Commands for working with docker images:"
|
2016-12-31 00:26:13 +01:00
|
|
|
@echo " coreboot-sdk - Build coreboot-sdk container"
|
2016-09-01 05:26:17 +02:00
|
|
|
@echo " upload-coreboot-sdk - Upload coreboot-sdk to hub.docker.com"
|
2016-12-31 00:26:13 +01:00
|
|
|
@echo " coreboot-jenkins-node - Build coreboot-jenkins-node container"
|
2016-09-01 05:26:17 +02:00
|
|
|
@echo " upload-coreboot-jenkins-node - Upload coreboot-jenkins-node to hub.docker.com"
|
2016-12-31 22:59:29 +01:00
|
|
|
@echo " clean-coreboot-containers - Remove all docker coreboot containers"
|
|
|
|
@echo " clean-coreboot-images - Remove all docker coreboot images"
|
|
|
|
@echo " clean-docker - Remove docker coreboot containers & images"
|
2016-09-01 05:26:17 +02:00
|
|
|
@echo
|
|
|
|
@echo "Commands for using docker images"
|
2016-12-31 22:59:29 +01:00
|
|
|
@echo " docker-build-coreboot - Build coreboot under coreboot-sdk"
|
|
|
|
@echo " <BUILD_CMD=target> "
|
|
|
|
@echo " docker-abuild - Run abuild under coreboot-sdk"
|
|
|
|
@echo " <ABUILD_ARGS='-a -B'>"
|
|
|
|
@echo " docker-what-jenkins-does - Run 'what-jenkins-does' target"
|
|
|
|
@echo " docker-shell - Bash prompt in coreboot-jenkins-node"
|
|
|
|
@echo " <USER=root or USER=coreboot>"
|
|
|
|
@echo " docker-jenkins-server - Run coreboot-jenkins-node image (for server)"
|
2016-12-31 01:00:19 +01:00
|
|
|
@echo
|
|
|
|
@echo "Variables:"
|
2016-12-31 22:59:29 +01:00
|
|
|
@echo " COREBOOT_JENKINS_PORT=$(COREBOOT_JENKINS_PORT)"
|
|
|
|
@echo " COREBOOT_JENKINS_CACHE_DIR=$(COREBOOT_JENKINS_CACHE_DIR)"
|
|
|
|
@echo " COREBOOT_JENKINS_CCACHE_DIR=$(COREBOOT_JENKINS_CCACHE_DIR)"
|
|
|
|
@echo " COREBOOT_JENKINS_CONTAINER=$(COREBOOT_JENKINS_CONTAINER)"
|
|
|
|
@echo " COREBOOT_CONTAINER_VERSION=$(COREBOOT_CONTAINER_VERSION)"
|
|
|
|
@echo " DOCKER_COMMIT=$(DOCKER_COMMIT)"
|
2016-09-01 05:26:17 +02:00
|
|
|
|
2016-12-31 00:26:13 +01:00
|
|
|
.PHONY: test-docker test-docker-login
|
|
|
|
.PHONY: coreboot-jenkins-node upload-coreboot-jenkins-node
|
|
|
|
.PHONY: coreboot-sdk upload-coreboot-sdk
|
|
|
|
.PHONY: clean-coreboot-containers clean-coreboot-images
|
|
|
|
.PHONY: docker-abuild
|
2016-12-31 22:59:29 +01:00
|
|
|
.PHONY: docker-what-jenkins-does docker-shell docker-jenkins-server
|
2016-12-31 00:26:13 +01:00
|
|
|
.PHONY: help
|