* [pve-devel] [PATCH proxmox-apt 1/3] upgrade to edition 2021 @ 2022-01-18 12:48 Fabian Ebner 2022-01-18 12:48 ` [pve-devel] [PATCH proxmox-apt 2/3] clippy fixes Fabian Ebner ` (2 more replies) 0 siblings, 3 replies; 4+ messages in thread From: Fabian Ebner @ 2022-01-18 12:48 UTC (permalink / raw) To: pve-devel std::convert::{TryFrom, TryInto} are now part of the prelude. Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> --- Cargo.toml | 2 +- rustfmt.toml | 2 +- src/repositories/file.rs | 1 - src/repositories/file/list_parser.rs | 1 - src/repositories/file/sources_parser.rs | 1 - src/repositories/release.rs | 1 - src/repositories/repository.rs | 1 - src/repositories/standard.rs | 1 - 8 files changed, 2 insertions(+), 8 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2098127..d2602d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ authors = [ "Fabian Ebner <f.ebner@proxmox.com>", "Proxmox Support Team <support@proxmox.com>", ] -edition = "2018" +edition = "2021" license = "AGPL-3" description = "Proxmox library for APT" homepage = "https://www.proxmox.com" diff --git a/rustfmt.toml b/rustfmt.toml index 32a9786..3a26366 100644 --- a/rustfmt.toml +++ b/rustfmt.toml @@ -1 +1 @@ -edition = "2018" +edition = "2021" diff --git a/src/repositories/file.rs b/src/repositories/file.rs index fffc47c..3e975fc 100644 --- a/src/repositories/file.rs +++ b/src/repositories/file.rs @@ -1,4 +1,3 @@ -use std::convert::{TryFrom, TryInto}; use std::fmt::Display; use std::path::{Path, PathBuf}; diff --git a/src/repositories/file/list_parser.rs b/src/repositories/file/list_parser.rs index 04c1729..deba41a 100644 --- a/src/repositories/file/list_parser.rs +++ b/src/repositories/file/list_parser.rs @@ -1,4 +1,3 @@ -use std::convert::TryInto; use std::io::BufRead; use std::iter::Iterator; diff --git a/src/repositories/file/sources_parser.rs b/src/repositories/file/sources_parser.rs index e824f3d..dc9170d 100644 --- a/src/repositories/file/sources_parser.rs +++ b/src/repositories/file/sources_parser.rs @@ -1,4 +1,3 @@ -use std::convert::TryInto; use std::io::BufRead; use std::iter::Iterator; diff --git a/src/repositories/release.rs b/src/repositories/release.rs index dbbc699..da391e5 100644 --- a/src/repositories/release.rs +++ b/src/repositories/release.rs @@ -1,4 +1,3 @@ -use std::convert::{TryFrom, TryInto}; use std::fmt::Display; use std::io::{BufRead, BufReader}; diff --git a/src/repositories/repository.rs b/src/repositories/repository.rs index ceaebef..05b98dd 100644 --- a/src/repositories/repository.rs +++ b/src/repositories/repository.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::fmt::Display; use std::io::{BufRead, BufReader, Write}; use std::path::PathBuf; diff --git a/src/repositories/standard.rs b/src/repositories/standard.rs index b6044e6..6b2cafd 100644 --- a/src/repositories/standard.rs +++ b/src/repositories/standard.rs @@ -1,4 +1,3 @@ -use std::convert::TryFrom; use std::fmt::Display; use anyhow::{bail, Error}; -- 2.30.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH proxmox-apt 2/3] clippy fixes 2022-01-18 12:48 [pve-devel] [PATCH proxmox-apt 1/3] upgrade to edition 2021 Fabian Ebner @ 2022-01-18 12:48 ` Fabian Ebner 2022-01-18 12:48 ` [pve-devel] [PATCH proxmox-apt 3/3] check suites: add special check for Debian security repository Fabian Ebner 2022-02-03 8:02 ` [pve-devel] applied-series: [PATCH proxmox-apt 1/3] upgrade to edition 2021 Wolfgang Bumiller 2 siblings, 0 replies; 4+ messages in thread From: Fabian Ebner @ 2022-01-18 12:48 UTC (permalink / raw) To: pve-devel Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> --- src/config.rs | 4 ++-- src/repositories/repository.rs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config.rs b/src/config.rs index aac8bc5..fcb66cb 100644 --- a/src/config.rs +++ b/src/config.rs @@ -24,12 +24,12 @@ impl APTConfig { /// /// Initializes with default values if init() wasn't called before. pub fn get() -> &'static APTConfig { - &GLOBAL_CONFIG.get_or_init(|| APTConfig::new(None, None)) + GLOBAL_CONFIG.get_or_init(|| APTConfig::new(None, None)) } /// Initialize the configuration. /// /// Only has an effect if no init() or get() has been called yet. pub fn init(config: APTConfig) -> &'static APTConfig { - &GLOBAL_CONFIG.get_or_init(|| config) + GLOBAL_CONFIG.get_or_init(|| config) } diff --git a/src/repositories/repository.rs b/src/repositories/repository.rs index 05b98dd..4c87f11 100644 --- a/src/repositories/repository.rs +++ b/src/repositories/repository.rs @@ -409,7 +409,7 @@ fn uri_to_filename(uri: &str) -> String { /// Get the host part from a given URI. fn host_from_uri(uri: &str) -> Option<&str> { let host = uri.strip_prefix("http")?; - let host = host.strip_prefix("s").unwrap_or(host); + let host = host.strip_prefix('s').unwrap_or(host); let mut host = host.strip_prefix("://")?; if let Some(end) = host.find('/') { -- 2.30.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] [PATCH proxmox-apt 3/3] check suites: add special check for Debian security repository 2022-01-18 12:48 [pve-devel] [PATCH proxmox-apt 1/3] upgrade to edition 2021 Fabian Ebner 2022-01-18 12:48 ` [pve-devel] [PATCH proxmox-apt 2/3] clippy fixes Fabian Ebner @ 2022-01-18 12:48 ` Fabian Ebner 2022-02-03 8:02 ` [pve-devel] applied-series: [PATCH proxmox-apt 1/3] upgrade to edition 2021 Wolfgang Bumiller 2 siblings, 0 replies; 4+ messages in thread From: Fabian Ebner @ 2022-01-18 12:48 UTC (permalink / raw) To: pve-devel since the suffix was changed with Debian Bullseye. Suggested-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Signed-off-by: Fabian Ebner <f.ebner@proxmox.com> --- src/repositories/file.rs | 31 +++++++++++++++++-- tests/repositories.rs | 31 +++++++++++++++++++ .../sources.list.d.expected/bad-security.list | 4 +++ tests/sources.list.d/bad-security.list | 4 +++ 4 files changed, 67 insertions(+), 3 deletions(-) create mode 100644 tests/sources.list.d.expected/bad-security.list create mode 100644 tests/sources.list.d/bad-security.list diff --git a/src/repositories/file.rs b/src/repositories/file.rs index 3e975fc..1b3ac85 100644 --- a/src/repositories/file.rs +++ b/src/repositories/file.rs @@ -297,8 +297,8 @@ impl APTRepositoryFile { Ok(()) } - /// Checks if old or unstable suites are configured and also that the - /// `stable` keyword is not used. + /// Checks if old or unstable suites are configured and that the Debian security repository + /// has the correct suite. Also checks that the `stable` keyword is not used. pub fn check_suites(&self, current_codename: DebianCodename) -> Vec<APTRepositoryInfo> { let mut infos = vec![]; @@ -307,6 +307,22 @@ impl APTRepositoryFile { continue; } + let is_security_repo = repo.uris.iter().any(|uri| { + let uri = uri.trim_end_matches('/'); + let uri = uri.strip_suffix("debian-security").unwrap_or(uri); + let uri = uri.trim_end_matches('/'); + matches!( + uri, + "http://security.debian.org" | "https://security.debian.org", + ) + }); + + let require_suffix = match is_security_repo { + true if current_codename >= DebianCodename::Bullseye => Some("-security"), + true => Some("/updates"), + false => None, + }; + let mut add_info = |kind: &str, message| { infos.push(APTRepositoryInfo { path: self.path.clone(), @@ -323,7 +339,7 @@ impl APTRepositoryFile { let message_stable = "use the name of the stable distribution instead of 'stable'!"; for suite in repo.suites.iter() { - let base_suite = suite_variant(suite).0; + let (base_suite, suffix) = suite_variant(suite); match base_suite { "oldoldstable" | "oldstable" => { @@ -352,6 +368,15 @@ impl APTRepositoryFile { } else if codename > current_codename { add_info("warning", message_new(base_suite)); } + + if let Some(require_suffix) = require_suffix { + if suffix != require_suffix { + add_info( + "warning", + format!("expected suite '{}{}'", current_codename, require_suffix), + ); + } + } } } diff --git a/tests/repositories.rs b/tests/repositories.rs index d79ea72..c6dd351 100644 --- a/tests/repositories.rs +++ b/tests/repositories.rs @@ -283,6 +283,37 @@ fn test_check_repositories() -> Result<(), Error> { assert_eq!(infos, expected_infos); + let bad_security = read_dir.join("bad-security.list"); + let mut file = APTRepositoryFile::new(&bad_security)?.unwrap(); + file.parse()?; + + let path_string = bad_security.into_os_string().into_string().unwrap(); + + let mut expected_infos = vec![]; + for n in 0..=1 { + expected_infos.push(APTRepositoryInfo { + path: path_string.clone(), + index: n, + property: Some("Suites".to_string()), + kind: "warning".to_string(), + message: "expected suite 'bullseye-security'".to_string(), + }); + } + for n in 0..=1 { + expected_infos.push(APTRepositoryInfo { + path: path_string.clone(), + index: n, + property: None, + kind: "origin".to_string(), + message: "Debian".to_string(), + }); + } + expected_infos.sort(); + + let mut infos = check_repositories(&vec![file], DebianCodename::Bullseye); + infos.sort(); + + assert_eq!(infos, expected_infos); Ok(()) } diff --git a/tests/sources.list.d.expected/bad-security.list b/tests/sources.list.d.expected/bad-security.list new file mode 100644 index 0000000..3f64ffa --- /dev/null +++ b/tests/sources.list.d.expected/bad-security.list @@ -0,0 +1,4 @@ +deb http://security.debian.org/debian-security/ bullseye/updates main contrib + +deb https://security.debian.org bullseye/updates main contrib + diff --git a/tests/sources.list.d/bad-security.list b/tests/sources.list.d/bad-security.list new file mode 100644 index 0000000..3f64ffa --- /dev/null +++ b/tests/sources.list.d/bad-security.list @@ -0,0 +1,4 @@ +deb http://security.debian.org/debian-security/ bullseye/updates main contrib + +deb https://security.debian.org bullseye/updates main contrib + -- 2.30.2 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [pve-devel] applied-series: [PATCH proxmox-apt 1/3] upgrade to edition 2021 2022-01-18 12:48 [pve-devel] [PATCH proxmox-apt 1/3] upgrade to edition 2021 Fabian Ebner 2022-01-18 12:48 ` [pve-devel] [PATCH proxmox-apt 2/3] clippy fixes Fabian Ebner 2022-01-18 12:48 ` [pve-devel] [PATCH proxmox-apt 3/3] check suites: add special check for Debian security repository Fabian Ebner @ 2022-02-03 8:02 ` Wolfgang Bumiller 2 siblings, 0 replies; 4+ messages in thread From: Wolfgang Bumiller @ 2022-02-03 8:02 UTC (permalink / raw) To: Fabian Ebner; +Cc: pve-devel applied series, thanks! ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-03 8:03 UTC | newest] Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2022-01-18 12:48 [pve-devel] [PATCH proxmox-apt 1/3] upgrade to edition 2021 Fabian Ebner 2022-01-18 12:48 ` [pve-devel] [PATCH proxmox-apt 2/3] clippy fixes Fabian Ebner 2022-01-18 12:48 ` [pve-devel] [PATCH proxmox-apt 3/3] check suites: add special check for Debian security repository Fabian Ebner 2022-02-03 8:02 ` [pve-devel] applied-series: [PATCH proxmox-apt 1/3] upgrade to edition 2021 Wolfgang Bumiller
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox