More work on install stage

This commit is contained in:
kira committed 2026-11-18 22:15:57 +01:00
1 parent 1399c56135
commit d68ee36afa
2 files changed
+65 -11

No files matched your search

+26 -1
View File
@@ -104,7 +104,7 @@ impl std::fmt::Display for ExecCommandError {
impl std::error::Error for ExecCommandError {}
/// exec given sommand with arguments, capturing stderr in case or failure
fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError> {
pub fn exec_command(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError> {
let out = Command::new(cmd).args(args).output()?;
if out.status.success() {
Ok(())
@@ -180,6 +180,20 @@ fn exec_command_log(cmd: &str, args: &Vec<&str>) -> Result<(), ExecCommandError>
}
}
///
/// Chroot to chroot_dir and executes specified command there
///
pub fn exec_cmd_chroot(
chroot_dir: &str,
cmd: &str,
args: &Vec<&str>,
) -> Result<(), ExecCommandError> {
let mut cmd_args: Vec<&str> = Vec::new();
cmd_args.push(cmd);
cmd_args.extend(args);
exec_command("artix-chroot", &cmd_args)
}
/// sync system time with chrony
/// dinitctl start chrony
pub fn dinit_sync_time_chrony() -> Result<(), ExecCommandError> {
@@ -440,3 +454,14 @@ pub fn ls_dir_rec(dir_part: &Path) -> Result<Vec<String>, std::io::Error> {
}
Ok(res)
}
///
/// Generates fstab file similar to
/// fstabgen -t PARTLABEL mnt_dir >> mnt_dir/etc/fstab
///
pub fn fstabgen(mnt_dir: &str) -> Result<(), ExecCommandError> {
let fstab_file_name = format!("{}/etc/fstab", mnt_dir);
let fstab = exec_command_out("fstabgen", &vec!["-t", "PARTLABEL", mnt_dir])?;
fs::write(&fstab_file_name, fstab)?;
Ok(())
}