diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-12-26 16:47:45 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2022-12-26 16:47:45 +0100 |
commit | 1654f9cc5d46343e7a9d3e8e9ee2e8940dedb7f3 (patch) | |
tree | 50f0adb3c368325f40bafcfdd6a3fdfb870bfba1 /src/main.rs | |
parent | ff8fc2e170e95286e1a2fbdd2ba128ed8dfd6bcc (diff) |
copy pre-built image to repository root
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index 7fcca0b..c323898 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,7 @@ use anyhow::bail; use std::env; use std::fs::File; -use std::io::Write; +use std::io::{Read, Write}; use std::path::Path; use std::process::Command; @@ -69,6 +69,19 @@ fn compile() -> anyhow::Result<()> { Ok(()) } +fn copy_file<P: AsRef<Path>, Q: AsRef<Path>>(src: P, dst: Q) -> anyhow::Result<()> { + let mut outfile = File::create(dst)?; + let mut infile = File::open(src)?; + + let mut buf = Vec::new(); + infile.read_to_end(&mut buf)?; + outfile.write_all(&buf)?; + + outfile.set_permissions(infile.metadata()?.permissions())?; + + Ok(()) +} + fn main() -> anyhow::Result<()> { let file_name = Path::new(LATEST).file_name().unwrap().to_str().unwrap(); @@ -89,5 +102,9 @@ fn main() -> anyhow::Result<()> { compile()?; println!("Kernel compiled successfully"); + let kernel_path = "arch/x86_64/boot/bzImage"; /* FIXME: arch independent */ + + copy_file(kernel_path, "vmlinuz")?; + Ok(()) } |