From edae355cd2b476f93a85ef148479feda8c9ccce8 Mon Sep 17 00:00:00 2001 From: niusmallnan Date: Mon, 6 Aug 2018 14:11:38 +0800 Subject: [PATCH] Avoid kernel too old error when building ROS --- .drone.yml | 2 +- Dockerfile.dapper | 2 +- scripts/build | 15 +++++++++++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.drone.yml b/.drone.yml index 67720304..a9905982 100644 --- a/.drone.yml +++ b/.drone.yml @@ -5,4 +5,4 @@ pipeline: volumes: - /var/run/docker.sock:/var/run/docker.sock commands: - - dapper ci + - KERNEL_CHECK=0 dapper ci diff --git a/Dockerfile.dapper b/Dockerfile.dapper index 51c980d5..7302e78d 100644 --- a/Dockerfile.dapper +++ b/Dockerfile.dapper @@ -40,7 +40,7 @@ RUN echo "Acquire::http { Proxy \"$APTPROXY\"; };" >> /etc/apt/apt.conf.d/01prox ########## Dapper Configuration ##################### -ENV DAPPER_ENV VERSION DEV_BUILD RUNTEST DEBUG APTPROXY ENGINE_REGISTRY_MIRROR INTEGRATION_TESTS +ENV DAPPER_ENV VERSION DEV_BUILD RUNTEST DEBUG APTPROXY ENGINE_REGISTRY_MIRROR INTEGRATION_TESTS KERNEL_CHECK ENV DAPPER_DOCKER_SOCKET true ENV DAPPER_SOURCE /go/src/github.com/rancher/os ENV DAPPER_OUTPUT ./bin ./dist ./build/initrd ./build/kernel diff --git a/scripts/build b/scripts/build index 118906ee..166a2e41 100755 --- a/scripts/build +++ b/scripts/build @@ -1,6 +1,21 @@ #!/bin/bash set -e +version_gt() { + test "$(printf '%s\n' "$@" | sort -V | head -n 1)" != "$1"; +} + + +if [ "$KERNEL_CHECK" != "0" ]; then + echo "Host Kernel: $(uname -r)" + echo "RancherOS Kernel: $KERNEL_VERSION" + + if ! version_gt $(uname -r) $KERNEL_VERSION; then + echo "Your host kernel must be greater than RancherOS KERNEL_VERSION" + exit 1 + fi +fi + echo -------------------------./build-target $(dirname $0)/build-target echo -------------------------./build-host