Skip to content

Commit

Permalink
add comments to fstab
Browse files Browse the repository at this point in the history
  • Loading branch information
korewaChino committed Oct 3, 2023
1 parent bc52732 commit c64354e
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -245,15 +245,13 @@ impl PartitionLayout {

let ordered = ordered.into_iter().rev().collect::<Vec<_>>();


debug!("Mounting partitions to chroot: {:#?}", ordered);

// Ok, so for some reason the partitions are swapped?

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);
Expand All @@ -269,9 +267,6 @@ impl PartitionLayout {
cmd_lib::run_cmd!(mount ${devname} ${mountpoint} 2>&1)?;
}




Ok(())
}

Expand All @@ -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);
Expand Down Expand Up @@ -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 = "# <file system>\t<mount point>\t<type>\t<options>\t<dump>\t<pass>\n\n";

fstab.push_str(LEGEND.trim());

let fsck = if part.filesystem == "efi" { "0" } else { "2" };

let entry = format!(
Expand Down Expand Up @@ -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)?;

Expand Down

0 comments on commit c64354e

Please sign in to comment.