1
0
mirror of https://github.com/ARM-software/devlib.git synced 2025-01-31 02:00:45 +00:00

Merge pull request #90 from derkling/improve-kversion-parsing

target: better parse kernel version numbers
This commit is contained in:
setrofim 2017-02-20 16:08:47 +00:00 committed by GitHub
commit e968901fe6

View File

@ -26,6 +26,9 @@ ANDROID_SCREEN_RESOLUTION_REGEX = re.compile(r'mUnrestrictedScreen=\(\d+,\d+\)'
r'\s+(?P<width>\d+)x(?P<height>\d+)')
DEFAULT_SHELL_PROMPT = re.compile(r'^.*(shell|root)@.*:/\S* [#$] ',
re.MULTILINE)
KVERSION_REGEX =re.compile(
r'(?P<version>\d+)(\.(?P<major>\d+)(\.(?P<minor>\d+)(-(rc)?(?P<rc>\d+))?)?)?(.*-g(?P<sha1>[0-9a-fA-F]{7,}))?'
)
class Target(object):
@ -1199,6 +1202,19 @@ class KernelVersion(object):
self.release = version_string
self.version = ''
self.version_number = None
self.major = None
self.minor = None
self.sha1 = None
self.rc = None
match = KVERSION_REGEX.match(version_string)
if match:
self.version_number = match.group('version')
self.major = match.group('major')
self.minor = match.group('minor')
self.sha1 = match.group('sha1')
self.rc = match.group('rc')
def __str__(self):
return '{} {}'.format(self.release, self.version)