From bc52732bd9e6cc0fb1fcd43d407d7cb12d344807 Mon Sep 17 00:00:00 2001 From: Cappy Ishihara Date: Tue, 3 Oct 2023 11:38:42 +0700 Subject: [PATCH] restore old boot layout --- src/config.rs | 9 ++++++--- tests/ng/grub-install.sh | 16 ++++++++++++---- tests/ng/katsu.yaml | 9 +++++++-- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/config.rs b/src/config.rs index 26e7bba..78177a0 100644 --- a/src/config.rs +++ b/src/config.rs @@ -5,6 +5,8 @@ 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}; + #[derive(Deserialize, Debug, Clone, Serialize)] pub struct Manifest { pub builder: String, @@ -567,8 +569,7 @@ impl Auth { pub fn add_to_chroot(&self, chroot: &PathBuf) -> Result<()> { // add user to chroot - let binding = chroot.to_string_lossy(); - let mut args = vec!["-R".to_string(), binding.as_ref().to_string()]; + let mut args = vec![]; if let Some(uid) = self.uid { args.push("-u".to_string()); @@ -606,7 +607,9 @@ impl Auth { trace!(args = ?args, "useradd args"); - cmd_lib::run_cmd!(useradd $[args] 2>&1)?; + + chroot_run_cmd!(chroot, unshare -R ${chroot} useradd $[args] 2>&1)?; + // cmd_lib::run_cmd!(useradd $[args] 2>&1)?; // add ssh keys if !self.ssh_keys.is_empty() { diff --git a/tests/ng/grub-install.sh b/tests/ng/grub-install.sh index e924281..53bbec2 100644 --- a/tests/ng/grub-install.sh +++ b/tests/ng/grub-install.sh @@ -9,10 +9,18 @@ grub2-mkconfig > /boot/grub2/grub.cfg rm /etc/default/grub - -# get /dev/ of /boot -bootdev=$(findmnt -n -o SOURCE /boot) - +# get /dev/ of /boot, or / if /boot is not a separate partition +function find_bootdev { + # try findmnt /boot + if findmnt -n -o SOURCE /boot; then + bootdev=$(findmnt -n -o SOURCE /boot) + else + bootdev=$(findmnt -n -o SOURCE /) + fi +} + + +find_bootdev # get blkid of /boot bootid=$(blkid -s UUID -o value $bootdev) diff --git a/tests/ng/katsu.yaml b/tests/ng/katsu.yaml index bc372d4..286c05a 100644 --- a/tests/ng/katsu.yaml +++ b/tests/ng/katsu.yaml @@ -38,6 +38,11 @@ disk: filesystem: efi mountpoint: /boot/efi + - label: boot + size: 1GiB + filesystem: ext4 + mountpoint: /boot + - label: root # size: 2.5MiB filesystem: ext4 @@ -55,8 +60,8 @@ users: dnf: releasever: 39 repodir: repodir/ - # options: - # - --setopt=cachedir=/var/cache/dnf + options: + - --setopt=cachedir=/var/cache/dnf # exclude: # - flatpak # - pkgconf