[pve-devel] [RFC proxmox-apt 3/3] repository check: check components for Proxmox repositories
Fabian Ebner
f.ebner at proxmox.com
Mon Jul 5 15:50:30 CEST 2021
for no-subscription and test, which is currently done directly in the
front-end.
Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
---
src/repositories/file.rs | 34 +++++++++++++++++++++++---
src/repositories/mod.rs | 4 +--
tests/repositories.rs | 23 ++++++++++++++---
tests/sources.list.d.expected/pve.list | 2 ++
tests/sources.list.d/pve.list | 1 +
5 files changed, 55 insertions(+), 9 deletions(-)
diff --git a/src/repositories/file.rs b/src/repositories/file.rs
index b5bdb77..83bccf1 100644
--- a/src/repositories/file.rs
+++ b/src/repositories/file.rs
@@ -298,8 +298,8 @@ impl APTRepositoryFile {
Ok(())
}
- /// Checks if old or unstable suites are configured, and also tries to
- /// determine the origin of each repository.
+ /// Checks if old or unstable suites or components are configured, and also
+ /// tries to determine the origin of each repository.
pub fn check(&self) -> Result<Vec<APTRepositoryInfo>, Error> {
let mut infos = vec![];
@@ -327,11 +327,11 @@ impl APTRepositoryFile {
continue;
}
- let mut add_info = |kind, message| {
+ let mut add_info = |property, kind, message| {
infos.push(APTRepositoryInfo {
path: self.path.clone(),
index: n,
- property: Some("Suites".to_string()),
+ property,
kind,
message,
})
@@ -351,6 +351,7 @@ impl APTRepositoryFile {
if repo.has_suite_variant(suite) {
if n < current_index {
add_info(
+ Some("Suites".to_string()),
"warning".to_string(),
format!("old suite '{}' configured!", suite),
);
@@ -358,6 +359,7 @@ impl APTRepositoryFile {
if n == current_index + 1 {
add_info(
+ Some("Suites".to_string()),
"ignore-pre-upgrade-warning".to_string(),
format!("suite '{}' should not be used in production!", suite),
);
@@ -365,6 +367,7 @@ impl APTRepositoryFile {
if n > current_index + 1 {
add_info(
+ Some("Suites".to_string()),
"warning".to_string(),
format!("suite '{}' should not be used in production!", suite),
);
@@ -376,10 +379,33 @@ impl APTRepositoryFile {
&& repo.has_suite_variant("stable")
{
add_info(
+ Some("Suites".to_string()),
"warning".to_string(),
"use the name of the stable distribution instead of 'stable'!".to_string(),
);
}
+
+ if origin != Some("Proxmox".to_string()) {
+ continue;
+ }
+
+ for component in repo.components.iter() {
+ if component.ends_with("no-subscription") {
+ add_info(
+ Some("Components".to_string()),
+ "warning".to_string(),
+ "The no-subscription repository is NOT production-ready".to_string(),
+ );
+ }
+
+ if component.ends_with("test") {
+ add_info(
+ Some("Components".to_string()),
+ "warning".to_string(),
+ "The test repository may contain unstable updates".to_string(),
+ );
+ }
+ }
}
Ok(infos)
diff --git a/src/repositories/mod.rs b/src/repositories/mod.rs
index 6dd07f0..e5dea03 100644
--- a/src/repositories/mod.rs
+++ b/src/repositories/mod.rs
@@ -43,8 +43,8 @@ fn common_digest(files: &[APTRepositoryFile]) -> [u8; 32] {
openssl::sha::sha256(&common_raw[..])
}
-/// Currently checks if old or unstable suites are configured, and also tries to
-/// determine the origin of each repository.
+/// Currently checks if old or unstable suites and components are configured,
+/// and also tries to determine the origin of each repository.
///
/// For problems, the kind of info will be `warning` for enabled repositories
/// and `info` for disabled repositories. For the origin, the kind is `origin`.
diff --git a/tests/repositories.rs b/tests/repositories.rs
index 67b0255..940cd06 100644
--- a/tests/repositories.rs
+++ b/tests/repositories.rs
@@ -197,11 +197,26 @@ fn test_check_repositories() -> Result<(), Error> {
let path_string = pve_list.into_os_string().into_string().unwrap();
let origins = [
- "Debian", "Debian", "Proxmox", "Proxmox", "Proxmox", "Debian",
+ "Debian", "Debian", "Proxmox", "Proxmox", "Proxmox", "Proxmox", "Debian",
];
- let mut expected_infos = vec![];
- for n in 0..=5 {
+ let mut expected_infos = vec![
+ APTRepositoryInfo {
+ path: path_string.clone(),
+ index: 2,
+ property: Some("Components".to_string()),
+ kind: "warning".to_string(),
+ message: "The no-subscription repository is NOT production-ready".to_string(),
+ },
+ APTRepositoryInfo {
+ path: path_string.clone(),
+ index: 3,
+ property: Some("Components".to_string()),
+ kind: "warning".to_string(),
+ message: "The test repository may contain unstable updates".to_string(),
+ },
+ ];
+ for n in 0..=6 {
expected_infos.push(APTRepositoryInfo {
path: path_string.clone(),
index: n,
@@ -304,6 +319,7 @@ fn test_get_cached_origin() -> Result<(), Error> {
Some("Debian".to_string()),
Some("Debian".to_string()),
Some("Proxmox".to_string()),
+ Some("Proxmox".to_string()),
None, // no cache file exists
None, // no cache file exists
Some("Debian".to_string()),
@@ -353,6 +369,7 @@ fn test_standard_repositories() -> Result<(), Error> {
expected[0].status = Some(false);
expected[1].status = Some(true);
+ expected[2].status = Some(false);
let std_repos = standard_repositories("pve", &file_vec);
diff --git a/tests/sources.list.d.expected/pve.list b/tests/sources.list.d.expected/pve.list
index c801261..a30566b 100644
--- a/tests/sources.list.d.expected/pve.list
+++ b/tests/sources.list.d.expected/pve.list
@@ -6,6 +6,8 @@ deb http://ftp.debian.org/debian bullseye-updates main contrib
# NOT recommended for production use
deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription
+# deb http://download.proxmox.com/debian/pve bullseye pvetest
+
# deb https://enterprise.proxmox.com/debian/pve bullseye pve-enterprise
deb-src https://enterprise.proxmox.com/debian/pve buster pve-enterprise
diff --git a/tests/sources.list.d/pve.list b/tests/sources.list.d/pve.list
index 4d36d3d..1dfc857 100644
--- a/tests/sources.list.d/pve.list
+++ b/tests/sources.list.d/pve.list
@@ -4,6 +4,7 @@ deb http://ftp.debian.org/debian bullseye-updates main contrib
# PVE pve-no-subscription repository provided by proxmox.com,
# NOT recommended for production use
deb http://download.proxmox.com/debian/pve bullseye pve-no-subscription
+# deb http://download.proxmox.com/debian/pve bullseye pvetest
# deb https://enterprise.proxmox.com/debian/pve bullseye pve-enterprise
deb-src https://enterprise.proxmox.com/debian/pve buster pve-enterprise
--
2.30.2
More information about the pve-devel
mailing list