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 7D99E8AB37 for ; Fri, 21 Oct 2022 11:13:24 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5D7CC1FA3E for ; Fri, 21 Oct 2022 11:12:54 +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 for ; Fri, 21 Oct 2022 11:12:53 +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 1E78344AFC for ; Fri, 21 Oct 2022 11:12:53 +0200 (CEST) From: =?UTF-8?q?Fabian=20Gr=C3=BCnbichler?= To: pve-devel@lists.proxmox.com Date: Fri, 21 Oct 2022 11:12:43 +0200 Message-Id: <20221021091244.3846051-2-f.gruenbichler@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20221021091244.3846051-1-f.gruenbichler@proxmox.com> References: <20221021091244.3846051-1-f.gruenbichler@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.136 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 T_FILL_THIS_FORM_SHORT 0.01 Fill in a short form with personal information URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox-offline-mirror.rs] Subject: [pve-devel] [PATCH proxmox-offline-mirror 2/3] mirror setup: query filters in guided mode 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: Fri, 21 Oct 2022 09:13:24 -0000 with a somewhat sensible default of filtering the games and debug sections - which already reduces a mirror of PVE + Debian bullseye by about 27% (105GB->77GB). Signed-off-by: Fabian Grünbichler --- src/bin/proxmox-offline-mirror.rs | 42 ++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/bin/proxmox-offline-mirror.rs b/src/bin/proxmox-offline-mirror.rs index 07b6ce6..67036f1 100644 --- a/src/bin/proxmox-offline-mirror.rs +++ b/src/bin/proxmox-offline-mirror.rs @@ -96,7 +96,20 @@ fn derive_debian_repo( release: &Release, variant: &DebianVariant, components: &str, -) -> (String, String, String) { +) -> Result<(String, String, String, SkipConfig), Error> { + println!("Configure filters for Debian mirror {release} / {variant}:"); + let skip_sections = match read_string_from_tty("\tEnter list of package sections to be skipped ('-' for None):", Some("debug,games"))?.as_str() { + "-" => None, + list => Some(list.split(',').map(|v| v.trim().to_owned()).collect::>()), + }; + let skip_packages = match read_string_from_tty("\tEnter list of package names/name globs to be skipped ('-' for None):", None)?.as_str() { + "-" => None, + list => Some(list.split(',').map(|v| v.trim().to_owned()).collect::>()), + }; + let filters = SkipConfig { + skip_packages, + skip_sections, + }; let url = match (release, variant) { (Release::Bullseye, DebianVariant::Main) => "http://deb.debian.org/debian bullseye", (Release::Bullseye, DebianVariant::Security) => { @@ -138,14 +151,14 @@ fn derive_debian_repo( let suggested_id = format!("debian_{release}_{variant}"); - (url, key.to_string(), suggested_id) + Ok((url, key.to_string(), suggested_id, filters)) } fn action_add_mirror(config: &SectionConfigData) -> Result, Error> { let mut use_subscription = None; let mut extra_repos = Vec::new(); - let (repository, key_path, architectures, suggested_id) = if read_bool_from_tty( + let (repository, key_path, architectures, suggested_id, skip) = if read_bool_from_tty( "Guided Setup", Some(true), )? { @@ -163,7 +176,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er let mut add_debian_repo = false; - let (url, key_path, suggested_id) = match dist { + let (url, key_path, suggested_id, skip) = match dist { Distro::Debian => { let variants = &[ (DebianVariant::Main, "Main repository"), @@ -179,7 +192,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er Some("main contrib non-free"), )?; - derive_debian_repo(release, variant, &components) + derive_debian_repo(release, variant, &components)? } Distro::PveCeph => { enum CephRelease { @@ -231,7 +244,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er ); let suggested_id = format!("ceph_{ceph_release}_{release}"); - (url, key.to_string(), suggested_id) + (url, key.to_string(), suggested_id, SkipConfig::default()) } product => { let variants = &[ @@ -272,7 +285,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er Some(true), )?; - (url, key.to_string(), suggested_id) + (url, key.to_string(), suggested_id, SkipConfig::default()) } }; @@ -283,23 +296,24 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er release, &DebianVariant::Main, "main contrib", - )); + )?); extra_repos.push(derive_debian_repo( release, &DebianVariant::Updates, "main contrib", - )); + )?); extra_repos.push(derive_debian_repo( release, &DebianVariant::Security, "main contrib", - )); + )?); } ( format!("deb {url}"), key_path, architectures, Some(suggested_id), + skip, ) } else { let repo = read_string_from_tty("Enter repository line in sources.list format", None)?; @@ -329,7 +343,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er )? .clone(); - (repo, key_path, architectures, None) + (repo, key_path, architectures, None, SkipConfig::default()) }; if !Path::new(&key_path).exists() { @@ -371,7 +385,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er let mut configs = Vec::with_capacity(extra_repos.len() + 1); - for (url, key_path, suggested_id) in extra_repos { + for (url, key_path, suggested_id, skip) in extra_repos { if config.sections.contains_key(&suggested_id) { eprintln!("config section '{suggested_id}' already exists, skipping.."); } else { @@ -387,7 +401,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er base_dir: base_dir.clone(), use_subscription: None, ignore_errors: false, - skip: SkipConfig::default(), // TODO sensible default? + skip, }); } } @@ -402,7 +416,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result, Er base_dir, use_subscription, ignore_errors: false, - skip: SkipConfig::default(), + skip, }; configs.push(main_config); -- 2.30.2