diff options
author | Stefan K. Berg <stefan.k.berg@ericsson.com> | 2015-10-27 00:10:33 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2015-10-27 00:10:33 +0000 |
commit | 7189d4fc5e7ceaf40bf230368c787f66f0af3aa2 (patch) | |
tree | 96f5bfae95d08f60ac1f6a55efe261d26b65e316 /fuel/build | |
parent | ad790a995855219ce876880f00ad59a8ffa2b2d9 (diff) | |
parent | 0635291a88dd006e15224169524a7fc761ad47ab (diff) |
Merge "Support for building Fuel behind a http proxy"
Diffstat (limited to 'fuel/build')
-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 |
7 files changed, 143 insertions, 11 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 |