Revert "10.2.0 release " (#215)
Revert "10.2.0 release (#213)"
This reverts commit 13076fcef6.
This commit is contained in:
@@ -1,10 +1,8 @@
|
||||
use crate::command::CommandExt;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::terminal::print_separator;
|
||||
use crate::utils::require;
|
||||
use crate::utils::which;
|
||||
use crate::Step;
|
||||
use color_eyre::eyre::Result;
|
||||
use anyhow::Result;
|
||||
|
||||
pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
//let pkg = require("pkg")?;
|
||||
@@ -12,7 +10,7 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Termux Packages");
|
||||
|
||||
let is_nala = pkg.ends_with("nala");
|
||||
let is_nala = pkg.end_with("nala");
|
||||
|
||||
let mut command = ctx.run_type().execute(&pkg);
|
||||
command.arg("upgrade");
|
||||
@@ -20,18 +18,20 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
|
||||
if !is_nala && ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&pkg).arg("clean").status_checked()?;
|
||||
if !is_nala {
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(&pkg).arg("clean").check_run()?;
|
||||
|
||||
let apt = require("apt")?;
|
||||
let mut command = ctx.run_type().execute(&apt);
|
||||
command.arg("autoremove");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
let apt = require("apt")?;
|
||||
let mut command = ctx.run_type().execute(&apt);
|
||||
command.arg("autoremove");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.check_run()?;
|
||||
}
|
||||
command.status_checked()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -3,11 +3,9 @@ use std::ffi::OsString;
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use color_eyre::eyre;
|
||||
use color_eyre::eyre::Result;
|
||||
use anyhow::Result;
|
||||
use walkdir::WalkDir;
|
||||
|
||||
use crate::command::CommandExt;
|
||||
use crate::error::TopgradeError;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::utils::which;
|
||||
@@ -31,7 +29,11 @@ pub struct YayParu {
|
||||
impl ArchPackageManager for YayParu {
|
||||
fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> {
|
||||
if ctx.config().show_arch_news() {
|
||||
Command::new(&self.executable).arg("-Pw").status_checked()?;
|
||||
Command::new(&self.executable)
|
||||
.arg("-Pw")
|
||||
.spawn()
|
||||
.and_then(|mut p| p.wait())
|
||||
.ok();
|
||||
}
|
||||
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
@@ -46,7 +48,7 @@ impl ArchPackageManager for YayParu {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
@@ -54,7 +56,7 @@ impl ArchPackageManager for YayParu {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -86,7 +88,7 @@ impl ArchPackageManager for Trizen {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
@@ -94,7 +96,7 @@ impl ArchPackageManager for Trizen {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -124,7 +126,7 @@ impl ArchPackageManager for Pacman {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&self.sudo);
|
||||
@@ -132,7 +134,7 @@ impl ArchPackageManager for Pacman {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -173,7 +175,7 @@ impl ArchPackageManager for Pikaur {
|
||||
command.arg("--noconfirm");
|
||||
}
|
||||
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
@@ -181,7 +183,7 @@ impl ArchPackageManager for Pikaur {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--noconfirm");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -212,7 +214,7 @@ impl ArchPackageManager for Pamac {
|
||||
command.arg("--no-confirm");
|
||||
}
|
||||
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
let mut command = ctx.run_type().execute(&self.executable);
|
||||
@@ -220,7 +222,7 @@ impl ArchPackageManager for Pamac {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("--no-confirm");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -255,7 +257,7 @@ impl ArchPackageManager for Aura {
|
||||
aur_update.arg("--noconfirm");
|
||||
}
|
||||
|
||||
aur_update.status_checked()?;
|
||||
aur_update.check_run()?;
|
||||
} else {
|
||||
println!("Aura requires sudo installed to work with AUR packages")
|
||||
}
|
||||
@@ -268,7 +270,7 @@ impl ArchPackageManager for Aura {
|
||||
if ctx.config().yes(Step::System) {
|
||||
pacman_update.arg("--noconfirm");
|
||||
}
|
||||
pacman_update.status_checked()?;
|
||||
pacman_update.check_run()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -302,7 +304,7 @@ pub fn get_arch_package_manager(ctx: &ExecutionContext) -> Option<Box<dyn ArchPa
|
||||
|
||||
pub fn upgrade_arch_linux(ctx: &ExecutionContext) -> Result<()> {
|
||||
let package_manager =
|
||||
get_arch_package_manager(ctx).ok_or_else(|| eyre::Report::from(TopgradeError::FailedGettingPackageManager))?;
|
||||
get_arch_package_manager(ctx).ok_or_else(|| anyhow::Error::from(TopgradeError::FailedGettingPackageManager))?;
|
||||
package_manager.upgrade(ctx)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,26 +1,26 @@
|
||||
use crate::command::CommandExt;
|
||||
use crate::executor::RunType;
|
||||
use crate::terminal::print_separator;
|
||||
use crate::utils::require_option;
|
||||
use color_eyre::eyre::Result;
|
||||
use anyhow::Result;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
pub fn upgrade_packages(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
||||
let sudo = require_option(sudo, String::from("No sudo detected"))?;
|
||||
print_separator("DragonFly BSD Packages");
|
||||
print_separator("DrgaonFly BSD Packages");
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.args(["/usr/local/sbin/pkg", "upgrade"])
|
||||
.status_checked()
|
||||
.args(&["/usr/local/sbin/pkg", "upgrade"])
|
||||
.check_run()
|
||||
}
|
||||
|
||||
pub fn audit_packages(sudo: &Option<PathBuf>) -> Result<()> {
|
||||
if let Some(sudo) = sudo {
|
||||
println!();
|
||||
Command::new(sudo)
|
||||
.args(["/usr/local/sbin/pkg", "audit", "-Fr"])
|
||||
.status_checked()?;
|
||||
.args(&["/usr/local/sbin/pkg", "audit", "-Fr"])
|
||||
.spawn()?
|
||||
.wait()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
use crate::command::CommandExt;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::executor::RunType;
|
||||
use crate::terminal::print_separator;
|
||||
use crate::utils::require_option;
|
||||
use crate::Step;
|
||||
use color_eyre::eyre::Result;
|
||||
use anyhow::Result;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
|
||||
@@ -13,29 +10,23 @@ pub fn upgrade_freebsd(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()>
|
||||
print_separator("FreeBSD Update");
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.args(["/usr/sbin/freebsd-update", "fetch", "install"])
|
||||
.status_checked()
|
||||
.args(&["/usr/sbin/freebsd-update", "fetch", "install"])
|
||||
.check_run()
|
||||
}
|
||||
|
||||
pub fn upgrade_packages(ctx: &ExecutionContext, sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
||||
pub fn upgrade_packages(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
||||
let sudo = require_option(sudo, String::from("No sudo detected"))?;
|
||||
print_separator("FreeBSD Packages");
|
||||
|
||||
let mut command = run_type.execute(sudo);
|
||||
|
||||
command.args(["/usr/sbin/pkg", "upgrade"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.status_checked()
|
||||
run_type.execute(sudo).args(&["/usr/sbin/pkg", "upgrade"]).check_run()
|
||||
}
|
||||
|
||||
pub fn audit_packages(sudo: &Option<PathBuf>) -> Result<()> {
|
||||
if let Some(sudo) = sudo {
|
||||
println!();
|
||||
Command::new(sudo)
|
||||
.args(["/usr/sbin/pkg", "audit", "-Fr"])
|
||||
.status_checked()?;
|
||||
.args(&["/usr/sbin/pkg", "audit", "-Fr"])
|
||||
.spawn()?
|
||||
.wait()?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::process::Command;
|
||||
|
||||
use color_eyre::eyre::Result;
|
||||
use anyhow::Result;
|
||||
use ini::Ini;
|
||||
use tracing::{debug, warn};
|
||||
use log::{debug, warn};
|
||||
|
||||
use crate::command::CommandExt;
|
||||
use crate::error::{SkipStep, TopgradeError};
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::executor::RunType;
|
||||
use crate::executor::{CommandExt, RunType};
|
||||
use crate::steps::os::archlinux;
|
||||
use crate::terminal::{print_separator, print_warning};
|
||||
use crate::utils::{require, require_option, which, PathExt};
|
||||
@@ -128,10 +127,11 @@ fn update_bedrock(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
ctx.run_type().execute(sudo).args(["brl", "update"]);
|
||||
|
||||
let output = Command::new("brl").arg("list").output_checked_utf8()?;
|
||||
let output = Command::new("brl").arg("list").output()?;
|
||||
debug!("brl list: {:?} {:?}", output.stdout, output.stderr);
|
||||
|
||||
for distribution in output.stdout.trim().lines() {
|
||||
let parsed_output = String::from_utf8(output.stdout).unwrap();
|
||||
for distribution in parsed_output.trim().split('\n') {
|
||||
debug!("Bedrock distribution {}", distribution);
|
||||
match distribution {
|
||||
"arch" => archlinux::upgrade_arch_linux(ctx)?,
|
||||
@@ -148,7 +148,7 @@ fn update_bedrock(ctx: &ExecutionContext) -> Result<()> {
|
||||
}
|
||||
|
||||
fn is_wsl() -> Result<bool> {
|
||||
let output = Command::new("uname").arg("-r").output_checked_utf8()?.stdout;
|
||||
let output = Command::new("uname").arg("-r").check_output()?;
|
||||
debug!("Uname output: {}", output);
|
||||
Ok(output.contains("microsoft"))
|
||||
}
|
||||
@@ -157,8 +157,8 @@ fn upgrade_alpine_linux(ctx: &ExecutionContext) -> Result<()> {
|
||||
let apk = require("apk")?;
|
||||
let sudo = ctx.sudo().as_ref().unwrap();
|
||||
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("update").status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("upgrade").status_checked()
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("update").check_run()?;
|
||||
ctx.run_type().execute(sudo).arg(&apk).arg("upgrade").check_run()
|
||||
}
|
||||
|
||||
fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -166,7 +166,7 @@ fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||
if ctx.config().rpm_ostree() {
|
||||
let mut command = ctx.run_type().execute(ostree);
|
||||
command.arg("upgrade");
|
||||
return command.status_checked();
|
||||
return command.check_run();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -188,7 +188,7 @@ fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.arg("-y");
|
||||
}
|
||||
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -198,7 +198,7 @@ fn upgrade_redhat(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_bedrock_strata(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
ctx.run_type().execute(sudo).args(["brl", "update"]).status_checked()?;
|
||||
ctx.run_type().execute(sudo).args(["brl", "update"]).check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -208,15 +208,12 @@ fn upgrade_bedrock_strata(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["zypper", "refresh"])
|
||||
.status_checked()?;
|
||||
ctx.run_type().execute(sudo).args(["zypper", "refresh"]).check_run()?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["zypper", "dist-upgrade"])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -238,7 +235,7 @@ fn upgrade_openmandriva(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.arg("-y");
|
||||
}
|
||||
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -253,14 +250,14 @@ fn upgrade_void(ctx: &ExecutionContext) -> Result<()> {
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
command.args(["xbps-install", "-u"]);
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -273,11 +270,7 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
if let Some(layman) = which("layman") {
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.arg(layman)
|
||||
.args(["-s", "ALL"])
|
||||
.status_checked()?;
|
||||
run_type.execute(sudo).arg(layman).args(["-s", "ALL"]).check_run()?;
|
||||
}
|
||||
|
||||
println!("Syncing portage");
|
||||
@@ -290,10 +283,10 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
|
||||
.map(|s| s.split_whitespace().collect())
|
||||
.unwrap_or_else(|| vec!["-q"]),
|
||||
)
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
|
||||
if let Some(eix_update) = which("eix-update") {
|
||||
run_type.execute(sudo).arg(eix_update).status_checked()?;
|
||||
run_type.execute(sudo).arg(eix_update).check_run()?;
|
||||
}
|
||||
|
||||
run_type
|
||||
@@ -305,7 +298,7 @@ fn upgrade_gentoo(ctx: &ExecutionContext) -> Result<()> {
|
||||
.map(|s| s.split_whitespace().collect())
|
||||
.unwrap_or_else(|| vec!["-uDNa", "--with-bdeps=y", "world"]),
|
||||
)
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -321,7 +314,7 @@ fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let is_nala = apt.ends_with("nala");
|
||||
if !is_nala {
|
||||
ctx.run_type().execute(sudo).arg(&apt).arg("update").status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(&apt).arg("update").check_run()?;
|
||||
}
|
||||
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
@@ -337,17 +330,17 @@ fn upgrade_debian(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(args) = ctx.config().apt_arguments() {
|
||||
command.args(args.split_whitespace());
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type().execute(sudo).arg(&apt).arg("clean").status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(&apt).arg("clean").check_run()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(sudo);
|
||||
command.arg(&apt).arg("autoremove");
|
||||
if ctx.config().yes(Step::System) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
}
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
@@ -361,11 +354,11 @@ pub fn run_deb_get(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("deb-get");
|
||||
|
||||
ctx.execute_elevated(&deb_get, false)?.arg("update").status_checked()?;
|
||||
ctx.execute_elevated(&deb_get, false)?.arg("upgrade").status_checked()?;
|
||||
ctx.execute_elevated(&deb_get, false)?.arg("update").check_run()?;
|
||||
ctx.execute_elevated(&deb_get, false)?.arg("upgrade").check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.execute_elevated(&deb_get, false)?.arg("clean").status_checked()?;
|
||||
ctx.execute_elevated(&deb_get, false)?.arg("clean").check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -373,10 +366,7 @@ pub fn run_deb_get(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_solus(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["eopkg", "upgrade"])
|
||||
.status_checked()?;
|
||||
ctx.run_type().execute(sudo).args(["eopkg", "upgrade"]).check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -389,10 +379,10 @@ pub fn run_pacdef(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("pacdef");
|
||||
|
||||
ctx.run_type().execute(&pacdef).arg("sync").status_checked()?;
|
||||
ctx.run_type().execute(&pacdef).arg("sync").check_run()?;
|
||||
|
||||
println!();
|
||||
ctx.run_type().execute(&pacdef).arg("review").status_checked()
|
||||
ctx.run_type().execute(&pacdef).arg("review").check_run()
|
||||
}
|
||||
|
||||
pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -400,16 +390,13 @@ pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Pacstall");
|
||||
|
||||
ctx.run_type().execute(&pacstall).arg("-U").status_checked()?;
|
||||
ctx.run_type().execute(pacstall).arg("-Up").status_checked()
|
||||
ctx.run_type().execute(&pacstall).arg("-U").check_run()?;
|
||||
ctx.run_type().execute(pacstall).arg("-Up").check_run()
|
||||
}
|
||||
|
||||
fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["swupd", "update"])
|
||||
.status_checked()?;
|
||||
ctx.run_type().execute(sudo).args(["swupd", "update"]).check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -419,29 +406,26 @@ fn upgrade_clearlinux(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
fn upgrade_exherbo(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = ctx.sudo() {
|
||||
ctx.run_type().execute(sudo).args(["cave", "sync"]).status_checked()?;
|
||||
ctx.run_type().execute(sudo).args(["cave", "sync"]).check_run()?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["cave", "resolve", "world", "-c1", "-Cs", "-km", "-Km", "-x"])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["cave", "purge", "-x"])
|
||||
.status_checked()?;
|
||||
ctx.run_type().execute(sudo).args(["cave", "purge", "-x"]).check_run()?;
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["cave", "fix-linkage", "-x", "--", "-Cs"])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["eclectic", "config", "interactive"])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
}
|
||||
@@ -454,13 +438,13 @@ fn upgrade_nixos(ctx: &ExecutionContext) -> Result<()> {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["/run/current-system/sw/bin/nixos-rebuild", "switch", "--upgrade"])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["/run/current-system/sw/bin/nix-collect-garbage", "-d"])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
}
|
||||
} else {
|
||||
print_warning("No sudo detected. Skipping system upgrade");
|
||||
@@ -478,11 +462,7 @@ fn upgrade_neon(ctx: &ExecutionContext) -> Result<()> {
|
||||
if let Some(sudo) = &ctx.sudo() {
|
||||
let pkcon = which("pkcon").unwrap();
|
||||
// pkcon ignores update with update and refresh provided together
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.arg(&pkcon)
|
||||
.arg("refresh")
|
||||
.status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(&pkcon).arg("refresh").check_run()?;
|
||||
let mut exe = ctx.run_type().execute(sudo);
|
||||
let cmd = exe.arg(&pkcon).arg("update");
|
||||
if ctx.config().yes(Step::System) {
|
||||
@@ -492,7 +472,7 @@ fn upgrade_neon(ctx: &ExecutionContext) -> Result<()> {
|
||||
cmd.arg("--autoremove");
|
||||
}
|
||||
// from pkcon man, exit code 5 is 'Nothing useful was done.'
|
||||
cmd.status_checked_with_codes(&[5])?;
|
||||
cmd.check_run_with_codes(&[5])?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -509,7 +489,7 @@ pub fn run_needrestart(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()>
|
||||
|
||||
print_separator("Check for needed restarts");
|
||||
|
||||
run_type.execute(sudo).arg(needrestart).status_checked()?;
|
||||
run_type.execute(sudo).arg(needrestart).check_run()?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -526,7 +506,7 @@ pub fn run_fwupdmgr(ctx: &ExecutionContext) -> Result<()> {
|
||||
ctx.run_type()
|
||||
.execute(&fwupdmgr)
|
||||
.arg("refresh")
|
||||
.status_checked_with_codes(&[2])?;
|
||||
.check_run_with_codes(&[2])?;
|
||||
|
||||
let mut updmgr = ctx.run_type().execute(&fwupdmgr);
|
||||
|
||||
@@ -538,7 +518,7 @@ pub fn run_fwupdmgr(ctx: &ExecutionContext) -> Result<()> {
|
||||
} else {
|
||||
updmgr.arg("get-updates");
|
||||
}
|
||||
updmgr.status_checked_with_codes(&[2])
|
||||
updmgr.check_run_with_codes(&[2])
|
||||
}
|
||||
|
||||
pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -553,14 +533,14 @@ pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
if yes {
|
||||
update_args.push("-y");
|
||||
}
|
||||
run_type.execute(&flatpak).args(&update_args).status_checked()?;
|
||||
run_type.execute(&flatpak).args(&update_args).check_run()?;
|
||||
|
||||
if cleanup {
|
||||
let mut cleanup_args = vec!["uninstall", "--user", "--unused"];
|
||||
if yes {
|
||||
cleanup_args.push("-y");
|
||||
}
|
||||
run_type.execute(&flatpak).args(&cleanup_args).status_checked()?;
|
||||
run_type.execute(&flatpak).args(&cleanup_args).check_run()?;
|
||||
}
|
||||
|
||||
print_separator("Flatpak System Packages");
|
||||
@@ -569,34 +549,26 @@ pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
if yes {
|
||||
update_args.push("-y");
|
||||
}
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.arg(&flatpak)
|
||||
.args(&update_args)
|
||||
.status_checked()?;
|
||||
run_type.execute(sudo).arg(&flatpak).args(&update_args).check_run()?;
|
||||
if cleanup {
|
||||
let mut cleanup_args = vec!["uninstall", "--system", "--unused"];
|
||||
if yes {
|
||||
cleanup_args.push("-y");
|
||||
}
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.arg(flatpak)
|
||||
.args(&cleanup_args)
|
||||
.status_checked()?;
|
||||
run_type.execute(sudo).arg(flatpak).args(&cleanup_args).check_run()?;
|
||||
}
|
||||
} else {
|
||||
let mut update_args = vec!["update", "--system"];
|
||||
if yes {
|
||||
update_args.push("-y");
|
||||
}
|
||||
run_type.execute(&flatpak).args(&update_args).status_checked()?;
|
||||
run_type.execute(&flatpak).args(&update_args).check_run()?;
|
||||
if cleanup {
|
||||
let mut cleanup_args = vec!["uninstall", "--system", "--unused"];
|
||||
if yes {
|
||||
cleanup_args.push("-y");
|
||||
}
|
||||
run_type.execute(flatpak).args(&cleanup_args).status_checked()?;
|
||||
run_type.execute(flatpak).args(&cleanup_args).check_run()?;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -612,7 +584,7 @@ pub fn run_snap(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
||||
}
|
||||
print_separator("snap");
|
||||
|
||||
run_type.execute(sudo).arg(snap).arg("refresh").status_checked()
|
||||
run_type.execute(sudo).arg(snap).arg("refresh").check_run()
|
||||
}
|
||||
|
||||
pub fn run_pihole_update(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
||||
@@ -622,7 +594,7 @@ pub fn run_pihole_update(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()
|
||||
|
||||
print_separator("pihole");
|
||||
|
||||
run_type.execute(sudo).arg(pihole).arg("-up").status_checked()
|
||||
run_type.execute(sudo).arg(pihole).arg("-up").check_run()
|
||||
}
|
||||
|
||||
pub fn run_protonup_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -630,7 +602,7 @@ pub fn run_protonup_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("protonup");
|
||||
|
||||
ctx.run_type().execute(protonup).status_checked()?;
|
||||
ctx.run_type().execute(protonup).check_run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -656,7 +628,8 @@ pub fn run_distrobox_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
(r, true) => r.arg("--root"),
|
||||
(r, false) => r,
|
||||
}
|
||||
.status_checked()
|
||||
.check_run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn run_config_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -667,14 +640,14 @@ pub fn run_config_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
if let Ok(etc_update) = require("etc-update") {
|
||||
print_separator("Configuration update");
|
||||
ctx.run_type().execute(sudo).arg(etc_update).status_checked()?;
|
||||
ctx.run_type().execute(sudo).arg(etc_update).check_run()?;
|
||||
} else if let Ok(pacdiff) = require("pacdiff") {
|
||||
if std::env::var("DIFFPROG").is_err() {
|
||||
require("vim")?;
|
||||
}
|
||||
|
||||
print_separator("Configuration update");
|
||||
ctx.execute_elevated(&pacdiff, false)?.status_checked()?;
|
||||
ctx.execute_elevated(&pacdiff, false)?.check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -1,30 +1,26 @@
|
||||
use crate::command::CommandExt;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::executor::RunType;
|
||||
use crate::executor::{CommandExt, RunType};
|
||||
use crate::terminal::{print_separator, prompt_yesno};
|
||||
use crate::{utils::require, Step};
|
||||
use color_eyre::eyre::Result;
|
||||
use crate::{error::TopgradeError, utils::require, Step};
|
||||
use anyhow::Result;
|
||||
use log::debug;
|
||||
use std::fs;
|
||||
use std::process::Command;
|
||||
use tracing::debug;
|
||||
|
||||
pub fn run_macports(ctx: &ExecutionContext) -> Result<()> {
|
||||
require("port")?;
|
||||
let sudo = ctx.sudo().as_ref().unwrap();
|
||||
print_separator("MacPorts");
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["port", "selfupdate"])
|
||||
.status_checked()?;
|
||||
ctx.run_type().execute(sudo).args(["port", "selfupdate"]).check_run()?;
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["port", "-u", "upgrade", "outdated"])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
if ctx.config().cleanup() {
|
||||
ctx.run_type()
|
||||
.execute(sudo)
|
||||
.args(["port", "-N", "reclaim"])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -34,7 +30,7 @@ pub fn run_mas(run_type: RunType) -> Result<()> {
|
||||
let mas = require("mas")?;
|
||||
print_separator("macOS App Store");
|
||||
|
||||
run_type.execute(mas).arg("upgrade").status_checked()
|
||||
run_type.execute(mas).arg("upgrade").check_run()
|
||||
}
|
||||
|
||||
pub fn upgrade_macos(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -62,15 +58,20 @@ pub fn upgrade_macos(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.arg("--no-scan");
|
||||
}
|
||||
|
||||
command.status_checked()
|
||||
command.check_run()
|
||||
}
|
||||
|
||||
fn system_update_available() -> Result<bool> {
|
||||
let output = Command::new("softwareupdate").arg("--list").output_checked_utf8()?;
|
||||
|
||||
let output = Command::new("softwareupdate").arg("--list").output()?;
|
||||
debug!("{:?}", output);
|
||||
|
||||
Ok(!output.stderr.contains("No new software available"))
|
||||
let status = output.status;
|
||||
if !status.success() {
|
||||
return Err(TopgradeError::ProcessFailed(status).into());
|
||||
}
|
||||
let string_output = String::from_utf8(output.stderr)?;
|
||||
debug!("{:?}", string_output);
|
||||
Ok(!string_output.contains("No new software available"))
|
||||
}
|
||||
|
||||
pub fn run_sparkle(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -82,12 +83,12 @@ pub fn run_sparkle(ctx: &ExecutionContext) -> Result<()> {
|
||||
let probe = Command::new(&sparkle)
|
||||
.args(["--probe", "--application"])
|
||||
.arg(application.path())
|
||||
.output_checked_utf8();
|
||||
.check_output();
|
||||
if probe.is_ok() {
|
||||
let mut command = ctx.run_type().execute(&sparkle);
|
||||
command.args(["bundle", "--check-immediately", "--application"]);
|
||||
command.arg(application.path());
|
||||
command.status_checked()?;
|
||||
command.spawn()?.wait()?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
||||
@@ -1,23 +1,17 @@
|
||||
use crate::executor::RunType;
|
||||
use crate::terminal::print_separator;
|
||||
use crate::utils::require_option;
|
||||
use color_eyre::eyre::Result;
|
||||
use anyhow::Result;
|
||||
use std::path::PathBuf;
|
||||
|
||||
pub fn upgrade_openbsd(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
||||
let sudo = require_option(sudo, String::from("No sudo detected"))?;
|
||||
print_separator("OpenBSD Update");
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.args(&["/usr/sbin/sysupgrade", "-n"])
|
||||
.status_checked()
|
||||
run_type.execute(sudo).args(&["/usr/sbin/sysupgrade", "-n"]).check_run()
|
||||
}
|
||||
|
||||
pub fn upgrade_packages(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> {
|
||||
let sudo = require_option(sudo, String::from("No sudo detected"))?;
|
||||
print_separator("OpenBSD Packages");
|
||||
run_type
|
||||
.execute(sudo)
|
||||
.args(&["/usr/sbin/pkg_add", "-u"])
|
||||
.status_checked()
|
||||
run_type.execute(sudo).args(&["/usr/sbin/pkg_add", "-u"]).check_run()
|
||||
}
|
||||
|
||||
@@ -1,43 +1,33 @@
|
||||
use crate::error::{SkipStep, TopgradeError};
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::executor::{CommandExt, Executor, ExecutorExitStatus, RunType};
|
||||
use crate::terminal::print_separator;
|
||||
#[cfg(not(target_os = "macos"))]
|
||||
use crate::utils::require_option;
|
||||
use crate::utils::{require, PathExt};
|
||||
use crate::Step;
|
||||
use anyhow::Result;
|
||||
use directories::BaseDirs;
|
||||
use home;
|
||||
use ini::Ini;
|
||||
use log::debug;
|
||||
use std::fs;
|
||||
use std::os::unix::fs::MetadataExt;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::{env, path::Path};
|
||||
|
||||
use crate::command::CommandExt;
|
||||
use crate::Step;
|
||||
use color_eyre::eyre::Result;
|
||||
use directories::BaseDirs;
|
||||
use home;
|
||||
use ini::Ini;
|
||||
use tracing::debug;
|
||||
|
||||
use crate::error::SkipStep;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
use crate::executor::Executor;
|
||||
use crate::executor::RunType;
|
||||
use crate::terminal::print_separator;
|
||||
#[cfg(not(any(target_os = "android", target_os = "macos")))]
|
||||
use crate::utils::require_option;
|
||||
use crate::utils::{require, PathExt};
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
const INTEL_BREW: &str = "/usr/local/bin/brew";
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
const ARM_BREW: &str = "/opt/homebrew/bin/brew";
|
||||
|
||||
#[derive(Copy, Clone, Debug)]
|
||||
#[allow(dead_code)]
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
pub enum BrewVariant {
|
||||
Path,
|
||||
MacIntel,
|
||||
MacArm,
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
impl BrewVariant {
|
||||
fn binary_name(self) -> &'static str {
|
||||
match self {
|
||||
@@ -87,36 +77,30 @@ impl BrewVariant {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_fisher(run_type: RunType) -> Result<()> {
|
||||
pub fn run_fisher(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> {
|
||||
let fish = require("fish")?;
|
||||
|
||||
Command::new(&fish)
|
||||
.args(["-c", "type -t fisher"])
|
||||
.output_checked_utf8()
|
||||
.map(|_| ())
|
||||
.map_err(|_| SkipStep("`fisher` is not defined in `fish`".to_owned()))?;
|
||||
|
||||
Command::new(&fish)
|
||||
.args(["-c", "echo \"$__fish_config_dir/fish_plugins\""])
|
||||
.output_checked_utf8()
|
||||
.and_then(|output| Path::new(&output.stdout.trim()).require().map(|_| ()))
|
||||
.map_err(|err| SkipStep(format!("`fish_plugins` path doesn't exist: {err}")))?;
|
||||
if env::var("fisher_path").is_err() {
|
||||
base_dirs
|
||||
.home_dir()
|
||||
.join(".config/fish/functions/fisher.fish")
|
||||
.require()?;
|
||||
}
|
||||
|
||||
print_separator("Fisher");
|
||||
|
||||
let version_str = run_type
|
||||
.execute(&fish)
|
||||
.args(["-c", "fisher --version"])
|
||||
.output_checked_utf8()?
|
||||
.stdout;
|
||||
.check_output()?;
|
||||
debug!("Fisher version: {}", version_str);
|
||||
|
||||
if version_str.starts_with("fisher version 3.") {
|
||||
// v3 - see https://github.com/topgrade-rs/topgrade/pull/37#issuecomment-1283844506
|
||||
run_type.execute(&fish).args(["-c", "fisher"]).status_checked()
|
||||
run_type.execute(&fish).args(["-c", "fisher"]).check_run()
|
||||
} else {
|
||||
// v4
|
||||
run_type.execute(&fish).args(["-c", "fisher update"]).status_checked()
|
||||
run_type.execute(&fish).args(["-c", "fisher update"]).check_run()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -128,7 +112,7 @@ pub fn run_bashit(ctx: &ExecutionContext) -> Result<()> {
|
||||
ctx.run_type()
|
||||
.execute("bash")
|
||||
.args(["-lic", &format!("bash-it update {}", ctx.config().bashit_branch())])
|
||||
.status_checked()
|
||||
.check_run()
|
||||
}
|
||||
|
||||
pub fn run_oh_my_fish(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -140,7 +124,7 @@ pub fn run_oh_my_fish(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("oh-my-fish");
|
||||
|
||||
ctx.run_type().execute(fish).args(["-c", "omf update"]).status_checked()
|
||||
ctx.run_type().execute(fish).args(["-c", "omf update"]).check_run()
|
||||
}
|
||||
|
||||
pub fn run_pkgin(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -151,14 +135,14 @@ pub fn run_pkgin(ctx: &ExecutionContext) -> Result<()> {
|
||||
if ctx.config().yes(Step::Pkgin) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.status_checked()?;
|
||||
command.check_run()?;
|
||||
|
||||
let mut command = ctx.run_type().execute(ctx.sudo().as_ref().unwrap());
|
||||
command.arg(&pkgin).arg("upgrade");
|
||||
if ctx.config().yes(Step::Pkgin) {
|
||||
command.arg("-y");
|
||||
}
|
||||
command.status_checked()
|
||||
command.check_run()
|
||||
}
|
||||
|
||||
pub fn run_fish_plug(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -170,10 +154,7 @@ pub fn run_fish_plug(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("fish-plug");
|
||||
|
||||
ctx.run_type()
|
||||
.execute(fish)
|
||||
.args(["-c", "plug update"])
|
||||
.status_checked()
|
||||
ctx.run_type().execute(fish).args(["-c", "plug update"]).check_run()
|
||||
}
|
||||
|
||||
/// Upgrades `fundle` and `fundle` plugins.
|
||||
@@ -190,7 +171,7 @@ pub fn run_fundle(ctx: &ExecutionContext) -> Result<()> {
|
||||
ctx.run_type()
|
||||
.execute(fish)
|
||||
.args(["-c", "fundle self-update && fundle update"])
|
||||
.status_checked()
|
||||
.check_run()
|
||||
}
|
||||
|
||||
#[cfg(not(any(target_os = "android", target_os = "macos")))]
|
||||
@@ -211,10 +192,10 @@ pub fn upgrade_gnome_extensions(ctx: &ExecutionContext) -> Result<()> {
|
||||
"--method",
|
||||
"org.freedesktop.DBus.ListActivatableNames",
|
||||
])
|
||||
.output_checked_utf8()?;
|
||||
.check_output()?;
|
||||
|
||||
debug!("Checking for gnome extensions: {}", output);
|
||||
if !output.stdout.contains("org.gnome.Shell.Extensions") {
|
||||
if !output.contains("org.gnome.Shell.Extensions") {
|
||||
return Err(SkipStep(String::from("Gnome shell extensions are unregistered in DBus")).into());
|
||||
}
|
||||
|
||||
@@ -232,10 +213,9 @@ pub fn upgrade_gnome_extensions(ctx: &ExecutionContext) -> Result<()> {
|
||||
"--method",
|
||||
"org.gnome.Shell.Extensions.CheckForUpdates",
|
||||
])
|
||||
.status_checked()
|
||||
.check_run()
|
||||
}
|
||||
|
||||
#[cfg(any(target_os = "linux", target_os = "macos"))]
|
||||
pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> {
|
||||
#[allow(unused_variables)]
|
||||
let binary_name = require(variant.binary_name())?;
|
||||
@@ -250,18 +230,18 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result<
|
||||
print_separator(variant.step_title());
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
variant.execute(run_type).arg("update").status_checked()?;
|
||||
variant.execute(run_type).arg("update").check_run()?;
|
||||
variant
|
||||
.execute(run_type)
|
||||
.args(["upgrade", "--ignore-pinned", "--formula"])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
variant.execute(run_type).arg("cleanup").status_checked()?;
|
||||
variant.execute(run_type).arg("cleanup").check_run()?;
|
||||
}
|
||||
|
||||
if ctx.config().brew_autoremove() {
|
||||
variant.execute(run_type).arg("autoremove").status_checked()?;
|
||||
variant.execute(run_type).arg("autoremove").check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -279,8 +259,8 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()>
|
||||
let cask_upgrade_exists = variant
|
||||
.execute(RunType::Wet)
|
||||
.args(["--repository", "buo/cask-upgrade"])
|
||||
.output_checked_utf8()
|
||||
.map(|p| Path::new(p.stdout.trim()).exists())?;
|
||||
.check_output()
|
||||
.map(|p| Path::new(p.trim()).exists())?;
|
||||
|
||||
let mut brew_args = vec![];
|
||||
|
||||
@@ -296,10 +276,10 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()>
|
||||
}
|
||||
}
|
||||
|
||||
variant.execute(run_type).args(&brew_args).status_checked()?;
|
||||
variant.execute(run_type).args(&brew_args).check_run()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
variant.execute(run_type).arg("cleanup").status_checked()?;
|
||||
variant.execute(run_type).arg("cleanup").check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -310,7 +290,7 @@ pub fn run_guix(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let run_type = ctx.run_type();
|
||||
|
||||
let output = Command::new(&guix).arg("pull").output_checked_utf8();
|
||||
let output = Command::new(&guix).arg("pull").check_output();
|
||||
debug!("guix pull output: {:?}", output);
|
||||
let should_upgrade = output.is_ok();
|
||||
debug!("Can Upgrade Guix: {:?}", should_upgrade);
|
||||
@@ -318,7 +298,7 @@ pub fn run_guix(ctx: &ExecutionContext) -> Result<()> {
|
||||
print_separator("Guix");
|
||||
|
||||
if should_upgrade {
|
||||
return run_type.execute(&guix).args(["package", "-u"]).status_checked();
|
||||
return run_type.execute(&guix).args(["package", "-u"]).check_run();
|
||||
}
|
||||
Err(SkipStep(String::from("Guix Pull Failed, Skipping")).into())
|
||||
}
|
||||
@@ -334,7 +314,7 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||
debug!("nix profile: {:?}", profile_path);
|
||||
let manifest_json_path = profile_path.join("manifest.json");
|
||||
|
||||
let output = Command::new(&nix_env).args(["--query", "nix"]).output_checked_utf8();
|
||||
let output = Command::new(&nix_env).args(["--query", "nix"]).check_output();
|
||||
debug!("nix-env output: {:?}", output);
|
||||
let should_self_upgrade = output.is_ok();
|
||||
|
||||
@@ -366,13 +346,13 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
if should_self_upgrade {
|
||||
if multi_user {
|
||||
ctx.execute_elevated(&nix, true)?.arg("upgrade-nix").status_checked()?;
|
||||
ctx.execute_elevated(&nix, true)?.arg("upgrade-nix").check_run()?;
|
||||
} else {
|
||||
run_type.execute(&nix).arg("upgrade-nix").status_checked()?;
|
||||
run_type.execute(&nix).arg("upgrade-nix").check_run()?;
|
||||
}
|
||||
}
|
||||
|
||||
run_type.execute(nix_channel).arg("--update").status_checked()?;
|
||||
run_type.execute(nix_channel).arg("--update").check_run()?;
|
||||
|
||||
if std::path::Path::new(&manifest_json_path).exists() {
|
||||
run_type
|
||||
@@ -380,9 +360,9 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> {
|
||||
.arg("profile")
|
||||
.arg("upgrade")
|
||||
.arg(".*")
|
||||
.status_checked()
|
||||
.check_run()
|
||||
} else {
|
||||
run_type.execute(&nix_env).arg("--upgrade").status_checked()
|
||||
run_type.execute(&nix_env).arg("--upgrade").check_run()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -391,40 +371,42 @@ pub fn run_yadm(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("yadm");
|
||||
|
||||
ctx.run_type().execute(yadm).arg("pull").status_checked()
|
||||
ctx.run_type().execute(yadm).arg("pull").check_run()
|
||||
}
|
||||
|
||||
pub fn run_asdf(run_type: RunType) -> Result<()> {
|
||||
let asdf = require("asdf")?;
|
||||
|
||||
print_separator("asdf");
|
||||
run_type.execute(&asdf).arg("update").status_checked_with_codes(&[42])?;
|
||||
let exit_status = run_type.execute(&asdf).arg("update").spawn()?.wait()?;
|
||||
|
||||
run_type
|
||||
.execute(&asdf)
|
||||
.args(["plugin", "update", "--all"])
|
||||
.status_checked()
|
||||
if let ExecutorExitStatus::Wet(e) = exit_status {
|
||||
if !(e.success() || e.code().map(|c| c == 42).unwrap_or(false)) {
|
||||
return Err(TopgradeError::ProcessFailed(e).into());
|
||||
}
|
||||
}
|
||||
run_type.execute(&asdf).args(["plugin", "update", "--all"]).check_run()
|
||||
}
|
||||
|
||||
pub fn run_home_manager(run_type: RunType) -> Result<()> {
|
||||
let home_manager = require("home-manager")?;
|
||||
|
||||
print_separator("home-manager");
|
||||
run_type.execute(home_manager).arg("switch").status_checked()
|
||||
run_type.execute(home_manager).arg("switch").check_run()
|
||||
}
|
||||
|
||||
pub fn run_tldr(run_type: RunType) -> Result<()> {
|
||||
let tldr = require("tldr")?;
|
||||
|
||||
print_separator("TLDR");
|
||||
run_type.execute(tldr).arg("--update").status_checked()
|
||||
run_type.execute(tldr).arg("--update").check_run()
|
||||
}
|
||||
|
||||
pub fn run_pearl(run_type: RunType) -> Result<()> {
|
||||
let pearl = require("pearl")?;
|
||||
print_separator("pearl");
|
||||
|
||||
run_type.execute(pearl).arg("update").status_checked()
|
||||
run_type.execute(pearl).arg("update").check_run()
|
||||
}
|
||||
|
||||
pub fn run_sdkman(base_dirs: &BaseDirs, cleanup: bool, run_type: RunType) -> Result<()> {
|
||||
@@ -458,33 +440,27 @@ pub fn run_sdkman(base_dirs: &BaseDirs, cleanup: bool, run_type: RunType) -> Res
|
||||
run_type
|
||||
.execute(&bash)
|
||||
.args(["-c", cmd_selfupdate.as_str()])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
}
|
||||
|
||||
let cmd_update = format!("source {} && sdk update", &sdkman_init_path);
|
||||
run_type
|
||||
.execute(&bash)
|
||||
.args(["-c", cmd_update.as_str()])
|
||||
.status_checked()?;
|
||||
run_type.execute(&bash).args(["-c", cmd_update.as_str()]).check_run()?;
|
||||
|
||||
let cmd_upgrade = format!("source {} && sdk upgrade", &sdkman_init_path);
|
||||
run_type
|
||||
.execute(&bash)
|
||||
.args(["-c", cmd_upgrade.as_str()])
|
||||
.status_checked()?;
|
||||
run_type.execute(&bash).args(["-c", cmd_upgrade.as_str()]).check_run()?;
|
||||
|
||||
if cleanup {
|
||||
let cmd_flush_archives = format!("source {} && sdk flush archives", &sdkman_init_path);
|
||||
run_type
|
||||
.execute(&bash)
|
||||
.args(["-c", cmd_flush_archives.as_str()])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
|
||||
let cmd_flush_temp = format!("source {} && sdk flush temp", &sdkman_init_path);
|
||||
run_type
|
||||
.execute(&bash)
|
||||
.args(["-c", cmd_flush_temp.as_str()])
|
||||
.status_checked()?;
|
||||
.check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
@@ -495,7 +471,7 @@ pub fn run_bun(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Bun");
|
||||
|
||||
ctx.run_type().execute(bun).arg("upgrade").status_checked()
|
||||
ctx.run_type().execute(bun).arg("upgrade").check_run()
|
||||
}
|
||||
|
||||
/// Update dotfiles with `rcm(7)`.
|
||||
@@ -505,10 +481,10 @@ pub fn run_rcm(ctx: &ExecutionContext) -> Result<()> {
|
||||
let rcup = require("rcup")?;
|
||||
|
||||
print_separator("rcm");
|
||||
ctx.run_type().execute(rcup).arg("-v").status_checked()
|
||||
ctx.run_type().execute(rcup).arg("-v").check_run()
|
||||
}
|
||||
|
||||
pub fn reboot() -> Result<()> {
|
||||
pub fn reboot() {
|
||||
print!("Rebooting...");
|
||||
Command::new("sudo").arg("reboot").status_checked()
|
||||
Command::new("sudo").arg("reboot").spawn().unwrap().wait().unwrap();
|
||||
}
|
||||
|
||||
@@ -2,12 +2,11 @@ use std::convert::TryFrom;
|
||||
use std::path::Path;
|
||||
use std::{ffi::OsStr, process::Command};
|
||||
|
||||
use color_eyre::eyre::Result;
|
||||
use tracing::debug;
|
||||
use anyhow::Result;
|
||||
use log::debug;
|
||||
|
||||
use crate::command::CommandExt;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::executor::RunType;
|
||||
use crate::executor::{CommandExt, RunType};
|
||||
use crate::terminal::{print_separator, print_warning};
|
||||
use crate::utils::require;
|
||||
use crate::{error::SkipStep, steps::git::Repositories};
|
||||
@@ -35,7 +34,7 @@ pub fn run_chocolatey(ctx: &ExecutionContext) -> Result<()> {
|
||||
command.arg("--yes");
|
||||
}
|
||||
|
||||
command.status_checked()
|
||||
command.check_run()
|
||||
}
|
||||
|
||||
pub fn run_winget(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -48,10 +47,7 @@ pub fn run_winget(ctx: &ExecutionContext) -> Result<()> {
|
||||
return Err(SkipStep(String::from("Winget is disabled by default")).into());
|
||||
}
|
||||
|
||||
ctx.run_type()
|
||||
.execute(&winget)
|
||||
.args(["upgrade", "--all"])
|
||||
.status_checked()
|
||||
ctx.run_type().execute(&winget).args(["upgrade", "--all"]).check_run()
|
||||
}
|
||||
|
||||
pub fn run_scoop(cleanup: bool, run_type: RunType) -> Result<()> {
|
||||
@@ -59,18 +55,18 @@ pub fn run_scoop(cleanup: bool, run_type: RunType) -> Result<()> {
|
||||
|
||||
print_separator("Scoop");
|
||||
|
||||
run_type.execute(&scoop).args(["update"]).status_checked()?;
|
||||
run_type.execute(&scoop).args(["update", "*"]).status_checked()?;
|
||||
run_type.execute(&scoop).args(["update"]).check_run()?;
|
||||
run_type.execute(&scoop).args(["update", "*"]).check_run()?;
|
||||
|
||||
if cleanup {
|
||||
run_type.execute(&scoop).args(["cleanup", "*"]).status_checked()?;
|
||||
run_type.execute(&scoop).args(["cleanup", "*"]).check_run()?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn get_wsl_distributions(wsl: &Path) -> Result<Vec<String>> {
|
||||
let output = Command::new(wsl).args(["--list", "-q"]).output_checked_utf8()?.stdout;
|
||||
let output = Command::new(wsl).args(["--list", "-q"]).check_output()?;
|
||||
Ok(output
|
||||
.lines()
|
||||
.filter(|s| !s.is_empty())
|
||||
@@ -81,7 +77,7 @@ fn get_wsl_distributions(wsl: &Path) -> Result<Vec<String>> {
|
||||
fn upgrade_wsl_distribution(wsl: &Path, dist: &str, ctx: &ExecutionContext) -> Result<()> {
|
||||
let topgrade = Command::new(wsl)
|
||||
.args(["-d", dist, "bash", "-lc", "which topgrade"])
|
||||
.output_checked_utf8()
|
||||
.check_output()
|
||||
.map_err(|_| SkipStep(String::from("Could not find Topgrade installed in WSL")))?;
|
||||
|
||||
let mut command = ctx.run_type().execute(wsl);
|
||||
@@ -93,7 +89,7 @@ fn upgrade_wsl_distribution(wsl: &Path, dist: &str, ctx: &ExecutionContext) -> R
|
||||
command.arg("-y");
|
||||
}
|
||||
|
||||
command.status_checked()
|
||||
command.check_run()
|
||||
}
|
||||
|
||||
pub fn run_wsl_topgrade(ctx: &ExecutionContext) -> Result<()> {
|
||||
@@ -133,17 +129,12 @@ pub fn windows_update(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
print_separator("Windows Update");
|
||||
println!("Running Windows Update. Check the control panel for progress.");
|
||||
ctx.run_type()
|
||||
.execute(&usoclient)
|
||||
.arg("ScanInstallWait")
|
||||
.status_checked()?;
|
||||
ctx.run_type().execute(&usoclient).arg("StartInstall").status_checked()
|
||||
ctx.run_type().execute(&usoclient).arg("ScanInstallWait").check_run()?;
|
||||
ctx.run_type().execute(&usoclient).arg("StartInstall").check_run()
|
||||
}
|
||||
|
||||
pub fn reboot() -> Result<()> {
|
||||
// If this works, it won't return, but if it doesn't work, it may return a useful error
|
||||
// message.
|
||||
Command::new("shutdown").args(["/R", "/T", "0"]).status_checked()
|
||||
pub fn reboot() {
|
||||
Command::new("shutdown").args(["/R", "/T", "0"]).spawn().ok();
|
||||
}
|
||||
|
||||
pub fn insert_startup_scripts(ctx: &ExecutionContext, git_repos: &mut Repositories) -> Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user