Refactor some data structures to move towards coping with the additional complexity, but fundamentally, add branches to download and use different binaries on different platforms. Having applied this patch, and having prepared hosts with a current Rhizome, it is possible to provision an arm64 VM like so: Prog::Vm::Nexus.assemble("pubkey", dev_project.id, arch: "arm64") As the host architectures are "learned" from teh host, there is no need to change how `Prog::Vm::HostNexus.assemble` is called.
35 lines
558 B
Ruby
35 lines
558 B
Ruby
# frozen_string_literal: true
|
|
|
|
require "rbconfig"
|
|
|
|
ArchClass = Struct.new(:sym) {
|
|
def self.from_system
|
|
new case RbConfig::CONFIG.fetch("target_cpu").downcase
|
|
when /arm64|aarch64/
|
|
"arm64"
|
|
when /amd64|x86_64|x64/
|
|
"x64"
|
|
else
|
|
fail "BUG: could not detect architecture"
|
|
end.intern
|
|
end
|
|
|
|
def arm64?
|
|
sym == :arm64
|
|
end
|
|
|
|
def x64?
|
|
sym == :x64
|
|
end
|
|
|
|
def render(x64: sym, arm64: sym)
|
|
if x64?
|
|
x64
|
|
elsif arm64?
|
|
arm64
|
|
else
|
|
fail "BUG: could not detect architecture"
|
|
end.to_s
|
|
end
|
|
}
|