diff options
-rw-r--r-- | INSTALL/common.d/10_base (renamed from INSTALL/setup.d/10_base) | 0 | ||||
-rw-r--r-- | INSTALL/common.d/20_worker_base (renamed from INSTALL/setup.d/20_worker_base) | 0 | ||||
-rw-r--r-- | INSTALL/common.d/99_cleanup (renamed from INSTALL/setup.d/99_cleanup) | 0 | ||||
-rw-r--r-- | INSTALL/flavours/generic.tasks | 20 | ||||
-rw-r--r-- | INSTALL/flavours/xds.tasks | 7 | ||||
-rwxr-xr-x | INSTALL/setup_image.sh | 39 | ||||
-rw-r--r-- | INSTALL/tasks.d/30_yocto (renamed from INSTALL/setup.d/30_yocto) | 0 | ||||
-rw-r--r-- | INSTALL/tasks.d/31_yocto_toaster (renamed from INSTALL/setup.d/31_yocto_toaster) | 0 | ||||
-rw-r--r-- | INSTALL/tasks.d/40_netboot (renamed from INSTALL/setup.d/40_netboot) | 0 | ||||
-rw-r--r-- | INSTALL/tasks.d/50_sdk (renamed from INSTALL/setup.d/50_sdk) | 0 | ||||
-rw-r--r-- | INSTALL/tasks.d/60_x11_tools (renamed from INSTALL/setup.d/60_x11_tools) | 0 | ||||
-rw-r--r-- | INSTALL/tasks.d/70_doc (renamed from INSTALL/setup.d/70_doc) | 0 | ||||
-rw-r--r-- | INSTALL/tasks.d/80_xds | 16 | ||||
-rw-r--r-- | Makefile | 33 | ||||
-rw-r--r-- | README.md | 30 |
15 files changed, 117 insertions, 28 deletions
diff --git a/INSTALL/setup.d/10_base b/INSTALL/common.d/10_base index e429e65..e429e65 100644 --- a/INSTALL/setup.d/10_base +++ b/INSTALL/common.d/10_base diff --git a/INSTALL/setup.d/20_worker_base b/INSTALL/common.d/20_worker_base index b262afb..b262afb 100644 --- a/INSTALL/setup.d/20_worker_base +++ b/INSTALL/common.d/20_worker_base diff --git a/INSTALL/setup.d/99_cleanup b/INSTALL/common.d/99_cleanup index 3cea352..3cea352 100644 --- a/INSTALL/setup.d/99_cleanup +++ b/INSTALL/common.d/99_cleanup diff --git a/INSTALL/flavours/generic.tasks b/INSTALL/flavours/generic.tasks new file mode 100644 index 0000000..58c6828 --- /dev/null +++ b/INSTALL/flavours/generic.tasks @@ -0,0 +1,20 @@ +# this file contains tasks to be added for generic container +# +# each task listed below should be present as a scriptlet in INSTALL/tasks.d/<taskname> + +# platform builds +30_yocto +31_yocto_toaster + +# boot target board from image located inside the container +40_netboot + +# tools & environment for Yocto SDK +50_sdk + +# extra UI tools +60_x11_tools + +# tools to generate documentation site +70_doc + diff --git a/INSTALL/flavours/xds.tasks b/INSTALL/flavours/xds.tasks new file mode 100644 index 0000000..a189fda --- /dev/null +++ b/INSTALL/flavours/xds.tasks @@ -0,0 +1,7 @@ +# this file contains tasks to be added for XDS container +# +# each task listed below should be present as a scriptlet in INSTALL/tasks.d/<taskname> + +40_netboot +50_sdk +80_xds diff --git a/INSTALL/setup_image.sh b/INSTALL/setup_image.sh index b7df59d..7f2099b 100755 --- a/INSTALL/setup_image.sh +++ b/INSTALL/setup_image.sh @@ -33,6 +33,9 @@ fi # source variables in conf file . $INSTDIR/image.conf +# source flavour config file (generated by top Makefile) +. $INSTDIR/flavour.conf + ################################## install docker endpoint ##################### # install the entrypoint script in /usr/bin @@ -80,16 +83,32 @@ ln -sf ../usr/share/zoneinfo/$TIMEZONE /etc/localtime ################################## run other scripts in turn ############## -for script in $INSTDIR/setup.d/*; do - case $(basename $script) in - [0-9][0-9]_*) - echo "--------------------- start script $script ---------------------" - . $script - echo "--------------------- end of script $script ---------------------" - ;; - *) - ;; - esac +function enumerate_tasks() { + for script in $INSTDIR/common.d/*; do + case $(basename $script) in + [0-9][0-9]_*) + echo $(basename $script):$script + ;; + esac + done + + for tsk in $(cat $INSTDIR/flavours/$FLAVOUR.tasks | sed 's/#.*$//g'); do + if [[ -f $INSTDIR/tasks.d/$tsk ]]; then + echo $tsk:$INSTDIR/tasks.d/$tsk + else + # fail to find task + echo "$INSTDIR/flavours/$FLAVOUR.tasks: invalid task '$tsk'" >&2 + return 1 + fi + done + return 0 +} + + +for script in $(enumerate_tasks | sort -k1 -t':' | cut -f2 -d':'); do + echo "--------------------- start script $script ---------------------" + . $script + echo "--------------------- end of script $script ---------------------" done ############################### cleanup ################################### diff --git a/INSTALL/setup.d/30_yocto b/INSTALL/tasks.d/30_yocto index af21a8c..af21a8c 100644 --- a/INSTALL/setup.d/30_yocto +++ b/INSTALL/tasks.d/30_yocto diff --git a/INSTALL/setup.d/31_yocto_toaster b/INSTALL/tasks.d/31_yocto_toaster index 9dbb698..9dbb698 100644 --- a/INSTALL/setup.d/31_yocto_toaster +++ b/INSTALL/tasks.d/31_yocto_toaster diff --git a/INSTALL/setup.d/40_netboot b/INSTALL/tasks.d/40_netboot index 05d6f30..05d6f30 100644 --- a/INSTALL/setup.d/40_netboot +++ b/INSTALL/tasks.d/40_netboot diff --git a/INSTALL/setup.d/50_sdk b/INSTALL/tasks.d/50_sdk index 1a44fd9..1a44fd9 100644 --- a/INSTALL/setup.d/50_sdk +++ b/INSTALL/tasks.d/50_sdk diff --git a/INSTALL/setup.d/60_x11_tools b/INSTALL/tasks.d/60_x11_tools index 5c2cd75..5c2cd75 100644 --- a/INSTALL/setup.d/60_x11_tools +++ b/INSTALL/tasks.d/60_x11_tools diff --git a/INSTALL/setup.d/70_doc b/INSTALL/tasks.d/70_doc index 9336de9..9336de9 100644 --- a/INSTALL/setup.d/70_doc +++ b/INSTALL/tasks.d/70_doc diff --git a/INSTALL/tasks.d/80_xds b/INSTALL/tasks.d/80_xds new file mode 100644 index 0000000..69d7999 --- /dev/null +++ b/INSTALL/tasks.d/80_xds @@ -0,0 +1,16 @@ +#!/bin/bash + +# install required tools for XDS +# TODO + +# clone XDS repo +# TODO + +# build daemon +# TODO + +# install in container +# TODO + +# cleanup (remove build tools) +# TODO @@ -5,14 +5,15 @@ REGISTRY=docker.automotivelinux.org REPO=agl NAME=worker VERSION=$(shell tail -1 VERSION) +FLAVOUR=generic # --------------------------------------------------- # --- computed - don't touch ! # --------------------------------------------------- -IMAGE_NAME=$(REGISTRY)/$(REPO)/$(NAME):$(VERSION) -IMAGE_LATEST=$(REGISTRY)/$(REPO)/$(NAME):latest -CNAME=vm-$(NAME) +IMAGE_NAME=$(REGISTRY)/$(REPO)/$(NAME)-$(FLAVOUR):$(VERSION) +IMAGE_LATEST=$(REGISTRY)/$(REPO)/$(NAME)-$(FLAVOUR):latest +CNAME=vm-$(NAME)-$(FLAVOUR) help: @echo "Available targets:" @@ -31,6 +32,7 @@ help: @echo "- Docker registry: REGISTRY=$(REGISTRY)" @echo "- Image repository: REPO=$(REPO)" @echo "- Image name: NAME=$(NAME)" + @echo "- Flavour: FLAVOUR=$(FLAVOUR)" @echo "- Image version: VERSION=$(VERSION)" @echo "- Container name/host name: CNAME=$(CNAME)" @echo @@ -40,6 +42,10 @@ help: @echo "Images:" @docker images @echo + @echo "Available flavours:" + @echo "- generic (default) : can be used for most of the tasks (platform builds, sdk builds, ...)" + @echo "- xds : dedicated to daemons and tools part of XDS (cross development system)" + .PHONY:clean clean: @@ -67,21 +73,24 @@ distclean: clean done .PHONY:build-debug -build-debug: - @echo "------------------- Building image $(NAME) (debug mode) -------------------" +build-debug: INSTALL/flavours/$(FLAVOUR).tasks + @echo "------------------- Building image $(NAME)-$(FLAVOUR) (debug mode) -------------------" @touch INSTALL/DEBUG + @echo "FLAVOUR=$(FLAVOUR)" >INSTALL/flavour.conf @docker build --no-cache=true --rm --pull -t $(IMAGE_NAME) . - @rm -f INSTALL/DEBUG + @rm -f INSTALL/DEBUG INSTALL/flavour.conf @docker images # inside jenkins, we don't want the build script to break and wait for interaction # after first error. So we remove the file inside INSTALL dir which indicates to the # setup script to enable DEBUG. .PHONY:build -build: - @echo "------------------- Building image $(NAME) -------------------" +build: INSTALL/flavours/$(FLAVOUR).tasks + @echo "------------------- Building image $(NAME)-$(FLAVOUR) -------------------" @rm -f INSTALL/DEBUG + @echo "FLAVOUR=$(FLAVOUR)" >INSTALL/flavour.conf @docker build --no-cache=true --rm --pull -t $(IMAGE_NAME) . + @rm -f INSTALL/flavour.conf @docker images .PHONY:test @@ -109,14 +118,14 @@ push-latest: push .PHONY:export export: - @echo "Export image to docker_$(REPO)_$(NAME)-$(VERSION).tar.xz" - docker save $(IMAGE_NAME) | xz -T0 -c >docker_$(REPO)_$(NAME)-$(VERSION).tar.xz + @echo "Export image to docker_$(REPO)_$(NAME)-$(FLAVOUR)-$(VERSION).tar.xz" + docker save $(IMAGE_NAME) | xz -T0 -c >docker_$(REPO)_$(NAME)-$(FLAVOUR)-$(VERSION).tar.xz .PHONY:export-latest export-latest: docker tag $(IMAGE_NAME) $(IMAGE_LATEST) - @echo "Export image to docker_$(REPO)_$(NAME)-latest.tar.xz" - docker save $(IMAGE_LATEST) | xz -T0 -c >docker_$(REPO)_$(NAME)-latest.tar.xz + @echo "Export image to docker_$(REPO)_$(NAME)-$(FLAVOUR)-latest.tar.xz" + docker save $(IMAGE_LATEST) | xz -T0 -c >docker_$(REPO)_$(NAME)-$(FLAVOUR)-latest.tar.xz .PHONY:show-image show-image: @@ -29,19 +29,35 @@ Typically, the sequence to build an image is: # make clean ``` +By default, the flavour 'generic' is used: the resulting container has multiple capabilities +(platform build, sdk build, documentation compiling etc.) at the cost of size. + +To change the flavour, specify FLAVOUR=your_flavour on the command line. For example: + +``` +# make build FLAVOUR=xds +... +# make export FLAVOUR=xds +... +# make clean FLAVOUR=xds +``` + ## How it works The Dockerfile is generic: it simply inherits from a Debian image. -When running a 'docker build': +When running a 'make build': +* the Makefile creates a temp file INSTALL/flavour.conf to record the selected flavour * Docker instantiates a new container based on the latest Debian image * Docker copies the INSTALL folder inside the container in /root/INSTALL -* then it runs the setup script /root/INSTALL/docker/setup_image.sh +* then it runs the setup script /root/INSTALL/setup_image.sh In turn, this setup script will: -* source the configuration file /root/INSTALL/docker/image.conf -* execute all scripts contained in /root/INSTALL/setup.d +* source the configuration file /root/INSTALL/image.conf +* source the flavour file /root/INSTALL/flavour.conf +* execute all scripts contained in /root/INSTALL/common.d +* execute all scripts located in /root/INSTALL/tasks.d and referenced from INSTALL/flavours/$FLAVOUR.tasks When the setup script finishes, Docker commits the temporary container in a new image. @@ -63,12 +79,14 @@ In the second case, the efficiency is better but requires to transfer the image ### Instantiate a container -The following command can be used as an example to instantiate a container: +The following command located in contrib/ subdir can be used as **an example** to instantiate a container: ``` -# ./create_container 0 +# contrib/create_container 0 ``` To instantiate more containers on the same host, the instance ID passed as argument must be different from the previous ones. +**PLEASE ADJUST THE SCRIPT create_container TO FIT YOUR ENVIRONMENT AND YOUR NEEDS** + |