committed by
GitHub
parent
cf34294a32
commit
819447dcdf
@@ -31,9 +31,6 @@
|
|||||||
# Arguments to pass tmux when pulling Repositories
|
# Arguments to pass tmux when pulling Repositories
|
||||||
#tmux_arguments = "-S /var/tmux.sock"
|
#tmux_arguments = "-S /var/tmux.sock"
|
||||||
|
|
||||||
# Arguments to pass yay when updating packages
|
|
||||||
#yay_arguments = "--nodevel"
|
|
||||||
|
|
||||||
# Manually select Windows updates
|
# Manually select Windows updates
|
||||||
# accept_all_windows_updates = false
|
# accept_all_windows_updates = false
|
||||||
|
|
||||||
@@ -56,3 +53,7 @@
|
|||||||
|
|
||||||
#[brew]
|
#[brew]
|
||||||
#greedy_cask = true
|
#greedy_cask = true
|
||||||
|
|
||||||
|
#[linux]
|
||||||
|
# Arguments to pass yay when updating packages
|
||||||
|
#yay_arguments = "--nodevel"
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
use super::utils::editor;
|
use super::utils::editor;
|
||||||
#[cfg(target_os = "macos")]
|
|
||||||
use crate::terminal::print_warning;
|
use crate::terminal::print_warning;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use directories::BaseDirs;
|
use directories::BaseDirs;
|
||||||
@@ -56,6 +55,12 @@ pub struct Brew {
|
|||||||
greedy_cask: Option<bool>,
|
greedy_cask: Option<bool>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Default, Debug)]
|
||||||
|
pub struct Linux {
|
||||||
|
yay_arguments: Option<String>,
|
||||||
|
dnf_arguments: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Default, Debug)]
|
#[derive(Deserialize, Default, Debug)]
|
||||||
pub struct Composer {
|
pub struct Composer {
|
||||||
self_update: Option<bool>,
|
self_update: Option<bool>,
|
||||||
@@ -85,6 +90,7 @@ pub struct ConfigFile {
|
|||||||
only: Option<Vec<Step>>,
|
only: Option<Vec<Step>>,
|
||||||
composer: Option<Composer>,
|
composer: Option<Composer>,
|
||||||
brew: Option<Brew>,
|
brew: Option<Brew>,
|
||||||
|
linux: Option<Linux>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConfigFile {
|
impl ConfigFile {
|
||||||
@@ -402,12 +408,23 @@ impl Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Extra yay arguments
|
/// Extra yay arguments
|
||||||
#[cfg(target_os = "linux")]
|
#[allow(dead_code)]
|
||||||
pub fn yay_arguments(&self) -> &str {
|
pub fn yay_arguments(&self) -> &str {
|
||||||
match &self.config_file.yay_arguments {
|
&self.config_file.yay_arguments.as_deref().map(|p| {
|
||||||
Some(args) => args.as_str(),
|
print_warning("Putting --yay-arguments in the top section is deprecated and will be removed in the future. Please move it to the [linux] section");
|
||||||
None => "--devel",
|
p
|
||||||
}
|
})
|
||||||
|
.or_else(|| self.config_file.linux.as_ref().and_then(|s| s.yay_arguments.as_deref()))
|
||||||
|
.unwrap_or("--devel")
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Extra yay arguments
|
||||||
|
#[allow(dead_code)]
|
||||||
|
pub fn dnf_arguments(&self) -> Option<&str> {
|
||||||
|
self.config_file
|
||||||
|
.linux
|
||||||
|
.as_ref()
|
||||||
|
.and_then(|linux| linux.dnf_arguments.as_deref())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn use_predefined_git_repos(&self) -> bool {
|
pub fn use_predefined_git_repos(&self) -> bool {
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ fn run() -> Result<()> {
|
|||||||
if config.should_run(Step::System) {
|
if config.should_run(Step::System) {
|
||||||
match &distribution {
|
match &distribution {
|
||||||
Ok(distribution) => {
|
Ok(distribution) => {
|
||||||
runner.execute("System update", || distribution.upgrade(&sudo, run_type, &config))?;
|
runner.execute("System update", || distribution.upgrade(&ctx))?;
|
||||||
}
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
println!("Error detecting current distribution: {}", e);
|
println!("Error detecting current distribution: {}", e);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use crate::config::Config;
|
|
||||||
use crate::error::{SkipStep, TopgradeError};
|
use crate::error::{SkipStep, TopgradeError};
|
||||||
|
use crate::execution_context::ExecutionContext;
|
||||||
use crate::executor::{ExecutorExitStatus, RunType};
|
use crate::executor::{ExecutorExitStatus, RunType};
|
||||||
use crate::terminal::{print_separator, print_warning};
|
use crate::terminal::{print_separator, print_warning};
|
||||||
use crate::utils::{require, require_option, which, PathExt};
|
use crate::utils::{require, require_option, which, PathExt};
|
||||||
@@ -79,15 +79,16 @@ impl Distribution {
|
|||||||
Err(TopgradeError::UnknownLinuxDistribution.into())
|
Err(TopgradeError::UnknownLinuxDistribution.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn upgrade(self, sudo: &Option<PathBuf>, run_type: RunType, config: &Config) -> Result<()> {
|
pub fn upgrade(self, ctx: &ExecutionContext) -> Result<()> {
|
||||||
print_separator("System update");
|
print_separator("System update");
|
||||||
|
let sudo = ctx.sudo();
|
||||||
let yes = config.yes();
|
let run_type = ctx.run_type();
|
||||||
let cleanup = config.cleanup();
|
let yes = ctx.config().yes();
|
||||||
|
let cleanup = ctx.config().cleanup();
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Distribution::Arch => upgrade_arch_linux(&sudo, cleanup, run_type, yes, &config.yay_arguments()),
|
Distribution::Arch => upgrade_arch_linux(&sudo, cleanup, run_type, yes, &ctx.config().yay_arguments()),
|
||||||
Distribution::CentOS | Distribution::Fedora => upgrade_redhat(&sudo, run_type, yes),
|
Distribution::CentOS | Distribution::Fedora => upgrade_redhat(ctx),
|
||||||
Distribution::ClearLinux => upgrade_clearlinux(&sudo, run_type),
|
Distribution::ClearLinux => upgrade_clearlinux(&sudo, run_type),
|
||||||
Distribution::Debian => upgrade_debian(&sudo, cleanup, run_type, yes),
|
Distribution::Debian => upgrade_debian(&sudo, cleanup, run_type, yes),
|
||||||
Distribution::Gentoo => upgrade_gentoo(&sudo, run_type),
|
Distribution::Gentoo => upgrade_gentoo(&sudo, run_type),
|
||||||
@@ -196,9 +197,9 @@ fn upgrade_arch_linux(
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn upgrade_redhat(sudo: &Option<PathBuf>, run_type: RunType, yes: bool) -> Result<()> {
|
fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||||
if let Some(sudo) = &sudo {
|
if let Some(sudo) = &ctx.sudo() {
|
||||||
let mut command = run_type.execute(&sudo);
|
let mut command = ctx.run_type().execute(&sudo);
|
||||||
command
|
command
|
||||||
.arg(Path::new("/usr/bin/dnf").if_exists().unwrap_or_else(|| {
|
.arg(Path::new("/usr/bin/dnf").if_exists().unwrap_or_else(|| {
|
||||||
Path::new("/usr/bin/yum")
|
Path::new("/usr/bin/yum")
|
||||||
@@ -206,7 +207,12 @@ fn upgrade_redhat(sudo: &Option<PathBuf>, run_type: RunType, yes: bool) -> Resul
|
|||||||
.unwrap_or_else(|| Path::new("/usr/bin/rpm-ostree"))
|
.unwrap_or_else(|| Path::new("/usr/bin/rpm-ostree"))
|
||||||
}))
|
}))
|
||||||
.arg("upgrade");
|
.arg("upgrade");
|
||||||
if yes {
|
|
||||||
|
if let Some(args) = ctx.config().dnf_arguments() {
|
||||||
|
command.args(args.split_whitespace());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ctx.config().yes() {
|
||||||
command.arg("-y");
|
command.arg("-y");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user