deb: add --inject to inject a package
CI / build (push) Failing after 20m25s
CI / snap (push) Has been skipped

This commit is contained in:
2026-02-18 23:19:57 +01:00
parent eb3e71a938
commit 87b48bf9c8
3 changed files with 50 additions and 4 deletions
+16
View File
@@ -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");
+13 -2
View File
@@ -24,6 +24,7 @@ pub async fn build_binary_package(
cross: bool,
mode: Option<BuildMode>,
ppa: Option<&str>,
inject_packages: Option<&[&str]>,
) -> Result<(), Box<dyn Error>> {
let cwd = cwd.unwrap_or_else(|| Path::new("."));
@@ -77,7 +78,17 @@ pub async fn build_binary_package(
// Run the build using target build mode
match mode {
BuildMode::Local => {
local::build(&package, &version, arch, series, &build_root, cross, ppa).await?
local::build(
&package,
&version,
arch,
series,
&build_root,
cross,
ppa,
inject_packages,
)
.await?
}
BuildMode::Sbuild => sbuild::build(&package, &version, arch, series, &build_root, cross)?,
};
@@ -237,7 +248,7 @@ mod tests {
log::debug!("Package directory: {}", cwd.display());
log::info!("Starting binary package build...");
crate::deb::build_binary_package(arch, Some(series), Some(&cwd), cross, None, None)
crate::deb::build_binary_package(arch, Some(series), Some(&cwd), cross, None, None, None)
.await
.expect("Cannot build binary package (deb)");
log::info!("Successfully built binary package");