This commit is contained in:
+2
-7
@@ -170,13 +170,8 @@ pub fn parse_changelog_footer(path: &Path) -> Result<(String, String), Box<dyn s
|
||||
)
|
||||
})?;
|
||||
let mut content = String::new();
|
||||
file.read_to_string(&mut content).map_err(|e| {
|
||||
format!(
|
||||
"Failed to read changelog '{}': {}",
|
||||
path.display(),
|
||||
e
|
||||
)
|
||||
})?;
|
||||
file.read_to_string(&mut content)
|
||||
.map_err(|e| format!("Failed to read changelog '{}': {}", path.display(), e))?;
|
||||
|
||||
// Find the last maintainer line (format: -- Name <email> Date)
|
||||
let re = Regex::new(r"--\s*([^<]+?)\s*<([^>]+)>\s*")?;
|
||||
|
||||
+1
-4
@@ -168,10 +168,7 @@ mod tests {
|
||||
ctx.copy_path(&src_dir, &dest_dir).unwrap();
|
||||
|
||||
// The regular file was copied.
|
||||
assert_eq!(
|
||||
ctx.read_file(&dest_dir.join("real.txt")).unwrap(),
|
||||
"data"
|
||||
);
|
||||
assert_eq!(ctx.read_file(&dest_dir.join("real.txt")).unwrap(), "data");
|
||||
// The symlink was reproduced as a symlink (not followed).
|
||||
let meta = std::fs::symlink_metadata(dest_dir.join("dangling")).unwrap();
|
||||
assert!(meta.file_type().is_symlink());
|
||||
|
||||
@@ -48,12 +48,8 @@ fn copy_dir_recursive(src: &Path, dest: &Path) -> io::Result<()> {
|
||||
Err(e) => {
|
||||
return Err(io::Error::new(
|
||||
e.kind(),
|
||||
format!(
|
||||
"Failed to read metadata of '{}': {}",
|
||||
src_path.display(),
|
||||
e
|
||||
),
|
||||
))
|
||||
format!("Failed to read metadata of '{}': {}", src_path.display(), e),
|
||||
));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
+2
-4
@@ -148,12 +148,10 @@ pub async fn build(
|
||||
)
|
||||
})?;
|
||||
if !status.success() {
|
||||
return Err(
|
||||
"apt-get update failed inside the build context. \
|
||||
return Err("apt-get update failed inside the build context. \
|
||||
If this is a local build, try executing with sudo, \
|
||||
or re-run with RUST_LOG=debug for more details."
|
||||
.into(),
|
||||
);
|
||||
.into());
|
||||
}
|
||||
|
||||
// Install essential packages
|
||||
|
||||
+19
-22
@@ -126,14 +126,13 @@ pub async fn get_ordered_series(dist: &str) -> Result<Vec<SeriesInformation>, Bo
|
||||
})?;
|
||||
let series_info = &dist_data.series;
|
||||
let content = if Path::new(series_info.local.as_str()).exists() {
|
||||
std::fs::read_to_string(format!("/usr/share/distro-info/{dist}.csv"))
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"Failed to read distribution series data for '{dist}' \
|
||||
std::fs::read_to_string(format!("/usr/share/distro-info/{dist}.csv")).map_err(|e| {
|
||||
format!(
|
||||
"Failed to read distribution series data for '{dist}' \
|
||||
from '{}': {}. The 'distro-info' package provides these CSV files.",
|
||||
series_info.local, e
|
||||
)
|
||||
})?
|
||||
series_info.local, e
|
||||
)
|
||||
})?
|
||||
} else {
|
||||
reqwest::get(series_info.network.as_str())
|
||||
.await?
|
||||
@@ -237,7 +236,8 @@ pub fn get_sources_url(base_url: &str, series: &str, pocket: &str, component: &s
|
||||
///
|
||||
/// Example: ubuntu => http://archive.ubuntu.com/ubuntu
|
||||
pub fn get_base_url(dist: &str) -> Result<String, Box<dyn Error>> {
|
||||
DATA.dist.get(dist)
|
||||
DATA.dist
|
||||
.get(dist)
|
||||
.map(|d| d.base_url.clone())
|
||||
.ok_or_else(|| {
|
||||
format!(
|
||||
@@ -281,15 +281,13 @@ pub async fn get_keyring_urls(series: &str) -> Result<Vec<String>, Box<dyn Error
|
||||
Ok(urls)
|
||||
}
|
||||
} else {
|
||||
let series_num = get_debian_series_number(series)
|
||||
.await?
|
||||
.ok_or_else(|| {
|
||||
format!(
|
||||
"Could not determine the version number for Debian series '{series}'. \
|
||||
let series_num = get_debian_series_number(series).await?.ok_or_else(|| {
|
||||
format!(
|
||||
"Could not determine the version number for Debian series '{series}'. \
|
||||
Make sure the 'distro-info' package is installed, which provides the \
|
||||
series CSV data used to map series names to version numbers."
|
||||
)
|
||||
})?;
|
||||
)
|
||||
})?;
|
||||
// Replace {series_num} placeholder with the actual series number
|
||||
Ok(vec![
|
||||
dist_data
|
||||
@@ -349,14 +347,13 @@ pub async fn get_debian_series_number(series: &str) -> Result<Option<String>, Bo
|
||||
})?;
|
||||
let series_info = &dist_data.series;
|
||||
let content = if Path::new(series_info.local.as_str()).exists() {
|
||||
std::fs::read_to_string(series_info.local.as_str())
|
||||
.map_err(|e| {
|
||||
format!(
|
||||
"Failed to read Debian series data from '{}': {}. \
|
||||
std::fs::read_to_string(series_info.local.as_str()).map_err(|e| {
|
||||
format!(
|
||||
"Failed to read Debian series data from '{}': {}. \
|
||||
The 'distro-info' package provides this file.",
|
||||
series_info.local, e
|
||||
)
|
||||
})?
|
||||
series_info.local, e
|
||||
)
|
||||
})?
|
||||
} else {
|
||||
reqwest::get(series_info.network.as_str())
|
||||
.await?
|
||||
|
||||
+2
-3
@@ -247,9 +247,8 @@ fn main() {
|
||||
let context = match type_str {
|
||||
"local" => ContextConfig::Local,
|
||||
"ssh" => {
|
||||
let endpoint = args
|
||||
.get_one::<String>("endpoint")
|
||||
.unwrap_or_else(|| {
|
||||
let endpoint =
|
||||
args.get_one::<String>("endpoint").unwrap_or_else(|| {
|
||||
error!(
|
||||
"An --endpoint is required to create an ssh context. \
|
||||
Expected format: [ssh://][user@]host[:port]"
|
||||
|
||||
+4
-1
@@ -104,7 +104,10 @@ fn copy_dir_all(src: &Path, dst: &Path) -> Result<(), Box<dyn Error>> {
|
||||
|
||||
// Reproduce symlinks as symlinks rather than following them, so that
|
||||
// dangling/absolute symlinks do not abort the copy.
|
||||
if std::fs::symlink_metadata(&src_path)?.file_type().is_symlink() {
|
||||
if std::fs::symlink_metadata(&src_path)?
|
||||
.file_type()
|
||||
.is_symlink()
|
||||
{
|
||||
let target = std::fs::read_link(&src_path)?;
|
||||
let _ = std::fs::remove_file(&dst_path);
|
||||
symlink(&target, &dst_path)?;
|
||||
|
||||
Reference in New Issue
Block a user