@@ -46,13 +46,33 @@ static bool parseOsRelease(const char* fileName, FFOSResult* result)
4646 });
4747}
4848
49+ // Common logic for detecting Armbian image version
50+ FF_MAYBE_UNUSED static bool detectArmbianVersion (FFOSResult * result )
51+ {
52+ if (ffStrbufStartsWithS (& result -> prettyName , "Armbian " )) // Official Armbian release images
53+ ffStrbufSetS (& result -> name , "Armbian" );
54+ else if (ffStrbufStartsWithS (& result -> prettyName , "Armbian-unofficial " )) // Unofficial Armbian image built from source
55+ ffStrbufSetS (& result -> name , "Armbian (custom build)" );
56+ else
57+ return false;
58+ ffStrbufSet (& result -> idLike , & result -> id );
59+ ffStrbufSetS (& result -> id , "armbian" );
60+ ffStrbufClear (& result -> versionID );
61+ uint32_t versionStart = ffStrbufFirstIndexC (& result -> prettyName , ' ' ) + 1 ;
62+ uint32_t versionEnd = ffStrbufNextIndexC (& result -> prettyName , versionStart , ' ' );
63+ ffStrbufSetNS (& result -> versionID , versionEnd - versionStart , result -> prettyName .chars + versionStart );
64+ return true;
65+ }
66+
4967FF_MAYBE_UNUSED static void getUbuntuFlavour (FFOSResult * result )
5068{
5169 const char * xdgConfigDirs = getenv ("XDG_CONFIG_DIRS" );
5270 if (!ffStrSet (xdgConfigDirs ))
5371 return ;
5472
55- if (ffStrbufStartsWithS (& result -> prettyName , "Linux Lite " ))
73+ if (detectArmbianVersion (result ))
74+ return ;
75+ else if (ffStrbufStartsWithS (& result -> prettyName , "Linux Lite " ))
5676 {
5777 ffStrbufSetS (& result -> name , "Linux Lite" );
5878 ffStrbufSetS (& result -> id , "linuxlite" );
@@ -164,28 +184,8 @@ FF_MAYBE_UNUSED static void getDebianVersion(FFOSResult* result)
164184
165185FF_MAYBE_UNUSED static bool detectDebianDerived (FFOSResult * result )
166186{
167- if (ffStrbufStartsWithS (& result -> prettyName , "Armbian " )) // Armbian 24.2.1 bookworm
168- {
169- ffStrbufSetS (& result -> name , "Armbian" );
170- ffStrbufSetS (& result -> id , "armbian" );
171- ffStrbufSetS (& result -> idLike , "debian" );
172- ffStrbufClear (& result -> versionID );
173- uint32_t versionStart = ffStrbufFirstIndexC (& result -> prettyName , ' ' ) + 1 ;
174- uint32_t versionEnd = ffStrbufNextIndexC (& result -> prettyName , versionStart , ' ' );
175- ffStrbufSetNS (& result -> versionID , versionEnd - versionStart , result -> prettyName .chars + versionStart );
176- return true;
177- }
178- else if (ffStrbufStartsWithS (& result -> prettyName , "Armbian-unofficial " )) // Unofficial Armbian image built from source
179- {
180- ffStrbufSetS (& result -> name , "Armbian (custom build)" );
181- ffStrbufSetS (& result -> id , "armbian" );
182- ffStrbufSetS (& result -> idLike , "debian" );
183- ffStrbufClear (& result -> versionID );
184- uint32_t versionStart = ffStrbufFirstIndexC (& result -> prettyName , ' ' ) + 1 ;
185- uint32_t versionEnd = ffStrbufNextIndexC (& result -> prettyName , versionStart , ' ' );
186- ffStrbufSetNS (& result -> versionID , versionEnd - versionStart , result -> prettyName .chars + versionStart );
187+ if (detectArmbianVersion (result ))
187188 return true;
188- }
189189 else if (ffStrbufStartsWithS (& result -> name , "Loc-OS" ))
190190 {
191191 ffStrbufSetS (& result -> id , "locos" );
0 commit comments