deb: allow injecting .deb files packages
This commit is contained in:
@@ -178,17 +178,7 @@ pub async fn build(
|
|||||||
|
|
||||||
// Install injected packages if specified
|
// Install injected packages if specified
|
||||||
if let Some(packages) = inject_packages {
|
if let Some(packages) = inject_packages {
|
||||||
log::info!("Installing injected packages: {:?}", packages);
|
install_injected_packages(packages, &env, ctx.clone())?;
|
||||||
let mut cmd = ctx.command("apt-get");
|
|
||||||
cmd.envs(env.clone())
|
|
||||||
.arg("-y")
|
|
||||||
.arg("--allow-downgrades")
|
|
||||||
.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
|
// Install arch-specific build dependencies
|
||||||
@@ -256,6 +246,64 @@ pub async fn build(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn install_injected_packages(
|
||||||
|
packages: &[&str],
|
||||||
|
env: &HashMap<String, String>,
|
||||||
|
ctx: Arc<Context>,
|
||||||
|
) -> Result<(), Box<dyn Error>> {
|
||||||
|
log::info!("Installing injected packages: {:?}", packages);
|
||||||
|
|
||||||
|
// Separate .deb files from package names
|
||||||
|
let mut deb_files: Vec<String> = Vec::new();
|
||||||
|
let mut package_names: Vec<&str> = Vec::new();
|
||||||
|
|
||||||
|
for pkg in packages {
|
||||||
|
// Check if it's a .deb file path (ends with .deb and exists as a file)
|
||||||
|
let pkg_path = Path::new(pkg);
|
||||||
|
if pkg.ends_with(".deb") && pkg_path.exists() {
|
||||||
|
// Copy the .deb file into the build context
|
||||||
|
let dest_root = ctx.create_temp_dir()?;
|
||||||
|
let chroot_path = ctx.ensure_available(pkg_path, &dest_root)?;
|
||||||
|
log::debug!(
|
||||||
|
"Copied .deb file '{}' to chroot path '{}'",
|
||||||
|
pkg,
|
||||||
|
chroot_path.display()
|
||||||
|
);
|
||||||
|
deb_files.push(chroot_path.to_string_lossy().to_string());
|
||||||
|
} else {
|
||||||
|
package_names.push(pkg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Install .deb files using dpkg -i
|
||||||
|
if !deb_files.is_empty() {
|
||||||
|
log::info!("Installing .deb files: {:?}", deb_files);
|
||||||
|
let mut cmd = ctx.command("dpkg");
|
||||||
|
cmd.envs(env.clone()).arg("-i").args(&deb_files);
|
||||||
|
let status = cmd.status()?;
|
||||||
|
if !status.success() {
|
||||||
|
return Err(format!("Could not install .deb files: {:?}", deb_files).into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Install package names using apt-get
|
||||||
|
if !package_names.is_empty() {
|
||||||
|
log::info!("Installing packages from archive: {:?}", package_names);
|
||||||
|
let mut cmd = ctx.command("apt-get");
|
||||||
|
cmd.envs(env.clone())
|
||||||
|
.arg("-y")
|
||||||
|
.arg("--allow-downgrades")
|
||||||
|
.arg("install")
|
||||||
|
.args(&package_names);
|
||||||
|
let status = cmd.status()?;
|
||||||
|
if !status.success() {
|
||||||
|
return Err(format!("Could not install injected packages: {:?}", package_names).into());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn dose3_explain_dependencies(
|
fn dose3_explain_dependencies(
|
||||||
package: &str,
|
package: &str,
|
||||||
version: &str,
|
version: &str,
|
||||||
|
|||||||
Reference in New Issue
Block a user