mirror of
https://git.proxmox.com/git/proxmox
synced 2025-05-21 20:37:51 +00:00
repo: remove has_suite_variant helper
by exchanging loops in the check_suites function, which was the only user. Exchanging loops also helps for introducing a type for Debian condenames. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
13cdf8d1df
commit
51c69d76a5
@ -326,37 +326,39 @@ impl APTRepositoryFile {
|
|||||||
None => bail!("unknown release {}", current_suite),
|
None => bail!("unknown release {}", current_suite),
|
||||||
};
|
};
|
||||||
|
|
||||||
for (n, suite) in DEBIAN_SUITES.iter().enumerate() {
|
for suite in repo.suites.iter() {
|
||||||
if repo.has_suite_variant(suite) {
|
let base_suite = suite_variant(suite).0;
|
||||||
|
|
||||||
|
if base_suite == "stable" {
|
||||||
|
add_info(
|
||||||
|
"warning".to_string(),
|
||||||
|
"use the name of the stable distribution instead of 'stable'!".to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(n) = DEBIAN_SUITES.iter().position(|&suite| suite == base_suite) {
|
||||||
if n < current_index {
|
if n < current_index {
|
||||||
add_info(
|
add_info(
|
||||||
"warning".to_string(),
|
"warning".to_string(),
|
||||||
format!("old suite '{}' configured!", suite),
|
format!("old suite '{}' configured!", base_suite),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if n == current_index + 1 {
|
if n == current_index + 1 {
|
||||||
add_info(
|
add_info(
|
||||||
"ignore-pre-upgrade-warning".to_string(),
|
"ignore-pre-upgrade-warning".to_string(),
|
||||||
format!("suite '{}' should not be used in production!", suite),
|
format!("suite '{}' should not be used in production!", base_suite),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if n > current_index + 1 {
|
if n > current_index + 1 {
|
||||||
add_info(
|
add_info(
|
||||||
"warning".to_string(),
|
"warning".to_string(),
|
||||||
format!("suite '{}' should not be used in production!", suite),
|
format!("suite '{}' should not be used in production!", base_suite),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if repo.has_suite_variant("stable") {
|
|
||||||
add_info(
|
|
||||||
"warning".to_string(),
|
|
||||||
"use the name of the stable distribution instead of 'stable'!".to_string(),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(infos)
|
Ok(infos)
|
||||||
@ -390,3 +392,12 @@ impl APTRepositoryFile {
|
|||||||
infos
|
infos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Splits the suite into its base part and variant.
|
||||||
|
/// Does not expect the base part to contain either `-` or `/`.
|
||||||
|
fn suite_variant(suite: &str) -> (&str, &str) {
|
||||||
|
match suite.find(&['-', '/'][..]) {
|
||||||
|
Some(n) => (&suite[0..n], &suite[n..]),
|
||||||
|
None => (suite, ""),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -293,13 +293,6 @@ impl APTRepository {
|
|||||||
&& self.components.contains(&component)
|
&& self.components.contains(&component)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Check if a variant of the given suite is configured in this repository
|
|
||||||
pub fn has_suite_variant(&self, base_suite: &str) -> bool {
|
|
||||||
self.suites
|
|
||||||
.iter()
|
|
||||||
.any(|suite| suite_variant(suite).0 == base_suite)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Guess the origin from the repository's URIs.
|
/// Guess the origin from the repository's URIs.
|
||||||
///
|
///
|
||||||
/// Intended to be used as a fallback for get_cached_origin.
|
/// Intended to be used as a fallback for get_cached_origin.
|
||||||
@ -432,15 +425,6 @@ fn host_from_uri(uri: &str) -> Option<&str> {
|
|||||||
Some(host)
|
Some(host)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Splits the suite into its base part and variant.
|
|
||||||
/// Does not expect the base part to contain either `-` or `/`.
|
|
||||||
fn suite_variant(suite: &str) -> (&str, &str) {
|
|
||||||
match suite.find(&['-', '/'][..]) {
|
|
||||||
Some(n) => (&suite[0..n], &suite[n..]),
|
|
||||||
None => (suite, ""),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Strips existing double quotes from the string first, and then adds double quotes at
|
/// Strips existing double quotes from the string first, and then adds double quotes at
|
||||||
/// the beginning and end if there is an ASCII whitespace in the `string`, which is not
|
/// the beginning and end if there is an ASCII whitespace in the `string`, which is not
|
||||||
/// escaped by `[]`.
|
/// escaped by `[]`.
|
||||||
|
Loading…
Reference in New Issue
Block a user