OS (Linux): Prioritize lsb-release over os-release

Fix #847
This commit is contained in:
李通洲
2024-05-03 09:47:55 +08:00
committed by 李通洲
parent 82285ebeb4
commit c4a876f6aa
2 changed files with 33 additions and 38 deletions
+8 -9
View File
@@ -12,6 +12,7 @@ static inline bool allRelevantValuesSet(const FFOSResult* result)
return result->id.length > 0
&& result->name.length > 0
&& result->prettyName.length > 0
&& result->version.length > 0
;
}
@@ -150,22 +151,20 @@ static void detectOS(FFOSResult* os)
if(os->prettyName.length == 0)
ffStrbufAppendS(&os->prettyName, "Bedrock Linux");
parseFile("/bedrock"FASTFETCH_TARGET_DIR_ETC"/os-release", os);
if(allRelevantValuesSet(os))
if(parseFile("/bedrock"FASTFETCH_TARGET_DIR_ETC"/os-release", os) && allRelevantValuesSet(os))
return;
}
parseFile(FASTFETCH_TARGET_DIR_ETC"/os-release", os);
if(allRelevantValuesSet(os))
// Seems some distros contain real distro name only in lsb-release
// https://github.com/fastfetch-cli/fastfetch/issues/847#issuecomment-2091999419
if(parseFile(FASTFETCH_TARGET_DIR_ETC"/lsb-release", os) && allRelevantValuesSet(os))
return;
if(parseFile(FASTFETCH_TARGET_DIR_ETC"/os-release", os) && allRelevantValuesSet(os))
return;
parseFile(FASTFETCH_TARGET_DIR_USR"/lib/os-release", os);
if(allRelevantValuesSet(os))
return;
parseFile(FASTFETCH_TARGET_DIR_ETC"/lsb-release", os);
}
void ffDetectOSImpl(FFOSResult* os)