]> git.proxmox.com Git - mirror_frr.git/commitdiff
Docker: Update buildscripts to be more efficient
authorChristian Franke <chris@opensourcerouting.org>
Thu, 18 Oct 2018 09:31:20 +0000 (11:31 +0200)
committerChristian Franke <chris@opensourcerouting.org>
Thu, 29 Nov 2018 15:51:27 +0000 (16:51 +0100)
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
tests/topotests/Dockerfile
tests/topotests/docker/compile_frr.sh
tests/topotests/docker/entrypoint.sh
tests/topotests/docker/funcs.sh
tests/topotests/docker/motd.txt
tests/topotests/docker/topotests_run.sh

index ecc91bc543ea0d55a7da2a29fafd02536dc944a9..d6a395a948a7ea6295d8fd5667cc4da7d0e3b0a7 100644 (file)
@@ -8,6 +8,7 @@ RUN export DEBIAN_FRONTEND=noninteractive \
         bison \
         flex \
         gdb \
+        git \
         inetutils-ping \
         install-info \
         iproute2 \
index 55046f9edb0dcf3e30fd16f64669ce4465cf7790..6b64f79d6077a530dfc3f60ea1ff4c77842df2b5 100755 (executable)
@@ -22,6 +22,8 @@
 # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 # SOFTWARE.
 
+set -e
+
 # Load shared functions
 CDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 . $CDIR/funcs.sh
@@ -29,36 +31,47 @@ CDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
 #
 # Script begin
 #
-if [ ! -f .sync_source -o $SYNC_SOURCE -ne 0 ]; then
-       log_info "Syncing FRR source with host..."
-       mkdir -p $FRR_BUILD_DIR >/dev/null 2>&1
-       rsync -a --info=progress2 --chown root:root $FRR_HOST_DIR/. $FRR_BUILD_DIR/
-       touch .sync_source
-fi
 
-log_info "Building FRR..."
+log_info "Syncing FRR source with host..."
+mkdir -p $FRR_SYNC_DIR
+rsync -a --info=progress2 \
+       --exclude '*.o' \
+       --exclude '*.lo'\
+       --chown root:root \
+       $FRR_HOST_DIR/. $FRR_SYNC_DIR/
+(cd $FRR_SYNC_DIR && git clean -xdf > /dev/null)
+mkdir -p $FRR_BUILD_DIR
+rsync -a --info=progress2 --chown root:root $FRR_SYNC_DIR/. $FRR_BUILD_DIR/
 
-cd $FRR_BUILD_DIR || \
+cd "$FRR_BUILD_DIR" || \
        log_fatal "failed to find frr directory"
 
-if [ $CLEAN -ne 0 ]; then
-       make distclean >/dev/null 2>&1
-       rm -f Makefile configure
+if [ "${TOPOTEST_VERBOSE}" != "0" ]; then
+       exec 3>&1
+else
+       exec 3>/dev/null
+fi
+
+if [ "${TOPOTEST_CLEAN}" != "0" ]; then
+       log_info "Cleaning FRR builddir..."
+       git clean -xdf > /dev/null
 fi
 
-if [ ! -f configure ]; then
-       bash bootstrap.sh || \
+log_info "Building FRR..."
+
+if [ ! -e configure ]; then
+       bash bootstrap.sh >&3 || \
                log_fatal "failed to bootstrap configuration"
 fi
 
-if [ $DOC -ne 0 ]; then
+if [ "${TOPOTEST_DOC}" != "0" ]; then
        EXTRA_CONFIGURE+=" --enable-doc "
 else
        EXTRA_CONFIGURE+=" --disable-doc "
 fi
 
-if [ ! -f Makefile ]; then
-       if [ $SANITIZER -ne 0 ]; then
+if [ ! -e Makefile ]; then
+       if [ "${TOPOTEST_SANITIZER}" != "0" ]; then
                export CC="gcc"
                export CFLAGS="-O1 -g -fsanitize=address -fno-omit-frame-pointer"
                export LD="gcc"
@@ -69,7 +82,7 @@ if [ ! -f Makefile ]; then
                rm -f .address_sanitizer
        fi
 
-       bash configure >/dev/null \
+       bash configure >&3 \
                --enable-multipath=64 \
                --prefix=/usr \
                --localstatedir=/var/run/frr \
@@ -82,18 +95,11 @@ fi
 
 # if '.address_sanitizer' file exists it means we are using address sanitizer.
 if [ -f .address_sanitizer ]; then
-       make -C lib CFLAGS="-g -O2" LDFLAGS="-g" clippy
+       make -C lib CFLAGS="-g -O2" LDFLAGS="-g" clippy >&3
 fi
 
-if [ $VERBOSE -ne 0 ]; then
-       make -j$(cpu_count) || \
-               log_fatal "failed to build the sources"
-else
-       make -j$(cpu_count) >/dev/null || \
-               log_fatal "failed to build the sources"
-fi
+make -j$(cpu_count) >&3 || \
+       log_fatal "failed to build the sources"
 
 make install >/dev/null || \
        log_fatal "failed to install frr"
-
-exit 0
index e2270295867380a6750d8e97626e8062b8eef9b1..707c521888b60e09126879b42c0f15d5f14c9004 100755 (executable)
@@ -57,11 +57,7 @@ ovs-vsctl --no-wait -- set-manager ptcp:6640
 ovs-appctl -t ovsdb-server \
        ovsdb-server/add-remote db:Open_vSwitch,Open_vSwitch,manager_options
 
