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