diff options
author | Dave Wallace <dwallacelf@gmail.com> | 2020-07-21 15:32:12 -0700 |
---|---|---|
committer | Dave Wallace <dwallacelf@gmail.com> | 2020-10-28 18:31:44 +0000 |
commit | 97963740c8f3ae0b5b17fc15a53b2b8c86c7df1f (patch) | |
tree | 0374dce3c49637add2199e94aabb5536e3ee4ac5 /docker/scripts/lib_vpp.sh | |
parent | ae401885b0f508e321e02ba84a928bf7a9049776 (diff) |
Automate generation of docker builder images.
- Add bash scripts to generate builder image Dockerfile
that invokes the scripts to iterate over project
branches installing OS packages and python
modules.
Change-Id: I9b3b355b593e2f982f287023c662cc4a4f35a734
Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
Diffstat (limited to 'docker/scripts/lib_vpp.sh')
-rw-r--r-- | docker/scripts/lib_vpp.sh | 90 |
1 files changed, 90 insertions, 0 deletions
diff --git a/docker/scripts/lib_vpp.sh b/docker/scripts/lib_vpp.sh new file mode 100644 index 000000000..38245c7b7 --- /dev/null +++ b/docker/scripts/lib_vpp.sh @@ -0,0 +1,90 @@ +# lib_vpp.sh - Docker build script VPP library. +# For import only. + +# Copyright (c) 2020 Cisco and/or its affiliates. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at: +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Don't import more than once. +if [ -n "$(alias lib_vpp_imported 2> /dev/null)" ] ; then + return 0 +fi +alias lib_vpp_imported=true + +export CIMAN_DOCKER_SCRIPTS=${CIMAN_DOCKER_SCRIPTS:-"$(dirname $BASH_SOURCE)"} +. $CIMAN_DOCKER_SCRIPTS/lib_common.sh + +make_vpp() { + local target=$1 + local branch=${2:-"master"} + local branchname="$(echo $branch | sed -e 's,/,_,')" + local bld_log="$DOCKER_BUILD_LOG_DIR" + bld_log="${bld_log}/$FDIOTOOLS_IMAGENAME-$branchname" + bld_log="${bld_log}-make_vpp_${target}-bld.log" + + makefile_target="^${target}:" + if [ -z "$(grep $makefile_target Makefile)" ] ; then + echo "Make target '$target' does not exist in VPP branch '$branch'!" + return + fi + git clean -qfdx + description="'make UNATTENDED=y $target' in $(pwd) ($branch)" + echo_log -e " Starting $description..." + local force_opts="--allow-downgrades --allow-remove-essential" + force_opts="$force_opts --allow-change-held-packages" + make UNATTENDED=y CONFIRM="-y" FORCE="$force_opts" \ + $target 2>&1 | tee -a "$bld_log" + git checkout -q -- . + echo_log " Completed $description!" +} + +make_vpp_test() { + local target=$1 + local branch=${2:-"master"} + local branchname="$(echo $branch | sed -e 's,/,_,')" + local bld_log="$DOCKER_BUILD_LOG_DIR" + bld_log="${bld_log}/$FDIOTOOLS_IMAGENAME-$branchname" + bld_log="${bld_log}-make_vpp_test_${target}-bld.log" + + makefile_target="^${target}:" + if [ -z "$(grep -e $makefile_target test/Makefile)" ] ; then + echo "Make test target '$target' does not exist in VPP branch '$branch'!" + return + fi + git clean -qfdx + description="'make -C test $target' in $(pwd) ($branch)" + echo_log " Starting $description..." + make WS_ROOT="$DOCKER_VPP_DIR" BR="$DOCKER_VPP_DIR/build-root" \ + TEST_DIR="$DOCKER_VPP_DIR/test" -C test $target 2>&1 | tee -a $bld_log + remove_pyc_files_and_pycache_dirs + git checkout -q -- . + echo_log " Completed $description!" +} + +docker_build_setup_vpp() { + if [ ! -d "$DOCKER_VPP_DIR" ] ; then + echo_log "Cloning VPP into $DOCKER_VPP_DIR..." + git clone -q https://gerrit.fd.io/r/vpp $DOCKER_VPP_DIR + fi + clean_git_repo $DOCKER_VPP_DIR +} + +# Branches must be listed in chronological order -- oldest stable branch +# first and master last. +declare -A VPP_BRANCHES +VPP_BRANCHES["centos-7"]="stable/1908 stable/2001 stable/2005 stable/2009 master" +VPP_BRANCHES["centos-8"]="stable/2009 master" +VPP_BRANCHES["debian-9"]="stable/2009 master" +VPP_BRANCHES["debian-10"]="stable/2009 master" +VPP_BRANCHES["ubuntu-18.04"]="stable/1908 stable/2001 stable/2005 stable/2009 master" +VPP_BRANCHES["ubuntu-20.04"]="stable/2009 master" +export VPP_BRANCHES |