in daisy_workflows/image_import/inspection/src/boot_inspect/inspectors/os/linux.py [0:0]
def match(
self,
fs: boot_inspect.system.filesystems.Filesystem) -> inspect_pb2.OsRelease:
"""Returns the OperatingSystem that is identified."""
etc_os_rel = {}
if fs.is_file('/etc/os-release'):
etc_os_rel = _parse_config_file(fs.read_utf8('/etc/os-release'))
if 'ID' in etc_os_rel or 'NAME' in etc_os_rel:
if 'ID' in etc_os_rel:
matches = self._name_matcher.fullmatch(etc_os_rel['ID']) is not None
if 'NAME' in etc_os_rel:
matches |= self._name_matcher.fullmatch(etc_os_rel['NAME']) is not None
if self._fs_predicate:
matches &= self._fs_predicate.matches(fs)
elif self._fs_predicate:
matches = self._fs_predicate.matches(fs)
else:
matches = False
if matches:
version = self._get_version(etc_os_rel, fs)
return inspect_pb2.OsRelease(
major_version=version.major,
minor_version=version.minor,
distro_id=self.distro,
)