mirror of
https://git.proxmox.com/git/proxmox-offline-mirror
synced 2025-08-14 02:34:01 +00:00
mirror setup: query filters in guided mode
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 <f.gruenbichler@proxmox.com>
This commit is contained in:
parent
695850273a
commit
f907fd5ed1
@ -96,7 +96,20 @@ fn derive_debian_repo(
|
|||||||
release: &Release,
|
release: &Release,
|
||||||
variant: &DebianVariant,
|
variant: &DebianVariant,
|
||||||
components: &str,
|
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::<Vec<String>>()),
|
||||||
|
};
|
||||||
|
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::<Vec<String>>()),
|
||||||
|
};
|
||||||
|
let filters = SkipConfig {
|
||||||
|
skip_packages,
|
||||||
|
skip_sections,
|
||||||
|
};
|
||||||
let url = match (release, variant) {
|
let url = match (release, variant) {
|
||||||
(Release::Bullseye, DebianVariant::Main) => "http://deb.debian.org/debian bullseye",
|
(Release::Bullseye, DebianVariant::Main) => "http://deb.debian.org/debian bullseye",
|
||||||
(Release::Bullseye, DebianVariant::Security) => {
|
(Release::Bullseye, DebianVariant::Security) => {
|
||||||
@ -138,14 +151,14 @@ fn derive_debian_repo(
|
|||||||
|
|
||||||
let suggested_id = format!("debian_{release}_{variant}");
|
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<Vec<MirrorConfig>, Error> {
|
fn action_add_mirror(config: &SectionConfigData) -> Result<Vec<MirrorConfig>, Error> {
|
||||||
let mut use_subscription = None;
|
let mut use_subscription = None;
|
||||||
let mut extra_repos = Vec::new();
|
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",
|
"Guided Setup",
|
||||||
Some(true),
|
Some(true),
|
||||||
)? {
|
)? {
|
||||||
@ -163,7 +176,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result<Vec<MirrorConfig>, Er
|
|||||||
|
|
||||||
let mut add_debian_repo = false;
|
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 => {
|
Distro::Debian => {
|
||||||
let variants = &[
|
let variants = &[
|
||||||
(DebianVariant::Main, "Main repository"),
|
(DebianVariant::Main, "Main repository"),
|
||||||
@ -179,7 +192,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result<Vec<MirrorConfig>, Er
|
|||||||
Some("main contrib non-free"),
|
Some("main contrib non-free"),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
derive_debian_repo(release, variant, &components)
|
derive_debian_repo(release, variant, &components)?
|
||||||
}
|
}
|
||||||
Distro::PveCeph => {
|
Distro::PveCeph => {
|
||||||
enum CephRelease {
|
enum CephRelease {
|
||||||
@ -231,7 +244,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result<Vec<MirrorConfig>, Er
|
|||||||
);
|
);
|
||||||
let suggested_id = format!("ceph_{ceph_release}_{release}");
|
let suggested_id = format!("ceph_{ceph_release}_{release}");
|
||||||
|
|
||||||
(url, key.to_string(), suggested_id)
|
(url, key.to_string(), suggested_id, SkipConfig::default())
|
||||||
}
|
}
|
||||||
product => {
|
product => {
|
||||||
let variants = &[
|
let variants = &[
|
||||||
@ -272,7 +285,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result<Vec<MirrorConfig>, Er
|
|||||||
Some(true),
|
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<Vec<MirrorConfig>, Er
|
|||||||
release,
|
release,
|
||||||
&DebianVariant::Main,
|
&DebianVariant::Main,
|
||||||
"main contrib",
|
"main contrib",
|
||||||
));
|
)?);
|
||||||
extra_repos.push(derive_debian_repo(
|
extra_repos.push(derive_debian_repo(
|
||||||
release,
|
release,
|
||||||
&DebianVariant::Updates,
|
&DebianVariant::Updates,
|
||||||
"main contrib",
|
"main contrib",
|
||||||
));
|
)?);
|
||||||
extra_repos.push(derive_debian_repo(
|
extra_repos.push(derive_debian_repo(
|
||||||
release,
|
release,
|
||||||
&DebianVariant::Security,
|
&DebianVariant::Security,
|
||||||
"main contrib",
|
"main contrib",
|
||||||
));
|
)?);
|
||||||
}
|
}
|
||||||
(
|
(
|
||||||
format!("deb {url}"),
|
format!("deb {url}"),
|
||||||
key_path,
|
key_path,
|
||||||
architectures,
|
architectures,
|
||||||
Some(suggested_id),
|
Some(suggested_id),
|
||||||
|
skip,
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
let repo = read_string_from_tty("Enter repository line in sources.list format", None)?;
|
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<Vec<MirrorConfig>, Er
|
|||||||
)?
|
)?
|
||||||
.clone();
|
.clone();
|
||||||
|
|
||||||
(repo, key_path, architectures, None)
|
(repo, key_path, architectures, None, SkipConfig::default())
|
||||||
};
|
};
|
||||||
|
|
||||||
if !Path::new(&key_path).exists() {
|
if !Path::new(&key_path).exists() {
|
||||||
@ -371,7 +385,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result<Vec<MirrorConfig>, Er
|
|||||||
|
|
||||||
let mut configs = Vec::with_capacity(extra_repos.len() + 1);
|
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) {
|
if config.sections.contains_key(&suggested_id) {
|
||||||
eprintln!("config section '{suggested_id}' already exists, skipping..");
|
eprintln!("config section '{suggested_id}' already exists, skipping..");
|
||||||
} else {
|
} else {
|
||||||
@ -387,7 +401,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result<Vec<MirrorConfig>, Er
|
|||||||
base_dir: base_dir.clone(),
|
base_dir: base_dir.clone(),
|
||||||
use_subscription: None,
|
use_subscription: None,
|
||||||
ignore_errors: false,
|
ignore_errors: false,
|
||||||
skip: SkipConfig::default(), // TODO sensible default?
|
skip,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -402,7 +416,7 @@ fn action_add_mirror(config: &SectionConfigData) -> Result<Vec<MirrorConfig>, Er
|
|||||||
base_dir,
|
base_dir,
|
||||||
use_subscription,
|
use_subscription,
|
||||||
ignore_errors: false,
|
ignore_errors: false,
|
||||||
skip: SkipConfig::default(),
|
skip,
|
||||||
};
|
};
|
||||||
|
|
||||||
configs.push(main_config);
|
configs.push(main_config);
|
||||||
|
Loading…
Reference in New Issue
Block a user