From c64354e94a31c7de54a4c65a7d6cb4c87ce875c1 Mon Sep 17 00:00:00 2001 From: Cappy Ishihara Date: Tue, 3 Oct 2023 11:55:54 +0700 Subject: [PATCH] add comments to fstab --- src/config.rs | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/config.rs b/src/config.rs index 78177a0..2f79d52 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,7 +5,7 @@ use serde_derive::{Deserialize, Serialize}; use std::{collections::BTreeMap, fs, io::Write, path::PathBuf, str::FromStr}; use tracing::{debug, info, trace}; -use crate::{util::run_with_chroot, chroot_run_cmd}; +use crate::{chroot_run_cmd, util::run_with_chroot}; #[derive(Deserialize, Debug, Clone, Serialize)] pub struct Manifest { @@ -245,7 +245,6 @@ impl PartitionLayout { let ordered = ordered.into_iter().rev().collect::>(); - debug!("Mounting partitions to chroot: {:#?}", ordered); // Ok, so for some reason the partitions are swapped? @@ -253,7 +252,6 @@ impl PartitionLayout { for (index, part) in ordered.iter() { let devname = partition_name(&disk.to_string_lossy(), *index as u32); - // clean the mountpoint so we don't have the slash at the start let mp_cleaned = part.mountpoint.trim_start_matches('/'); let mountpoint = chroot.join(&mp_cleaned); @@ -269,9 +267,6 @@ impl PartitionLayout { cmd_lib::run_cmd!(mount ${devname} ${mountpoint} 2>&1)?; } - - - Ok(()) } @@ -281,11 +276,9 @@ impl PartitionLayout { // sort partitions by mountpoint let ordered = self.clone().sort_partitions(); - for (index, part) in ordered.iter() { let devname = partition_name(&disk.to_string_lossy(), *index as u32); - // clean the mountpoint so we don't have the slash at the start let mp_cleaned = part.mountpoint.trim_start_matches('/'); let mountpoint = chroot.join(&mp_cleaned); @@ -341,6 +334,19 @@ impl PartitionLayout { } }; + const PREPEND_COMMENT: &str = r#" +# /etc/fstab: static file system information. +# Automatically generated by Katsu Image Builder. See +# katsu::config::PartitionLayout::fstab for more information. + +"#; + + fstab.push_str(PREPEND_COMMENT.trim()); + + const LEGEND: &str = "# \t\t\t\t\t\n\n"; + + fstab.push_str(LEGEND.trim()); + let fsck = if part.filesystem == "efi" { "0" } else { "2" }; let entry = format!( @@ -607,7 +613,6 @@ impl Auth { trace!(args = ?args, "useradd args"); - chroot_run_cmd!(chroot, unshare -R ${chroot} useradd $[args] 2>&1)?; // cmd_lib::run_cmd!(useradd $[args] 2>&1)?;