From: Fabian Ebner <f.ebner@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH proxmox-apt 2/3] repository check: limit 'stable' to Proxmox and Debian origin
Date: Mon, 5 Jul 2021 15:50:29 +0200 [thread overview]
Message-ID: <20210705135033.101390-3-f.ebner@proxmox.com> (raw)
In-Reply-To: <20210705135033.101390-1-f.ebner@proxmox.com>
For foreign repositories, it's a better heuristic to assume it's used
in a non-dangerous (i.e. no sudden major upgrade on release day) way.
Reported-by: Dominik Csapak <d.csapak@proxmox.com>
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
src/repositories/file.rs | 57 ++++++++++++++++++----------------------
src/repositories/mod.rs | 12 ++++-----
2 files changed, 30 insertions(+), 39 deletions(-)
diff --git a/src/repositories/file.rs b/src/repositories/file.rs
index 49cc358..b5bdb77 100644
--- a/src/repositories/file.rs
+++ b/src/repositories/file.rs
@@ -298,12 +298,31 @@ impl APTRepositoryFile {
Ok(())
}
- /// 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> {
+ /// Checks if old or unstable suites are configured, and also tries to
+ /// determine the origin of each repository.
+ pub fn check(&self) -> Result<Vec<APTRepositoryInfo>, Error> {
let mut infos = vec![];
for (n, repo) in self.repositories.iter().enumerate() {
+ let mut origin = match repo.get_cached_origin() {
+ Ok(option) => option,
+ Err(_) => None,
+ };
+
+ if origin.is_none() {
+ origin = repo.origin_from_uris();
+ }
+
+ if let Some(ref origin) = origin {
+ infos.push(APTRepositoryInfo {
+ path: self.path.clone(),
+ index: n,
+ kind: "origin".to_string(),
+ property: None,
+ message: origin.to_string(),
+ });
+ }
+
if !repo.types.contains(&APTRepositoryPackageType::Deb) {
continue;
}
@@ -353,7 +372,9 @@ impl APTRepositoryFile {
}
}
- if repo.has_suite_variant("stable") {
+ if (origin == Some("Proxmox".to_string()) || origin == Some("Debian".to_string()))
+ && repo.has_suite_variant("stable")
+ {
add_info(
"warning".to_string(),
"use the name of the stable distribution instead of 'stable'!".to_string(),
@@ -363,32 +384,4 @@ impl APTRepositoryFile {
Ok(infos)
}
-
- /// Checks for official URIs.
- pub fn check_uris(&self) -> Vec<APTRepositoryInfo> {
- let mut infos = vec![];
-
- for (n, repo) in self.repositories.iter().enumerate() {
- let mut origin = match repo.get_cached_origin() {
- Ok(option) => option,
- Err(_) => None,
- };
-
- if origin.is_none() {
- origin = repo.origin_from_uris();
- }
-
- if let Some(origin) = origin {
- infos.push(APTRepositoryInfo {
- path: self.path.clone(),
- index: n,
- kind: "origin".to_string(),
- property: None,
- message: origin,
- });
- }
- }
-
- infos
- }
}
diff --git a/src/repositories/mod.rs b/src/repositories/mod.rs
index 7bac333..6dd07f0 100644
--- a/src/repositories/mod.rs
+++ b/src/repositories/mod.rs
@@ -43,18 +43,16 @@ fn common_digest(files: &[APTRepositoryFile]) -> [u8; 32] {
openssl::sha::sha256(&common_raw[..])
}
-/// Provides additional information about the repositories.
+/// Currently checks if old or unstable suites are configured, and also tries to
+/// determine the origin of each repository.
///
-/// The kind of information can be:
-/// `warnings` for bad suites.
-/// `ignore-pre-upgrade-warning` when the next stable suite is configured.
-/// `badge` for official URIs.
+/// For problems, the kind of info will be `warning` for enabled repositories
+/// and `info` for disabled repositories. For the origin, the kind is `origin`.
pub fn check_repositories(files: &[APTRepositoryFile]) -> Result<Vec<APTRepositoryInfo>, Error> {
let mut infos = vec![];
for file in files.iter() {
- infos.append(&mut file.check_suites()?);
- infos.append(&mut file.check_uris());
+ infos.append(&mut file.check()?);
}
Ok(infos)
--
2.30.2
next prev parent reply other threads:[~2021-07-05 13:51 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-05 13:50 [pve-devel] [PATCH-SERIES apt/widget-toolkit/manager] small refinements for APT repositories Fabian Ebner
2021-07-05 13:50 ` [pve-devel] [PATCH proxmox-apt 1/3] code cleanup: use contains() Fabian Ebner
2021-07-16 14:19 ` [pve-devel] applied: " Thomas Lamprecht
2021-07-05 13:50 ` Fabian Ebner [this message]
2021-07-05 13:50 ` [pve-devel] [RFC proxmox-apt 3/3] repository check: check components for Proxmox repositories Fabian Ebner
2021-07-05 13:50 ` [pve-devel] [PATCH proxmox-widget-toolkit 1/2] node: repos: properly ignore warnings for other properties Fabian Ebner
2021-07-05 13:50 ` [pve-devel] [RFC proxmox-widget-toolkit 2/2] node: repos: show components warnings from the backend Fabian Ebner
2021-07-05 13:50 ` [pve-devel] [PATCH manager 1/1] api: apt: repositories: add description to return schema Fabian Ebner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210705135033.101390-3-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox