fmt, clippy
This commit is contained in:
+21
-8
@@ -6,7 +6,7 @@ use std::collections::{HashMap, HashSet, VecDeque};
|
||||
use std::path::Path;
|
||||
|
||||
use crate::debian::checksums::FileChecksums;
|
||||
use crate::debian::control::{parse_paragraphs, write_paragraph, Paragraph};
|
||||
use crate::debian::control::{Paragraph, parse_paragraphs, write_paragraph};
|
||||
|
||||
/// One installed package relevant for dependency resolution.
|
||||
#[derive(Debug, Clone)]
|
||||
@@ -52,13 +52,20 @@ impl StatusDb {
|
||||
};
|
||||
let arch = para.get("Architecture").unwrap_or("").to_string();
|
||||
if let (Some(version), false) = (para.get("Version"), arch.is_empty()) {
|
||||
db.pkgs.entry(package.to_string()).or_default().push(InstalledPkg {
|
||||
version: version.to_string(),
|
||||
arch: arch.clone(),
|
||||
});
|
||||
db.pkgs
|
||||
.entry(package.to_string())
|
||||
.or_default()
|
||||
.push(InstalledPkg {
|
||||
version: version.to_string(),
|
||||
arch: arch.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
if para.get("Essential").map(|v| v.eq_ignore_ascii_case("yes")).unwrap_or(false) {
|
||||
if para
|
||||
.get("Essential")
|
||||
.map(|v| v.eq_ignore_ascii_case("yes"))
|
||||
.unwrap_or(false)
|
||||
{
|
||||
db.essential.push(package.to_string());
|
||||
}
|
||||
|
||||
@@ -291,7 +298,10 @@ pub fn render_buildinfo(input: &BuildInfoInput) -> Paragraph {
|
||||
}
|
||||
|
||||
/// Serialize and atomically write a `.buildinfo` file.
|
||||
pub fn save_buildinfo(path: &Path, paragraph: &Paragraph) -> Result<(), Box<dyn std::error::Error>> {
|
||||
pub fn save_buildinfo(
|
||||
path: &Path,
|
||||
paragraph: &Paragraph,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
let tmp = path.with_extension("new");
|
||||
std::fs::write(&tmp, write_paragraph(paragraph))
|
||||
.map_err(|e| format!("cannot write '{}': {}", tmp.display(), e))?;
|
||||
@@ -366,7 +376,10 @@ Architecture: amd64
|
||||
#[test]
|
||||
fn wrap_binary_field() {
|
||||
assert_eq!(wrap_long("abc"), "abc");
|
||||
let long = (0..500).map(|i| i.to_string()).collect::<Vec<_>>().join(" ");
|
||||
let long = (0..500)
|
||||
.map(|i| i.to_string())
|
||||
.collect::<Vec<_>>()
|
||||
.join(" ");
|
||||
let wrapped = wrap_long(&long);
|
||||
assert!(wrapped.contains('\n'));
|
||||
for line in wrapped.lines() {
|
||||
|
||||
@@ -114,7 +114,7 @@ impl BuildType {
|
||||
|
||||
/// The architecture suffix used in artifact file names:
|
||||
/// host arch, `all` or `source`.
|
||||
pub fn arch_suffix<'a>(self, host_arch: &'a str) -> &'a str {
|
||||
pub fn arch_suffix(self, host_arch: &str) -> &str {
|
||||
if self.has_any(ARCH_DEP) {
|
||||
host_arch
|
||||
} else if self.has_any(ARCH_INDEP) {
|
||||
@@ -133,7 +133,10 @@ mod tests {
|
||||
fn parse_options() {
|
||||
assert_eq!(BuildType::from_options("full").unwrap(), FULL);
|
||||
assert_eq!(BuildType::from_options("source").unwrap(), SOURCE);
|
||||
assert_eq!(BuildType::from_options("source,any").unwrap(), SOURCE_ARCH_DEP);
|
||||
assert_eq!(
|
||||
BuildType::from_options("source,any").unwrap(),
|
||||
SOURCE_ARCH_DEP
|
||||
);
|
||||
assert_eq!(BuildType::from_options("any,all").unwrap(), BINARY);
|
||||
assert!(BuildType::from_options("bogus").is_err());
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
use std::path::Path;
|
||||
|
||||
use crate::debian::checksums::FileChecksums;
|
||||
use crate::debian::control::{write_paragraph, Paragraph};
|
||||
use crate::debian::control::{Paragraph, write_paragraph};
|
||||
use crate::debian::files::FilesList;
|
||||
|
||||
/// Everything needed to render a `.changes` file.
|
||||
@@ -165,7 +165,10 @@ mod tests {
|
||||
"verylongpkgname - short (udeb)"
|
||||
);
|
||||
let long_summary = "x".repeat(100);
|
||||
assert_eq!(format_description("p", "deb", &long_summary).len(), 10 + 3 + 65);
|
||||
assert_eq!(
|
||||
format_description("p", "deb", &long_summary).len(),
|
||||
10 + 3 + 65
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
@@ -230,7 +233,7 @@ mod tests {
|
||||
assert_eq!(
|
||||
files_value,
|
||||
"\n<md5> 8 utils optional pkg_1.0.dsc"
|
||||
.replace("<md5>", &files_value.split_whitespace().next().unwrap_or(""))
|
||||
.replace("<md5>", files_value.split_whitespace().next().unwrap_or(""))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
+8
-11
@@ -54,14 +54,12 @@ pub fn arch_env(host_arch: Option<&str>) -> Result<BTreeMap<String, String>, Str
|
||||
cmd.args(["--host-arch", arch]);
|
||||
}
|
||||
|
||||
let output = cmd
|
||||
.output()
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"failed to run 'dpkg-architecture': {}. Is 'dpkg-dev' installed?",
|
||||
e
|
||||
)
|
||||
})?;
|
||||
let output = cmd.output().map_err(|e| {
|
||||
format!(
|
||||
"failed to run 'dpkg-architecture': {}. Is 'dpkg-dev' installed?",
|
||||
e
|
||||
)
|
||||
})?;
|
||||
|
||||
if !output.status.success() {
|
||||
return Err(format!(
|
||||
@@ -83,8 +81,7 @@ pub fn arch_env(host_arch: Option<&str>) -> Result<BTreeMap<String, String>, Str
|
||||
/// Read the current vendor name from `/etc/dpkg/origins/default`
|
||||
/// (its `Vendor:` or `Origin:` field), defaulting to `"debian"`.
|
||||
pub fn current_vendor() -> String {
|
||||
read_vendor_from(Path::new("/etc/dpkg/origins/default"))
|
||||
.unwrap_or_else(|| "debian".to_string())
|
||||
read_vendor_from(Path::new("/etc/dpkg/origins/default")).unwrap_or_else(|| "debian".to_string())
|
||||
}
|
||||
|
||||
fn read_vendor_from(path: &Path) -> Option<String> {
|
||||
@@ -289,7 +286,7 @@ mod tests {
|
||||
let env = build_env(1787392800, 16, &[]);
|
||||
assert_eq!(env.get("SOURCE_DATE_EPOCH").unwrap(), "1787392800");
|
||||
assert_eq!(env.get("DEB_BUILD_OPTIONS").unwrap(), "parallel=16");
|
||||
assert!(env.get("DEB_BUILD_PROFILES").is_none());
|
||||
assert!(!env.contains_key("DEB_BUILD_PROFILES"));
|
||||
|
||||
let env = build_env(1, 4, &["nodoc".to_string(), "cross".to_string()]);
|
||||
assert_eq!(env.get("DEB_BUILD_PROFILES").unwrap(), "nodoc,cross");
|
||||
|
||||
+17
-4
@@ -17,7 +17,7 @@ use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use crate::debian::{
|
||||
parse_paragraphs, ChecksumEntry, ControlInfo, FileChecksums, FilesEntry, FilesList,
|
||||
ChecksumEntry, ControlInfo, FileChecksums, FilesEntry, FilesList, parse_paragraphs,
|
||||
};
|
||||
|
||||
/// Options for a native source-package build.
|
||||
@@ -151,7 +151,10 @@ pub fn run_source_build(
|
||||
);
|
||||
}
|
||||
Err(e) => {
|
||||
log::warn!("failed to check for GPG key: {}, building without signing", e);
|
||||
log::warn!(
|
||||
"failed to check for GPG key: {}, building without signing",
|
||||
e
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,7 +170,12 @@ pub fn run_source_build(
|
||||
// ------------------------------------------------------------------
|
||||
// 5. dpkg-source lifecycle: before-build + source build
|
||||
// ------------------------------------------------------------------
|
||||
run_command(cwd, "dpkg-source", &["-I", "-i", "--before-build", "."], &pipeline_env)?;
|
||||
run_command(
|
||||
cwd,
|
||||
"dpkg-source",
|
||||
&["-I", "-i", "--before-build", "."],
|
||||
&pipeline_env,
|
||||
)?;
|
||||
run_command(cwd, "dpkg-source", &["-I", "-i", "-b", "."], &pipeline_env)?;
|
||||
|
||||
if !dsc_path.exists() {
|
||||
@@ -333,7 +341,12 @@ pub fn run_source_build(
|
||||
// ------------------------------------------------------------------
|
||||
// 8. dpkg-source after-build (unapplies quilt patches it applied)
|
||||
// ------------------------------------------------------------------
|
||||
run_command(cwd, "dpkg-source", &["-I", "-i", "--after-build", "."], &pipeline_env)?;
|
||||
run_command(
|
||||
cwd,
|
||||
"dpkg-source",
|
||||
&["-I", "-i", "--after-build", "."],
|
||||
&pipeline_env,
|
||||
)?;
|
||||
|
||||
// ------------------------------------------------------------------
|
||||
// 9. Signing cascade: dsc -> buildinfo -> changes
|
||||
|
||||
Reference in New Issue
Block a user