systeminfo: log system package versions (#11946)
This commit is contained in:
parent
73f06434a4
commit
02cda6bebf
4 changed files with 60 additions and 5 deletions
|
|
@ -929,3 +929,41 @@ std::string deviceNameToInternalString(std::string in) {
|
|||
std::ranges::transform(in, in.begin(), ::tolower);
|
||||
return in;
|
||||
}
|
||||
|
||||
static const std::vector<const char*> PKGCONF_PATHS = {"/usr/lib/pkgconfig", "/usr/local/lib/pkgconfig"};
|
||||
|
||||
//
|
||||
std::string getSystemLibraryVersion(const std::string& name) {
|
||||
for (const auto& pkgconf : PKGCONF_PATHS) {
|
||||
std::error_code ec;
|
||||
const std::string PATH = std::string{pkgconf} + "/" + name + ".pc";
|
||||
if (!std::filesystem::exists(PATH, ec))
|
||||
continue;
|
||||
|
||||
const auto DATA = NFsUtils::readFileAsString(PATH);
|
||||
|
||||
if (!DATA)
|
||||
continue;
|
||||
|
||||
size_t versionAt = DATA->find("\nVersion: ");
|
||||
size_t versionAtEnd = DATA->find("\n", versionAt + 11);
|
||||
|
||||
if (versionAt == std::string::npos)
|
||||
continue;
|
||||
|
||||
versionAt += 10;
|
||||
|
||||
return DATA->substr(versionAt, versionAtEnd == std::string::npos ? std::string::npos : versionAtEnd - versionAt);
|
||||
}
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
std::string getBuiltSystemLibraryNames() {
|
||||
std::string result = "Libraries:\n";
|
||||
result += std::format("Hyprgraphics: built against {}, system has {}\n", HYPRGRAPHICS_VERSION, getSystemLibraryVersion("hyprgraphics"));
|
||||
result += std::format("Hyprutils: built against {}, system has {}\n", HYPRUTILS_VERSION, getSystemLibraryVersion("hyprutils"));
|
||||
result += std::format("Hyprcursor: built against {}, system has {}\n", HYPRCURSOR_VERSION, getSystemLibraryVersion("hyprcursor"));
|
||||
result += std::format("Hyprlang: built against {}, system has {}\n", HYPRLANG_VERSION, getSystemLibraryVersion("hyprlang"));
|
||||
result += std::format("Aquamarine: built against {}, system has {}\n", AQUAMARINE_VERSION, getSystemLibraryVersion("aquamarine"));
|
||||
return result;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,6 +43,8 @@ bool isNvidiaDriverVersionAtLeast(int thresho
|
|||
std::expected<std::string, std::string> binaryNameForWlClient(wl_client* client);
|
||||
std::expected<std::string, std::string> binaryNameForPid(pid_t pid);
|
||||
std::string deviceNameToInternalString(std::string in);
|
||||
std::string getSystemLibraryVersion(const std::string& name);
|
||||
std::string getBuiltSystemLibraryNames();
|
||||
|
||||
template <typename... Args>
|
||||
[[deprecated("use std::format instead")]] std::string getFormat(std::format_string<Args...> fmt, Args&&... args) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue