From f2c7e4848e016996d46cab8747c315bc334f466f Mon Sep 17 00:00:00 2001 From: Guilherme Silva <626206+guihkx@users.noreply.github.com> Date: Thu, 24 Nov 2022 16:15:13 -0300 Subject: [PATCH 01/12] CI: Install only necessary components (#218) * CI: Install only necessary components --- .github/workflows/check-and-lint.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/check-and-lint.yaml b/.github/workflows/check-and-lint.yaml index de30d19d..cb825f48 100644 --- a/.github/workflows/check-and-lint.yaml +++ b/.github/workflows/check-and-lint.yaml @@ -23,8 +23,7 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: '${{ env.RUST_VER }}' - targets: ${{ matrix.target }} - components: clippy, rustfmt + components: rustfmt - name: Run cargo fmt run: | @@ -72,8 +71,7 @@ jobs: uses: dtolnay/rust-toolchain@master with: toolchain: '${{ env.RUST_VER }}' - targets: ${{ matrix.target }} - components: clippy, rustfmt + components: clippy - name: Setup Rust Cache uses: Swatinem/rust-cache@v2 From e456155562a27079dce53663404dfe9ee21cff9c Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Thu, 24 Nov 2022 14:15:43 -0500 Subject: [PATCH 02/12] Add `pre_sudo` option (#219) * Add `pre_sudo` option --- config.example.toml | 4 ++++ src/config.rs | 7 +++++++ src/main.rs | 7 ++++++- src/steps/node.rs | 4 +++- src/sudo.rs | 34 ++++++++++++++++++++++++++++++++++ src/utils.rs | 7 ------- 6 files changed, 54 insertions(+), 9 deletions(-) create mode 100644 src/sudo.rs diff --git a/config.example.toml b/config.example.toml index 53267e21..00d4a205 100644 --- a/config.example.toml +++ b/config.example.toml @@ -13,6 +13,10 @@ # Do not ask to retry failed steps (default: false) #no_retry = true +# Run `sudo -v` to cache credentials at the start of the run; this avoids a +# blocking password prompt in the middle of a possibly-unattended run. +#pre_sudo = false + # Run inside tmux #run_in_tmux = true diff --git a/src/config.rs b/src/config.rs index b98910d9..e4a2dd63 100644 --- a/src/config.rs +++ b/src/config.rs @@ -269,6 +269,7 @@ pub struct Vim { #[serde(deny_unknown_fields)] /// Configuration file pub struct ConfigFile { + pre_sudo: Option, pre_commands: Option, post_commands: Option, commands: Option, @@ -947,6 +948,12 @@ impl Config { .unwrap_or(false) } + /// If `true`, `sudo` should be called after `pre_commands` in order to elevate at the + /// start of the session (and not in the middle). + pub fn pre_sudo(&self) -> bool { + self.config_file.pre_sudo.unwrap_or(false) + } + #[cfg(target_os = "linux")] pub fn npm_use_sudo(&self) -> bool { self.config_file diff --git a/src/main.rs b/src/main.rs index f4dbcecf..b62a50a9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -30,6 +30,7 @@ mod self_renamer; #[cfg(feature = "self-update")] mod self_update; mod steps; +mod sudo; mod terminal; mod utils; @@ -82,7 +83,7 @@ fn run() -> Result<()> { let git = git::Git::new(); let mut git_repos = git::Repositories::new(&git); - let sudo = utils::sudo(); + let sudo = sudo::path(); let run_type = executor::RunType::new(config.dry_run()); let ctx = execution_context::ExecutionContext::new(run_type, &sudo, &git, &config, &base_dirs); @@ -119,6 +120,10 @@ fn run() -> Result<()> { } } + if config.pre_sudo() { + sudo::elevate(&ctx, sudo.as_ref())?; + } + let powershell = powershell::Powershell::new(); let should_run_powershell = powershell.profile().is_some() && config.should_run(Step::Powershell); diff --git a/src/steps/node.rs b/src/steps/node.rs index 4909867b..d9a71e58 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -4,6 +4,8 @@ use std::os::unix::fs::MetadataExt; use std::path::PathBuf; use std::process::Command; + +use crate::sudo; use crate::utils::require_option; use color_eyre::eyre::Result; #[cfg(target_os = "linux")] @@ -93,7 +95,7 @@ impl NPM { fn upgrade(&self, run_type: RunType, use_sudo: bool) -> Result<()> { let args = ["update", self.global_location_arg()]; if use_sudo { - let sudo_option = sudo(); + let sudo_option = sudo::path(); let sudo = require_option(sudo_option, String::from("sudo is not installed"))?; run_type.execute(sudo).arg(&self.command).args(args).status_checked()?; } else { diff --git a/src/sudo.rs b/src/sudo.rs new file mode 100644 index 00000000..0a66cf37 --- /dev/null +++ b/src/sudo.rs @@ -0,0 +1,34 @@ +use std::path::PathBuf; + +use color_eyre::eyre::Context; +use color_eyre::eyre::Result; + +use crate::command::CommandExt; +use crate::execution_context::ExecutionContext; +use crate::terminal::print_separator; +use crate::utils::which; + +/// Get the path of the `sudo` utility. +/// +/// Detects `doas`, `sudo`, `gsudo`, or `pkexec`. +pub fn path() -> Option { + which("doas") + .or_else(|| which("sudo")) + .or_else(|| which("gsudo")) + .or_else(|| which("pkexec")) +} + +/// Elevate permissions with `sudo`. +pub fn elevate(ctx: &ExecutionContext, sudo: Option<&PathBuf>) -> Result<()> { + if let Some(sudo) = sudo { + print_separator("Sudo"); + ctx.run_type() + .execute(sudo) + // TODO: Does this work with `doas`, `pkexec`, `gsudo`, GNU `sudo`...? + .arg("-v") + .status_checked() + .wrap_err("Failed to elevate permissions")?; + } + + Ok(()) +} diff --git a/src/utils.rs b/src/utils.rs index 326e4ad6..486bab1f 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -67,13 +67,6 @@ pub fn which + Debug>(binary_name: T) -> Option { } } -pub fn sudo() -> Option { - which("doas") - .or_else(|| which("sudo")) - .or_else(|| which("gsudo")) - .or_else(|| which("pkexec")) -} - pub fn editor() -> Vec { env::var("EDITOR") .unwrap_or_else(|_| String::from(if cfg!(windows) { "notepad" } else { "vi" })) From 25c505717171df464565226d205d3c496948c91d Mon Sep 17 00:00:00 2001 From: Ruben Molina Date: Thu, 24 Nov 2022 14:17:58 -0500 Subject: [PATCH 03/12] Add support for juliaup (#208) * Add support for juliaup * Update config.rs * Change the position for Juliaup Step. * Update generic.rs --- .github/workflows/check-and-lint.yaml | 2 +- src/config.rs | 1 + src/main.rs | 1 + src/steps/generic.rs | 13 +++++++++++++ src/steps/node.rs | 1 - 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-and-lint.yaml b/.github/workflows/check-and-lint.yaml index cb825f48..587c8c1a 100644 --- a/.github/workflows/check-and-lint.yaml +++ b/.github/workflows/check-and-lint.yaml @@ -22,7 +22,7 @@ jobs: - name: Setup Rust uses: dtolnay/rust-toolchain@master with: - toolchain: '${{ env.RUST_VER }}' + toolchain: '${{ env.RUST_VER }} components: rustfmt - name: Run cargo fmt diff --git a/src/config.rs b/src/config.rs index e4a2dd63..f551236d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -106,6 +106,7 @@ pub enum Step { HomeManager, Jetpack, Julia, + Juliaup, Kakoune, Krew, Macports, diff --git a/src/main.rs b/src/main.rs index b62a50a9..c082742b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -324,6 +324,7 @@ fn run() -> Result<()> { runner.execute(Step::Atom, "apm", || generic::run_apm(run_type))?; runner.execute(Step::Fossil, "fossil", || generic::run_fossil(run_type))?; runner.execute(Step::Rustup, "rustup", || generic::run_rustup(&base_dirs, run_type))?; + runner.execute(Step::Juliaup, "juliaup", || generic::run_juliaup(&base_dirs, run_type))?; runner.execute(Step::Dotnet, ".NET", || generic::run_dotnet_upgrade(&ctx))?; runner.execute(Step::Choosenim, "choosenim", || generic::run_choosenim(&ctx))?; runner.execute(Step::Cargo, "cargo", || generic::run_cargo_update(&ctx))?; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 1646b0be..eb9c5428 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -175,6 +175,19 @@ pub fn run_rustup(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { run_type.execute(&rustup).arg("update").status_checked() } +pub fn run_juliaup(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { + let juliaup = utils::require("juliaup")?; + + print_separator("juliaup"); + + if juliaup.canonicalize()?.is_descendant_of(base_dirs.home_dir()) { + run_type.execute(&juliaup).args(["self", "update"]).status_checked()?; + } + + run_type.execute(&juliaup).arg("update").status_checked() + +} + pub fn run_choosenim(ctx: &ExecutionContext) -> Result<()> { let choosenim = utils::require("choosenim")?; diff --git a/src/steps/node.rs b/src/steps/node.rs index d9a71e58..5455b4c7 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -4,7 +4,6 @@ use std::os::unix::fs::MetadataExt; use std::path::PathBuf; use std::process::Command; - use crate::sudo; use crate::utils::require_option; use color_eyre::eyre::Result; From 3c1dda0c39db9a6f71c451e82f1d4e1ae2e23db3 Mon Sep 17 00:00:00 2001 From: Julien ITARD Date: Thu, 24 Nov 2022 20:21:03 +0100 Subject: [PATCH 04/12] Add RubyGems update (#217) --- src/config.rs | 1 + src/main.rs | 3 +++ src/steps/generic.rs | 19 ++++++++++++++++++- 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index f551236d..412a0dc8 100644 --- a/src/config.rs +++ b/src/config.rs @@ -130,6 +130,7 @@ pub enum Step { Remotes, Restarts, Rtcl, + RubyGems, Rustup, Scoop, Sdkman, diff --git a/src/main.rs b/src/main.rs index c082742b..9789b701 100644 --- a/src/main.rs +++ b/src/main.rs @@ -360,6 +360,9 @@ fn run() -> Result<()> { runner.execute(Step::Composer, "composer", || generic::run_composer_update(&ctx))?; runner.execute(Step::Krew, "krew", || generic::run_krew_upgrade(run_type))?; runner.execute(Step::Gem, "gem", || generic::run_gem(&base_dirs, run_type))?; + runner.execute(Step::RubyGems, "rubygems", || { + generic::run_rubygems(&base_dirs, run_type) + })?; runner.execute(Step::Julia, "julia", || generic::update_julia_packages(&ctx))?; runner.execute(Step::Haxelib, "haxelib", || generic::run_haxelib_update(&ctx))?; runner.execute(Step::Sheldon, "sheldon", || generic::run_sheldon(&ctx))?; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index eb9c5428..b6da5937 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -70,7 +70,7 @@ pub fn run_gem(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { let gem = utils::require("gem")?; base_dirs.home_dir().join(".gem").require()?; - print_separator("RubyGems"); + print_separator("Gems"); let mut command = run_type.execute(gem); command.arg("update"); @@ -83,6 +83,23 @@ pub fn run_gem(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { command.status_checked() } +pub fn run_rubygems(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { + let gem = utils::require("gem")?; + base_dirs.home_dir().join(".gem").require()?; + + print_separator("RubyGems"); + + let mut command = run_type.execute(gem); + command.arg("update --system"); + + if env::var_os("RBENV_SHELL").is_none() { + debug!("Detected rbenv. Avoiding --user-install"); + command.arg("--user-install"); + } + + command.status_checked() +} + pub fn run_haxelib_update(ctx: &ExecutionContext) -> Result<()> { let haxelib = utils::require("haxelib")?; From 526c4c9a583600dd50ae1466ae34741dc6b5a477 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Fri, 25 Nov 2022 18:44:36 +0000 Subject: [PATCH 05/12] Fixes typo --- .github/workflows/check-and-lint.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/check-and-lint.yaml b/.github/workflows/check-and-lint.yaml index 587c8c1a..cb825f48 100644 --- a/.github/workflows/check-and-lint.yaml +++ b/.github/workflows/check-and-lint.yaml @@ -22,7 +22,7 @@ jobs: - name: Setup Rust uses: dtolnay/rust-toolchain@master with: - toolchain: '${{ env.RUST_VER }} + toolchain: '${{ env.RUST_VER }}' components: rustfmt - name: Run cargo fmt From b31778bdd8b1f123468a7aea94636c5af2946349 Mon Sep 17 00:00:00 2001 From: Rebecca Turner Date: Fri, 25 Nov 2022 17:19:32 -0500 Subject: [PATCH 06/12] Add `Sudo` type (#221) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Create `Sudo` type and `SudoKind` enum * Fix build * reformat * Fix choco on windows * Fix linux * Fix linux more * more fix stuff hehe hoho hahaha * more fix stuff hehe hoho hahaha Co-authored-by: Thomas Schönauer <37108907+DottoDev@users.noreply.github.com> --- src/execution_context.rs | 24 +++------ src/main.rs | 28 +++++----- src/steps/generic.rs | 1 - src/steps/node.rs | 37 ++++++------- src/steps/os/archlinux.rs | 5 +- src/steps/os/dragonfly.rs | 5 +- src/steps/os/freebsd.rs | 8 +-- src/steps/os/linux.rs | 7 +-- src/steps/os/windows.rs | 19 ++++--- src/sudo.rs | 110 +++++++++++++++++++++++++++++++------- 10 files changed, 156 insertions(+), 88 deletions(-) diff --git a/src/execution_context.rs b/src/execution_context.rs index 661e8bc8..757418c4 100644 --- a/src/execution_context.rs +++ b/src/execution_context.rs @@ -1,16 +1,17 @@ #![allow(dead_code)] use crate::executor::RunType; use crate::git::Git; +use crate::sudo::Sudo; use crate::utils::require_option; use crate::{config::Config, executor::Executor}; use color_eyre::eyre::Result; use directories::BaseDirs; -use std::path::{Path, PathBuf}; +use std::path::Path; use std::sync::Mutex; pub struct ExecutionContext<'a> { run_type: RunType, - sudo: &'a Option, + sudo: Option, git: &'a Git, config: &'a Config, base_dirs: &'a BaseDirs, @@ -23,7 +24,7 @@ pub struct ExecutionContext<'a> { impl<'a> ExecutionContext<'a> { pub fn new( run_type: RunType, - sudo: &'a Option, + sudo: Option, git: &'a Git, config: &'a Config, base_dirs: &'a BaseDirs, @@ -40,18 +41,7 @@ impl<'a> ExecutionContext<'a> { pub fn execute_elevated(&self, command: &Path, interactive: bool) -> Result { let sudo = require_option(self.sudo.clone(), "Sudo is required for this operation".into())?; - let mut cmd = self.run_type.execute(&sudo); - - if sudo.ends_with("sudo") { - cmd.arg("--preserve-env=DIFFPROG"); - } - - if interactive { - cmd.arg("-i"); - } - - cmd.arg(command); - Ok(cmd) + Ok(sudo.execute_elevated(self, command, interactive)) } pub fn run_type(&self) -> RunType { @@ -62,8 +52,8 @@ impl<'a> ExecutionContext<'a> { self.git } - pub fn sudo(&self) -> &Option { - self.sudo + pub fn sudo(&self) -> &Option { + &self.sudo } pub fn config(&self) -> &Config { diff --git a/src/main.rs b/src/main.rs index 9789b701..b77a1621 100644 --- a/src/main.rs +++ b/src/main.rs @@ -83,10 +83,10 @@ fn run() -> Result<()> { let git = git::Git::new(); let mut git_repos = git::Repositories::new(&git); - let sudo = sudo::path(); + let sudo = sudo::Sudo::detect(); let run_type = executor::RunType::new(config.dry_run()); - let ctx = execution_context::ExecutionContext::new(run_type, &sudo, &git, &config, &base_dirs); + let ctx = execution_context::ExecutionContext::new(run_type, sudo, &git, &config, &base_dirs); let mut runner = runner::Runner::new(&ctx); @@ -121,7 +121,9 @@ fn run() -> Result<()> { } if config.pre_sudo() { - sudo::elevate(&ctx, sudo.as_ref())?; + if let Some(sudo) = ctx.sudo() { + sudo.elevate(&ctx)?; + } } let powershell = powershell::Powershell::new(); @@ -202,17 +204,17 @@ fn run() -> Result<()> { #[cfg(target_os = "dragonfly")] runner.execute(Step::Pkg, "DragonFly BSD Packages", || { - dragonfly::upgrade_packages(sudo.as_ref(), run_type) + dragonfly::upgrade_packages(ctx.sudo().as_ref(), run_type) })?; #[cfg(target_os = "freebsd")] runner.execute(Step::Pkg, "FreeBSD Packages", || { - freebsd::upgrade_packages(&ctx, sudo.as_ref(), run_type) + freebsd::upgrade_packages(&ctx, ctx.sudo().as_ref(), run_type) })?; #[cfg(target_os = "openbsd")] runner.execute(Step::Pkg, "OpenBSD Packages", || { - openbsd::upgrade_packages(sudo.as_ref(), run_type) + openbsd::upgrade_packages(ctx.sudo().as_ref(), run_type) })?; #[cfg(target_os = "android")] @@ -383,7 +385,7 @@ fn run() -> Result<()> { runner.execute(Step::DebGet, "deb-get", || linux::run_deb_get(&ctx))?; runner.execute(Step::Toolbx, "toolbx", || toolbx::run_toolbx(&ctx))?; runner.execute(Step::Flatpak, "Flatpak", || linux::flatpak_update(&ctx))?; - runner.execute(Step::Snap, "snap", || linux::run_snap(sudo.as_ref(), run_type))?; + runner.execute(Step::Snap, "snap", || linux::run_snap(ctx.sudo().as_ref(), run_type))?; runner.execute(Step::Pacstall, "pacstall", || linux::run_pacstall(&ctx))?; runner.execute(Step::Pacdef, "pacdef", || linux::run_pacdef(&ctx))?; runner.execute(Step::Protonup, "protonup", || linux::run_protonup_update(&ctx))?; @@ -403,11 +405,11 @@ fn run() -> Result<()> { #[cfg(target_os = "linux")] { runner.execute(Step::System, "pihole", || { - linux::run_pihole_update(sudo.as_ref(), run_type) + linux::run_pihole_update(ctx.sudo().as_ref(), run_type) })?; runner.execute(Step::Firmware, "Firmware upgrades", || linux::run_fwupdmgr(&ctx))?; runner.execute(Step::Restarts, "Restarts", || { - linux::run_needrestart(sudo.as_ref(), run_type) + linux::run_needrestart(ctx.sudo().as_ref(), run_type) })?; } @@ -420,12 +422,12 @@ fn run() -> Result<()> { #[cfg(target_os = "freebsd")] runner.execute(Step::System, "FreeBSD Upgrade", || { - freebsd::upgrade_freebsd(sudo.as_ref(), run_type) + freebsd::upgrade_freebsd(ctx.sudo().as_ref(), run_type) })?; #[cfg(target_os = "openbsd")] runner.execute(Step::System, "OpenBSD Upgrade", || { - openbsd::upgrade_openbsd(sudo.as_ref(), run_type) + openbsd::upgrade_openbsd(ctx.sudo().as_ref(), run_type) })?; #[cfg(windows)] @@ -457,10 +459,10 @@ fn run() -> Result<()> { } #[cfg(target_os = "freebsd")] - freebsd::audit_packages(&sudo).ok(); + freebsd::audit_packages(ctx.sudo().as_ref()).ok(); #[cfg(target_os = "dragonfly")] - dragonfly::audit_packages(&sudo).ok(); + dragonfly::audit_packages(ctx.sudo().as_ref()).ok(); } let mut post_command_failed = false; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index b6da5937..952fb8a2 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -202,7 +202,6 @@ pub fn run_juliaup(base_dirs: &BaseDirs, run_type: RunType) -> Result<()> { } run_type.execute(&juliaup).arg("update").status_checked() - } pub fn run_choosenim(ctx: &ExecutionContext) -> Result<()> { diff --git a/src/steps/node.rs b/src/steps/node.rs index 5455b4c7..f1e2e89d 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -4,7 +4,6 @@ use std::os::unix::fs::MetadataExt; use std::path::PathBuf; use std::process::Command; -use crate::sudo; use crate::utils::require_option; use color_eyre::eyre::Result; #[cfg(target_os = "linux")] @@ -13,9 +12,7 @@ use semver::Version; use tracing::debug; use crate::command::CommandExt; -use crate::executor::RunType; use crate::terminal::print_separator; -use crate::utils::sudo; use crate::utils::{require, PathExt}; use crate::{error::SkipStep, execution_context::ExecutionContext}; @@ -91,14 +88,17 @@ impl NPM { Version::parse(&version_str?).map_err(|err| err.into()) } - fn upgrade(&self, run_type: RunType, use_sudo: bool) -> Result<()> { + fn upgrade(&self, ctx: &ExecutionContext, use_sudo: bool) -> Result<()> { let args = ["update", self.global_location_arg()]; if use_sudo { - let sudo_option = sudo::path(); - let sudo = require_option(sudo_option, String::from("sudo is not installed"))?; - run_type.execute(sudo).arg(&self.command).args(args).status_checked()?; + let sudo = require_option(ctx.sudo().clone(), String::from("sudo is not installed"))?; + ctx.run_type() + .execute(sudo) + .arg(&self.command) + .args(args) + .status_checked()?; } else { - run_type.execute(&self.command).args(args).status_checked()?; + ctx.run_type().execute(&self.command).args(args).status_checked()?; } Ok(()) @@ -151,17 +151,18 @@ impl Yarn { .map(|s| PathBuf::from(s.stdout.trim())) } - fn upgrade(&self, run_type: RunType, use_sudo: bool) -> Result<()> { + fn upgrade(&self, ctx: &ExecutionContext, use_sudo: bool) -> Result<()> { let args = ["global", "upgrade"]; if use_sudo { - run_type - .execute("sudo") + let sudo = require_option(ctx.sudo().clone(), String::from("sudo is not installed"))?; + ctx.run_type() + .execute(sudo) .arg(self.yarn.as_ref().unwrap_or(&self.command)) .args(args) .status_checked()?; } else { - run_type.execute(&self.command).args(args).status_checked()?; + ctx.run_type().execute(&self.command).args(args).status_checked()?; } Ok(()) @@ -216,12 +217,12 @@ pub fn run_npm_upgrade(ctx: &ExecutionContext) -> Result<()> { #[cfg(target_os = "linux")] { - npm.upgrade(ctx.run_type(), should_use_sudo(&npm, ctx)?) + npm.upgrade(ctx, should_use_sudo(&npm, ctx)?) } #[cfg(not(target_os = "linux"))] { - npm.upgrade(ctx.run_type(), false) + npm.upgrade(ctx, false) } } @@ -232,12 +233,12 @@ pub fn run_pnpm_upgrade(ctx: &ExecutionContext) -> Result<()> { #[cfg(target_os = "linux")] { - pnpm.upgrade(ctx.run_type(), should_use_sudo(&pnpm, ctx)?) + pnpm.upgrade(ctx, should_use_sudo(&pnpm, ctx)?) } #[cfg(not(target_os = "linux"))] { - pnpm.upgrade(ctx.run_type(), false) + pnpm.upgrade(ctx, false) } } @@ -253,12 +254,12 @@ pub fn run_yarn_upgrade(ctx: &ExecutionContext) -> Result<()> { #[cfg(target_os = "linux")] { - yarn.upgrade(ctx.run_type(), should_use_sudo_yarn(&yarn, ctx)?) + yarn.upgrade(ctx, should_use_sudo_yarn(&yarn, ctx)?) } #[cfg(not(target_os = "linux"))] { - yarn.upgrade(ctx.run_type(), false) + yarn.upgrade(ctx, false) } } diff --git a/src/steps/os/archlinux.rs b/src/steps/os/archlinux.rs index 7c4e938c..e75fb855 100644 --- a/src/steps/os/archlinux.rs +++ b/src/steps/os/archlinux.rs @@ -10,6 +10,7 @@ use walkdir::WalkDir; use crate::command::CommandExt; use crate::error::TopgradeError; use crate::execution_context::ExecutionContext; +use crate::sudo::Sudo; use crate::utils::which; use crate::{config, Step}; @@ -110,7 +111,7 @@ impl Trizen { } pub struct Pacman { - sudo: PathBuf, + sudo: Sudo, executable: PathBuf, } @@ -229,7 +230,7 @@ impl ArchPackageManager for Pamac { pub struct Aura { executable: PathBuf, - sudo: PathBuf, + sudo: Sudo, } impl Aura { diff --git a/src/steps/os/dragonfly.rs b/src/steps/os/dragonfly.rs index b314a47f..63452a82 100644 --- a/src/steps/os/dragonfly.rs +++ b/src/steps/os/dragonfly.rs @@ -1,12 +1,13 @@ use crate::command::CommandExt; use crate::executor::RunType; +use crate::sudo::Sudo; use crate::terminal::print_separator; use crate::utils::require_option; use color_eyre::eyre::Result; use std::path::PathBuf; use std::process::Command; -pub fn upgrade_packages(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> { +pub fn upgrade_packages(sudo: Option<&Sudo>, run_type: RunType) -> Result<()> { let sudo = require_option(sudo, String::from("No sudo detected"))?; print_separator("DragonFly BSD Packages"); run_type @@ -15,7 +16,7 @@ pub fn upgrade_packages(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> .status_checked() } -pub fn audit_packages(sudo: &Option) -> Result<()> { +pub fn audit_packages(sudo: Option<&Sudo>) -> Result<()> { if let Some(sudo) = sudo { println!(); Command::new(sudo) diff --git a/src/steps/os/freebsd.rs b/src/steps/os/freebsd.rs index 8109057a..3cb06848 100644 --- a/src/steps/os/freebsd.rs +++ b/src/steps/os/freebsd.rs @@ -1,14 +1,14 @@ use crate::command::CommandExt; use crate::execution_context::ExecutionContext; use crate::executor::RunType; +use crate::sudo::Sudo; use crate::terminal::print_separator; use crate::utils::require_option; use crate::Step; use color_eyre::eyre::Result; -use std::path::PathBuf; use std::process::Command; -pub fn upgrade_freebsd(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> { +pub fn upgrade_freebsd(sudo: Option<&Sudo>, run_type: RunType) -> Result<()> { let sudo = require_option(sudo, String::from("No sudo detected"))?; print_separator("FreeBSD Update"); run_type @@ -17,7 +17,7 @@ pub fn upgrade_freebsd(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> .status_checked() } -pub fn upgrade_packages(ctx: &ExecutionContext, sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> { +pub fn upgrade_packages(ctx: &ExecutionContext, sudo: Option<&Sudo>, run_type: RunType) -> Result<()> { let sudo = require_option(sudo, String::from("No sudo detected"))?; print_separator("FreeBSD Packages"); @@ -30,7 +30,7 @@ pub fn upgrade_packages(ctx: &ExecutionContext, sudo: Option<&PathBuf>, run_type command.status_checked() } -pub fn audit_packages(sudo: &Option) -> Result<()> { +pub fn audit_packages(sudo: Option<&Sudo>) -> Result<()> { if let Some(sudo) = sudo { println!(); Command::new(sudo) diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 25a40c0a..20d3653f 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -10,6 +10,7 @@ use crate::error::{SkipStep, TopgradeError}; use crate::execution_context::ExecutionContext; use crate::executor::RunType; use crate::steps::os::archlinux; +use crate::sudo::Sudo; use crate::terminal::{print_separator, print_warning}; use crate::utils::{require, require_option, which, PathExt}; use crate::Step; @@ -498,7 +499,7 @@ fn upgrade_neon(ctx: &ExecutionContext) -> Result<()> { Ok(()) } -pub fn run_needrestart(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> { +pub fn run_needrestart(sudo: Option<&Sudo>, run_type: RunType) -> Result<()> { let sudo = require_option(sudo, String::from("sudo is not installed"))?; let needrestart = require("needrestart")?; let distribution = Distribution::detect()?; @@ -603,7 +604,7 @@ pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> { Ok(()) } -pub fn run_snap(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> { +pub fn run_snap(sudo: Option<&Sudo>, run_type: RunType) -> Result<()> { let sudo = require_option(sudo, String::from("sudo is not installed"))?; let snap = require("snap")?; @@ -615,7 +616,7 @@ pub fn run_snap(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> { run_type.execute(sudo).arg(snap).arg("refresh").status_checked() } -pub fn run_pihole_update(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()> { +pub fn run_pihole_update(sudo: Option<&Sudo>, run_type: RunType) -> Result<()> { let sudo = require_option(sudo, String::from("sudo is not installed"))?; let pihole = require("pihole")?; Path::new("/opt/pihole/update.sh").require()?; diff --git a/src/steps/os/windows.rs b/src/steps/os/windows.rs index 909847c9..987704aa 100644 --- a/src/steps/os/windows.rs +++ b/src/steps/os/windows.rs @@ -19,17 +19,16 @@ pub fn run_chocolatey(ctx: &ExecutionContext) -> Result<()> { print_separator("Chocolatey"); - let mut cmd = &choco; - let mut args = vec!["upgrade", "all"]; - - if let Some(sudo) = ctx.sudo() { - cmd = sudo; - args.insert(0, "choco"); - } - - let mut command = ctx.run_type().execute(cmd); + let mut command = match ctx.sudo() { + Some(sudo) => { + let mut command = ctx.run_type().execute(sudo); + command.arg(choco); + command + } + None => ctx.run_type().execute(choco), + }; - command.args(&args); + command.args(["upgrade", "all"]); if yes { command.arg("--yes"); diff --git a/src/sudo.rs b/src/sudo.rs index 0a66cf37..28c6fee9 100644 --- a/src/sudo.rs +++ b/src/sudo.rs @@ -1,3 +1,5 @@ +use std::ffi::OsStr; +use std::path::Path; use std::path::PathBuf; use color_eyre::eyre::Context; @@ -5,30 +7,102 @@ use color_eyre::eyre::Result; use crate::command::CommandExt; use crate::execution_context::ExecutionContext; +use crate::executor::Executor; use crate::terminal::print_separator; use crate::utils::which; -/// Get the path of the `sudo` utility. -/// -/// Detects `doas`, `sudo`, `gsudo`, or `pkexec`. -pub fn path() -> Option { - which("doas") - .or_else(|| which("sudo")) - .or_else(|| which("gsudo")) - .or_else(|| which("pkexec")) +#[derive(Clone, Debug)] +pub struct Sudo { + /// The path to the `sudo` binary. + path: PathBuf, + /// The type of program being used as `sudo`. + kind: SudoKind, } -/// Elevate permissions with `sudo`. -pub fn elevate(ctx: &ExecutionContext, sudo: Option<&PathBuf>) -> Result<()> { - if let Some(sudo) = sudo { +impl Sudo { + /// Get the `sudo` binary for this platform. + pub fn detect() -> Option { + which("doas") + .map(|p| (p, SudoKind::Doas)) + .or_else(|| which("sudo").map(|p| (p, SudoKind::Sudo))) + .or_else(|| which("gsudo").map(|p| (p, SudoKind::Gsudo))) + .or_else(|| which("pkexec").map(|p| (p, SudoKind::Pkexec))) + .map(|(path, kind)| Self { path, kind }) + } + + /// Elevate permissions with `sudo`. + /// + /// This helps prevent blocking `sudo` prompts from stopping the run in the middle of a + /// step. + /// + /// See: https://github.com/topgrade-rs/topgrade/issues/205 + pub fn elevate(&self, ctx: &ExecutionContext) -> Result<()> { print_separator("Sudo"); - ctx.run_type() - .execute(sudo) - // TODO: Does this work with `doas`, `pkexec`, `gsudo`, GNU `sudo`...? - .arg("-v") - .status_checked() - .wrap_err("Failed to elevate permissions")?; + let mut cmd = ctx.run_type().execute(self); + match self.kind { + SudoKind::Doas => { + // `doas` doesn't have anything like `sudo -v` to cache credentials, + // so we just execute a dummy `echo` command so we have something + // unobtrusive to run. + // See: https://man.openbsd.org/doas + cmd.arg("echo"); + } + SudoKind::Sudo => { + // From `man sudo` on macOS: + // -v, --validate + // Update the user's cached credentials, authenticating the user + // if necessary. For the sudoers plugin, this extends the sudo + // timeout for another 5 minutes by default, but does not run a + // command. Not all security policies support cached credentials. + cmd.arg("-v"); + } + SudoKind::Gsudo => { + // Shows current user, cache and console status. + // See: https://gerardog.github.io/gsudo/docs/usage + cmd.arg("status"); + } + SudoKind::Pkexec => { + // I don't think this does anything; `pkexec` usually asks for + // authentication every time, although it can be configured + // differently. + // + // See the note for `doas` above. + // + // See: https://linux.die.net/man/1/pkexec + cmd.arg("echo"); + } + } + cmd.status_checked().wrap_err("Failed to elevate permissions") + } + + /// Execute a command with `sudo`. + pub fn execute_elevated(&self, ctx: &ExecutionContext, command: &Path, interactive: bool) -> Executor { + let mut cmd = ctx.run_type().execute(self); + + if let SudoKind::Sudo = self.kind { + cmd.arg("--preserve-env=DIFFPROG"); + } + + if interactive { + cmd.arg("-i"); + } + + cmd.arg(command); + + cmd } +} - Ok(()) +#[derive(Clone, Copy, Debug)] +enum SudoKind { + Doas, + Sudo, + Gsudo, + Pkexec, +} + +impl AsRef for Sudo { + fn as_ref(&self) -> &OsStr { + self.path.as_ref() + } } From e26ec4d9e0cc8bfc32a3ed0ba83d47b28ee97efc Mon Sep 17 00:00:00 2001 From: Guilherme Silva <626206+guihkx@users.noreply.github.com> Date: Sat, 26 Nov 2022 14:52:14 -0300 Subject: [PATCH 07/12] Fix clippy warning for DragonFly BSD (#231) --- src/steps/os/dragonfly.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/steps/os/dragonfly.rs b/src/steps/os/dragonfly.rs index 63452a82..b38b4b9d 100644 --- a/src/steps/os/dragonfly.rs +++ b/src/steps/os/dragonfly.rs @@ -4,7 +4,6 @@ use crate::sudo::Sudo; use crate::terminal::print_separator; use crate::utils::require_option; use color_eyre::eyre::Result; -use std::path::PathBuf; use std::process::Command; pub fn upgrade_packages(sudo: Option<&Sudo>, run_type: RunType) -> Result<()> { From 37b900c56a771da77c778f6fac21bd3c9e88bde4 Mon Sep 17 00:00:00 2001 From: Jason Stelzer Date: Sat, 26 Nov 2022 14:38:18 -0500 Subject: [PATCH 08/12] Add garuda-update (#227) --- src/config.rs | 1 + src/steps/os/archlinux.rs | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/config.rs b/src/config.rs index 412a0dc8..3c65db33 100644 --- a/src/config.rs +++ b/src/config.rs @@ -225,6 +225,7 @@ pub struct Brew { #[derive(Debug, Deserialize, Clone, Copy)] #[serde(rename_all = "snake_case")] pub enum ArchPackageManager { + GarudaUpdate, Autodetect, Trizen, Paru, diff --git a/src/steps/os/archlinux.rs b/src/steps/os/archlinux.rs index e75fb855..6b22d95e 100644 --- a/src/steps/os/archlinux.rs +++ b/src/steps/os/archlinux.rs @@ -71,6 +71,27 @@ impl YayParu { } } +pub struct GarudaUpdate { + executable: PathBuf, +} + +impl ArchPackageManager for GarudaUpdate { + fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> { + let mut command = ctx.run_type().execute(&self.executable); + command.env("PATH", get_execution_path()); + command.status_checked()?; + Ok(()) + } +} + +impl GarudaUpdate { + fn get() -> Option { + Some(Self { + executable: which("garuda-update")?, + }) + } +} + pub struct Trizen { executable: PathBuf, } @@ -283,14 +304,16 @@ pub fn get_arch_package_manager(ctx: &ExecutionContext) -> Option YayParu::get("paru", &pacman) + config::ArchPackageManager::Autodetect => GarudaUpdate::get() .map(box_package_manager) + .or_else(|| YayParu::get("paru", &pacman).map(box_package_manager)) .or_else(|| YayParu::get("yay", &pacman).map(box_package_manager)) .or_else(|| Trizen::get().map(box_package_manager)) .or_else(|| Pikaur::get().map(box_package_manager)) .or_else(|| Pamac::get().map(box_package_manager)) .or_else(|| Pacman::get(ctx).map(box_package_manager)) .or_else(|| Aura::get(ctx).map(box_package_manager)), + config::ArchPackageManager::GarudaUpdate => GarudaUpdate::get().map(box_package_manager), config::ArchPackageManager::Trizen => Trizen::get().map(box_package_manager), config::ArchPackageManager::Paru => YayParu::get("paru", &pacman).map(box_package_manager), config::ArchPackageManager::Yay => YayParu::get("yay", &pacman).map(box_package_manager), From f6ec6c76dbbe46681dfd0231682152094b76215c Mon Sep 17 00:00:00 2001 From: Marcin Puc Date: Sat, 26 Nov 2022 20:42:35 +0100 Subject: [PATCH 09/12] Add shell completion and manpage generation (#233) --- Cargo.lock | 27 +++++++++++++++++ Cargo.toml | 2 ++ src/config.rs | 9 ++++++ src/main.rs | 13 +++++++++ topgrade.8 | 80 --------------------------------------------------- 5 files changed, 51 insertions(+), 80 deletions(-) delete mode 100644 topgrade.8 diff --git a/Cargo.lock b/Cargo.lock index 81de8e5e..4872a4a5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -258,6 +258,15 @@ dependencies = [ "textwrap", ] +[[package]] +name = "clap_complete" +version = "3.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "da92e6facd8d73c22745a5d3cbb59bdf8e46e3235c923e516527d8e81eec14a4" +dependencies = [ + "clap", +] + [[package]] name = "clap_derive" version = "3.1.18" @@ -280,6 +289,16 @@ dependencies = [ "os_str_bytes", ] +[[package]] +name = "clap_mangen" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "121b598d1b9d63d4ff3b7dae8defd88cc23e41850ee89fd2feec2e7d992e6ec8" +dependencies = [ + "clap", + "roff", +] + [[package]] name = "codespan-reporting" version = "0.11.1" @@ -1533,6 +1552,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "roff" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b833d8d034ea094b1ea68aa6d5c740e0d04bad9d16568d08ba6f76823a114316" + [[package]] name = "rust-ini" version = "0.18.0" @@ -2041,6 +2066,8 @@ dependencies = [ "cfg-if", "chrono", "clap", + "clap_complete", + "clap_mangen", "color-eyre", "console", "directories", diff --git a/Cargo.toml b/Cargo.toml index 7ae19233..1c65d471 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,6 +28,8 @@ toml = "0.5" which_crate = { version = "~4.1", package = "which" } shellexpand = "~2.1" clap = { version = "~3.1", features = ["cargo", "derive"] } +clap_complete = "~3.1" +clap_mangen = "~0.1" walkdir = "~2.3" console = "~0.15" lazy_static = "~1.4" diff --git a/src/config.rs b/src/config.rs index 3c65db33..552d3d89 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,6 +6,7 @@ use std::process::Command; use std::{env, fs}; use clap::{ArgEnum, Parser}; +use clap_complete::Shell; use color_eyre::eyre; use color_eyre::eyre::Context; use color_eyre::eyre::Result; @@ -489,6 +490,14 @@ pub struct CommandLineArgs { /// See: https://docs.rs/tracing-subscriber/latest/tracing_subscriber/struct.EnvFilter.html #[clap(long, default_value = "info")] pub log_filter: String, + + /// Print completion script for the given shell and exit + #[clap(long, arg_enum, hide = true)] + pub gen_completion: Option, + + /// Print roff manpage and exit + #[clap(long, hide = true)] + pub gen_manpage: bool, } impl CommandLineArgs { diff --git a/src/main.rs b/src/main.rs index b77a1621..c4f55dff 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,6 +4,7 @@ use std::env; use std::io; use std::process::exit; +use clap::CommandFactory; use clap::{crate_version, Parser}; use color_eyre::eyre::Context; use color_eyre::eyre::{eyre, Result}; @@ -42,6 +43,18 @@ fn run() -> Result<()> { let opt = CommandLineArgs::parse(); + if let Some(shell) = opt.gen_completion { + let cmd = &mut CommandLineArgs::command(); + clap_complete::generate(shell, cmd, clap::crate_name!(), &mut std::io::stdout()); + return Ok(()); + } + + if opt.gen_manpage { + let man = clap_mangen::Man::new(CommandLineArgs::command()); + man.render(&mut std::io::stdout())?; + return Ok(()); + } + install_tracing(&opt.tracing_filter_directives())?; for env in opt.env_variables() { diff --git a/topgrade.8 b/topgrade.8 deleted file mode 100644 index 7dad0565..00000000 --- a/topgrade.8 +++ /dev/null @@ -1,80 +0,0 @@ -.hy -.TH "topgrade" "8" -.SH NAME -.PP -Topgrade \- Upgrade everything -.SH SYNOPSIS -.PP -topgrade [\fIoptions\f[]] -.SH DESCRIPTION -.PP -Keeping your system up to date usually involves invoking multiple package managers. -This results in big, non-portable shell one-liners saved in your shell. -To remedy this, \fBTopgrade\fR detects which tools you use and runs the appropriate commands to update them. -.SH OPTIONS -.TP -.B \-\-only -Run only specific steps -.RS -.RE -.TP -.B \-\-disable -Disable specific steps -.RS -.RE -.TP -.B \-c, \-\-cleanup -Cleanup temporary or old files -.RS -.RE -.TP -.B \-n, \-\-dry\-run -List the commands that would be run -.RS -.RE -.TP -.B \-\-edit\-config -Edit the configuration file -.RS -.RE -.TP -.B \-h, \-\-help -Print help information -.RS -.RE -.TP -.B \-k, \-\-keep -Prompt for a key before exiting -.RS -.RE -.TP -.B \-\-no\-retry -Do not ask to retry failed steps -.RS -.RE -.TP -.B \-t, \-\-tmux -Run inside tmux -.RS -.RE -.TP -.B \-V, \-\-version -Print version information -.RS -.RE -.TP -.B \-v, \-\-verbose -Output logs -.RS -.RE -.B \-y, \-\-yes -Skip package manager's prompts (experimental) -.SH ARGUMENT FORMAT -Options can be given in any order. -A list of steps must be provided as a list of separate arguments, i.e. 'topgrade --only system shell'. -.SH BUGS -For a list of bugs see <\fIhttps://github.com/r-darwish/topgrade/issues\fR>. -.SH AUTHOR -\fBTopgrade\fR is maintained by Roey Dror (\[aq]r\-darwish\[aq]) and many other contributors. -You can view the full list at -<\fIhttps://github.com/r-darwish/topgrade/graphs/contributors\fR> From 70045fca2901bf9ea6f18750b6377ed1daaa95ae Mon Sep 17 00:00:00 2001 From: Guilherme Silva <626206+guihkx@users.noreply.github.com> Date: Sat, 26 Nov 2022 20:21:29 -0300 Subject: [PATCH 10/12] CI: Force color support for Rustfmt (#230) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Thomas Schönauer <37108907+DottoDev@users.noreply.github.com> --- .github/workflows/check-and-lint.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/check-and-lint.yaml b/.github/workflows/check-and-lint.yaml index cb825f48..fbd0a531 100644 --- a/.github/workflows/check-and-lint.yaml +++ b/.github/workflows/check-and-lint.yaml @@ -26,6 +26,8 @@ jobs: components: rustfmt - name: Run cargo fmt + env: + TERM: xterm-256color run: | cargo fmt --all -- --check From 22ab07d88e523ece10ea11bcd38cf0fa358178b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Tue, 29 Nov 2022 06:49:26 +0000 Subject: [PATCH 11/12] Fixes paru/yay -Pw return code error (#228) --- src/executor.rs | 2 +- src/steps/os/archlinux.rs | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/executor.rs b/src/executor.rs index a403a65e..b3e16e44 100644 --- a/src/executor.rs +++ b/src/executor.rs @@ -176,7 +176,7 @@ impl Executor { /// An extension of `status_checked` that allows you to set a sequence of codes /// that can indicate success of a script - #[cfg_attr(windows, allow(dead_code))] + #[allow(dead_code)] pub fn status_checked_with_codes(&mut self, codes: &[i32]) -> Result<()> { match self { Executor::Wet(c) => c.status_checked_with(|status| { diff --git a/src/steps/os/archlinux.rs b/src/steps/os/archlinux.rs index 6b22d95e..cd8b767a 100644 --- a/src/steps/os/archlinux.rs +++ b/src/steps/os/archlinux.rs @@ -1,7 +1,6 @@ use std::env::var_os; use std::ffi::OsString; use std::path::{Path, PathBuf}; -use std::process::Command; use color_eyre::eyre; use color_eyre::eyre::Result; @@ -32,7 +31,10 @@ 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()?; + ctx.run_type() + .execute(&self.executable) + .arg("-Pw") + .status_checked_with_codes(&[1, 0])?; } let mut command = ctx.run_type().execute(&self.executable); From 70616b2ec5cc258ddfe7401ac7879b4a6e0b1c2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Tue, 29 Nov 2022 15:17:20 +0000 Subject: [PATCH 12/12] Version bump (#237) --- Cargo.lock | 82 +++++++++++++++++++++++++----------------------------- Cargo.toml | 2 +- 2 files changed, 39 insertions(+), 45 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4872a4a5..2739a188 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -59,11 +59,11 @@ dependencies = [ [[package]] name = "async-channel" -version = "1.7.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14485364214912d3b19cc3435dde4df66065127f05fa0d75c712f36f12c2f28" +checksum = "cf46fee83e5ccffc220104713af3292ff9bc7c64c7de289f66dae8e38d826833" dependencies = [ - "concurrent-queue 1.2.4", + "concurrent-queue", "event-listener", "futures-core", ] @@ -76,7 +76,7 @@ checksum = "17adb73da160dfb475c183343c8cccd80721ea5a605d3eb57125f0a7b7a92d0b" dependencies = [ "async-lock", "async-task", - "concurrent-queue 2.0.0", + "concurrent-queue", "fastrand", "futures-lite", "slab", @@ -84,13 +84,13 @@ dependencies = [ [[package]] name = "async-io" -version = "1.10.0" +version = "1.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e8121296a9f05be7f34aa4196b1747243b3b62e048bb7906f644f3fbfc490cf7" +checksum = "8c374dda1ed3e7d8f0d9ba58715f924862c63eae6849c92d3a18e7fbde9e2794" dependencies = [ "async-lock", "autocfg", - "concurrent-queue 1.2.4", + "concurrent-queue", "futures-lite", "libc", "log", @@ -99,7 +99,7 @@ dependencies = [ "slab", "socket2", "waker-fn", - "winapi", + "windows-sys", ] [[package]] @@ -131,9 +131,9 @@ checksum = "7a40729d2133846d9ed0ea60a8b9541bccddab49cd30f0715a1da672fe9a2524" [[package]] name = "async-trait" -version = "0.1.58" +version = "0.1.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e805d94e6b5001b651426cf4cd446b1ab5f319d27bab5c644f61de0a804360c" +checksum = "31e6e93155431f3931513b243d371981bb2770112b370c82745a1d19d2f99364" dependencies = [ "proc-macro2", "quote", @@ -167,7 +167,7 @@ dependencies = [ "cc", "cfg-if", "libc", - "miniz_oxide", + "miniz_oxide 0.5.4", "object", "rustc-demangle", ] @@ -208,12 +208,6 @@ version = "1.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" -[[package]] -name = "cache-padded" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1db59621ec70f09c5e9b597b220c7a2b43611f4710dc03ceb8748637775692c" - [[package]] name = "cc" version = "1.0.77" @@ -236,7 +230,7 @@ dependencies = [ "js-sys", "num-integer", "num-traits", - "time 0.1.44", + "time 0.1.45", "wasm-bindgen", "winapi", ] @@ -336,15 +330,6 @@ dependencies = [ "tracing-error", ] -[[package]] -name = "concurrent-queue" -version = "1.2.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "af4780a44ab5696ea9e28294517f1fffb421a83a25af521333c838635509db9c" -dependencies = [ - "cache-padded", -] - [[package]] name = "concurrent-queue" version = "2.0.0" @@ -584,12 +569,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.24" +version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82b0f4c27ad9f8bfd1f3208d882da2b09c301bc1c828fd3a00d0216d2fbbff6" +checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" dependencies = [ "crc32fast", - "miniz_oxide", + "miniz_oxide 0.6.2", ] [[package]] @@ -1065,6 +1050,15 @@ dependencies = [ "adler", ] +[[package]] +name = "miniz_oxide" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +dependencies = [ + "adler", +] + [[package]] name = "mio" version = "0.7.14" @@ -1280,9 +1274,9 @@ dependencies = [ [[package]] name = "parking_lot_core" -version = "0.9.4" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4dc9e0dc2adc1c69d09143aff38d3d30c5c3f0df0dad82e6d25547af174ebec0" +checksum = "7ff9f3fef3968a3ec5945535ed654cb38ff72d7495a25619e2247fb15a2ed9ba" dependencies = [ "cfg-if", "libc", @@ -1324,16 +1318,16 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "polling" -version = "2.4.0" +version = "2.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab4609a838d88b73d8238967b60dd115cc08d38e2bbaf51ee1e4b695f89122e2" +checksum = "166ca89eb77fd403230b9c156612965a81e094ec6ec3aa13663d4c8b113fa748" dependencies = [ "autocfg", "cfg-if", "libc", "log", "wepoll-ffi", - "winapi", + "windows-sys", ] [[package]] @@ -1667,18 +1661,18 @@ checksum = "e25dfac463d778e353db5be2449d1cce89bd6fd23c9f1ea21310ce6e5a1b29c4" [[package]] name = "serde" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d193d69bae983fc11a79df82342761dfbf28a99fc8d203dca4c3c1b590948965" +checksum = "e53f64bb4ba0191d6d0676e1b141ca55047d83b74f5607e6d8eb88126c52c2dc" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.147" +version = "1.0.148" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4f1d362ca8fc9c3e3a7484440752472d68a6caa98f1ab81d99b5dfe517cec852" +checksum = "a55492425aa53521babf6137309e7d34c20bbfbbfcfe2c7f3a047fd1f6b92c0c" dependencies = [ "proc-macro2", "quote", @@ -1855,9 +1849,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.103" +version = "1.0.104" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a864042229133ada95abf3b54fdc62ef5ccabe9515b64717bcb9a1919e59445d" +checksum = "4ae548ec36cf198c0ef7710d3c230987c2d6d7bd98ad6edc0274462724c585ce" dependencies = [ "proc-macro2", "quote", @@ -1956,9 +1950,9 @@ dependencies = [ [[package]] name = "time" -version = "0.1.44" +version = "0.1.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +checksum = "1b797afad3f312d1c66a56d11d0316f916356d11bd158fbc6ca6389ff6bf805a" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", @@ -2061,7 +2055,7 @@ dependencies = [ [[package]] name = "topgrade" -version = "10.2.0" +version = "10.2.1" dependencies = [ "cfg-if", "chrono", diff --git a/Cargo.toml b/Cargo.toml index 1c65d471..85b53f87 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ keywords = ["upgrade", "update"] license = "GPL-3.0" # license-file = "LICENSE" repository = "https://github.com/topgrade-rs/topgrade" -version = "10.2.0" +version = "10.2.1" authors = ["Roey Darwish Dror ", "Thomas Schönauer "] exclude = ["doc/screenshot.gif"] edition = "2021"