require_relative('system/architecture') module System def self.detect_os case RUBY_PLATFORM when /darwin/ :macos when /linux/ if File.exist?('/etc/debian_version') :debian else :linux_other end else :unknown end end OS = detect_os case OS when :macos require_relative './system/macos' extend MacOSSystem when :debian require_relative './system/debian' extend DebianSystem else raise "Operating system not supported" end ARCH = normalize_architecture_string(arch) def self.os_info puts os_name end def self.qemu_paths { code_fd: qemu_code_fd_path, vars_fd: qemu_vars_fd_path } end def self.arch_to_symbol(arch) normalize_architecture_string(arch) end def self.exec_ssh(port) require "socket" host = "localhost" cmd = "ssh -p #{port} user@#{host}" # Wait until the port is open puts "Waiting for #{host}:#{port}..." until begin TCPSocket.new(host, port).close true rescue Errno::ECONNREFUSED, Errno::EHOSTUNREACH, SocketError false end sleep 0.1 end puts "Port open! Executing: #{cmd}" exec cmd end end