From 0e230642c5401b6a533a4080f9dddb338109daae Mon Sep 17 00:00:00 2001
From: Ian Wienand <iwienand@redhat.com>
Date: Wed, 25 Sep 2019 01:22:08 +0000
Subject: [PATCH] dib-python : handle centos 8

Match on centos 8 and use the inbuilt system python like on RHEL

Change-Id: I81d94481422b4982777160f736dcf463e2fc45d0
---
 .../elements/dib-python/environment.d/50-dib-python-version   | 4 +---
 .../elements/dib-python/pre-install.d/01-dib-python           | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/diskimage_builder/elements/dib-python/environment.d/50-dib-python-version b/diskimage_builder/elements/dib-python/environment.d/50-dib-python-version
index 0c957ed07..b51b360f0 100644
--- a/diskimage_builder/elements/dib-python/environment.d/50-dib-python-version
+++ b/diskimage_builder/elements/dib-python/environment.d/50-dib-python-version
@@ -10,14 +10,12 @@ if [ -z "${DIB_PYTHON_VERSION:-}" ]; then
         if [ "$DIB_RELEASE" -le 22 ]; then
             DIB_PYTHON_VERSION=2
         fi
-    elif [ "$DISTRO_NAME" == "centos" ]; then
-        DIB_PYTHON_VERSION=2
     elif [ "$DISTRO_NAME" == "centos7" ]; then
         DIB_PYTHON_VERSION=2
     elif [ "$DISTRO_NAME" == "rhel7" ]; then
         # TODO(nmagnezi): Remove this when the 'rhel7' element gets replaced by 'rhel'
         DIB_PYTHON_VERSION=2
-    elif [ "$DISTRO_NAME" == "rhel" ]; then
+    elif [[ "$DISTRO_NAME" =~ (rhel|centos) ]]; then
         if [ "$DIB_RELEASE" -le 7 ]; then
             DIB_PYTHON_VERSION=2
         elif [ "$DIB_RELEASE" -ge 8 ]; then
diff --git a/diskimage_builder/elements/dib-python/pre-install.d/01-dib-python b/diskimage_builder/elements/dib-python/pre-install.d/01-dib-python
index 3120fcd89..8142547dc 100755
--- a/diskimage_builder/elements/dib-python/pre-install.d/01-dib-python
+++ b/diskimage_builder/elements/dib-python/pre-install.d/01-dib-python
@@ -6,7 +6,7 @@ fi
 set -eu
 set -o pipefail
 
-if [[ ${DISTRO_NAME} == "rhel" && ${DIB_RELEASE} == 8 ]]; then
+if [[ ${DISTRO_NAME} =~ (centos|rhel) && ${DIB_RELEASE} == 8 ]]; then
     # RHEL8 has a system python, separate from the user python.  What
     # a good idea, abstracting the python binary for system scripts!
     # :)  Use it for dib-python.