Skip to content

Commit ed18839

Browse files
committed
OS (Linux): detect DietPi
Fix #1816
1 parent 049701a commit ed18839

File tree

1 file changed

+24
-5
lines changed

1 file changed

+24
-5
lines changed

src/detection/os/os_linux.c

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -233,12 +233,31 @@ FF_MAYBE_UNUSED static bool detectDebianDerived(FFOSResult* result)
233233
}
234234
else if (ffStrbufContainS(&instance.state.platform.sysinfo.release, "+rpt-rpi-"))
235235
{
236-
// Raspberry Pi OS
237-
ffStrbufSetS(&result->id, "raspbian");
238236
ffStrbufSetS(&result->idLike, "debian");
239-
ffStrbufSetS(&result->name, "Raspberry Pi OS");
240-
ffStrbufSetS(&result->prettyName, "Raspberry Pi OS");
241-
return true;
237+
if (ffPathExists("/boot/dietpi/.version", FF_PATHTYPE_FILE))
238+
{
239+
// DietPi
240+
ffStrbufSetS(&result->id, "dietpi");
241+
ffStrbufSetS(&result->name, "DietPi");
242+
ffStrbufClear(&result->version);
243+
FF_STRBUF_AUTO_DESTROY sub = ffStrbufCreate();
244+
FF_STRBUF_AUTO_DESTROY rc = ffStrbufCreate();
245+
if (ffParsePropFileValues("/boot/dietpi/.version", 3, (FFpropquery[]) {
246+
{"G_DIETPI_VERSION_CORE=", &result->version},
247+
{"G_DIETPI_VERSION_SUB=", &sub},
248+
{"G_DIETPI_VERSION_RC=", &rc},
249+
})) ffStrbufAppendF(&result->version, ".%s.%s", sub.chars, rc.chars);
250+
ffStrbufSet(&result->versionID, &result->version);
251+
ffStrbufSetF(&result->prettyName, "DietPi %s", result->version.chars);
252+
}
253+
else
254+
{
255+
// Raspberry Pi OS
256+
ffStrbufSetS(&result->id, "raspbian");
257+
ffStrbufSetS(&result->name, "Raspberry Pi OS");
258+
ffStrbufSetS(&result->prettyName, "Raspberry Pi OS");
259+
return true;
260+
}
242261
}
243262
else if (ffStrbufEndsWithS(&instance.state.platform.sysinfo.release, "+truenas"))
244263
{

0 commit comments

Comments
 (0)