Fix the run-in-chroot check

main^2
trivernis 1 year ago
parent eb88743d01
commit 4ad2700f06
Signed by: Trivernis
GPG Key ID: DFFFCC2C7A02DB45

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `configure-locale`
def main [cfg] {
echo "Executing up task `configure-locale` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `configure-network`
def main [cfg] {
echo "Executing up task `configure-network` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `configure-unakite`
def main [cfg] {
echo "Executing up task `configure-unakite` with config" $cfg

@ -1,4 +1,3 @@
let REQUIRES_CHROOT = true;
# Applies all system changes of `install-base`
def main [cfg] {
echo "Executing up task `install-base` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `install-bootloader`
def main [cfg] {
echo "Executing up task `install-bootloader` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `install-desktop`
def main [cfg] {
echo "Executing up task `install-desktop` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `install-extra-packages`
def main [cfg] {
echo "Executing up task `install-extra-packages` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `install-flatpak`
def main [cfg] {
echo "Executing up task `install-flatpak` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `install-kernels`
def main [cfg] {
echo "Executing up task `install-kernels` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `install-timeshift`
def main [cfg] {
echo "Executing up task `install-timeshift` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `install-zramd`
def main [cfg] {
echo "Executing up task `install-zramd` with config" $cfg

@ -1,3 +1,4 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `setup-root-user`
def main [cfg] {
echo "Executing up task `setup-root-user` with config" $cfg

@ -1,5 +1,5 @@
let RUN_IN_CHROOT = true;
# Applies all system changes of `setup-users`
def main [cfg] {
echo "Executing up task `setup-users` with config" $cfg
echo $TRM_CONFIG
}

@ -144,7 +144,7 @@ impl Mapping {
.await
.map_err(|e| ChrootError::Link(src.to_owned(), e))?;
Ok(MappingHandle::Link(LinkDrop {
path: src.to_owned(),
path: dst.to_owned(),
}))
}
@ -155,9 +155,11 @@ impl Mapping {
.map_err(|e| ChrootError::Copy(src.to_owned(), e))?;
}
fs::copy(src, dst)
.await
.map_err(|e| ChrootError::Copy(src.to_owned(), e))?;
if src.exists() {
fs::copy(src, dst)
.await
.map_err(|e| ChrootError::Copy(src.to_owned(), e))?;
}
Ok(MappingHandle::None)
}

@ -54,7 +54,7 @@ impl ExecBuilder {
/// Returns if the script needs to be run inside the new root
pub fn requires_chroot(&self) -> bool {
self.ctx
.get_var("run_in_chroot")
.get_var("RUN_IN_CHROOT")
.and_then(|v| v.as_bool().ok())
.unwrap_or(false)
}

@ -63,12 +63,20 @@ impl TaskExecutor {
#[tracing::instrument(level = "trace", skip_all)]
pub async fn execute(&mut self) -> Result<()> {
self.tasks.sort_by(Task::compare);
let chroot = Chroot::create(&*ROOT_MNT).await?;
let mut chroot = None;
for task in &self.tasks {
if let Some(up_task) = task.up(&self.os_config)? {
if up_task.requires_chroot() {
chroot.run(|| up_task.exec()).await.unwrap()??;
if chroot.is_none() {
chroot = Some(Chroot::create(&*ROOT_MNT).await?);
}
chroot
.as_ref()
.unwrap()
.run(|| up_task.exec())
.await
.unwrap()??;
} else {
up_task.exec()?;
}

Loading…
Cancel
Save