diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-12-26 15:12:46 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-12-26 15:12:46 +0100 |
commit | b09e5315f4e8ba66482f2afffe549e1f89c37330 (patch) | |
tree | 6a0b0b270d70d5b610a79c3b0243386e9816be34 | |
parent | 710225840fe54924de11c4a6185e14e749c28073 (diff) |
download kernel
-rw-r--r-- | Cargo.toml | 2 | ||||
-rw-r--r-- | src/main.rs | 30 |
2 files changed, 30 insertions, 2 deletions
@@ -6,3 +6,5 @@ edition = "2021" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] +anyhow = "1.0.68" +reqwest = { version = "0.11.13", features = ["blocking"] } diff --git a/src/main.rs b/src/main.rs index e7a11a9..8048fc2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,29 @@ -fn main() { - println!("Hello, world!"); +use std::fs::File; +use std::path::Path; + +const LATEST: &str = "https://cdn.kernel.org/pub/linux/kernel/v6.x/linux-6.1.1.tar.xz"; + +const CONFIG: &str = r#" +CONFIG_IPV6=y +"#; + +fn download_kernel() -> anyhow::Result<()> { + println!("Downloading kernel source..."); + + let file_name = Path::new(LATEST).file_name().unwrap().to_str().unwrap(); + + let mut file = File::create(file_name)?; + + reqwest::blocking::get(LATEST)? + .error_for_status()? + .copy_to(&mut file)?; + + println!("Kernel source downloaded successfully"); + Ok(()) +} + +fn main() -> anyhow::Result<()> { + download_kernel()?; + + Ok(()) } |