ubicloud/rhizome/host/lib/vhost_block_backend.rb
Hadi Moshayedi d0e9f13d14 Rhizome: remove ubiblk v0.1-7 sha256 entries.
We'll only use ubiblk v0.2.0 going forward, therefore we can remove the
redundant sha256 entries.
2025-09-16 12:14:48 -07:00

47 lines
1.1 KiB
Ruby

# frozen_string_literal: true
require "fileutils"
require_relative "../../common/lib/arch"
class VhostBlockBackend
def initialize(version)
@version = version
end
def sha256
if @version == "v0.2.0" && Arch.x64?
"68638b779a227424cbe81674de4b26122ea27a337f1c6d81db895a1ffa3a917a"
elsif @version == "v0.2.0" && Arch.arm64?
"6b15ca96cd3134524a639d3c913b43b794423a8dddc897c1604a5085625d44e3"
else
fail "Unsupported version: #{@version}, #{Arch.sym}"
end
end
def url
"https://github.com/ubicloud/ubiblk/releases/download/#{@version}/vhost-backend-#{Arch.sym}.tar.gz"
end
def dir
"/opt/vhost-block-backend/#{@version}"
end
def bin_path
"#{dir}/vhost-backend"
end
def init_metadata_path
"#{dir}/init-metadata"
end
def download
temp_tarball = "/tmp/vhost-backend-#{@version}.tar.gz"
puts "Downloading ubiblk package from #{url}"
r "curl -L3 --connect-timeout 5 --max-time 30 -o #{temp_tarball} #{url}"
FileUtils.mkdir_p(dir)
FileUtils.cd dir do
r "tar -xzf #{temp_tarball}"
end
FileUtils.rm_f temp_tarball
end
end