Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

convert dot-less CentOS versions to X.999 #1139

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,16 @@ def get_os_release(path):
try:
with open(path) as f:
data = dict(l.strip().split('=', 1) for l in f.readlines() if '=' in l)
release_id = data.get('ID', '').strip('"')
version_id = data.get('VERSION_ID', '').strip('"')
if release_id == 'centos' and '.' not in version_id:
version_id = "{}.999".format(version_id)
Copy link
Member

@fernflower fernflower Nov 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not too happy about 999 magic constant tbh :(
Is there a universe where version_id doesn't have 999 and leapp is still happy?

return OSRelease(
release_id=data.get('ID', '').strip('"'),
release_id=release_id,
name=data.get('NAME', '').strip('"'),
pretty_name=data.get('PRETTY_NAME', '').strip('"'),
version=data.get('VERSION', '').strip('"'),
version_id=data.get('VERSION_ID', '').strip('"'),
version_id=version_id,
variant=data.get('VARIANT', '').strip('"') or None,
variant_id=data.get('VARIANT_ID', '').strip('"') or None
)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
NAME="CentOS Stream"
VERSION="8"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="8"
PLATFORM_ID="platform:el8"
PRETTY_NAME="CentOS Stream 8"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:8"
HOME_URL="https://centos.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_SUPPORT_PRODUCT_VERSION="CentOS Stream"
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ def test_get_os_release_info(monkeypatch):
ipuworkflowconfig.get_os_release(os.path.join(CUR_DIR, 'files/non-existent-file'))


def test_get_os_release_info_centos_stream(monkeypatch):
expected = OSRelease(
release_id='centos',
name='CentOS Stream',
pretty_name='CentOS Stream 8',
version='8',
version_id='8.999'
)
assert expected == ipuworkflowconfig.get_os_release(os.path.join(CUR_DIR, 'files/os-release-stream8'))


def test_get_booted_kernel(monkeypatch):
monkeypatch.setattr(ipuworkflowconfig, 'run', lambda x: {'stdout': '4.14.0-100.8.2.el7a.x86_64\n'})
assert ipuworkflowconfig.get_booted_kernel() == '4.14.0-100.8.2.el7a.x86_64'
Expand Down
Loading