Merge branch 'main' of https://git.vhaudiquet.fr/vhaudiquet/pkh
* 'main' of https://git.vhaudiquet.fr/vhaudiquet/pkh: deb: fix injection of .deb packages with apt-get deb: allow injecting .deb files packages
This commit is contained in:
+54
-11
@@ -188,17 +188,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
|
||||||
@@ -266,6 +256,59 @@ 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
|
||||||
|
if !deb_files.is_empty() || !package_names.is_empty() {
|
||||||
|
log::info!("Installing .deb files: {:?}", deb_files);
|
||||||
|
let mut cmd = ctx.command("apt-get");
|
||||||
|
cmd.envs(env.clone())
|
||||||
|
.arg("-y")
|
||||||
|
.arg("--allow-downgrades")
|
||||||
|
.arg("install");
|
||||||
|
// Add the .deb file paths with ./ prefix for apt to recognize them as local files
|
||||||
|
for deb_path in &deb_files {
|
||||||
|
cmd.arg(format!("./{}", deb_path.trim_start_matches('/')));
|
||||||
|
}
|
||||||
|
if !package_names.is_empty() {
|
||||||
|
cmd.args(&package_names);
|
||||||
|
}
|
||||||
|
let status = cmd.status()?;
|
||||||
|
if !status.success() {
|
||||||
|
return Err(format!("Could not install injected packages: {:?}", deb_files).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