This commit is contained in:
JMARyA 2025-04-06 22:05:10 +02:00
parent caf4165f13
commit 69e1f5d458
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263

View file

@ -1,4 +1,4 @@
use std::process::Command;
use std::process::{Command, Stdio};
use based::get_pg;
@ -72,6 +72,29 @@ impl BuildEnv {
.unwrap();
}
pub fn run_command_inherit(&self, cmd: &str) -> bool {
let output = Command::new("systemd-nspawn")
.arg("-D")
.arg(self.path())
.arg("--bind")
.arg("./pacman.conf:/etc/pacman.conf")
.arg("bash")
.arg("-c")
.arg(cmd)
.stdout(Stdio::inherit())
.output()
.expect("Failed to run systemd-nspawn container");
let success = output.status.success();
if !success {
let stderr = String::from_utf8_lossy(&output.stderr).to_string();
log::error!("Error running command: {stderr}");
}
success
}
pub fn run_command(&self, cmd: &str) -> (bool, String) {
let output = Command::new("systemd-nspawn")
.arg("-D")
@ -133,7 +156,7 @@ pub async fn build(pkg: &PackageIndex) -> (String, Vec<(String, Vec<u8>)>) {
}
);
let (success, stdout) = base_env.run_command(
let success = base_env.run_command_inherit(
r#"cd /build;pacman -Syu --noconfirm;useradd -m build;echo "ALL ALL=(ALL) NOPASSWD: ALL"|tee -a /etc/sudoers;chown -R build /build;su -c "makepkg -c -C -s --noconfirm --skippgpcheck" build"#);
if success {
@ -183,7 +206,7 @@ pub async fn build(pkg: &PackageIndex) -> (String, Vec<(String, Vec<u8>)>) {
.await;
}
(stdout, packages)
(String::new(), packages)
} else {
log::error!(
"Error building {} / {} @ {}{}",
@ -196,6 +219,6 @@ pub async fn build(pkg: &PackageIndex) -> (String, Vec<(String, Vec<u8>)>) {
String::new()
}
);
(stdout, Vec::new())
(String::new(), Vec::new())
}
}