🩹 fix
This commit is contained in:
parent
caf4165f13
commit
69e1f5d458
1 changed files with 27 additions and 4 deletions
|
@ -1,4 +1,4 @@
|
||||||
use std::process::Command;
|
use std::process::{Command, Stdio};
|
||||||
|
|
||||||
use based::get_pg;
|
use based::get_pg;
|
||||||
|
|
||||||
|
@ -72,6 +72,29 @@ impl BuildEnv {
|
||||||
.unwrap();
|
.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) {
|
pub fn run_command(&self, cmd: &str) -> (bool, String) {
|
||||||
let output = Command::new("systemd-nspawn")
|
let output = Command::new("systemd-nspawn")
|
||||||
.arg("-D")
|
.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"#);
|
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 {
|
if success {
|
||||||
|
@ -183,7 +206,7 @@ pub async fn build(pkg: &PackageIndex) -> (String, Vec<(String, Vec<u8>)>) {
|
||||||
.await;
|
.await;
|
||||||
}
|
}
|
||||||
|
|
||||||
(stdout, packages)
|
(String::new(), packages)
|
||||||
} else {
|
} else {
|
||||||
log::error!(
|
log::error!(
|
||||||
"Error building {} / {} @ {}{}",
|
"Error building {} / {} @ {}{}",
|
||||||
|
@ -196,6 +219,6 @@ pub async fn build(pkg: &PackageIndex) -> (String, Vec<(String, Vec<u8>)>) {
|
||||||
String::new()
|
String::new()
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
(stdout, Vec::new())
|
(String::new(), Vec::new())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue