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 281CC69317 for ; Wed, 10 Mar 2021 16:17:46 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 200781F52B for ; Wed, 10 Mar 2021 16:17:46 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (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 E01801F51F for ; Wed, 10 Mar 2021 16:17:44 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9710F41A67 for ; Wed, 10 Mar 2021 16:17:44 +0100 (CET) Date: Wed, 10 Mar 2021 16:17:43 +0100 From: Wolfgang Bumiller To: Fabian Ebner Cc: pbs-devel@lists.proxmox.com Message-ID: <20210310151743.uyqeb7yp5ataz7hj@wobu-vie.proxmox.com> References: <20210226150959.9518-1-f.ebner@proxmox.com> <20210226150959.9518-5-f.ebner@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210226150959.9518-5-f.ebner@proxmox.com> User-Agent: NeoMutt/20180716 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.038 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [repositories.rs, mod.rs, types.rs, check.rs] Subject: Re: [pbs-devel] [PATCH v2 proxmox-apt 04/10] add check_repositories function X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Mar 2021 15:17:46 -0000 On Fri, Feb 26, 2021 at 04:09:53PM +0100, Fabian Ebner wrote: > which, for now, checks the suites. > > Signed-off-by: Fabian Ebner > --- > > Changes from v1: > * split this and information about Proxmox repositories in two > * add tests > > src/repositories/check.rs | 78 ++++++++++++++++++++++- > src/repositories/mod.rs | 16 ++++- > src/types.rs | 30 +++++++++ > tests/repositories.rs | 60 ++++++++++++++++- > tests/sources.list.d.expected/bad.sources | 20 ++++++ > tests/sources.list.d/bad.sources | 19 ++++++ > 6 files changed, 219 insertions(+), 4 deletions(-) > create mode 100644 tests/sources.list.d.expected/bad.sources > create mode 100644 tests/sources.list.d/bad.sources > > diff --git a/src/repositories/check.rs b/src/repositories/check.rs > index d0656cd..7726ff3 100644 > --- a/src/repositories/check.rs > +++ b/src/repositories/check.rs > @@ -1,6 +1,23 @@ > use anyhow::{bail, Error}; > > -use crate::types::{APTRepository, APTRepositoryFileType}; > +use crate::types::{ > + APTRepository, APTRepositoryFileType, APTRepositoryPackageType, APTRepositoryWarning, > +}; > + > +/// Checks if `suite` is some variant of `base_suite`, e.g. `buster-backports` > +/// is a variant of `buster`. > +#[allow(clippy::useless_format)] > +fn suite_is_variant(suite: &str, base_suite: &str) -> bool { > + let variants = vec![ > + format!("{}", base_suite), > + format!("{}-backports", base_suite), > + format!("{}-backports-sloppy", base_suite), > + format!("{}-updates", base_suite), > + format!("{}/updates", base_suite), > + ]; > + > + variants.iter().any(|variant| *variant == suite) Shouldn't `.strip_prefix()` get this job done as well? ;-) matches!( suite.strip_prefix(base_suite), Some("") | Some("-backports") | Some("-backports-sloppy") | Some("-updates") | Some("/updates") ) > +} > > impl APTRepository { > /// Makes sure that all basic properties of a repository are present and