From 742c7817ba517aea9c6763598f7234bf26fdd6dd Mon Sep 17 00:00:00 2001 From: oliver Date: Sun, 3 May 2026 21:38:40 +0800 Subject: [PATCH 1/5] feat(os): enhance Deepin detection with os-version data Add a Deepin-specific enhancement in Linux OS detection that reads `/etc/os-version` for `MinorVersion` and `EditionName`. When available, it now: - sets `versionID` to `MinorVersion` - updates `prettyName` to include version and optional edition This improves Deepin version accuracy and provides a clearer OS name than relying solely on generic `os-release` fields.feat(os): enhance Deepin detection with os-version data Add a Deepin-specific enhancement in Linux OS detection that reads `/etc/os-version` for `MinorVersion` and `EditionName`. When available, it now: - sets `versionID` to `MinorVersion` - updates `prettyName` to include version and optional edition This improves Deepin version accuracy and provides a clearer OS name than relying solely on generic `os-release` fields. --- src/detection/os/os_linux.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 2c6fd47851..db0cc04066 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -306,6 +306,37 @@ static bool detectBedrock(FFOSResult* os) { return parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock/strata/bedrock/etc/os-release", os); } +static void detectDeepinEnhancement(FFOSResult* result) +{ + if (!ffStrbufEqualS(&result->id, "deepin")) + return; + + FFstrbuf minor = ffStrbufCreate(); + FFstrbuf edition = ffStrbufCreate(); + + ffParsePropFileValues( + FASTFETCH_TARGET_DIR_ETC "/os-version", + 2, + (FFpropquery[]) { + { "MinorVersion=", &minor }, + { "EditionName=", &edition }, + } + ); + + if (minor.length > 0) + { + ffStrbufSet(&result->versionID, &minor); + + if (edition.length > 0) + ffStrbufSetF(&result->prettyName, "Deepin %s (%s)", minor.chars, edition.chars); + else + ffStrbufSetF(&result->prettyName, "Deepin %s", minor.chars); + } + + ffStrbufDestroy(&minor); + ffStrbufDestroy(&edition); +} + static void detectOS(FFOSResult* os) { #ifdef FF_CUSTOM_OS_RELEASE_PATH parseOsRelease(FF_STR(FF_CUSTOM_OS_RELEASE_PATH), os); @@ -322,6 +353,7 @@ static void detectOS(FFOSResult* os) { // Refer: https://gist.github.com/natefoo/814c5bf936922dad97ff parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os); + detectDeepinEnhancement(os); if (os->id.length == 0 || os->version.length == 0 || os->prettyName.length == 0 || os->codename.length == 0) { parseLsbRelease(FASTFETCH_TARGET_DIR_ETC "/lsb-release", os); } From 180825673098ec7231643ceee50d39099c68cc03 Mon Sep 17 00:00:00 2001 From: oliver Date: Sun, 3 May 2026 21:40:07 +0800 Subject: [PATCH 2/5] fix(os): use distro name when formatting Deepin prettyName Update Deepin enhancement formatting to build `prettyName` from `result->name` instead of hardcoding "Deepin". This keeps output consistent with the detected distro name while still appending version and edition details.fix(os): use distro name when formatting Deepin prettyName Update Deepin enhancement formatting to build `prettyName` from `result->name` instead of hardcoding "Deepin". This keeps output consistent with the detected distro name while still appending version and edition details. --- src/detection/os/os_linux.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index db0cc04066..8246559ce6 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -328,9 +328,9 @@ static void detectDeepinEnhancement(FFOSResult* result) ffStrbufSet(&result->versionID, &minor); if (edition.length > 0) - ffStrbufSetF(&result->prettyName, "Deepin %s (%s)", minor.chars, edition.chars); + ffStrbufSetF(&result->prettyName, "%s %s (%s)", result->name.chars, minor.chars, edition.chars); else - ffStrbufSetF(&result->prettyName, "Deepin %s", minor.chars); + ffStrbufSetF(&result->prettyName, "%s %s", result->name.chars, minor.chars); } ffStrbufDestroy(&minor); From 8c16cf9785068e9f0bbeede12df678ed9bcfb452 Mon Sep 17 00:00:00 2001 From: oliver Date: Sun, 3 May 2026 21:44:59 +0800 Subject: [PATCH 3/5] fix(os/linux): guard Deepin minor version override MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Only apply Deepin’s `minor` value to `versionID` when an edition is present and `prettyName` does not already include parenthesized details. This avoids incorrectly overriding parsed version info in enhanced names.fix(os/linux): guard Deepin minor version override Only apply Deepin’s `minor` value to `versionID` when an edition is present and `prettyName` does not already include parenthesized details. This avoids incorrectly overriding parsed version info in enhanced names. Co-authored-by: Copilot --- src/detection/os/os_linux.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 8246559ce6..9c1a8e71fb 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -323,7 +323,7 @@ static void detectDeepinEnhancement(FFOSResult* result) } ); - if (minor.length > 0) + if (edition.length > 0 && !ffStrbufContainC(&result->prettyName, '(')) { ffStrbufSet(&result->versionID, &minor); From 15dde48087353ee4b2726717ca662b41dcd34638 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Mon, 4 May 2026 19:56:39 +0800 Subject: [PATCH 4/5] Refactor Deepin enhancement detection logic --- src/detection/os/os_linux.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 9c1a8e71fb..695bc90772 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -308,11 +308,8 @@ static bool detectBedrock(FFOSResult* os) { static void detectDeepinEnhancement(FFOSResult* result) { - if (!ffStrbufEqualS(&result->id, "deepin")) - return; - - FFstrbuf minor = ffStrbufCreate(); - FFstrbuf edition = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate(); + FF_STRBUF_AUTO_DESTROY edition = ffStrbufCreate(); ffParsePropFileValues( FASTFETCH_TARGET_DIR_ETC "/os-version", @@ -332,9 +329,6 @@ static void detectDeepinEnhancement(FFOSResult* result) else ffStrbufSetF(&result->prettyName, "%s %s", result->name.chars, minor.chars); } - - ffStrbufDestroy(&minor); - ffStrbufDestroy(&edition); } static void detectOS(FFOSResult* os) { @@ -353,7 +347,7 @@ static void detectOS(FFOSResult* os) { // Refer: https://gist.github.com/natefoo/814c5bf936922dad97ff parseOsRelease(FASTFETCH_TARGET_DIR_ETC "/os-release", os); - detectDeepinEnhancement(os); + if (os->id.length == 0 || os->version.length == 0 || os->prettyName.length == 0 || os->codename.length == 0) { parseLsbRelease(FASTFETCH_TARGET_DIR_ETC "/lsb-release", os); } @@ -392,6 +386,8 @@ void ffDetectOSImpl(FFOSResult* os) { ffStrbufSetS(&os->id, "lmde"); ffStrbufSetS(&os->idLike, "linuxmint"); } + } else if (ffStrbufEqualS(&result->id, "deepin")) { + detectDeepinEnhancement(&result); } #endif } From bbf5c318c3c3e38208544d39aeadf2811be13133 Mon Sep 17 00:00:00 2001 From: Carter Li Date: Mon, 4 May 2026 20:09:38 +0800 Subject: [PATCH 5/5] Refactor detectDeepinEnhancement function --- src/detection/os/os_linux.c | 44 +++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/detection/os/os_linux.c b/src/detection/os/os_linux.c index 695bc90772..b07bc3a2ec 100644 --- a/src/detection/os/os_linux.c +++ b/src/detection/os/os_linux.c @@ -95,8 +95,7 @@ FF_A_UNUSED static bool getUbuntuFlavour(FFOSResult* result) { } // xdgConfigDirs contains plasma only - if (ffPathExists("/var/lib/dpkg/info/ubuntustudio-desktop.list", FF_PATHTYPE_FILE)) - { + if (ffPathExists("/var/lib/dpkg/info/ubuntustudio-desktop.list", FF_PATHTYPE_FILE)) { ffStrbufSetStatic(&result->name, "Ubuntu Studio"); ffStrbufSetStatic(&result->id, "ubuntu-studio"); ffStrbufSetStatic(&result->idLike, "ubuntu"); @@ -306,28 +305,31 @@ static bool detectBedrock(FFOSResult* os) { return parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock/strata/bedrock/etc/os-release", os); } -static void detectDeepinEnhancement(FFOSResult* result) -{ +static void detectDeepinEnhancement(FFOSResult* result) { + if (ffStrbufContainC(&result->prettyName, '(')) { + return; + } + FF_STRBUF_AUTO_DESTROY minor = ffStrbufCreate(); FF_STRBUF_AUTO_DESTROY edition = ffStrbufCreate(); - ffParsePropFileValues( - FASTFETCH_TARGET_DIR_ETC "/os-version", - 2, - (FFpropquery[]) { - { "MinorVersion=", &minor }, - { "EditionName=", &edition }, - } - ); + if (!ffParsePropFileValues( + FASTFETCH_TARGET_DIR_ETC "/os-version", + 2, + (FFpropquery[]) { + { "MinorVersion=", &minor }, + { "EditionName=", &edition }, + }) || + minor.length == 0) { + return; + } - if (edition.length > 0 && !ffStrbufContainC(&result->prettyName, '(')) - { - ffStrbufSet(&result->versionID, &minor); + ffStrbufSet(&result->versionID, &minor); - if (edition.length > 0) - ffStrbufSetF(&result->prettyName, "%s %s (%s)", result->name.chars, minor.chars, edition.chars); - else - ffStrbufSetF(&result->prettyName, "%s %s", result->name.chars, minor.chars); + if (edition.length > 0) { + ffStrbufSetF(&result->prettyName, "%s %s (%s)", result->name.chars, minor.chars, edition.chars); + } else { + ffStrbufSetF(&result->prettyName, "%s %s", result->name.chars, minor.chars); } } @@ -386,8 +388,8 @@ void ffDetectOSImpl(FFOSResult* os) { ffStrbufSetS(&os->id, "lmde"); ffStrbufSetS(&os->idLike, "linuxmint"); } - } else if (ffStrbufEqualS(&result->id, "deepin")) { - detectDeepinEnhancement(&result); + } else if (ffStrbufEqualS(&os->id, "deepin")) { + detectDeepinEnhancement(os); } #endif }