add regex check in def

This commit is contained in:
Louis Abel 2023-10-02 21:13:09 -07:00
parent 6f5b1f59ac
commit dadc382dae
Signed by: label
GPG Key ID: B37E62D143879B36

View File

@ -89,6 +89,10 @@ def set_releasever(releasever):
""" """
Sets a release version Sets a release version
""" """
check_for_rel = re.search(regex, releasever)
if not check_for_rel:
print(f'Release version does not conform to X.Y or it does not start with {dist}')
sys.exit(1)
print(f'Setting releasever to {releasever}') print(f'Setting releasever to {releasever}')
with open('/etc/dnf/vars/releasever', 'w') as f: with open('/etc/dnf/vars/releasever', 'w') as f:
f.write(releasever) f.write(releasever)
@ -138,12 +142,12 @@ def repoutil(results):
if results.use_baseurl and results.use_mirrorlist: if results.use_baseurl and results.use_mirrorlist:
print('You cannot set both baseurl and mirrorlist.') print('You cannot set both baseurl and mirrorlist.')
sys.exit(1) sys.exit(1)
if results.use_baseurl: if results.use_baseurl:
switch_to_baseurl() switch_to_baseurl()
elif results.use_mirrorlist: elif results.use_mirrorlist:
switch_to_mirrorlist() switch_to_mirrorlist()
if len(results.releasever) > 0: if len(results.releasever) > 0:
set_releasever(results.releasever) set_releasever(results.releasever)