From e5c9717d241c005b4546ada80b5b85a40cde2061 Mon Sep 17 00:00:00 2001 From: Peter Mikus Date: Wed, 5 Jun 2019 08:59:37 +0000 Subject: FIX: OS detection Change-Id: I3ba6c7dc6a72e376419990ce7f5acc8d373f246f Signed-off-by: Peter Mikus --- resources/libraries/bash/function/common.sh | 34 +++++++++++++++-------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'resources/libraries/bash/function') diff --git a/resources/libraries/bash/function/common.sh b/resources/libraries/bash/function/common.sh index 399b449fa0..02c65c82c2 100644 --- a/resources/libraries/bash/function/common.sh +++ b/resources/libraries/bash/function/common.sh @@ -765,27 +765,29 @@ function select_os () { set -exuo pipefail - # Variables read: - # - OS - os or distro for selecting container image. # Variables set: # - VPP_VER_FILE - Name of File in CSIT dir containing vpp stable version. # - IMAGE_VER_FILE - Name of File in CSIT dir containing the image name. # - PKG_SUFFIX - Suffix of OS package file name, "rpm" or "deb." - case "${OS}" in - "ubuntu"*) - IMAGE_VER_FILE="VPP_DEVICE_IMAGE_UBUNTU" - VPP_VER_FILE="VPP_STABLE_VER_UBUNTU_BIONIC" - PKG_SUFFIX="deb" - ;; - "centos"*) - IMAGE_VER_FILE="VPP_DEVICE_IMAGE_CENTOS" - VPP_VER_FILE="VPP_STABLE_VER_CENTOS" - PKG_SUFFIX="rpm" - ;; - *) - die "Unable to identify distro or os from ${OS}" - ;; + os_id=$(grep '^ID=' /etc/os-release | cut -f2- -d= | sed -e 's/\"//g') || { + die "Get OS release failed." + } + + case "${os_id}" in + "ubuntu"*) + IMAGE_VER_FILE="VPP_DEVICE_IMAGE_UBUNTU" + VPP_VER_FILE="VPP_STABLE_VER_UBUNTU_BIONIC" + PKG_SUFFIX="deb" + ;; + "centos"*) + IMAGE_VER_FILE="VPP_DEVICE_IMAGE_CENTOS" + VPP_VER_FILE="VPP_STABLE_VER_CENTOS" + PKG_SUFFIX="rpm" + ;; + *) + die "Unable to identify distro or os from ${OS}" + ;; esac } -- cgit 1.2.3-korg