Fix diskimage-create.sh for Debian
As Ubuntu is debian-like platform, there is no reason to not support building image on Debian platform. Currently diskimage-create.sh is using head -n 1 to read /etc/os-release to fill platform bash variable. Bash platform variable is filled with NAME="Ubuntu" string as it is first line of Ubuntu's /etc/os-release. In debian the first line is for example PRETTY_NAME="Debian GNU/Linux 10 (buster)". This commit is fixing this behavior and fill platform bash variable to exact NAME variable from /etc/os-release. Change-Id: If7b507c30720516dc8dfd181170476f9ef003748
This commit is contained in:
parent
5972d7b0fa
commit
7f929bab96
@ -286,7 +286,7 @@ fi
|
|||||||
|
|
||||||
# Find out what platform we are on
|
# Find out what platform we are on
|
||||||
if [ -e /etc/os-release ]; then
|
if [ -e /etc/os-release ]; then
|
||||||
platform=$(head -1 /etc/os-release)
|
platform=$(cat /etc/os-release | grep ^NAME= | sed -e 's/\(NAME="\)\(.*\)\("\)/\2/g')
|
||||||
else
|
else
|
||||||
platform=$(head -1 /etc/system-release | grep -e CentOS -e 'Red Hat Enterprise Linux' || :)
|
platform=$(head -1 /etc/system-release | grep -e CentOS -e 'Red Hat Enterprise Linux' || :)
|
||||||
if [ -z "$platform" ]; then
|
if [ -z "$platform" ]; then
|
||||||
@ -295,7 +295,7 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$AMP_ROOTPW" ] && [ "$platform" != 'NAME="Ubuntu"' ]; then
|
if [[ "$AMP_ROOTPW" ]] && [[ "$platform" != 'Ubuntu' ]] && ! [[ "$platform" =~ "Debian" ]]; then
|
||||||
if [ "$(getenforce)" == "Enforcing" ]; then
|
if [ "$(getenforce)" == "Enforcing" ]; then
|
||||||
echo "A root password cannot be enabled for images built on this platform while SELinux is enabled."
|
echo "A root password cannot be enabled for images built on this platform while SELinux is enabled."
|
||||||
exit 1
|
exit 1
|
||||||
@ -307,7 +307,7 @@ if [ "$AMP_ROOTPW" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# Make sure we have the required packages installed
|
# Make sure we have the required packages installed
|
||||||
if [ "$platform" = 'NAME="Ubuntu"' ]; then
|
if [[ "$platform" = 'Ubuntu' || "$platform" =~ 'Debian' ]]; then
|
||||||
PKG_LIST="qemu-utils git kpartx debootstrap"
|
PKG_LIST="qemu-utils git kpartx debootstrap"
|
||||||
for pkg in $PKG_LIST; do
|
for pkg in $PKG_LIST; do
|
||||||
if ! dpkg --get-selections 2> /dev/null | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
|
if ! dpkg --get-selections 2> /dev/null | grep -q "^$pkg[[:space:]]*install$" >/dev/null; then
|
||||||
@ -317,6 +317,7 @@ if [ "$platform" = 'NAME="Ubuntu"' ]; then
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [[ "$platform" = 'Ubuntu' ]]; then
|
||||||
# Also check if we can build the BASEOS on this Ubuntu version
|
# Also check if we can build the BASEOS on this Ubuntu version
|
||||||
UBUNTU_VERSION=`lsb_release -r | awk '{print $2}'`
|
UBUNTU_VERSION=`lsb_release -r | awk '{print $2}'`
|
||||||
if [ "$AMP_BASEOS" != "ubuntu-minimal" ] && \
|
if [ "$AMP_BASEOS" != "ubuntu-minimal" ] && \
|
||||||
@ -325,6 +326,17 @@ if [ "$platform" = 'NAME="Ubuntu"' ]; then
|
|||||||
echo "Earlier versions don't support the extended attributes required."
|
echo "Earlier versions don't support the extended attributes required."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
# Check if we can build the BASEOS on this Debian version
|
||||||
|
DEBIAN_VERSION=`lsb_release -r | awk '{print $2}'`
|
||||||
|
# As minimal Ubuntu version is 14.04, for debian it is Debian 8 Jessie
|
||||||
|
if [ "$AMP_BASEOS" != "ubuntu-minimal" ] && \
|
||||||
|
[ 1 -eq $(echo "$DEBIAN_VERSION < 8" | bc) ]; then
|
||||||
|
echo "Debian minimum version 8 required to build $AMP_BASEOS."
|
||||||
|
echo "Earlier versions don't support the extended attributes required."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
elif [[ $platform =~ "SUSE" ]]; then
|
elif [[ $platform =~ "SUSE" ]]; then
|
||||||
# OpenSUSE
|
# OpenSUSE
|
||||||
# use rpm -q to check for qemu-tools and git-core
|
# use rpm -q to check for qemu-tools and git-core
|
||||||
|
Loading…
x
Reference in New Issue
Block a user