diff options
-rw-r--r-- | fuel/build/Makefile | 40 | ||||
-rw-r--r-- | fuel/build/docker/Dockerfile (renamed from fuel/build/docker/ubuntu-builder/Dockerfile) | 9 | ||||
-rw-r--r-- | fuel/build/docker/Makefile | 12 | ||||
-rwxr-xr-x | fuel/build/docker/runcontext | 48 | ||||
-rw-r--r-- | fuel/build/f_isoroot/f_odlpluginbuild/Makefile | 2 | ||||
-rw-r--r-- | fuel/build/f_isoroot/f_repobuild/Makefile | 13 | ||||
-rw-r--r-- | fuel/build/fuel-main_6.patch | 30 | ||||
-rw-r--r-- | fuel/docs/src/build-instructions.rst | 119 |
8 files changed, 246 insertions, 27 deletions
diff --git a/fuel/build/Makefile b/fuel/build/Makefile index 767b930d7..80ef8ea51 100644 --- a/fuel/build/Makefile +++ b/fuel/build/Makefile @@ -9,6 +9,11 @@ ############################################################################## SHELL = /bin/bash + +# This file will be created if needed by runcontext to contain proxy +# settings. +-include environment.mk + ############################################################################ # BEGIN of variables to customize # @@ -77,6 +82,8 @@ $(ISOCACHE): cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-main_3.patch # Patch for adding dosfstools, as Fuel 6.1 is running mkfs.vfat cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-main_5.patch + # Patch for changing the second layer Docker --bip address + cd /tmp/fuel-main && patch -p0 < $(TOPDIR)/fuel-main_6.patch # Remove Docker optimizations, otherwise multistrap will fail during # Fuel build. sudo rm -f /etc/apt/apt.conf.d/docker* @@ -85,8 +92,8 @@ $(ISOCACHE): cd /tmp/fuel-main && make repos $(REPOINFO) -r /tmp/fuel-main > gitinfo_fuel.txt # - cd /tmp/fuel-main && make iso - mv /tmp/fuel-main/build/artifacts/fuel*.iso . + cd /tmp/fuel-main && sudo make iso + cp /tmp/fuel-main/build/artifacts/fuel*.iso . .PHONY: mount-origiso umount-origiso mount-origiso: $(ISOCACHE) @@ -114,16 +121,38 @@ clean: $(SUBCLEAN) @rm -f *.iso @rm -Rf release @rm -Rf newiso + @rm -Rf .versions @rm -f $(NEWISO) @rm -f $(BUILD_BASE)/gitinfo_*.txt +.PHONY: deepclean +deepclean: clean clean-cache + make -C docker clean + docker rmi opnfv.org/ubuntu-builder:14.04 &>/dev/null || exit 0 + docker rmi opnfv.org/ubuntu-builder:latest &>/dev/null || exit 0 + docker rmi ubuntu:14.04 &>/dev/null || exit 0 + @if docker images | grep -q "ubuntu *14.04"; then \ + echo "Error: ubuntu:14.04 still present!"; \ + exit 1; \ + fi + @if docker images | grep -q "opnfv.org/ubuntu-builder"; then \ + echo "Error: opnfv.org/ubuntu-builder still present!"; \ + exit 1; \ + fi + $(SUBCLEAN): %.clean: $(MAKE) -C $* -f Makefile clean +.PHONY: setup-env +setup-env: + @if [ -f environment.mk ]; then \ + sudo bash -c "cat environment.mk >> /etc/environment"; \ + fi + # Todo: Make things smarter - we shouldn't need to clean everything # betwen make invocations. .PHONY: iso -iso: $(ISOCACHE) $(SUBDIRS) patch-packages +iso: setup-env $(ISOCACHE) $(SUBDIRS) patch-packages $(REPOINFO) . > gitinfo_main.txt install/install.sh iso $(ISOCACHE) $(NEWISO) $(PRODNO) $(REVSTATE) @printf "\n\nProduct ISO is $(NEWISO)\n\n" @@ -132,7 +161,8 @@ iso: $(ISOCACHE) $(SUBDIRS) patch-packages .PHONY: debug debug: @docker version >/dev/null 2>&1 || (echo 'No Docker installation available'; exit 1) - docker/runcontext $(DOCKERIMG) bash + @make -C docker + docker/runcontext $(DOCKERIMG) debug ############################################################################# # Cache operations - only used when building through ci/build.sh @@ -152,7 +182,7 @@ debug: # Clean local data related to caching - called prior to ordinary build .PHONY: clean-cache -clean-cache: +clean-cache: $(SUBCLEANCACHE) rm -f .cachedata .cacheid # Try to download cache - called prior to ordinary build diff --git a/fuel/build/docker/ubuntu-builder/Dockerfile b/fuel/build/docker/Dockerfile index d568acd0e..f3d122db9 100644 --- a/fuel/build/docker/ubuntu-builder/Dockerfile +++ b/fuel/build/docker/Dockerfile @@ -10,6 +10,10 @@ ############################################################################## FROM ubuntu:14.04 +ENV http_proxy INSERT_HTTP_PROXY +ENV https_proxy INSERT_HTTPS_PROXY +ENV no_proxy INSERT_NO_PROXY + RUN apt-get update RUN apt-get install -y software-properties-common python-software-properties \ make python-setuptools python-all dpkg-dev debhelper \ @@ -17,7 +21,12 @@ RUN apt-get install -y software-properties-common python-software-properties \ ca-certificates sudo apt-utils lsb-release dosfstools debmirror RUN echo "ALL ALL=NOPASSWD: ALL" > /etc/sudoers.d/open-sudo +RUN echo "Defaults env_keep += \"ftp_proxy http_proxy https_proxy no_proxy RSYNC_PROXY RSYNC_CONNECT_PROG npm_config_registry\"" > /etc/sudoers.d/keep-proxies +# Keeping PWD is needed to build as root +RUN echo "Defaults env_keep += \"PWD\"" > /etc/sudoers.d/keep-pwd RUN chmod 0440 /etc/sudoers.d/open-sudo +RUN chmod 0440 /etc/sudoers.d/keep-proxies +RUN chmod 0440 /etc/sudoers.d/keep-pwd RUN chmod 4755 /bin/fusermount ADD ./setcontext /root/setcontext diff --git a/fuel/build/docker/Makefile b/fuel/build/docker/Makefile index c2853c856..a2434447a 100644 --- a/fuel/build/docker/Makefile +++ b/fuel/build/docker/Makefile @@ -8,16 +8,26 @@ # http://www.apache.org/licenses/LICENSE-2.0 ############################################################################## +SHELL = /bin/bash FILES = $(wildcard ubuntu-builder/*) runcontext .PHONY: all all: .docker .docker: $(FILES) + cp Dockerfile ubuntu-builder/Dockerfile + # Only add proxy ENVs where set in host - needed to pull the base Ubuntu image + test -n "${http_proxy}" && sed -i "s;INSERT_HTTP_PROXY;${http_proxy};" ubuntu-builder/Dockerfile || exit 0 + test -n "${https_proxy}" && sed -i "s;INSERT_HTTPS_PROXY;${https_proxy};" ubuntu-builder/Dockerfile || exit 0 + test -n "${no_proxy}" && sed -i "s;INSERT_NO_PROXY;${no_proxy};" ubuntu-builder/Dockerfile || exit 0 + test -n "${HTTP_PROXY}" && sed -i "s;INSERT_HTTP_PROXY;${HTTP_PROXY};" ubuntu-builder/Dockerfile || exit 0 + test -n "${HTTPS_PROXY}" && sed -i "s;INSERT_HTTPS_PROXY;${HTTPS_PROXY};" ubuntu-builder/Dockerfile || exit 0 + test -n "${NO_PROXY}" && sed -i "s;INSERT_NO_PROXY;${NO_PROXY};" ubuntu-builder/Dockerfile || exit 0 + sed -i '/INSERT_/d' ubuntu-builder/Dockerfile /usr/bin/docker build --rm=true --no-cache=true -t opnfv.org/ubuntu-builder:14.04 ubuntu-builder /usr/bin/docker tag -f opnfv.org/ubuntu-builder:14.04 opnfv.org/ubuntu-builder touch .docker .PHONY: clean clean: - rm .docker + rm -f .docker ubuntu-builder/Dockerfile diff --git a/fuel/build/docker/runcontext b/fuel/build/docker/runcontext index 341612b4e..a874fb8e9 100755 --- a/fuel/build/docker/runcontext +++ b/fuel/build/docker/runcontext @@ -29,20 +29,57 @@ do_exit () { # End of Exit handlers ############################################################################ + trap do_exit SIGINT SIGTERM EXIT + context=$1 shift GID=`id -g` USER=`whoami` res=`docker build -q --force-rm - <<EOF FROM $context +$(env | egrep -i 'proxy|rsync' | sed 's/^/ENV /' | sed 's/=/ /') RUN date || date RUN /root/setcontext $USER $UID $GID $HOME EOF` GITROOT=`git rev-parse --show-toplevel` IID=`echo $res | sed 's/.* //'` + CID_FILE=`mktemp -u -t runcontext.XXXXXXXXXX` +# Handle proxy settings passed to the context +if env | grep -iq .*proxy; then + envfile="$(readlink -f $(dirname $0)/..)/environment.mk" + + test -n "$HTTP_PROXY" && my_http_proxy=$HTTP_PROXY + test -n "$http_proxy" && my_http_proxy=$http_proxy + + test -n "$HTTPS_PROXY" && my_https_proxy=$HTTPS_PROXY + test -n "$https_proxy" && my_https_proxy=$https_proxy + + test -n "$NO_PROXY" && my_no_proxy=$NO_PROXY + test -n "$no_proxy" && my_no_proxy=$no_proxy + + # Make sure to add the Docker socket in no_proxy + if [ -n "$my_no_proxy" ]; then + my_no_proxy+=",/var/run/docker.sock" + else + my_no_proxy="/var/run/docker.sock" + fi + + echo "Creating $envfile" + echo "# This file is automatically generated by runcontext, do not edit!" > $envfile + test -n "$my_http_proxy" && echo "export http_proxy=$my_http_proxy" >> $envfile + test -n "$my_https_proxy" && echo "export https_proxy=$my_https_proxy" >> $envfile + test -n "$my_no_proxy" && echo "export no_proxy=$my_no_proxy" >> $envfile + test -n "$RSYNC_PROXY" && echo "export RSYNC_PROXY=$RSYNC_PROXY" >> $envfile + test -n "$RSYNC_CONNECT_PROG" && echo "export RSYNC_CONNECT_PROG=$RSYNC_CONNECT_PROG" >> $envfile + echo "export npm_config_registry=http://registry.npmjs.org/" >> $envfile +else + echo "No need to generate environment.mk" + rm -f $envfile +fi + # Evaluate the need for bind mounting the cache directory if [ -n "$CACHEBASE" ]; then if echo $CACHEBASE | grep -q '^file://'; then @@ -52,5 +89,12 @@ fi RUN_CONTEXT_OPT="--cidfile $CID_FILE --privileged=true --rm -e HOME=$HOME -e CACHEDEBUG -e CACHETRANSPORT -e CACHEMAXAGE -e CACHEBASE -u $USER -w $PWD -v ${HOME}/.ssh:${HOME}/.ssh -v $GITROOT:$GITROOT $CACHEMOUNT" -echo command: docker run ${RUN_CONTEXT_OPT} $IID "$@" -docker run ${RUN_CONTEXT_OPT} $IID "$@" +# Passing "debug" puts up an interactive bash shell +if [ "$1" == "debug" ]; then + echo command: docker run ${RUN_CONTEXT_OPT} $IID $@ + docker run -i -t ${RUN_CONTEXT_OPT} $IID bash +else + echo command: docker run ${RUN_CONTEXT_OPT} $IID $@ + docker run -t ${RUN_CONTEXT_OPT} $IID $@ +fi + diff --git a/fuel/build/f_isoroot/f_odlpluginbuild/Makefile b/fuel/build/f_isoroot/f_odlpluginbuild/Makefile index 5b10de9b2..9d79d3531 100644 --- a/fuel/build/f_isoroot/f_odlpluginbuild/Makefile +++ b/fuel/build/f_isoroot/f_odlpluginbuild/Makefile @@ -17,7 +17,7 @@ all: .odlbuild .PHONY: clean clean: @rm -f .odlbuild ../release/opnfv/opendaylight*.rpm opendaylight*.rpm - @rm -f $(BUILD_BASE)/gitinfo_odlplugin.txt + @rm -f $(BUILD_BASE)/gitinfo_odlplugin.txt gitinfo_odlplugin.txt .PHONY: release release:.odlbuild diff --git a/fuel/build/f_isoroot/f_repobuild/Makefile b/fuel/build/f_isoroot/f_repobuild/Makefile index ad40d0b9a..0f5a6ac12 100644 --- a/fuel/build/f_isoroot/f_repobuild/Makefile +++ b/fuel/build/f_isoroot/f_repobuild/Makefile @@ -10,13 +10,22 @@ SHELL := /bin/bash TOP := $(shell pwd) - RSYNC_HOST := $(shell ./select_ubuntu_repo.sh) + .PHONY: all all: nailgun nailgun: +# If RSYNC_CONNECT_PROG is set we need to do some magic to copy the +# keys. Make sure to have the username set in the SSH_CONNECT_PROG +# as well! + @if [ -n "${RSYNC_CONNECT_PROG}" -a ! -d /root/.ssh ]; then \ + sudo mkdir -p /root/.ssh; \ + test -d ${HOME}/.ssh && sudo find ${HOME}/.ssh -maxdepth 1 -type f -exec cp {} /root/.ssh \; ; \ + sudo bash -c "echo StrictHostKeyChecking=no > /root/.ssh/config"; \ + sudo chmod 700 /root/.ssh; \ + fi sudo apt-get install -y rsync python python-yaml dpkg-dev openssl rm -rf tmpiso tmpdir mkdir tmpiso @@ -27,7 +36,7 @@ nailgun: sudo dpkg -i fuel-createmirror_6.1*.deb sudo sed -i 's/DOCKER_MODE=true/DOCKER_MODE=false/' /etc/fuel-createmirror/common.cfg sudo sed -i 's/DEBUG="no"/DEBUG="yes"/' /etc/fuel-createmirror/ubuntu.cfg - sudo sed -i 's/MIRROR_UBUNTU_HOST="archive.ubuntu.com"/MIRROR_UBUNTU_HOST="${RSYNC_HOST}"/' /etc/fuel-createmirror/common.cfg + sudo sed -i "s/MIRROR_UBUNTU_HOST=\".*\"/MIRROR_UBUNTU_HOST=\"$(RSYNC_HOST)\"/" /etc/fuel-createmirror/common.cfg rm -Rf nailgun sudo mkdir -p /var/www sudo su - -c /opt/fuel-createmirror-6.1/fuel-createmirror diff --git a/fuel/build/fuel-main_6.patch b/fuel/build/fuel-main_6.patch new file mode 100644 index 000000000..2659e2d17 --- /dev/null +++ b/fuel/build/fuel-main_6.patch @@ -0,0 +1,30 @@ +*** prepare-build-env.sh.orig Mon Oct 19 13:28:30 2015 +--- prepare-build-env.sh Mon Oct 19 13:29:10 2015 +*************** +*** 87,92 **** +--- 87,93 ---- + echo "Docker is running." + else + echo "Process is not running, starting it..." ++ sudo sh -c 'echo DOCKER_OPTS=\"--dns 8.8.8.8 --dns 8.8.4.4 --bip 172.45.0.1/24\" >> /etc/default/docker*' + sudo service docker start + fi + else +*************** +*** 102,108 **** + sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 + # Install docker + sudo apt-get update +! sudo apt-get -y install lxc-docker-1.5.0 + fi + + # Install software +--- 103,110 ---- + sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 36A1D7869245C8950F966E92D8576A8BA88D21E9 + # Install docker + sudo apt-get update +! sudo sh -c 'echo DOCKER_OPTS=\"--dns 8.8.8.8 --dns 8.8.4.4 --bip 172.45.0.1/24\" > /etc/default/docker' +! sudo apt-get -y -o Dpkg::Options::="--force-confold" install lxc-docker-1.5.0 + fi + + # Install software diff --git a/fuel/docs/src/build-instructions.rst b/fuel/docs/src/build-instructions.rst index 790bcf513..08b560375 100644 --- a/fuel/docs/src/build-instructions.rst +++ b/fuel/docs/src/build-instructions.rst @@ -1,5 +1,5 @@ ============================================================================ -OPNFV Build instructions for - Fuel deployment tool - OPNFV Arno SR1 release +OPNFV Build instructions for the Fuel deployment tool ============================================================================ .. contents:: Table of Contents @@ -8,13 +8,13 @@ OPNFV Build instructions for - Fuel deployment tool - OPNFV Arno SR1 release Abstract ======== -This document describes how to build the Fuel deployment tool for the Arno SR1 release of OPNFV, the build system, dependencies and required system resources. +This document describes how to build the Fuel deployment tool for the B release of OPNFV - the build system, dependencies and required system resources. License ======= -Arno SR1 release of OPNFV when using Fuel as a deployment tool DOCs (c) by Jonas Bjurel (Ericsson AB) +Brahmaputra release of OPNFV when using Fuel as a deployment tool DOCs (c) by Jonas Bjurel (Ericsson AB) and others. -Arno SR1 release of OPNFV when using Fuel as a deployment tool DOCs (c) are licensed under a Creative Commons Attribution 4.0 International License. You should have received a copy of the license along with this. If not, see <http://creativecommons.org/licenses/by/4.0/>. +Brahmaputra release of OPNFV when using Fuel as a deployment tool DOCs (c) are licensed under a Creative Commons Attribution 4.0 International License. You should have received a copy of the license along with this. If not, see <http://creativecommons.org/licenses/by/4.0/>. @@ -31,11 +31,14 @@ Version history | 2015-09-24 | 1.1.0 | Jonas Bjurel | Instructions for | | | | (Ericsson AB) | the Arno SR1 release | +--------------------+--------------------+--------------------+----------------------+ +| 2015-10-23 | 1.1.1 | Stefan Berg | Added instructions | +| | | (Ericsson AB) | for proxy builds | ++--------------------+--------------------+--------------------+----------------------+ Introduction ============ -This document describes the build system used to build the Fuel deployment tool for the Arno SR1 release of OPNFV, required dependencies and minimum requirements on the host to be used for the buildsystem. +This document describes the build system used to build the Fuel deployment tool for the Brahmaputra release of OPNFV, required dependencies and minimum requirements on the host to be used for the buildsystem. The Fuel build system is desigened around Docker containers such that dependencies outside of the build system can be kept to a minimum. It also shields the host from any potential dangerous operations performed by the build system. @@ -78,7 +81,7 @@ After having installed Docker, add yourself to the docker group: <usermod -a -G docker [userid]> Also make sure to define relevant DNS servers part of the global dns chain in -in your </etc/default/docker> configuration file, eg. +in your </etc/default/docker> configuration file, for example: <DOCKER_OPTS=" --dns=8.8.8.8 --dns=8.8.8.4"> @@ -95,17 +98,26 @@ Setting up OPNFV Gerrit in order to being able to clone the code - Select "SSH Public Keys" to the left and then "Add Key" and paste your public key in. -Clone the OPNFV code git repository -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +Clone the OPNFV code Git repository with your SSH key +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Now it is time to clone the code repository: -<git clone ssh://'Linux foundation user'@gerrit.opnfv.org:29418/genesis> +<git clone ssh://'Linux foundation user'@gerrit.opnfv.org:29418/fuel> + +Now you should have the OPNFV fuel repository with the Fuel directories stored locally on your build host. + +Check out the Brahmaputra release: +<cd fuel> +<git checkout insert-b-release-tag-here0> + +Clone the OPNFV code Git repository without a SSH key +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +You can also opt to clone the code repository without a SSH key: -Now you should have the OPNFV genesis repository with the Fuel directories stored locally on your build host. +<git clone https://gerrit.opnfv.org:29418/gerrit/fuel> + +Make sure to checkout the release tag as described above. -Check out the Arno SR1 release: -<cd genesis> -<git checkout arno.2015.2.0> Building ======== @@ -116,10 +128,85 @@ There are two methods available for building Fuel: - An abstracted method using build.sh + +Support for building behind a http/https/rsync proxy +---------------------------------------------------- + +The build system is able to make use of a web proxy setup if the +http_proxy, https_proxy, no_proxy (if needed) and RSYNC_PROXY or +RSYNC_CONNECT_PROG environment variables have been set before invoking make. + +The proxy setup must permit port 80 (http), 443 (https) and 873 +(rsync). + +Important note about the host Docker daemon settings +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The Docker daemon on the host must be configured to use the http proxy +for it to be able to pull the base Ubuntu 14.04 image from the Docker +registry before invoking make! In Ubuntu this is done by adding a line +like: + +export http_proxy="http://10.0.0.1:8888/" + +to /etc/default/docker and restarting the Docker daemon. + +Setting proxy environment variables prior to build +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The build system will make use the following environment variables +that needs to be exported to subshells by using export (bash) or +setenv (csh/tcsh). + +| http_proxy (or HTTP_PROXY) +| https_proxy (or HTTP_PROXY) +| no_proxy (or NO_PROXY) +| RSYNC_PROXY +| RSYNC_CONNECT_PROG + +As an example, these are the settings that were put in the user's +.bashrc when verifying the proxy build functionality: + +| export RSYNC_PROXY=10.0.0.1:8888 +| export http_proxy=http://10.0.0.1:8888 +| export https_proxy=http://10.0.0.1:8888 +| export no_proxy=localhost,127.0.0.1,.consultron.com,.sock + +Using a ssh proxy for the rsync connection +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +If the proxy setup is not allowing the rsync protocol, an alternative +solution is to use a SSH tunnel to a machine capable of accessing the +outbound port 873. Set the RSYNC_CONNECT_PROG according to the rsync +manual page (for example to "ssh <username>@<hostname> nc %H 873") to enable +this. Also note that netcat needs to be installed on the remote +system! + +Make sure that the ssh command also refers to the user on the remote +system, as the command itself will be run from the Docker build container +as the root user (but with the invoking user's SSH keys). + +Disabling the Ubuntu repo cache if rsync is not allowed +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +During the build phase, a local Ubuntu package repository is fetched +from upstream in order to be added to the OPNFV Fuel ISO and for parts +of this process rsync is used. + +If neither of the two available methods for proxying rsync are +available, the last resort is to turn off the caching of the Ubuntu +packages in the build system. This is done by removing the +"f_repobuild" from SUBDIRS in the beginning of +the fuel/build/f_isoroot/Makefile. + +Note! Doing this will require the Fuel master node to have Internet +access when installing the ISO artifact built as no Ubuntu package +cache will be on the ISO! + Configure your build environment ------------------------------------- -** Configuring the build environment should not be performed if building standard Arno release ** +** Configuring the build environment should not be performed if building standard Brahmaputra release ** Select the versions of the components you want to build by editing the fuel/build/config.mk file. @@ -172,8 +259,8 @@ References ========== - -:Authors: Jonas Bjurel (Ericsson) -:Version: 1.1.0 +:Authors: Jonas Bjurel (Ericsson), Stefan Berg (Ericsson) +:Version: x.x.x **Documentation tracking** |