예제 #1
0
 def matches(self, value):
     if self.compare == 'eq':
         return value == self.value
     if self.compare == 'lt':
         return AppStreamGlib.utils_vercmp(value, self.value) < 0
     if self.compare == 'le':
         return AppStreamGlib.utils_vercmp(value, self.value) <= 0
     if self.compare == 'gt':
         return AppStreamGlib.utils_vercmp(value, self.value) > 0
     if self.compare == 'ge':
         return AppStreamGlib.utils_vercmp(value, self.value) >= 0
     if self.compare == 'glob':
         return fnmatch.fnmatch(value, self.value)
     if self.compare == 'regex':
         return re.search(self.value, value)
     return False
예제 #2
0
def _user_agent_safe_for_requirement(user_agent):

    # very early versions of fwupd used 'fwupdmgr' as the user agent
    if user_agent == 'fwupdmgr':
        return False

    # gnome-software/3.26.5 (Linux x86_64 4.14.0) fwupd/1.0.4
    sections = user_agent.split(' ')
    for chunk in sections:
        toks = chunk.split('/')
        if len(toks) == 2 and toks[0] == 'fwupd':
            return AppStreamGlib.utils_vercmp(toks[1], '0.8.0') >= 0

    # this is a heuristic; the logic is that it's unlikely that a distro would
    # ship a very new gnome-software and a very old fwupd
    for chunk in sections:
        toks = chunk.split('/')
        if len(toks) == 2 and toks[0] == 'gnome-software':
            return AppStreamGlib.utils_vercmp(toks[1], '3.26.0') >= 0

    # is is probably okay
    return True