mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-24 15:11:19 +02:00
Fix versioning logic in ctest to get the correct latest version.
Change-Id: I2721bcd2da38b764ebe21dfb8fe7a39dd947075c BUG=8500 TEST=Ran it against all boards Review URL: http://codereview.chromium.org/4235001
This commit is contained in:
parent
6203601529
commit
b4b09d40a7
16
bin/ctest.py
16
bin/ctest.py
@ -93,6 +93,19 @@ def ModifyBootDesc(download_folder, redirect_file=None):
|
||||
fileinput.close()
|
||||
|
||||
|
||||
def _GreaterVersion(version_a, version_b):
|
||||
"""Returns the higher version number of two version number strings."""
|
||||
version_regex = re.compile('.*(\d+)\.(\d+)\.(\d+)\.(\d+).*')
|
||||
version_a_tokens = version_regex.match(version_a).groups()
|
||||
version_b_tokens = version_regex.match(version_b).groups()
|
||||
for i in range(4):
|
||||
(a, b) = (int(version_a_tokens[i]), int(version_b_tokens[i]))
|
||||
if a != b:
|
||||
if a > b: return version_a
|
||||
return version_b
|
||||
return version_a
|
||||
|
||||
|
||||
def GetLatestLinkFromPage(url, regex):
|
||||
"""Returns the latest link from the given url that matches regex.
|
||||
|
||||
@ -102,12 +115,13 @@ def GetLatestLinkFromPage(url, regex):
|
||||
"""
|
||||
url_file = urllib.urlopen(url)
|
||||
url_html = url_file.read()
|
||||
|
||||
url_file.close()
|
||||
|
||||
# Parses links with versions embedded.
|
||||
url_parser = HTMLDirectoryParser(regex=regex)
|
||||
url_parser.feed(url_html)
|
||||
return max(url_parser.link_list)
|
||||
return reduce(_GreaterVersion, url_parser.link_list)
|
||||
|
||||
|
||||
def GetNewestLinkFromZipBase(board, channel, zip_server_base):
|
||||
|
Loading…
x
Reference in New Issue
Block a user