mirror of
https://github.com/containers/bootc.git
synced 2026-02-05 15:45:53 +01:00
Merge pull request #1507 from cgwalters/composefs-more-cleanups
install: Use read_file from composefs-boot
This commit is contained in:
@@ -15,7 +15,7 @@ pub(crate) mod osconfig;
|
||||
|
||||
use std::collections::HashMap;
|
||||
use std::fs::create_dir_all;
|
||||
use std::io::{Read, Write};
|
||||
use std::io::Write;
|
||||
use std::os::fd::{AsFd, AsRawFd};
|
||||
use std::os::unix::fs::symlink;
|
||||
use std::os::unix::process::CommandExt;
|
||||
@@ -40,9 +40,9 @@ use cap_std_ext::cmdext::CapStdExtCommandExt;
|
||||
use cap_std_ext::prelude::CapStdExtDirExt;
|
||||
use chrono::prelude::*;
|
||||
use clap::ValueEnum;
|
||||
use composefs_boot::bootloader::read_file;
|
||||
use fn_error_context::context;
|
||||
use ostree::gio;
|
||||
use ostree_ext::composefs::tree::RegularFile;
|
||||
use ostree_ext::composefs::{
|
||||
fsverity::{FsVerityHashValue, Sha256HashValue},
|
||||
repository::Repository as ComposefsRepository,
|
||||
@@ -1591,24 +1591,6 @@ fn get_booted_bls() -> Result<BLSConfig> {
|
||||
Err(anyhow::anyhow!("Booted BLS not found"))
|
||||
}
|
||||
|
||||
pub fn read_file<ObjectID: FsVerityHashValue>(
|
||||
file: &RegularFile<ObjectID>,
|
||||
repo: &ComposefsRepository<ObjectID>,
|
||||
) -> Result<Box<[u8]>> {
|
||||
match file {
|
||||
RegularFile::Inline(data) => Ok(data.clone()),
|
||||
RegularFile::External(id, size) => {
|
||||
let mut data = vec![];
|
||||
std::fs::File::from(repo.open_object(id)?).read_to_end(&mut data)?;
|
||||
ensure!(
|
||||
*size == data.len() as u64,
|
||||
"File content doesn't have the expected length"
|
||||
);
|
||||
Ok(data.into_boxed_slice())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) enum BootSetupType<'a> {
|
||||
/// For initial setup, i.e. install to-disk
|
||||
Setup((&'a RootSetup, &'a State)),
|
||||
|
||||
Reference in New Issue
Block a user