Skip to content

Commit

Permalink
Add: map arch to canonical name
Browse files Browse the repository at this point in the history
  • Loading branch information
dnzbk committed Jun 28, 2024
1 parent afd1654 commit e2f8760
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
23 changes: 21 additions & 2 deletions daemon/system/CPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,25 @@ namespace SystemInfo
return m_arch;
}

std::string CPU::GetCanonicalCPUArch(const std::string& arch) const
{
if (arch == "i386" || arch == "x86")
return "i686";

if (arch == "amd64" || arch == "AMD64")
return "x86_64";

if (arch.find("armv5") != std::string::npos ||
arch.find("armv6") != std::string::npos)
return "armel";

if (arch.find("armv7") != std::string::npos ||
arch.find("armv8") != std::string::npos)
return "armhf";

return arch;
}

#ifdef WIN32
void CPU::Init()
{
Expand Down Expand Up @@ -100,7 +119,7 @@ namespace SystemInfo
{
std::string arch{ buffer };
Util::Trim(arch);
return arch;
return GetCanonicalCPUArch(arch);
}

return std::nullopt;
Expand Down Expand Up @@ -240,7 +259,7 @@ namespace SystemInfo
return std::nullopt;
}

return res.value();
return GetCanonicalCPUArch(res.value());
}
#endif
}
1 change: 1 addition & 0 deletions daemon/system/CPU.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ namespace SystemInfo
void Init();
std::optional<std::string> GetCPUArch() const;
std::optional<std::string> GetCPUModel() const;
std::string GetCanonicalCPUArch(const std::string& arch) const;

#ifndef WIN32
std::optional<std::string> GetCPUModelFromCPUInfo() const;
Expand Down

0 comments on commit e2f8760

Please sign in to comment.