Add configuration flags for portage arguments (#436)
This commit is contained in:
committed by
GitHub
parent
63ae33c841
commit
4a4e779621
@@ -58,6 +58,8 @@
|
||||
#yay_arguments = "--nodevel"
|
||||
#trizen_arguments = "--devel"
|
||||
#enable_tlmgr = true
|
||||
emerge_sync_flags = "-q"
|
||||
emerge_update_flags = "-uDNa --with-bdeps=y world"
|
||||
|
||||
#[windows]
|
||||
# Manually select Windows updates
|
||||
|
||||
@@ -12,6 +12,18 @@ use std::{env, fs};
|
||||
use structopt::StructOpt;
|
||||
use strum::{EnumIter, EnumString, EnumVariantNames, IntoEnumIterator, VariantNames};
|
||||
|
||||
#[allow(unused_macros)]
|
||||
macro_rules! str_value {
|
||||
($section:ident, $value:ident) => {
|
||||
pub fn $value(&self) -> Option<&str> {
|
||||
self.config_file
|
||||
.$section
|
||||
.as_ref()
|
||||
.and_then(|section| section.$value.as_deref())
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! check_deprecated {
|
||||
($config:expr, $old:ident, $section:ident, $new:ident) => {
|
||||
if $config.$old.is_some() {
|
||||
@@ -110,6 +122,8 @@ pub struct Linux {
|
||||
trizen_arguments: Option<String>,
|
||||
dnf_arguments: Option<String>,
|
||||
enable_tlmgr: Option<bool>,
|
||||
emerge_sync_flags: Option<String>,
|
||||
emerge_update_flags: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Default, Debug)]
|
||||
@@ -553,4 +567,10 @@ impl Config {
|
||||
!self.opt.disable_predefined_git_repos
|
||||
&& get_deprecated!(&self.config_file, predefined_git_repos, git, pull_predefined).unwrap_or(true)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
str_value!(linux, emerge_sync_flags);
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
str_value!(linux, emerge_update_flags);
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ impl Distribution {
|
||||
Distribution::CentOS | Distribution::Fedora => upgrade_redhat(ctx),
|
||||
Distribution::ClearLinux => upgrade_clearlinux(&sudo, run_type),
|
||||
Distribution::Debian => upgrade_debian(&sudo, cleanup, run_type, yes),
|
||||
Distribution::Gentoo => upgrade_gentoo(&sudo, run_type),
|
||||
Distribution::Gentoo => upgrade_gentoo(ctx),
|
||||
Distribution::Suse => upgrade_suse(&sudo, run_type),
|
||||
Distribution::Void => upgrade_void(&sudo, run_type),
|
||||
Distribution::Solus => upgrade_solus(&sudo, run_type),
|
||||
@@ -289,8 +289,10 @@ fn upgrade_void(sudo: &Option<PathBuf>, run_type: RunType) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn upgrade_gentoo(sudo: &Option<PathBuf>, run_type: RunType) -> Result<()> {
|
||||
if let Some(sudo) = &sudo {
|
||||
fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
if let Some(layman) = which("layman") {
|
||||
run_type.execute(&sudo).arg(layman).args(&["-s", "ALL"]).check_run()?;
|
||||
}
|
||||
@@ -298,8 +300,13 @@ fn upgrade_gentoo(sudo: &Option<PathBuf>, run_type: RunType) -> Result<()> {
|
||||
println!("Syncing portage");
|
||||
run_type
|
||||
.execute(&sudo)
|
||||
.arg("/usr/bin/emerge")
|
||||
.args(&["-q", "--sync"])
|
||||
.args(&["/usr/bin/emerge", "--sync"])
|
||||
.args(
|
||||
ctx.config()
|
||||
.emerge_sync_flags()
|
||||
.map(|s| s.split_whitespace().collect())
|
||||
.unwrap_or_else(|| vec!["-q"]),
|
||||
)
|
||||
.check_run()?;
|
||||
|
||||
if let Some(eix_update) = which("eix-update") {
|
||||
@@ -309,7 +316,12 @@ fn upgrade_gentoo(sudo: &Option<PathBuf>, run_type: RunType) -> Result<()> {
|
||||
run_type
|
||||
.execute(&sudo)
|
||||
.arg("/usr/bin/emerge")
|
||||
.args(&["-uDNa", "--with-bdeps=y", "world"])
|
||||
.args(
|
||||
ctx.config()
|
||||
.emerge_update_flags()
|
||||
.map(|s| s.split_whitespace().collect())
|
||||
.unwrap_or_else(|| vec!["-uDNa", "--with-bdeps=y", "world"]),
|
||||
)
|
||||
.check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
|
||||
Reference in New Issue
Block a user