55 lines
1.9 KiB
Ruby
55 lines
1.9 KiB
Ruby
|
|
module System
|
||
|
|
def self.normalize_architecture_string(s)
|
||
|
|
str = s.to_s.strip.downcase
|
||
|
|
exact = {
|
||
|
|
"x86_64" => :x86_64, "amd64" => :x86_64,
|
||
|
|
"i386" => :x86_32, "i486" => :x86_32, "i586" => :x86_32, "i686" => :x86_32,
|
||
|
|
|
||
|
|
"arm64" => :arm64, "aarch64" => :arm64,
|
||
|
|
"armhf" => :armv7, "armel" => :armv5, "armv7l" => :armv7, "armv6l" => :armv6, "armv5tel" => :armv5,
|
||
|
|
|
||
|
|
"riscv64" => :riscv64,
|
||
|
|
|
||
|
|
"ppc64el" => :ppc64le, "ppc64le" => :ppc64le,
|
||
|
|
"ppc64" => :ppc64, "powerpc64" => :ppc64,
|
||
|
|
"ppc" => :ppc32, "powerpc" => :ppc32,
|
||
|
|
|
||
|
|
"s390x" => :s390x,
|
||
|
|
|
||
|
|
"mips64el" => :mips64el, "mips64" => :mips64,
|
||
|
|
"mipsel" => :mipsel, "mips" => :mips,
|
||
|
|
|
||
|
|
"loong64" => :loongarch64, "loongarch64" => :loongarch64,
|
||
|
|
|
||
|
|
"sparc64" => :sparc64,
|
||
|
|
|
||
|
|
"alpha" => :alpha,
|
||
|
|
"hppa" => :hppa,
|
||
|
|
"ia64" => :ia64,
|
||
|
|
}
|
||
|
|
return exact[str] if exact.key?(str)
|
||
|
|
|
||
|
|
return :x86_64 if str.include?("x64") || str.include?("amd64")
|
||
|
|
return :x86_32 if str =~ /\Ai[3-6]86\z/ || str.include?("x86")
|
||
|
|
return :arm64 if str.include?("aarch64") || str.include?("arm64")
|
||
|
|
return :armv7 if str.include?("armv7")
|
||
|
|
return :armv6 if str.include?("armv6")
|
||
|
|
return :armv5 if str.include?("armv5")
|
||
|
|
return :riscv64 if str.include?("riscv64")
|
||
|
|
return :ppc64le if str.include?("ppc64el") || str.include?("ppc64le")
|
||
|
|
return :ppc64 if str.include?("ppc64")
|
||
|
|
return :ppc32 if str.include?("ppc") || str.include?("powerpc")
|
||
|
|
return :s390x if str.include?("s390x")
|
||
|
|
return :mips64el if str.include?("mips64el")
|
||
|
|
return :mips64 if str.include?("mips64")
|
||
|
|
return :mipsel if str.include?("mipsel")
|
||
|
|
return :mips if str.start_with?("mips")
|
||
|
|
return :loongarch64 if str.include?("loong") || str.include?("loongarch")
|
||
|
|
return :sparc64 if str.include?("sparc64")
|
||
|
|
return :alpha if str.include?("alpha")
|
||
|
|
return :hppa if str.include?("hppa")
|
||
|
|
return :ia64 if str.include?("ia64")
|
||
|
|
|
||
|
|
:unknown
|
||
|
|
end
|
||
|
|
end
|