make scylla_util OS detection robust against empty lines

Newer versions of RHEL ship the os-release file with newlines in the
end, which our script was not prepared to handle. As such, scylla_setup
would fail.

This patch makes our OS detection robust against that.

Fixes #4473

Branches: master, branch-3.1
Signed-off-by: Glauber Costa <glauber@scylladb.com>
Message-Id: <20190502152224.31307-1-glauber@scylladb.com>
(cherry picked from commit 99c00547ad)
This commit is contained in:
Glauber Costa
2019-05-02 11:22:24 -04:00
committed by Pekka Enberg
parent a45b6e41a0
commit 178fb5fe5f

View File

@@ -304,7 +304,7 @@ def parse_os_release_line(line):
val = shlex.split(data)[0]
return (id, val.split(' ') if id == 'ID' or id == 'ID_LIKE' else val)
os_release = dict([parse_os_release_line(x) for x in open('/etc/os-release').read().splitlines()])
os_release = dict([parse_os_release_line(x) for x in open('/etc/os-release').read().splitlines() if re.match(r'\w+=', x) ])
def is_debian_variant():
d = os_release['ID_LIKE'] if 'ID_LIKE' in os_release else os_release['ID']