Skip to content

Commit 3e24cdc

Browse files
committed
CMake: add option CUSTOM_OS_RELEASE_PATH
And remove `--os-file`
1 parent dc9c285 commit 3e24cdc

File tree

5 files changed

+13
-20
lines changed

5 files changed

+13
-20
lines changed

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ option(IS_MUSL "Build with musl libc" OFF) # Used by Github Actions
8080
if (LINUX)
8181
set(CUSTOM_PCI_IDS_PATH "" CACHE STRING "Custom path to file pci.ids, defaults to `/usr/share/hwdata/pci.ids`")
8282
set(CUSTOM_AMDGPU_IDS_PATH "" CACHE STRING "Custom path to file amdgpu.ids, defaults to `/usr/share/libdrm/amdgpu.ids`")
83+
set(CUSTOM_OS_RELEASE_PATH "" CACHE STRING "Custom path to file os-release, defaults to `/etc/os-release`")
8384
endif()
8485

8586
####################
@@ -789,6 +790,10 @@ if(NOT "${CUSTOM_AMDGPU_IDS_PATH}" STREQUAL "")
789790
message(STATUS "Custom file path of amdgpu.ids: ${CUSTOM_AMDGPU_IDS_PATH}")
790791
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_AMDGPU_IDS_PATH=${CUSTOM_AMDGPU_IDS_PATH})
791792
endif()
793+
if(NOT "${CUSTOM_OS_RELEASE_PATH}" STREQUAL "")
794+
message(STATUS "Custom file path of os_release: ${CUSTOM_OS_RELEASE_PATH}")
795+
target_compile_definitions(libfastfetch PRIVATE FF_CUSTOM_OS_RELEASE_PATH=${CUSTOM_OS_RELEASE_PATH})
796+
endif()
792797

793798
function(ff_lib_enable VARNAME PKGCONFIG_NAMES CMAKE_NAME)
794799
if(NOT ENABLE_${VARNAME})

doc/json_schema.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -294,10 +294,6 @@
294294
"type": "string",
295295
"description": "The name of the player to use for module Media and Player. Linux only"
296296
},
297-
"osFile": {
298-
"type": "string",
299-
"description": "Set the path to the file containing OS information. Linux only"
300-
},
301297
"dsForceDrm": {
302298
"description": "Force display detection to use DRM. Linux only",
303299
"oneOf": [

src/detection/os/os_linux.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
#include <string.h>
88
#include <stdlib.h>
99

10+
#define FF_STR_INDIR(x) #x
11+
#define FF_STR(x) FF_STR_INDIR(x)
12+
1013
static inline bool allRelevantValuesSet(const FFOSResult* result)
1114
{
1215
return result->id.length > 0
@@ -141,12 +144,11 @@ static void getDebianVersion(FFOSResult* result)
141144

142145
static void detectOS(FFOSResult* os)
143146
{
144-
if(instance.config.general.osFile.length > 0)
145-
{
146-
parseLsbRelease(instance.config.general.osFile.chars, os);
147-
parseOsRelease(instance.config.general.osFile.chars, os);
148-
return;
149-
}
147+
#ifdef FF_CUSTOM_OS_RELEASE_PATH
148+
parseOsRelease(FF_STR(FF_CUSTOM_OS_RELEASE_PATH), os);
149+
parseLsbRelease(FF_STR(FF_CUSTOM_OS_RELEASE_PATH), os);
150+
return;
151+
#endif
150152

151153
if(instance.config.general.escapeBedrock && parseOsRelease(FASTFETCH_TARGET_DIR_ROOT "/bedrock" FASTFETCH_TARGET_DIR_ETC "/bedrock-release", os))
152154
{

src/options/general.c

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@ const char* ffOptionsParseGeneralJsonConfig(FFOptionsGeneral* options, yyjson_va
2727
options->escapeBedrock = yyjson_get_bool(val);
2828
else if (ffStrEqualsIgnCase(key, "playerName"))
2929
ffStrbufSetS(&options->playerName, yyjson_get_str(val));
30-
else if (ffStrEqualsIgnCase(key, "osFile"))
31-
ffStrbufSetS(&options->osFile, yyjson_get_str(val));
3230
else if (ffStrEqualsIgnCase(key, "dsForceDrm"))
3331
{
3432
if (yyjson_is_str(val))
@@ -79,8 +77,6 @@ bool ffOptionsParseGeneralCommandLine(FFOptionsGeneral* options, const char* key
7977
options->escapeBedrock = ffOptionParseBoolean(value);
8078
else if(ffStrEqualsIgnCase(key, "--player-name"))
8179
ffOptionParseString(key, value, &options->playerName);
82-
else if (ffStrEqualsIgnCase(key, "--os-file"))
83-
ffOptionParseString(key, value, &options->osFile);
8480
else if(ffStrEqualsIgnCase(key, "--ds-force-drm"))
8581
{
8682
if (ffOptionParseBoolean(value))
@@ -109,7 +105,6 @@ void ffOptionsInitGeneral(FFOptionsGeneral* options)
109105
#if defined(__linux__) || defined(__FreeBSD__)
110106
options->escapeBedrock = true;
111107
ffStrbufInit(&options->playerName);
112-
ffStrbufInit(&options->osFile);
113108
options->dsForceDrm = FF_DS_FORCE_DRM_TYPE_FALSE;
114109
#elif defined(_WIN32)
115110
options->wmiTimeout = 5000;
@@ -120,7 +115,6 @@ void ffOptionsDestroyGeneral(FF_MAYBE_UNUSED FFOptionsGeneral* options)
120115
{
121116
#if defined(__linux__) || defined(__FreeBSD__)
122117
ffStrbufDestroy(&options->playerName);
123-
ffStrbufDestroy(&options->osFile);
124118
#endif
125119
}
126120

@@ -145,9 +139,6 @@ void ffOptionsGenerateGeneralJsonConfig(FFOptionsGeneral* options, yyjson_mut_do
145139
if (!ffStrbufEqual(&options->playerName, &defaultOptions.playerName))
146140
yyjson_mut_obj_add_strbuf(doc, obj, "playerName", &options->playerName);
147141

148-
if (!ffStrbufEqual(&options->osFile, &defaultOptions.osFile))
149-
yyjson_mut_obj_add_strbuf(doc, obj, "osFile", &options->osFile);
150-
151142
if (options->dsForceDrm != defaultOptions.dsForceDrm)
152143
{
153144
switch (options->dsForceDrm)

src/options/general.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ typedef struct FFOptionsGeneral
1717
// Module options that cannot be put in module option structure
1818
#if defined(__linux__) || defined(__FreeBSD__)
1919
FFstrbuf playerName;
20-
FFstrbuf osFile;
2120
bool escapeBedrock;
2221
FFDsForceDrmType dsForceDrm;
2322
#elif defined(_WIN32)

0 commit comments

Comments
 (0)