Do a better job of identifying CentOS 6

Since DIB creates a chroot but doesn't actually chroot in an
extra-data script, look for /etc/redhat-release relative to the
temporary chroot base path. Also given that the centos element
leaves DIB_RELEASE exported as am empty string in the calling
environment rather than unset, place it first in the conditional
list.

Change-Id: I0a51f88ff5ea71b6aa6e6406b656cefb0e135e88
This commit is contained in:
Jeremy Stanley 2015-05-04 04:19:31 +00:00
parent 08dc5cf613
commit 6a8f64190d
1 changed files with 8 additions and 6 deletions

View File

@ -20,20 +20,25 @@ import os
import subprocess
import sys
TMP_MOUNT_PATH = os.environ['TMP_MOUNT_PATH']
TMP_HOOKS_PATH = os.environ['TMP_HOOKS_PATH']
# this is a bit weird; we want to get the filter to use on the
# devstack lib/[apt|rpm] files to pre-install them. So we have to
# swizzle things around
RELEASE=None
if 'DIB_RELEASE' in os.environ:
RELEASE=os.environ['DIB_RELEASE']
try:
if open('/etc/redhat-release').read().startswith('CentOS release 6'):
if open(os.path.join(
TMP_MOUNT_PATH,
'etc/redhat-release')).read().startswith('CentOS release 6'):
# not actually used in devstack, but for consistency and because this
# script will error if run on a platform where RELEASE isn't detected
# as something
RELEASE='rhel6'
except IOError:
pass
if 'DIB_RELEASE' in os.environ:
RELEASE=os.environ['DIB_RELEASE']
if 'DISTRO_NAME' in os.environ:
if os.environ['DISTRO_NAME'] == 'centos7':
# centos7 matches as rhel7 in devstack
@ -42,9 +47,6 @@ if not RELEASE:
print "Can not determine RELEASE"
sys.exit(1)
TMP_MOUNT_PATH = os.environ['TMP_MOUNT_PATH']
TMP_HOOKS_PATH = os.environ['TMP_HOOKS_PATH']
DEVSTACK = os.path.join(TMP_MOUNT_PATH, 'opt/git/openstack-dev/devstack')
CACHEDIR = os.path.join(TMP_MOUNT_PATH, 'tmp')
IMAGES=os.path.join(TMP_HOOKS_PATH, 'source-repository-images')