fmt
This commit is contained in:
+33
-51
@@ -15,7 +15,7 @@ use std::sync::Arc;
|
||||
|
||||
use crate::context::Context;
|
||||
use crate::debian::{
|
||||
parse_changelog_entry_from_str, ChecksumEntry, ControlInfo, FileChecksums, FilesList,
|
||||
ChecksumEntry, ControlInfo, FileChecksums, FilesList, parse_changelog_entry_from_str,
|
||||
};
|
||||
|
||||
/// Digests of one artifact.
|
||||
@@ -80,16 +80,12 @@ pub fn generate_binary_metadata(
|
||||
// ------------------------------------------------------------------
|
||||
let artifact_names: Vec<String> = files_list
|
||||
.iter()
|
||||
.filter(|e| {
|
||||
matches!(e.package_type.as_deref(), Some("deb") | Some("udeb"))
|
||||
})
|
||||
.filter(|e| matches!(e.package_type.as_deref(), Some("deb") | Some("udeb")))
|
||||
.map(|e| e.filename.clone())
|
||||
.collect();
|
||||
|
||||
if artifact_names.is_empty() {
|
||||
return Err(
|
||||
"binary build with no binary artifacts found; cannot distribute".into(),
|
||||
);
|
||||
return Err("binary build with no binary artifacts found; cannot distribute".into());
|
||||
}
|
||||
|
||||
let mut hashes = hashes_in_context(ctx, upload_dir, &artifact_names)?;
|
||||
@@ -98,9 +94,9 @@ pub fn generate_binary_metadata(
|
||||
let mut arch_values: Vec<String> = Vec::new();
|
||||
let mut arch_seen = std::collections::HashSet::new();
|
||||
for name in &artifact_names {
|
||||
let entry_hashes = hashes.remove(name).ok_or_else(|| {
|
||||
format!("artifact '{name}' listed in debian/files but not found")
|
||||
})?;
|
||||
let entry_hashes = hashes
|
||||
.remove(name)
|
||||
.ok_or_else(|| format!("artifact '{name}' listed in debian/files but not found"))?;
|
||||
checksums.insert_entry(
|
||||
name,
|
||||
ChecksumEntry {
|
||||
@@ -112,9 +108,10 @@ pub fn generate_binary_metadata(
|
||||
);
|
||||
// Architecture accumulation in encounter order (dpkg-genchanges).
|
||||
if let Some(file_entry) = files_list.get(name)
|
||||
&& let Some(arch) = file_entry.arch.as_ref().or_else(|| {
|
||||
file_entry.attrs.get("architecture")
|
||||
})
|
||||
&& let Some(arch) = file_entry
|
||||
.arch
|
||||
.as_ref()
|
||||
.or_else(|| file_entry.attrs.get("architecture"))
|
||||
&& arch_seen.insert(arch.clone())
|
||||
{
|
||||
arch_values.push(arch.clone());
|
||||
@@ -129,19 +126,15 @@ pub fn generate_binary_metadata(
|
||||
let mut binary_only_changes = None;
|
||||
|
||||
if entry.binary_only
|
||||
&& let Ok(prev_entry) =
|
||||
crate::debian::changelog::parse_previous_version_from_str(&ctx.read_file(
|
||||
&package_dir.join("debian/changelog"),
|
||||
)?)
|
||||
&& let Ok(prev_entry) = crate::debian::changelog::parse_previous_version_from_str(
|
||||
&ctx.read_file(&package_dir.join("debian/changelog"))?,
|
||||
)
|
||||
&& let Some(prev) = prev_entry
|
||||
{
|
||||
source_display = format!("{} ({})", entry.source, prev);
|
||||
binary_only_changes = Some(format!(
|
||||
"{}\n\n -- {} <{}> {}",
|
||||
entry.changes_field,
|
||||
entry.maintainer_name,
|
||||
entry.maintainer_email,
|
||||
entry.date_raw
|
||||
entry.changes_field, entry.maintainer_name, entry.maintainer_email, entry.date_raw
|
||||
));
|
||||
let prev_version = crate::debian::DebianVersion::parse(&prev)?;
|
||||
let dsc_name = format!("{}_{}.dsc", entry.source, prev_version.no_epoch());
|
||||
@@ -210,10 +203,7 @@ pub fn generate_binary_metadata(
|
||||
control.source.get("Build-Depends-Indep").unwrap_or(""),
|
||||
];
|
||||
let installed_build_depends =
|
||||
crate::build::buildinfo::installed_build_depends_from_content(
|
||||
&status_content,
|
||||
&bd_fields,
|
||||
)?;
|
||||
crate::build::buildinfo::installed_build_depends_from_content(&status_content, &bd_fields)?;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// .buildinfo generation, then registration in debian/files
|
||||
@@ -226,14 +216,9 @@ pub fn generate_binary_metadata(
|
||||
let mut buildinfo_arch_values = arch_values.clone();
|
||||
buildinfo_arch_values.sort();
|
||||
|
||||
let buildinfo_name = format!(
|
||||
"{}_{}_{}.buildinfo",
|
||||
entry.source,
|
||||
sversion,
|
||||
opts.host_arch
|
||||
);
|
||||
let buildinfo_doc = crate::build::buildinfo::render_buildinfo(
|
||||
&crate::build::buildinfo::BuildInfoInput {
|
||||
let buildinfo_name = format!("{}_{}_{}.buildinfo", entry.source, sversion, opts.host_arch);
|
||||
let buildinfo_doc =
|
||||
crate::build::buildinfo::render_buildinfo(&crate::build::buildinfo::BuildInfoInput {
|
||||
source: source_display.clone(),
|
||||
binaries: binaries.clone(),
|
||||
architecture: buildinfo_arch_values.join(" "),
|
||||
@@ -245,10 +230,12 @@ pub fn generate_binary_metadata(
|
||||
checksums: checksums.clone(),
|
||||
installed_build_depends,
|
||||
environment,
|
||||
},
|
||||
);
|
||||
});
|
||||
let buildinfo_path = upload_dir.join(&buildinfo_name);
|
||||
ctx.write_file(&buildinfo_path, &crate::debian::control::write_paragraph(&buildinfo_doc))?;
|
||||
ctx.write_file(
|
||||
&buildinfo_path,
|
||||
&crate::debian::control::write_paragraph(&buildinfo_doc),
|
||||
)?;
|
||||
|
||||
// Register the .buildinfo in debian/files, like dpkg-genbuildinfo does,
|
||||
// so the .changes distributes it.
|
||||
@@ -257,17 +244,11 @@ pub fn generate_binary_metadata(
|
||||
control.section(),
|
||||
control.priority(),
|
||||
));
|
||||
ctx.write_file(
|
||||
&package_dir.join("debian/files"),
|
||||
&files_list.render(),
|
||||
)?;
|
||||
ctx.write_file(&package_dir.join("debian/files"), &files_list.render())?;
|
||||
|
||||
// Hash the freshly written .buildinfo inside the context.
|
||||
let buildinfo_hashes = hashes_in_context(
|
||||
ctx,
|
||||
upload_dir,
|
||||
std::slice::from_ref(&buildinfo_name),
|
||||
)?;
|
||||
let buildinfo_hashes =
|
||||
hashes_in_context(ctx, upload_dir, std::slice::from_ref(&buildinfo_name))?;
|
||||
if let Some(h) = buildinfo_hashes.get(&buildinfo_name) {
|
||||
checksums.insert_entry(
|
||||
&buildinfo_name,
|
||||
@@ -303,7 +284,10 @@ pub fn generate_binary_metadata(
|
||||
files_list,
|
||||
});
|
||||
let changes_path = upload_dir.join(&changes_name);
|
||||
ctx.write_file(&changes_path, &crate::debian::control::write_paragraph(&changes_doc))?;
|
||||
ctx.write_file(
|
||||
&changes_path,
|
||||
&crate::debian::control::write_paragraph(&changes_doc),
|
||||
)?;
|
||||
|
||||
Ok((buildinfo_path, changes_path))
|
||||
}
|
||||
@@ -321,10 +305,7 @@ fn pipeline_environment(opts: &BinaryMetadataOptions) -> BTreeMap<String, String
|
||||
format!("parallel={}", opts.parallel),
|
||||
);
|
||||
if !opts.profiles.is_empty() {
|
||||
env.insert(
|
||||
"DEB_BUILD_PROFILES".to_string(),
|
||||
opts.profiles.join(","),
|
||||
);
|
||||
env.insert("DEB_BUILD_PROFILES".to_string(), opts.profiles.join(","));
|
||||
}
|
||||
env
|
||||
}
|
||||
@@ -453,7 +434,8 @@ fn include_dsc_artifacts(
|
||||
|
||||
// The .dsc itself is hashed fresh (it may be signed/rewritten); the
|
||||
// tarballs reuse the .dsc-recorded digests, like dpkg-genchanges does.
|
||||
let dsc_hashes = hashes_in_context(ctx, upload_dir, std::slice::from_ref(&dsc_name.to_string()))?;
|
||||
let dsc_hashes =
|
||||
hashes_in_context(ctx, upload_dir, std::slice::from_ref(&dsc_name.to_string()))?;
|
||||
if let Some(h) = dsc_hashes.get(dsc_name) {
|
||||
checksums.insert_entry(
|
||||
dsc_name,
|
||||
|
||||
@@ -127,8 +127,7 @@ pub fn installed_build_depends(
|
||||
) -> Result<String, Box<dyn std::error::Error>> {
|
||||
let content = std::fs::read_to_string(status_path)
|
||||
.map_err(|e| format!("cannot read status file '{}': {}", status_path.display(), e))?;
|
||||
installed_build_depends_from_content(&content, build_depends_fields)
|
||||
.map_err(|e| e.into())
|
||||
installed_build_depends_from_content(&content, build_depends_fields).map_err(|e| e.into())
|
||||
}
|
||||
|
||||
/// Compute the `Installed-Build-Depends` value from the textual content of a
|
||||
|
||||
+30
-13
@@ -219,7 +219,9 @@ pub fn run_source_build(
|
||||
let report = crate::debian::deps::check_build_depends(&ctrl, &check_opts)?;
|
||||
if !report.is_ok() {
|
||||
eprintln!("{}", report.message());
|
||||
return Err(Box::new(crate::debian::deps::UnmetBuildDependencies(report)));
|
||||
return Err(Box::new(crate::debian::deps::UnmetBuildDependencies(
|
||||
report,
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -892,7 +894,9 @@ mod differential_tests {
|
||||
if let Some(a) = arch {
|
||||
cmd.args(["-a", a]);
|
||||
}
|
||||
let output = cmd.output().expect("run dpkg-architecture (is dpkg-dev installed?)");
|
||||
let output = cmd
|
||||
.output()
|
||||
.expect("run dpkg-architecture (is dpkg-dev installed?)");
|
||||
assert!(
|
||||
output.status.success(),
|
||||
"dpkg-architecture -f {arch:?} failed: {}",
|
||||
@@ -907,7 +911,10 @@ mod differential_tests {
|
||||
|
||||
let ours = crate::debian::arch::arch_env(arch)
|
||||
.unwrap_or_else(|e| panic!("native arch_env({arch:?}) failed: {e}"));
|
||||
assert_eq!(ours, expected, "arch_env({arch:?}) differs from dpkg-architecture");
|
||||
assert_eq!(
|
||||
ours, expected,
|
||||
"arch_env({arch:?}) differs from dpkg-architecture"
|
||||
);
|
||||
}
|
||||
|
||||
/// Every architecture known to the local dpkg must produce an identical
|
||||
@@ -993,12 +1000,16 @@ mod differential_tests {
|
||||
ignore_builtin: true,
|
||||
admindir: admindir.clone(),
|
||||
};
|
||||
let control_info = crate::debian::ControlInfo::parse_content(control).expect("parse control");
|
||||
let control_info =
|
||||
crate::debian::ControlInfo::parse_content(control).expect("parse control");
|
||||
let report = crate::debian::deps::check_build_depends(&control_info, &opts)
|
||||
.expect("native parse failure");
|
||||
|
||||
let ours_exit = if report.is_ok() { 0 } else { 1 };
|
||||
assert_eq!(ours_exit, real_exit, "exit status mismatch for {control:?} {args:?}");
|
||||
assert_eq!(
|
||||
ours_exit, real_exit,
|
||||
"exit status mismatch for {control:?} {args:?}"
|
||||
);
|
||||
assert_eq!(
|
||||
report.message(),
|
||||
real_msg,
|
||||
@@ -1083,7 +1094,11 @@ Provides: virtual-thing (= 2.0), plain-virtual
|
||||
diff_checkbuilddeps_case(&control_ab, STATUS, &["-B", "-P", "cross"]);
|
||||
|
||||
// Combined unmet + conflict reporting in one run.
|
||||
case("missing-one, libc6 (>> 999)", "libfoo-dev", &["-P", "cross"]);
|
||||
case(
|
||||
"missing-one, libc6 (>> 999)",
|
||||
"libfoo-dev",
|
||||
&["-P", "cross"],
|
||||
);
|
||||
}
|
||||
|
||||
/// Differential check of [`crate::debian::version`] against real
|
||||
@@ -1094,10 +1109,10 @@ Provides: virtual-thing (= 2.0), plain-virtual
|
||||
let vectors = crate::debian::version::test_vectors::COMPARE;
|
||||
assert!(!vectors.is_empty());
|
||||
for (a, b, expected) in vectors {
|
||||
let va = crate::debian::DebianVersion::parse(a)
|
||||
.unwrap_or_else(|e| panic!("parse {a}: {e}"));
|
||||
let vb = crate::debian::DebianVersion::parse(b)
|
||||
.unwrap_or_else(|e| panic!("parse {b}: {e}"));
|
||||
let va =
|
||||
crate::debian::DebianVersion::parse(a).unwrap_or_else(|e| panic!("parse {a}: {e}"));
|
||||
let vb =
|
||||
crate::debian::DebianVersion::parse(b).unwrap_or_else(|e| panic!("parse {b}: {e}"));
|
||||
let ours = match va.cmp(&vb) {
|
||||
std::cmp::Ordering::Less => -1,
|
||||
std::cmp::Ordering::Equal => 0,
|
||||
@@ -1151,8 +1166,7 @@ Provides: virtual-thing (= 2.0), plain-virtual
|
||||
let tree = root.join(NAME);
|
||||
fs::write(tree.join("debian/control"), &control).expect("write control");
|
||||
fs::write(tree.join("debian/changelog"), &changelog).expect("write changelog");
|
||||
fs::write(tree.join("debian/source/format"), "3.0 (native)\n")
|
||||
.expect("write format");
|
||||
fs::write(tree.join("debian/source/format"), "3.0 (native)\n").expect("write format");
|
||||
fs::write(tree.join("debian/rules"), &rules).expect("write rules");
|
||||
#[cfg(unix)]
|
||||
{
|
||||
@@ -1192,7 +1206,10 @@ Provides: virtual-thing (= 2.0), plain-virtual
|
||||
let parallel = env::num_parallel();
|
||||
let build_env_vars: Vec<(String, String)> = [
|
||||
("LANG".to_string(), "C".to_string()),
|
||||
("DEB_BUILD_OPTIONS".to_string(), format!("parallel={parallel}")),
|
||||
(
|
||||
"DEB_BUILD_OPTIONS".to_string(),
|
||||
format!("parallel={parallel}"),
|
||||
),
|
||||
("SOURCE_DATE_EPOCH".to_string(), entry.timestamp.to_string()),
|
||||
]
|
||||
.into_iter()
|
||||
|
||||
Reference in New Issue
Block a user