From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id EDBD7731AF for ; Mon, 5 Jul 2021 15:51:10 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 666DD202D9 for ; Mon, 5 Jul 2021 15:50:42 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 6B08F202C2 for ; Mon, 5 Jul 2021 15:50:40 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 4313C40BCF for ; Mon, 5 Jul 2021 15:50:40 +0200 (CEST) From: Fabian Ebner To: pve-devel@lists.proxmox.com Date: Mon, 5 Jul 2021 15:50:30 +0200 Message-Id: <20210705135033.101390-4-f.ebner@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210705135033.101390-1-f.ebner@proxmox.com> References: <20210705135033.101390-1-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.571 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [RFC proxmox-apt 3/3] repository check: check components for Proxmox repositories X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 05 Jul 2021 13:51:11 -0000 for no-subscription and test, which is currently done directly in the front-end. Signed-off-by: Fabian Ebner --- 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, 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