From 67eb92cda9604c95ce62b6f4230834a31f6ca6b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Leroy?= <frederic.leroy@b-com.com> Date: Mon, 13 Jun 2016 08:50:39 +0200 Subject: [PATCH] Check if the distribution is supported Thank to Thomas Laurent for refactorize get_distribution_released --- cmake_targets/tools/build_helper | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index b48f33d282..b5c7a86d71 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -67,7 +67,33 @@ echo_warning() { cecho "$*" $yellow ;} echo_success() { cecho "$*" $green ;} echo_info() { cecho "$*" $blue ;} +######################## +# distribution helpers # +######################## + +# This function return a string to identify the distribution we are running +# If we can't check the distribution, it returns "Unknown" +# This function return always true as exit code by design +# Examples: +# Ubuntu16.04 +# Debian8.5 +get_distribution_release() { + local distributor + if distributor=$(lsb_release -si 2>/dev/null) ; then + echo $distributor$(lsb_release -sr) + else + echo Unknown + fi +} +check_supported_distribution() { + local distribution=$(get_distribution_release) + case "$distribution" in + "Ubuntu16.04") return 0 ;; + "Ubuntu14.04") return 0 ;; + esac + return 1 +} ########################### # Cleaners @@ -231,6 +257,10 @@ check_install_additional_tools (){ } check_install_oai_software() { + if ! check_supported_distribution; then + echo_error "Your distribution $(get_distribution_release) is not supported by oai !" + exit 1 + fi $SUDO apt-get update $SUDO apt-get install -y \ autoconf \ -- GitLab