deb: add --inject to inject a package
This commit is contained in:
@@ -10,6 +10,7 @@ use std::path::Path;
|
||||
use crate::apt;
|
||||
use crate::deb::cross;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub async fn build(
|
||||
package: &str,
|
||||
version: &str,
|
||||
@@ -18,6 +19,7 @@ pub async fn build(
|
||||
build_root: &str,
|
||||
cross: bool,
|
||||
ppa: Option<&str>,
|
||||
inject_packages: Option<&[&str]>,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
// Environment
|
||||
let mut env = HashMap::<String, String>::new();
|
||||
@@ -166,6 +168,20 @@ pub async fn build(
|
||||
.to_str()
|
||||
.ok_or("Invalid package directory path")?;
|
||||
|
||||
// Install injected packages if specified
|
||||
if let Some(packages) = inject_packages {
|
||||
log::info!("Installing injected packages: {:?}", packages);
|
||||
let mut cmd = ctx.command("apt-get");
|
||||
cmd.envs(env.clone())
|
||||
.arg("-y")
|
||||
.arg("install")
|
||||
.args(packages);
|
||||
let status = cmd.status()?;
|
||||
if !status.success() {
|
||||
return Err(format!("Could not install injected packages: {:?}", packages).into());
|
||||
}
|
||||
}
|
||||
|
||||
// Install arch-specific build dependencies
|
||||
log::debug!("Installing arch-specific build dependencies...");
|
||||
let mut cmd = ctx.command("apt-get");
|
||||
|
||||
Reference in New Issue
Block a user