REPBUILD: Fix

pull/11/head
ondra05 2023-08-30 01:12:40 +02:00
parent 9f2fea5eef
commit ad686be239
No known key found for this signature in database
GPG Key ID: 0DA6D2BB2285E881
4 changed files with 986 additions and 20 deletions

984
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,3 @@
[workspace]
resolver = "2"
members = ["kernel"]
members = ["kernel", "repbuild"]

View File

@ -5,7 +5,7 @@ edition = "2021"
[dependencies]
derive_more = "0.99"
error-stack = "0.3"
error-stack = "0.4"
fatfs = "0.3"
[dependencies.reqwest]

View File

@ -1,6 +1,8 @@
use error_stack::Report;
use {
derive_more::Display,
error_stack::{bail, report, Context, IntoReport, Result, ResultExt},
error_stack::{bail, report, Context, Result, ResultExt},
fatfs::{FileSystem, FormatVolumeOptions, FsOptions, ReadWriteSeek},
std::{fmt::Display, fs::File, io, path::Path, process::Command},
};
@ -86,14 +88,14 @@ fn get_fs() -> Result<FileSystem<impl ReadWriteSeek>, io::Error> {
io::copy(
&mut File::open("limine/BOOTX64.EFI")
.into_report()
.map_err(Report::from)
.attach_printable("copying Limine bootloader (have you pulled the submodule?)")?,
&mut bootdir.create_file("bootx64.efi")?,
)?;
io::copy(
&mut File::open("limine/BOOTAA64.EFI")
.into_report()
.map_err(Report::from)
.attach_printable(
"copying Limine bootloader arm version (have you pulled the submodule?)",
)?,
@ -162,7 +164,7 @@ fn build(release: bool, target: Target) -> Result<(), Error> {
)
.map(|_| ())
})()
.into_report()
.map_err(Report::from)
.change_context(Error::Io)
}
@ -215,7 +217,7 @@ fn run(release: bool, target: Target) -> Result<(), Error> {
match com
.status()
.into_report()
.map_err(Report::from)
.change_context(Error::ProcessSpawn)?
{
s if s.success() => Ok(()),
@ -242,18 +244,18 @@ fn fetch_ovmf(target: Target) -> Result<String, OvmfFetchError> {
.write(true)
.read(true)
.open(ovmf_path)
.into_report()
.map_err(Report::from)
.change_context(OvmfFetchError::Io)?,
Ok(_) => return Ok(ovmf_path.to_owned()),
Err(e) => return Err(report!(e).change_context(OvmfFetchError::Io)),
};
let mut bytes = reqwest::blocking::get(ovmf_url)
.into_report()
.map_err(Report::from)
.change_context(OvmfFetchError::Fetch)?;
bytes
.copy_to(&mut file)
.into_report()
.map_err(Report::from)
.change_context(OvmfFetchError::Io)?;
Ok(ovmf_path.to_owned())