-# Build FRR
-env \
-       CLEAN=1 \
-       VERBOSE=0 \
-       bash "${CDIR}/compile_frr.sh"
+bash "${CDIR}/compile_frr.sh"
 
 log_info "Setting permissions on /tmp so we can generate logs"
 chmod -v 1777 /tmp
@@ -69,7 +65,4 @@ chmod -v 1777 /tmp
 log_info "Starting bash shell to interact with topotests"
 echo ''
 
-tmux
-
-log_info "Stopping OpenvSwitch"
-service openvswitch-switch stop
+exec bash
index dae71de3297d7c923adbefeb8a9c70ca233f4882..acb8b55e970b63b58bdcd157bd004709ae35a135 100755 (executable)
 # SOFTWARE.
 
 FRR_HOST_DIR=/root/host-frr
+FRR_SYNC_DIR=/root/persist/frr-sync
 FRR_BUILD_DIR=/root/persist/frr-build
-TOPOTESTS_DIR=/root/topotests
 
 if [ ! -L "/root/frr" ]; then
        ln -s $FRR_BUILD_DIR /root/frr
 fi
 
-[ -z $CLEAN ] && CLEAN=0
-[ -z $VERBOSE ] && VERBOSE=1
-[ -z $DOC ] && DOC=0
-[ -z $SANITIZER ] && SANITIZER=1
-[ -z $SYNC_SOURCE ] && SYNC_SOURCE=0
+[ -z $TOPOTEST_CLEAN ] && TOPOTEST_CLEAN=0
+[ -z $TOPOTEST_VERBOSE ] && TOPOTEST_VERBOSE=1
+[ -z $TOPOTEST_DOC ] && TOPOTEST_DOC=0
+[ -z $TOPOTEST_SANITIZER ] && TOPOTEST_SANITIZER=1
 
 log_info() {
        local msg=$1
index cb02540f5cf843a403b45b17578675ab63716c16..1e2f34f8fbf830519bb5cbcd292cbed63a9250c8 100644 (file)
@@ -4,13 +4,12 @@ Here are some useful tips:
 * After changing the FRR/Topotests sources, you may rebuild them
   using the command `compile_frr.sh`. The build command has the
   following environment variables:
-  - CLEAN: whether we should distclean or not (disabled by default)
-  - VERBOSE: show build messages (enabled by default)
-  - DOC: whether we should build docs or not (disabled by default)
-  - SANITIZER: whether we should use the address sanitizer (enabled by default)
-  - SYNC_SOURCE: copy new changes from host FRR sources (disabled by default)
+  - TOPOTEST_CLEAN: whether we should distclean or not (disabled by default)
+  - TOPOTEST_VERBOSE: show build messages (enabled by default)
+  - TOPOTEST_DOC: whether we should build docs or not (disabled by default)
+  - TOPOTEST_SANITIZER: whether we should use the address sanitizer (enabled by default)
 
-  Usage example: env CLEAN=1 SYNC_SOURCE=1 DOC=1 compile_frr.sh
+  Usage example: env TOPOTEST_CLEAN=1 compile_frr.sh
 
 * The topotests log directory can be found on your host machine on
   `/tmp/topotests_logs`.
index a68896789a0ec0a52e983b78916e02b06315edcf..e5e91156a56d9ae9c3ff9d4c5f0b1e91eae61b60 100755 (executable)
@@ -114,21 +114,20 @@ if [ -z "$TOPOTEST_BUILDCACHE" ]; then
                || docker volume create "${TOPOTEST_BUILDCACHE}"
 fi
 
-if [ -z "$TOPOTEST_PATH" ]; then
-       docker run --rm -ti \
-               -v "$TOPOTEST_LOGS:/tmp" \
-               -v "$TOPOTEST_FRR:/root/host-frr:ro" \
-               -v "$TOPOTEST_BUILDCACHE:/root/persist" \
-               --privileged \
-               $TOPOTEST_OPTIONS \
-               frrouting/topotests "$@"
-else
-       docker run --rm -ti \
-               -v "$TOPOTEST_LOGS:/tmp" \
-               -v "$TOPOTEST_FRR:/root/host-frr:ro" \
-               -v "$TOPOTEST_BUILDCACHE:/root/persist" \
-               -v "$TOPOTEST_PATH:/root/topotests:ro" \
-               --privileged \
-               $TOPOTEST_OPTIONS \
-               frrouting/topotests "$@"
+set -- --rm -ti \
+       -v "$TOPOTEST_LOGS:/tmp" \
+       -v "$TOPOTEST_FRR:/root/host-frr:ro" \
+       -v "$TOPOTEST_BUILDCACHE:/root/persist" \
+       -e "TOPOTEST_CLEAN=$TOPOTEST_CLEAN" \
+       -e "TOPOTEST_VERBOSE=$TOPOTEST_VERBOSE" \
+       -e "TOPOTEST_DOC=$TOPOTEST_DOC" \
+       -e "TOPOTEST_SANITIZER=$TOPOTEST_SANITIZER" \
+       --privileged \
+       $TOPOTEST_OPTIONS \
+       frrouting/topotests "$@"
+
+if [ -n "TOPOTEST_PATH" ]; then
+       set -- -v "$TOPOTEST_PATH:/root/topotests:ro" "$@"
 fi
+
+exec docker run "$@"