Skip to content

Commit

Permalink
issue #17: fixing the regex for base repos and doing version compares
Browse files Browse the repository at this point in the history
  • Loading branch information
doccaz committed Sep 23, 2021
1 parent 4facb37 commit e20ca18
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions vercheck.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,15 @@ def search_package(self, product_id, package_name):
print('could not find any version for package ' + package_name)
return

def is_newer(self, version_one, version_two):
result = False
try:
v1 = LooseVersion(str(version_one))
v2 = LooseVersion(str(version_two))
result = v1.__gt__(v2)
except TypeError as e:
print('error comparing: %s and %s (%s and %s)' % (version_one, version_two, str(v1.version), str(v2.version)))
return result

def check_supportconfig(self, supportconfigdir):

Expand All @@ -358,7 +367,7 @@ def check_supportconfig(self, supportconfigdir):
if match_os != -1 and match_arch != "unknown":
print('product name = ' + self.product_list[match_os]['name'] + ' (id ' + str(match_os) + ', ' + match_arch + ')')
selected_product_id = match_os
base_regex = r"Basesystem.*" # primary repositories for trusted updates should have this regex
base_regex = r"(SUSE Linux Enterprise.*|Basesystem.*)" # primary repositories for trusted updates should have this regex
if match_suma != -1:
print('found ' + self.suma_product_list[match_suma]['name'] + ', will use alternate id ' + str(match_suma))
selected_product_id = match_suma
Expand Down Expand Up @@ -407,7 +416,7 @@ def check_supportconfig(self, supportconfigdir):
else:
latest = None
for item in refined_data['results']:
if re.match(base_regex, item['repository']) is not None:
if re.match(base_regex, item['repository']) is not None and self.is_newer(item['version'] + '-' + item['release'], refined_data['supplied_version']):
if self.verbose:
print('---> found version %s-%s for package %s in repository %s which is a base repository, ignoring the rest' % (item['version'], item['release'], refined_data['query'], item['repository']))
latest = item['version'] + '-' + item['release']
Expand Down

0 comments on commit e20ca18

Please sign in to comment.