[pve-devel] [PATCH proxmox-apt 3/5] check repos: have caller specify the current suite
Fabian Ebner
f.ebner at proxmox.com
Thu Jul 29 14:25:50 CEST 2021
Like that, a potential error is further up the stack, and it's more
consistent with what the standard_repository functions do.
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
src/repositories/file.rs | 6 ++----
src/repositories/mod.rs | 7 +++++--
tests/repositories.rs | 6 +++---
3 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/src/repositories/file.rs b/src/repositories/file.rs
index 49cc358..254af4d 100644
--- a/src/repositories/file.rs
+++ b/src/repositories/file.rs
@@ -5,7 +5,7 @@ use std::path::{Path, PathBuf};
use anyhow::{bail, format_err, Error};
use serde::{Deserialize, Serialize};
-use crate::repositories::release::{get_current_release_codename, DEBIAN_SUITES};
+use crate::repositories::release::DEBIAN_SUITES;
use crate::repositories::repository::{
APTRepository, APTRepositoryFileType, APTRepositoryPackageType,
};
@@ -300,7 +300,7 @@ impl APTRepositoryFile {
/// Checks if old or unstable suites are configured and also that the
/// `stable` keyword is not used.
- pub fn check_suites(&self) -> Result<Vec<APTRepositoryInfo>, Error> {
+ pub fn check_suites(&self, current_suite: &str) -> Result<Vec<APTRepositoryInfo>, Error> {
let mut infos = vec![];
for (n, repo) in self.repositories.iter().enumerate() {
@@ -318,8 +318,6 @@ impl APTRepositoryFile {
})
};
- let current_suite = get_current_release_codename()?;
-
let current_index = match DEBIAN_SUITES
.iter()
.position(|&suite| suite == current_suite)
diff --git a/src/repositories/mod.rs b/src/repositories/mod.rs
index 8637851..8f5500e 100644
--- a/src/repositories/mod.rs
+++ b/src/repositories/mod.rs
@@ -49,11 +49,14 @@ fn common_digest(files: &[APTRepositoryFile]) -> [u8; 32] {
/// `warnings` for bad suites.
/// `ignore-pre-upgrade-warning` when the next stable suite is configured.
/// `badge` for official URIs.
-pub fn check_repositories(files: &[APTRepositoryFile]) -> Result<Vec<APTRepositoryInfo>, Error> {
+pub fn check_repositories(
+ files: &[APTRepositoryFile],
+ current_suite: &str,
+) -> Result<Vec<APTRepositoryInfo>, Error> {
let mut infos = vec![];
for file in files.iter() {
- infos.append(&mut file.check_suites()?);
+ infos.append(&mut file.check_suites(current_suite)?);
infos.append(&mut file.check_uris());
}
diff --git a/tests/repositories.rs b/tests/repositories.rs
index 4cbde60..a9a7b96 100644
--- a/tests/repositories.rs
+++ b/tests/repositories.rs
@@ -187,7 +187,7 @@ fn test_check_repositories() -> Result<(), Error> {
let mut file = APTRepositoryFile::new(&absolute_suite_list)?.unwrap();
file.parse()?;
- let infos = check_repositories(&vec![file])?;
+ let infos = check_repositories(&vec![file], "bullseye")?;
assert_eq!(infos.is_empty(), true);
let pve_list = read_dir.join("pve.list");
@@ -212,7 +212,7 @@ fn test_check_repositories() -> Result<(), Error> {
}
expected_infos.sort();
- let mut infos = check_repositories(&vec![file])?;
+ let mut infos = check_repositories(&vec![file], "bullseye")?;
infos.sort();
assert_eq!(infos, expected_infos);
@@ -278,7 +278,7 @@ fn test_check_repositories() -> Result<(), Error> {
}
expected_infos.sort();
- let mut infos = check_repositories(&vec![file])?;
+ let mut infos = check_repositories(&vec![file], "bullseye")?;
infos.sort();
assert_eq!(infos, expected_infos);
--
2.30.2
More information about the pve-devel
mailing list