[pbs-devel] [PATCH v2 proxmox-apt 04/10] add check_repositories function
Wolfgang Bumiller
w.bumiller at proxmox.com
Wed Mar 10 16:17:43 CET 2021
On Fri, Feb 26, 2021 at 04:09:53PM +0100, Fabian Ebner wrote:
> which, for now, checks the suites.
>
> Signed-off-by: Fabian Ebner <f.ebner at proxmox.com>
> ---
>
> 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
More information about the pbs-devel
mailing list