exp: cross #3
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
/// Local binary package building
|
||||
/// Directly calling 'debian/rules' in current context
|
||||
use crate::context;
|
||||
use crate::deb::find_dsc_file;
|
||||
use std::collections::HashMap;
|
||||
use std::error::Error;
|
||||
use std::path::Path;
|
||||
@@ -8,9 +9,8 @@ use std::path::Path;
|
||||
use crate::deb::cross;
|
||||
|
||||
pub fn build(
|
||||
_cwd: &Path,
|
||||
package: &str,
|
||||
_version: &str,
|
||||
version: &str,
|
||||
arch: &str,
|
||||
series: &str,
|
||||
build_root: &str,
|
||||
@@ -19,6 +19,7 @@ pub fn build(
|
||||
// Environment
|
||||
let mut env = HashMap::<String, String>::new();
|
||||
env.insert("LANG".to_string(), "C".to_string());
|
||||
env.insert("DEBIAN_FRONTEND".to_string(), "noninteractive".to_string());
|
||||
|
||||
let ctx = context::current();
|
||||
|
||||
@@ -47,6 +48,7 @@ pub fn build(
|
||||
.arg("-y")
|
||||
.arg("install")
|
||||
.arg("build-essential")
|
||||
.arg("dose-builddebcheck")
|
||||
.arg("fakeroot");
|
||||
if cross {
|
||||
cmd.arg(format!("crossbuild-essential-{arch}"));
|
||||
@@ -66,7 +68,10 @@ pub fn build(
|
||||
cmd.arg(format!("--host-architecture={arch}"));
|
||||
}
|
||||
let status = cmd.arg("./").status()?;
|
||||
|
||||
// If build-dep fails, we try to explain the failure using dose-debcheck
|
||||
if !status.success() {
|
||||
dose3_explain_dependencies(package, version, arch, build_root, cross)?;
|
||||
return Err("Could not install build-dependencies for the build".into());
|
||||
}
|
||||
|
||||
@@ -97,3 +102,60 @@ pub fn build(
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn dose3_explain_dependencies(
|
||||
package: &str,
|
||||
version: &str,
|
||||
arch: &str,
|
||||
build_root: &str,
|
||||
cross: bool,
|
||||
) -> Result<(), Box<dyn Error>> {
|
||||
let ctx = context::current();
|
||||
|
||||
// Construct the list of Packages files
|
||||
let mut bg_args = Vec::new();
|
||||
let mut cmd = ctx.command("apt-get");
|
||||
cmd.arg("indextargets")
|
||||
.arg("--format")
|
||||
.arg("$(FILENAME)")
|
||||
.arg("Created-By: Packages");
|
||||
|
||||
let output = cmd.output()?;
|
||||
if output.status.success() {
|
||||
let filenames = String::from_utf8_lossy(&output.stdout);
|
||||
for file in filenames.lines() {
|
||||
let file = file.trim();
|
||||
if !file.is_empty() {
|
||||
bg_args.push(file.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Transform the dsc file into a 'Source' stanza (replacing 'Source' with 'Package')
|
||||
let dsc_path = find_dsc_file(build_root, package, version)?;
|
||||
let mut dsc_content = ctx.read_file(&dsc_path)?;
|
||||
dsc_content = dsc_content.replace("Source", "Package");
|
||||
ctx.write_file(
|
||||
Path::new(&format!("{build_root}/dsc-processed")),
|
||||
&dsc_content,
|
||||
)?;
|
||||
|
||||
// Call dose-builddebcheck
|
||||
let local_arch = crate::get_current_arch();
|
||||
let mut cmd = ctx.command("dose-builddebcheck");
|
||||
cmd.arg("--verbose")
|
||||
.arg("--failures")
|
||||
.arg("--explain")
|
||||
.arg("--summary")
|
||||
.arg(format!("--deb-native-arch={}", local_arch));
|
||||
|
||||
if cross {
|
||||
cmd.arg(format!("--deb-host-arch={}", arch))
|
||||
.arg("--deb-profiles=cross")
|
||||
.arg(format!("--deb-foreign-archs={}", arch));
|
||||
}
|
||||
|
||||
cmd.args(bg_args).arg(format!("{build_root}/dsc-processed"));
|
||||
cmd.status()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user