Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement proper caching in VM builder v2 #55

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
target/
.vscode/
.cache/
59 changes: 55 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ toml = "0.8.19"
openssl = { version = "*", optional = true }

# Linux VM builder dependencies
mia-installer = { git = "https://github.com/gevulotnetwork/mia.git", tag = "mia-installer-0.2.5" }
mia-installer = { git = "https://github.com/gevulotnetwork/mia.git", tag = "mia-installer-0.3.0" }

anyhow = "1"
log = "0.4.22"
Expand All @@ -38,7 +38,9 @@ thiserror = "1"

# Linux VM builder v2 dependencies
backhand = { version = "0.20", optional = true, default-features = false, features = ["xz"] }
base64 = { version = "0.22", optional = true }
bytesize = { version = "1", optional = true }
crc = { version = "3", optional = true }
directories = { version = "5", optional = true }
fatfs = { version = "0.3", optional = true }
fscommon = { version = "0.1", optional = true }
Expand All @@ -60,7 +62,9 @@ openssl-vendored = ["openssl/vendored"]
# Use new version of Linux VM builder (unstable)
vm-builder-v2 = [
"dep:backhand",
"dep:base64",
"dep:bytesize",
"dep:crc",
"dep:directories",
"dep:fatfs",
"dep:fscommon",
Expand Down
7 changes: 5 additions & 2 deletions src/builders_v2/linux_vm/image_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,11 @@ pub struct UseImageFile;

impl Step<LinuxVMBuildContext> for UseImageFile {
fn run(&mut self, ctx: &mut LinuxVMBuildContext) -> Result<()> {
let base_image_path = ctx.cache().join("base.img");
if !base_image_path.exists() {
let crc_instance = crc::Crc::<u64>::new(&crc::CRC_64_ECMA_182);
let checksum = format!("{:x}", crc_instance.checksum(BASE_IMAGE));
debug!("base image checksum: {}", &checksum);
let base_image_path = ctx.cache().join(format!("{}.base.img", checksum));
if !base_image_path.is_file() {
info!("creating base image file: {}", base_image_path.display());
let mut file = fs::File::create_new(&base_image_path)
.context("failed to create base image file")?;
Expand Down
Loading
Loading