Skip to content

Commit

Permalink
implemented kernel build feature
Browse files Browse the repository at this point in the history
- add_kernel: add kernel binary to quardle

Signed-off-by: leofvo <[email protected]>
  • Loading branch information
leofvo committed May 2, 2022
1 parent 36da407 commit fb80298
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions src/quardle/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ impl Quardle {

self
.setup()
.add_kernel()
.add_config_file()
.make_archive()?;

Expand Down Expand Up @@ -89,6 +90,56 @@ impl Quardle {
.expect("failed to setup quark");
}

// Install a default kernel configuration file
if !std::path::Path::new(&format!("{}linux-config-x86_64", QUARK_CONFIG_DIR)).exists() {
println!("Kernel config file not found, installing it !");
Command::new("curl")
.arg("https://raw.githubusercontent.com/virt-do/lab/main/do-vmm/kernel/linux-config-x86_64")
.arg("-O")
.current_dir(format!("{}", QUARK_CONFIG_DIR))
.output()
.expect("failed to fetch kernel config file");
}

// Install a script to build kernel
if !std::path::Path::new(&format!("{}mkkernel.sh", QUARK_CONFIG_DIR)).exists() {
println!("Kernel build script not found, installing it !");
Command::new("curl")
.arg("https://raw.githubusercontent.com/virt-do/lab/main/do-vmm/kernel/mkkernel.sh")
.arg("-O")
.current_dir(format!("{}", QUARK_CONFIG_DIR))
.output()
.expect("failed to fetch kernel build script");

Command::new("chmod")
.arg("+x")
.arg(format!("{}mkkernel.sh", QUARK_CONFIG_DIR))
.current_dir(format!("{}", QUARK_CONFIG_DIR))
.output()
.expect("failed to make kernel build script executable");
}

// Building kernel binary
if !std::path::Path::new(&format!("{}linux-cloud-hypervisor", QUARK_CONFIG_DIR)).exists() {
println!("Kernel not builded, building it !");
Command::new(format!("{}mkkernel.sh", QUARK_CONFIG_DIR))
.current_dir(format!("{}", QUARK_CONFIG_DIR))
.output()
.expect("failed to build kernel");
}

self
}

/// Append kernel configuration
/// Fetch automated script if isn't already installed, and use some bash script to build it
fn add_kernel(&self) -> &Quardle {
println!("Installing kernel binary !");
Command::new("cp")
.arg(format!("{}linux-cloud-hypervisor/arch/x86/boot/compressed/vmlinux.bin", QUARK_CONFIG_DIR))
.arg(format!("{}/", self.clone().get_work_dir()))
.spawn()
.expect("failed to copy kernel");
self
}

Expand Down

0 comments on commit fb80298

Please sign in to comment.