From 5dffa2c6cca7639387dcb74386399f6dea9661fb Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:03:34 +0000 Subject: [PATCH 01/30] Add new step: GNU Guix by JamesClarke7283 (#1) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Added new step: guix (basic support) * Fixed clippy errors and better practice, Thanks To guidence from @enchant97 * Removed accidental swp file, as pointed out by @strangelittlemonkey in pull request #982 Authored-by: James Clarke Approved-by: Thomas Schönauer --- src/config.rs | 1 + src/main.rs | 2 ++ src/steps/os/unix.rs | 18 ++++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/src/config.rs b/src/config.rs index 9eec74c7..4e69b0b9 100644 --- a/src/config.rs +++ b/src/config.rs @@ -94,6 +94,7 @@ pub enum Step { GithubCliExtensions, GitRepos, Go, + Guix, Haxelib, GnomeShellExtensions, HomeManager, diff --git a/src/main.rs b/src/main.rs index 88d0f605..e47b1770 100644 --- a/src/main.rs +++ b/src/main.rs @@ -191,6 +191,8 @@ fn run() -> Result<()> { { runner.execute(Step::Yadm, "yadm", || unix::run_yadm(&ctx))?; runner.execute(Step::Nix, "nix", || unix::run_nix(&ctx))?; + runner.execute(Step::Guix, "guix", || unix::run_guix(&ctx))?; + runner.execute(Step::HomeManager, "home-manager", || unix::run_home_manager(run_type))?; runner.execute(Step::Asdf, "asdf", || unix::run_asdf(run_type))?; runner.execute(Step::Pkgin, "pkgin", || unix::run_pkgin(&ctx))?; diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index dd90b2d0..a6c1468a 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -251,6 +251,24 @@ pub fn run_brew_cask(ctx: &ExecutionContext, variant: BrewVariant) -> Result<()> Ok(()) } +pub fn run_guix(ctx: &ExecutionContext) -> Result<()> { + let guix = require("guix")?; + + let run_type = ctx.run_type(); + + 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); + + print_separator("Guix"); + + if should_upgrade { + return run_type.execute(&guix).args(&["package", "-u"]).check_run(); + } + Err(SkipStep(String::from("Guix Pull Failed, Skipping")).into()) +} + pub fn run_nix(ctx: &ExecutionContext) -> Result<()> { let nix = require("nix")?; let nix_channel = require("nix-channel")?; From 057fc3b5338434627fb5a3be8308d765b5ebea99 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 18:29:56 +0000 Subject: [PATCH 02/30] Add step for updating Julia packages (#2) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Add step for updating julia packages * Appease clippy Authored-by: Jules Bertholet Approved-by: Thomas Schönauer --- src/config.rs | 3 ++- src/error.rs | 2 +- src/main.rs | 1 + src/steps/generic.rs | 11 +++++++++++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/config.rs b/src/config.rs index 4e69b0b9..8078c45d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -62,7 +62,7 @@ macro_rules! get_deprecated { type Commands = BTreeMap; -#[derive(ArgEnum, EnumString, EnumVariantNames, Debug, Clone, PartialEq, Deserialize, EnumIter, Copy)] +#[derive(ArgEnum, EnumString, EnumVariantNames, Debug, Clone, PartialEq, Eq, Deserialize, EnumIter, Copy)] #[clap(rename_all = "snake_case")] #[serde(rename_all = "snake_case")] #[strum(serialize_all = "snake_case")] @@ -99,6 +99,7 @@ pub enum Step { GnomeShellExtensions, HomeManager, Jetpack, + Julia, Kakoune, Krew, Macports, diff --git a/src/error.rs b/src/error.rs index 34605806..5ec6ce75 100644 --- a/src/error.rs +++ b/src/error.rs @@ -2,7 +2,7 @@ use std::process::ExitStatus; use thiserror::Error; -#[derive(Error, Debug, PartialEq)] +#[derive(Error, Debug, PartialEq, Eq)] pub enum TopgradeError { #[error("{0}")] ProcessFailed(ExitStatus), diff --git a/src/main.rs b/src/main.rs index e47b1770..f6eea263 100644 --- a/src/main.rs +++ b/src/main.rs @@ -342,6 +342,7 @@ 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::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))?; runner.execute(Step::Rtcl, "rtcl", || generic::run_rtcl(&ctx))?; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 698f10d8..485bd7d5 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -496,3 +496,14 @@ pub fn run_ghcli_extensions_upgrade(ctx: &ExecutionContext) -> Result<()> { .args(&["extension", "upgrade", "--all"]) .check_run() } + +pub fn update_julia_packages(ctx: &ExecutionContext) -> Result<()> { + let julia = utils::require("julia")?; + + print_separator("Julia Packages"); + + ctx.run_type() + .execute(&julia) + .args(&["-e", "using Pkg; Pkg.update()"]) + .check_run() +} From 6bfdc4974b5399d5cb472226b00d49aa68783909 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:08:11 +0000 Subject: [PATCH 03/30] Add yarn support. Fix #958 (#15) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authored-by: 0xMRTT <0xMRTT@tuta.io> Approved-by: Thomas Schönauer --- src/config.rs | 17 ++++++++++ src/main.rs | 1 + src/steps/node.rs | 83 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 101 insertions(+) diff --git a/src/config.rs b/src/config.rs index 8078c45d..5b6d150f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -168,6 +168,13 @@ pub struct Windows { enable_winget: Option, } +#[derive(Deserialize, Default, Debug)] +#[serde(deny_unknown_fields)] +#[allow(clippy::upper_case_acronyms)] +pub struct Yarn { + use_sudo: Option, +} + #[derive(Deserialize, Default, Debug)] #[serde(deny_unknown_fields)] #[allow(clippy::upper_case_acronyms)] @@ -270,6 +277,7 @@ pub struct ConfigFile { git: Option, windows: Option, npm: Option, + yarn: Option, vim: Option, firmware: Option, vagrant: Option, @@ -841,6 +849,15 @@ impl Config { .and_then(|npm| npm.use_sudo) .unwrap_or(false) } + #[cfg(target_os = "linux")] + pub fn yarn_use_sudo(&self) -> bool { + self.config_file + .yarn + .as_ref() + .and_then(|yarn| yarn.use_sudo) + .unwrap_or(false) + } + #[cfg(target_os = "linux")] pub fn firmware_upgrade(&self) -> bool { diff --git a/src/main.rs b/src/main.rs index f6eea263..a4231dc7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -337,6 +337,7 @@ fn run() -> Result<()> { runner.execute(Step::Vim, "voom", || vim::run_voom(&base_dirs, run_type))?; runner.execute(Step::Kakoune, "Kakoune", || kakoune::upgrade_kak_plug(&ctx))?; runner.execute(Step::Node, "npm", || node::run_npm_upgrade(&ctx))?; + runner.execute(Step::Node, "yarn", || node::run_yarn_upgrade(&ctx))?; runner.execute(Step::Containers, "Containers", || containers::run_containers(&ctx))?; runner.execute(Step::Deno, "deno", || node::deno_upgrade(&ctx))?; runner.execute(Step::Composer, "composer", || generic::run_composer_update(&ctx))?; diff --git a/src/steps/node.rs b/src/steps/node.rs index 2541e7cd..c27b4b45 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -88,6 +88,59 @@ impl NPM { } } +struct Yarn { + command: PathBuf, + yarn: Option, +} + +impl Yarn { + fn new(command: PathBuf) -> Self { + Self { + command, + yarn: require("yarn").ok(), + } + } + + #[cfg(target_os = "linux")] + fn root(&self) -> Result { + let args = ["global", "dir"]; + Command::new(&self.command) + .args(args) + .check_output() + .map(|s| PathBuf::from(s.trim())) + } + + fn upgrade(&self, run_type: RunType, use_sudo: bool) -> Result<()> { + print_separator("Yarn Package Manager"); + let args = ["global", "upgrade"]; + + if use_sudo { + run_type + .execute("sudo") + .arg(self.yarn.as_ref().unwrap_or(&self.command)) + .args(args) + .check_run()?; + } else { + run_type.execute(&self.command).args(args).check_run()?; + } + + Ok(()) + } + + #[cfg(target_os = "linux")] + pub fn should_use_sudo(&self) -> Result { + let yarn_root = self.root()?; + if !yarn_root.exists() { + return Err(SkipStep(format!("NPM root at {} doesn't exist", yarn_root.display(),)).into()); + } + + let metadata = std::fs::metadata(&yarn_root)?; + let uid = Uid::effective(); + + Ok(metadata.uid() != uid.as_raw() && metadata.uid() == 0) + } +} + #[cfg(target_os = "linux")] fn should_use_sudo(npm: &NPM, ctx: &ExecutionContext) -> Result { if npm.should_use_sudo()? { @@ -102,6 +155,20 @@ fn should_use_sudo(npm: &NPM, ctx: &ExecutionContext) -> Result { } } +#[cfg(target_os = "linux")] +fn should_use_sudo_yarn(yarn: &Yarn, ctx: &ExecutionContext) -> Result { + if yarn.should_use_sudo()? { + if ctx.config().yarn_use_sudo() { + Ok(true) + } else { + Err(SkipStep("NPM root is owned by another user which is not the current user. Set use_sudo = true under the NPM section in your configuration to run NPM as sudo".to_string()) + .into()) + } + } else { + Ok(false) + } +} + pub fn run_npm_upgrade(ctx: &ExecutionContext) -> Result<()> { let npm = require("npm").map(NPM::new)?; @@ -116,6 +183,22 @@ pub fn run_npm_upgrade(ctx: &ExecutionContext) -> Result<()> { } } +pub fn run_yarn_upgrade(ctx: &ExecutionContext) -> Result<()> { + let yarn = require("yarn").map(Yarn::new)?; + + #[cfg(target_os = "linux")] + { + yarn.upgrade(ctx.run_type(), should_use_sudo_yarn(&yarn, ctx)?) + } + + #[cfg(not(target_os = "linux"))] + { + yarn.upgrade(ctx.run_type(), false) + } +} + + + pub fn deno_upgrade(ctx: &ExecutionContext) -> Result<()> { let deno = require("deno")?; let deno_dir = ctx.base_dirs().home_dir().join(".deno"); From ffe8613b2ed955d9415748aa92d2af502942e23f Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:09:24 +0000 Subject: [PATCH 04/30] add pacdef support (#4) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authored-by: arctic-penguin Approved-by: Thomas Schönauer --- src/config.rs | 1 + src/main.rs | 1 + src/steps/os/linux.rs | 11 +++++++++++ 3 files changed, 13 insertions(+) diff --git a/src/config.rs b/src/config.rs index 5b6d150f..d7c45696 100644 --- a/src/config.rs +++ b/src/config.rs @@ -109,6 +109,7 @@ pub enum Step { Nix, Node, Opam, + Pacdef, Pacstall, Pearl, Pipx, diff --git a/src/main.rs b/src/main.rs index a4231dc7..b1c29e28 100644 --- a/src/main.rs +++ b/src/main.rs @@ -365,6 +365,7 @@ fn run() -> Result<()> { 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::Pacstall, "pacstall", || linux::run_pacstall(&ctx))?; + runner.execute(Step::Pacdef, "pacdef", || linux::run_pacdef(&ctx))?; } if let Some(commands) = config.commands() { diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 16171038..2b19600e 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -348,6 +348,17 @@ fn upgrade_solus(ctx: &ExecutionContext) -> Result<()> { Ok(()) } +pub fn run_pacdef(ctx: &ExecutionContext) -> Result<()> { + let pacdef = require("pacdef")?; + + print_separator("pacdef"); + + ctx.run_type().execute(&pacdef).arg("sync").check_run()?; + + println!(); + ctx.run_type().execute(&pacdef).arg("review").check_run() +} + pub fn run_pacstall(ctx: &ExecutionContext) -> Result<()> { let pacstall = require("pacstall")?; From aebf3f159442009c27e2d34b2397b840ef001a7a Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:15:30 +0000 Subject: [PATCH 05/30] Fix typo (to -> or) (#8) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authored-by: Sohum Approved-by: Thomas Schönauer --- config.example.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.example.toml b/config.example.toml index 231a6e60..8ed8bdbe 100644 --- a/config.example.toml +++ b/config.example.toml @@ -87,7 +87,7 @@ # Causes Topgrade to rename itself during the run to allow package managers # to upgrade it. Use this only if you installed Topgrade by using a package -# manager such as Scoop to Cargo +# manager such as Scoop or Cargo #self_rename = true [npm] From 3f7614b8855c849843965bec92ae9b8719e8b0c1 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:16:13 +0000 Subject: [PATCH 06/30] feat: add support for bun (#7) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authored-by: Matthieu Vion Approved-by: Thomas Schönauer --- src/config.rs | 1 + src/main.rs | 1 + src/steps/bun.rs | 0 src/steps/os/unix.rs | 8 ++++++++ 4 files changed, 10 insertions(+) create mode 100644 src/steps/bun.rs diff --git a/src/config.rs b/src/config.rs index d7c45696..79fc9c33 100644 --- a/src/config.rs +++ b/src/config.rs @@ -71,6 +71,7 @@ pub enum Step { Atom, BrewCask, BrewFormula, + Bun, Bin, Cargo, Chezmoi, diff --git a/src/main.rs b/src/main.rs index b1c29e28..1757cdaa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -196,6 +196,7 @@ fn run() -> Result<()> { runner.execute(Step::HomeManager, "home-manager", || unix::run_home_manager(run_type))?; runner.execute(Step::Asdf, "asdf", || unix::run_asdf(run_type))?; runner.execute(Step::Pkgin, "pkgin", || unix::run_pkgin(&ctx))?; + runner.execute(Step::Bun, "bun", || unix::run_bun(&ctx))?; } #[cfg(target_os = "dragonfly")] diff --git a/src/steps/bun.rs b/src/steps/bun.rs new file mode 100644 index 00000000..e69de29b diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index a6c1468a..377d9ae8 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -409,6 +409,14 @@ pub fn run_sdkman(base_dirs: &BaseDirs, cleanup: bool, run_type: RunType) -> Res Ok(()) } +pub fn run_bun(ctx: &ExecutionContext) -> Result<()> { + let bun = require("bun")?; + + print_separator("Bun"); + + ctx.run_type().execute(&bun).arg("upgrade").check_run() +} + pub fn reboot() { print!("Rebooting..."); Command::new("sudo").arg("reboot").spawn().unwrap().wait().unwrap(); From 8472467d003f3efffafa9ac5d5851afdd2199b05 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:17:50 +0000 Subject: [PATCH 07/30] brew autoremove (#6) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authored-by: Kilian Tyler Approved-by: Thomas Schönauer --- config.example.toml | 1 + src/config.rs | 10 ++++++++++ src/steps/os/unix.rs | 4 ++++ 3 files changed, 15 insertions(+) diff --git a/config.example.toml b/config.example.toml index 8ed8bdbe..5cc7eaea 100644 --- a/config.example.toml +++ b/config.example.toml @@ -64,6 +64,7 @@ [brew] #greedy_cask = true +#autoremove = true [linux] # Arch Package Manager to use. Allowed values: autodetect, trizen, paru, yay, pikaur, pacman, pamac. diff --git a/src/config.rs b/src/config.rs index 79fc9c33..fcfdcdee 100644 --- a/src/config.rs +++ b/src/config.rs @@ -202,6 +202,7 @@ pub struct Flatpak { #[serde(deny_unknown_fields)] pub struct Brew { greedy_cask: Option, + autoremove: Option, } #[derive(Debug, Deserialize, Clone, Copy)] @@ -668,6 +669,15 @@ impl Config { .unwrap_or(false) } + /// Whether Brew should autoremove + pub fn brew_autoremove(&self) -> bool { + self.config_file + .brew + .as_ref() + .and_then(|c| c.autoremove) + .unwrap_or(false) + } + /// Whether Composer should update itself pub fn composer_self_update(&self) -> bool { self.config_file diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index 377d9ae8..540d2ad3 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -210,6 +210,10 @@ pub fn run_brew_formula(ctx: &ExecutionContext, variant: BrewVariant) -> Result< variant.execute(run_type).arg("cleanup").check_run()?; } + if ctx.config().brew_autoremove() { + variant.execute(run_type).arg("autoremove").check_run()?; + } + Ok(()) } From dc1c5d64907330ebcdecf19d43edd0c915e318b5 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:19:14 +0000 Subject: [PATCH 08/30] steps/linux/flatpak: Respect `-y` flag (#9) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit when deciding whether the `-y` argument should be added to an operation. Previously the `-y` was implicitly assumed for regular updates but was ignored for the cleanup steps. Now, it is added as defined in the topgrade runtime configuration. Authored-by: Andreas Hartmann Approved-by: Thomas Schönauer --- src/steps/os/linux.rs | 58 ++++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 2b19600e..aa820095 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -502,44 +502,50 @@ pub fn flatpak_update(ctx: &ExecutionContext) -> Result<()> { let flatpak = require("flatpak")?; let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?; let cleanup = ctx.config().cleanup(); + let yes = ctx.config().yes(Step::Flatpak); let run_type = ctx.run_type(); print_separator("Flatpak User Packages"); - run_type - .execute(&flatpak) - .args(&["update", "--user", "-y"]) - .check_run()?; + let mut update_args = vec!["update", "--user"]; + if yes { + update_args.push("-y"); + } + run_type.execute(&flatpak).args(&update_args).check_run()?; + if cleanup { - run_type - .execute(&flatpak) - .args(&["uninstall", "--user", "--unused"]) - .check_run()?; + let mut cleanup_args = vec!["uninstall", "--user", "--unused"]; + if yes { + cleanup_args.push("-y"); + } + run_type.execute(&flatpak).args(&cleanup_args).check_run()?; } print_separator("Flatpak System Packages"); if ctx.config().flatpak_use_sudo() || std::env::var("SSH_CLIENT").is_ok() { - run_type - .execute(&sudo) - .arg(&flatpak) - .args(&["update", "--system", "-y"]) - .check_run()?; + let mut update_args = vec!["update", "--system"]; + if yes { + update_args.push("-y"); + } + run_type.execute(&sudo).arg(&flatpak).args(&update_args).check_run()?; if cleanup { - run_type - .execute(sudo) - .arg(flatpak) - .args(&["uninstall", "--system", "--unused"]) - .check_run()?; + let mut cleanup_args = vec!["uninstall", "--system", "--unused"]; + if yes { + cleanup_args.push("-y"); + } + run_type.execute(sudo).arg(flatpak).args(&cleanup_args).check_run()?; } } else { - run_type - .execute(&flatpak) - .args(&["update", "--system", "-y"]) - .check_run()?; + let mut update_args = vec!["update", "--system"]; + if yes { + update_args.push("-y"); + } + run_type.execute(&flatpak).args(&update_args).check_run()?; if cleanup { - run_type - .execute(flatpak) - .args(&["uninstall", "--system", "--unused"]) - .check_run()?; + let mut cleanup_args = vec!["uninstall", "--system", "--unused"]; + if yes { + cleanup_args.push("-y"); + } + run_type.execute(flatpak).args(&cleanup_args).check_run()?; } } From 2d94eb974f0f536883642a9547d5e5a5e5a1311a Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:21:20 +0000 Subject: [PATCH 09/30] feat: flag and config to skip notifications by jlucktay (#5) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: flag and config to skip notifications At the end of a run, topgrade normally sends a system notification. This change adds a command-line flag and a config-file option to disable this behaviour. * fix: clippy issues Also derive Eq where PartialEq is being derived. https://rust-lang.github.io/rust-clippy/master/index.html#derive_partial_eq_without_eq Authored-by: James Lucktaylor Approved-by: Thomas Schönauer --- Cargo.lock | 2 +- Cargo.toml | 2 +- config.example.toml | 3 +++ src/config.rs | 14 ++++++++++++++ src/main.rs | 18 +++++++++++------- 5 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index d91d01ae..dcde0ca0 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1834,7 +1834,7 @@ dependencies = [ [[package]] name = "topgrade" -version = "9.0.1" +version = "9.1.0" dependencies = [ "anyhow", "cfg-if", diff --git a/Cargo.toml b/Cargo.toml index 1c63663a..2a00c1ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -5,7 +5,7 @@ categories = ["os"] keywords = ["upgrade", "update"] license-file = "LICENSE" repository = "https://github.com/r-darwish/topgrade" -version = "9.0.1" +version = "9.1.0" authors = ["Roey Darwish Dror "] exclude = ["doc/screenshot.gif"] edition = "2018" diff --git a/config.example.toml b/config.example.toml index 5cc7eaea..df506e86 100644 --- a/config.example.toml +++ b/config.example.toml @@ -37,6 +37,9 @@ # Cleanup temporary or old files #cleanup = true +# Skip sending a notification at the end of a run +#skip_notify = true + [git] #max_concurrency = 5 # Additional git repositories to pull diff --git a/src/config.rs b/src/config.rs index fcfdcdee..001c242a 100644 --- a/src/config.rs +++ b/src/config.rs @@ -272,6 +272,7 @@ pub struct ConfigFile { cleanup: Option, notify_each_step: Option, accept_all_windows_updates: Option, + skip_notify: Option, bashit_branch: Option, only: Option>, composer: Option, @@ -428,6 +429,10 @@ pub struct CommandLineArgs { #[clap(short = 'k', long = "keep")] keep_at_end: bool, + /// Skip sending a notification at the end of a run + #[clap(long = "skip-notify")] + skip_notify: bool, + /// Say yes to package manager's prompt #[clap(short = 'y', long = "yes", arg_enum, multiple_values = true, min_values = 0)] yes: Option>, @@ -613,6 +618,15 @@ impl Config { self.opt.keep_at_end || env::var("TOPGRADE_KEEP_END").is_ok() } + /// Skip sending a notification at the end of a run + pub fn skip_notify(&self) -> bool { + if let Some(yes) = self.config_file.skip_notify { + return yes; + } + + self.opt.skip_notify + } + /// Whether to set the terminal title pub fn set_title(&self) -> bool { self.config_file.set_title.unwrap_or(true) diff --git a/src/main.rs b/src/main.rs index 1757cdaa..ea591742 100644 --- a/src/main.rs +++ b/src/main.rs @@ -466,13 +466,17 @@ fn run() -> Result<()> { } let failed = post_command_failed || runner.report().data().iter().any(|(_, result)| result.failed()); - terminal::notify_desktop( - format!( - "Topgrade finished {}", - if failed { "with errors" } else { "successfully" } - ), - None, - ); + + if !config.skip_notify() { + terminal::notify_desktop( + format!( + "Topgrade finished {}", + if failed { "with errors" } else { "successfully" } + ), + None, + ); + } + if failed { Err(StepFailed.into()) } else { From ae544cdaae94f12b2804e1a5b2007a1073f108b5 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:22:06 +0000 Subject: [PATCH 10/30] fix: skip nix on darwin only when nix-darwin is installed (#14) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authored-by: XYenon Approved-by: Thomas Schönauer --- src/steps/os/unix.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index 540d2ad3..5ee4687c 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -296,6 +296,16 @@ pub fn run_nix(ctx: &ExecutionContext) -> Result<()> { } } + #[cfg(target_os = "macos")] + { + if let Ok(..) = require("darwin-rebuild") { + return Err(SkipStep(String::from( + "Nix-darwin on macOS must be upgraded via darwin-rebuild switch", + )) + .into()); + } + } + let run_type = ctx.run_type(); if should_self_upgrade { From 27349b1571b0765ac428c8e428afec636c531553 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:23:51 +0000 Subject: [PATCH 11/30] fix-pnpm (#3) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authored-by: Ved Kothavade Approved-by: Thomas Schönauer --- src/steps/node.rs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/steps/node.rs b/src/steps/node.rs index c27b4b45..91837673 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -20,15 +20,11 @@ use crate::{error::SkipStep, execution_context::ExecutionContext}; #[allow(clippy::upper_case_acronyms)] struct NPM { command: PathBuf, - pnpm: Option, } impl NPM { fn new(command: PathBuf) -> Self { - Self { - command, - pnpm: require("pnpm").ok(), - } + Self { command } } #[cfg(target_os = "linux")] @@ -56,17 +52,13 @@ impl NPM { fn upgrade(&self, run_type: RunType, use_sudo: bool) -> Result<()> { print_separator("Node Package Manager"); let version = self.version()?; - let args = if version < Version::new(8, 11, 0) || self.pnpm.is_some() { + let args = if version < Version::new(8, 11, 0) { ["update", "-g"] } else { ["update", "--location=global"] }; if use_sudo { - run_type - .execute("sudo") - .arg(self.pnpm.as_ref().unwrap_or(&self.command)) - .args(args) - .check_run()?; + run_type.execute("sudo").args(args).check_run()?; } else { run_type.execute(&self.command).args(args).check_run()?; } @@ -170,7 +162,7 @@ fn should_use_sudo_yarn(yarn: &Yarn, ctx: &ExecutionContext) -> Result { } pub fn run_npm_upgrade(ctx: &ExecutionContext) -> Result<()> { - let npm = require("npm").map(NPM::new)?; + let npm = require("pnpm").or_else(|_| require("npm")).map(NPM::new)?; #[cfg(target_os = "linux")] { From a9d5d24a358e4f82cdb38d7a30ad659870791f85 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:24:41 +0000 Subject: [PATCH 12/30] Clean up OPAM if requested (#12) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit OPAM has a built-in `clean` command that automatically removes download caches, logs, and cleans the current OPAM switch. We should call `opam clean` when the cleanup flag is set. Authored-by: Victor Song Approved-by: Thomas Schönauer --- src/main.rs | 2 +- src/steps/generic.rs | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index ea591742..5d8ac775 100644 --- a/src/main.rs +++ b/src/main.rs @@ -318,7 +318,7 @@ fn run() -> Result<()> { runner.execute(Step::Flutter, "Flutter", || generic::run_flutter_upgrade(run_type))?; runner.execute(Step::Go, "Go", || generic::run_go(run_type))?; runner.execute(Step::Emacs, "Emacs", || emacs.upgrade(&ctx))?; - runner.execute(Step::Opam, "opam", || generic::run_opam_update(run_type))?; + runner.execute(Step::Opam, "opam", || generic::run_opam_update(&ctx))?; runner.execute(Step::Vcpkg, "vcpkg", || generic::run_vcpkg_update(run_type))?; runner.execute(Step::Pipx, "pipx", || generic::run_pipx_update(run_type))?; runner.execute(Step::Conda, "conda", || generic::run_conda_update(&ctx))?; diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 485bd7d5..9f7dae43 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -220,13 +220,19 @@ pub fn run_rtcl(ctx: &ExecutionContext) -> Result<()> { ctx.run_type().execute(&rupdate).check_run() } -pub fn run_opam_update(run_type: RunType) -> Result<()> { +pub fn run_opam_update(ctx: &ExecutionContext) -> Result<()> { let opam = utils::require("opam")?; print_separator("OCaml Package Manager"); - run_type.execute(&opam).arg("update").check_run()?; - run_type.execute(&opam).arg("upgrade").check_run() + ctx.run_type().execute(&opam).arg("update").check_run()?; + ctx.run_type().execute(&opam).arg("upgrade").check_run()?; + + if ctx.config().cleanup() { + ctx.run_type().execute(&opam).arg("clean").check_run()?; + } + + Ok(()) } pub fn run_vcpkg_update(run_type: RunType) -> Result<()> { From f063afe536ae54ed2cc209938d3d2a5642bf4085 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:26:20 +0000 Subject: [PATCH 13/30] Fix doom emacs upgrading (fix #961) (#13) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Authored-by: Rotem Yaari Approved-by: Thomas Schönauer --- src/steps/emacs.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/steps/emacs.rs b/src/steps/emacs.rs index 862ff16d..75ab817b 100644 --- a/src/steps/emacs.rs +++ b/src/steps/emacs.rs @@ -67,25 +67,24 @@ impl Emacs { print_separator("Doom Emacs"); let mut command = ctx.run_type().execute(doom); - command.args(&["-y", "upgrade"]); - if ctx.config().yes(Step::Emacs) { command.arg("--force"); } + command.args(&["upgrade"]); + command.check_run() } pub fn upgrade(&self, ctx: &ExecutionContext) -> Result<()> { let emacs = require("emacs")?; + if let Some(doom) = &self.doom { + Emacs::update_doom(doom, ctx)?; + } let init_file = require_option(self.directory.as_ref(), String::from("Emacs directory does not exist"))? .join("init.el") .require()?; - if let Some(doom) = &self.doom { - return Emacs::update_doom(doom, ctx); - } - print_separator("Emacs"); let mut command = ctx.run_type().execute(&emacs); From 77db29f299173d735e0cabe352bf3ae2a21d2c0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= Date: Mon, 10 Oct 2022 22:41:39 +0200 Subject: [PATCH 14/30] Cleanup --- src/config.rs | 1 - src/steps/node.rs | 4 +--- src/steps/os/unix.rs | 2 +- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/config.rs b/src/config.rs index 001c242a..09aab522 100644 --- a/src/config.rs +++ b/src/config.rs @@ -883,7 +883,6 @@ impl Config { .and_then(|yarn| yarn.use_sudo) .unwrap_or(false) } - #[cfg(target_os = "linux")] pub fn firmware_upgrade(&self) -> bool { diff --git a/src/steps/node.rs b/src/steps/node.rs index 91837673..6d22d07e 100644 --- a/src/steps/node.rs +++ b/src/steps/node.rs @@ -105,7 +105,7 @@ impl Yarn { fn upgrade(&self, run_type: RunType, use_sudo: bool) -> Result<()> { print_separator("Yarn Package Manager"); let args = ["global", "upgrade"]; - + if use_sudo { run_type .execute("sudo") @@ -189,8 +189,6 @@ pub fn run_yarn_upgrade(ctx: &ExecutionContext) -> Result<()> { } } - - pub fn deno_upgrade(ctx: &ExecutionContext) -> Result<()> { let deno = require("deno")?; let deno_dir = ctx.base_dirs().home_dir().join(".deno"); diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index 5ee4687c..cdbc9ad3 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -270,7 +270,7 @@ pub fn run_guix(ctx: &ExecutionContext) -> Result<()> { if should_upgrade { return run_type.execute(&guix).args(&["package", "-u"]).check_run(); } - Err(SkipStep(String::from("Guix Pull Failed, Skipping")).into()) + Err(SkipStep(String::from("Guix Pull Failed, Skipping")).into()) } pub fn run_nix(ctx: &ExecutionContext) -> Result<()> { From 646b56dc9d29f1286db665fecb40fb111041cf46 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Mon, 10 Oct 2022 20:59:07 +0000 Subject: [PATCH 15/30] Add rust ubuntu runner (#16) * Update issue templates * Create rust-ubuntu.yml Added plain Github Action Runner for ubuntu --- .github/ISSUE_TEMPLATE/bug_report.md | 5 ++++- .github/ISSUE_TEMPLATE/feature_request.md | 5 ++++- .github/workflows/rust-ubuntu.yml | 24 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/rust-ubuntu.yml diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index da49501a..1ea4de5a 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,7 +1,10 @@ --- name: Bug report about: Topgrade is misbehaving -labels: is:bug +title: '' +labels: '' +assignees: '' + --- diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 6bbd46d6..94f39e57 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,7 +1,10 @@ --- name: Feature request about: Can you please support...? -labels: is:new +title: '' +labels: '' +assignees: '' + --- ## I want to suggest a new step diff --git a/.github/workflows/rust-ubuntu.yml b/.github/workflows/rust-ubuntu.yml new file mode 100644 index 00000000..18bcd0ae --- /dev/null +++ b/.github/workflows/rust-ubuntu.yml @@ -0,0 +1,24 @@ +name: Rust + +on: + push: + branches: [ "master", "dev" ] + pull_request: + branches: [ "master", "dev" ] + +env: + CARGO_TERM_COLOR: always + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build + run: cargo build --verbose + - name: Fmt + run: cargo fmt --check --all + - name: Run tests + run: cargo test --verbose From ce5211e0b4e8f7c2406b69e4733234419115bba8 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:10:52 +0000 Subject: [PATCH 16/30] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index f339f966..cf90eaa5 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ ![Demo](doc/screenshot.gif) +##Fork +This is a fork of [topgrade by r-darwish](https://github.com/r-darwish/topgrade) to keep it maintained. + + 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, _topgrade_ detects which tools you use and runs the appropriate commands to update them. From de6590440fbe23aed0006433d7a832c3591614d6 Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Tue, 11 Oct 2022 16:11:12 +0000 Subject: [PATCH 17/30] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf90eaa5..d88299e6 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ ![Demo](doc/screenshot.gif) -##Fork +## Fork This is a fork of [topgrade by r-darwish](https://github.com/r-darwish/topgrade) to keep it maintained. From f50c26cc97f8beef06d4c3573de396fe0631807a Mon Sep 17 00:00:00 2001 From: DottoDev <37108907+DottoDev@users.noreply.github.com> Date: Tue, 11 Oct 2022 18:01:09 +0000 Subject: [PATCH 18/30] Create build-and-test.yml --- .github/workflows/build-and-test.yml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 .github/workflows/build-and-test.yml diff --git a/.github/workflows/build-and-test.yml b/.github/workflows/build-and-test.yml new file mode 100644 index 00000000..f520b42e --- /dev/null +++ b/.github/workflows/build-and-test.yml @@ -0,0 +1,24 @@ +name: Cargo Build & Test + +on: + push: + pull_request: + +env: + CARGO_TERM_COLOR: always + +jobs: + build_and_test: + name: Rust project - latest + runs-on: ubuntu-latest + strategy: + matrix: + toolchain: + - stable + - beta + - nightly + steps: + - uses: actions/checkout@v3 + - run: rustup update ${{ matrix.toolchain }} && rustup default ${{ matrix.toolchain }} + - run: cargo build --verbose + - run: cargo test --verbose From d7dfc90bce0c2d87effad111ac96a136e3d6b9d8 Mon Sep 17 00:00:00 2001 From: Kyle Date: Fri, 14 Oct 2022 15:12:02 +1100 Subject: [PATCH 19/30] Add support for Nobara Linux --- src/steps/os/linux.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index bca05509..ecf9ab18 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -44,7 +44,7 @@ impl Distribution { Some("alpine") => Distribution::Alpine, Some("centos") | Some("rhel") | Some("ol") => Distribution::CentOS, Some("clear-linux-os") => Distribution::ClearLinux, - Some("fedora") => Distribution::Fedora, + Some("fedora") | Some("nobara") => Distribution::Fedora, Some("void") => Distribution::Void, Some("debian") | Some("pureos") => Distribution::Debian, Some("arch") | Some("anarchy") | Some("manjaro-arm") | Some("garuda") | Some("artix") => Distribution::Arch, From 366a742d408ac9ad03855e215a121b88291e8b96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= Date: Fri, 14 Oct 2022 16:46:21 +0200 Subject: [PATCH 20/30] Added Protonup support --- src/config.rs | 1 + src/main.rs | 1 + src/steps/os/linux.rs | 4 ++++ 3 files changed, 6 insertions(+) diff --git a/src/config.rs b/src/config.rs index 09aab522..1428be5b 100644 --- a/src/config.rs +++ b/src/config.rs @@ -118,6 +118,7 @@ pub enum Step { Pkg, Pkgin, Powershell, + Protonup, Raco, Remotes, Restarts, diff --git a/src/main.rs b/src/main.rs index 5d8ac775..cdcfe9e2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -367,6 +367,7 @@ fn run() -> Result<()> { runner.execute(Step::Snap, "snap", || linux::run_snap(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))?; } if let Some(commands) = config.commands() { diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index aa820095..6854a0b9 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -574,6 +574,10 @@ pub fn run_pihole_update(sudo: Option<&PathBuf>, run_type: RunType) -> Result<() run_type.execute(sudo).arg(pihole).arg("-up").check_run() } +pub fn run_protonup_update(ctx: &ExecutionContext) -> Result<()> { + todo!(); +} + pub fn run_config_update(ctx: &ExecutionContext) -> Result<()> { let sudo = require_option(ctx.sudo().as_ref(), String::from("sudo is not installed"))?; if ctx.config().yes(Step::ConfigUpdate) { From b2c9c746a548ac5547ed79828325dfc22b6c4f7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= Date: Fri, 14 Oct 2022 16:56:03 +0200 Subject: [PATCH 21/30] Added Protonup update code --- src/steps/os/linux.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 6854a0b9..96d3e7c2 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -575,7 +575,12 @@ pub fn run_pihole_update(sudo: Option<&PathBuf>, run_type: RunType) -> Result<() } pub fn run_protonup_update(ctx: &ExecutionContext) -> Result<()> { - todo!(); + let protonup = require("protonup")?; + + print_separator("protonup"); + + ctx.run_type().execute(protonup).check_run()?; + Ok(()) } pub fn run_config_update(ctx: &ExecutionContext) -> Result<()> { From d8deb3d9bee77683c425567e48f246fa39606859 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Sun, 16 Oct 2022 16:22:21 +0000 Subject: [PATCH 22/30] Delete main.yml --- .github/workflows/main.yml | 42 -------------------------------------- 1 file changed, 42 deletions(-) delete mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index cfec6d82..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: CI - -on: - pull_request: - push: - branches: - - master - -jobs: - build: - strategy: - matrix: - platform: [ubuntu-latest, macos-latest, windows-latest] - fail-fast: false - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.57.0 - profile: minimal - override: true - components: rustfmt, clippy - - uses: actions-rs/cargo@v1.0.1 - name: Check format - with: - command: fmt - args: --all -- --check - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy - with: - command: clippy - args: --all-targets --locked -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy (All features) - with: - command: clippy - args: --all-targets --locked --all-features -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run tests - with: - command: test From 0f85107c1962724f5a1bf9f66d498cf39735858f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Sun, 16 Oct 2022 16:22:44 +0000 Subject: [PATCH 23/30] Delete release.yml --- .github/workflows/release.yml | 73 ----------------------------------- 1 file changed, 73 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index ed30643f..00000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: CD Native - -on: - release: - types: [ created ] - -jobs: - build: - strategy: - fail-fast: false - matrix: - platform: [ ubuntu-latest, macos-latest, windows-latest ] - runs-on: ${{ matrix.platform }} - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.57.0 - profile: minimal - override: true - components: rustfmt, clippy - - uses: actions-rs/cargo@v1.0.1 - name: Check format - with: - command: fmt - args: --all -- --check - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy - with: - command: clippy - args: --all-targets --locked -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy (All features) - with: - command: clippy - args: --all-targets --locked --all-features -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run tests - with: - command: test - - uses: actions-rs/cargo@v1.0.1 - name: Build - with: - command: build - args: --release --all-features - - name: Rename Release (Unix) - run: | - cargo install default-target - mkdir assets - FILENAME=topgrade-${{github.event.release.tag_name}}-$(default-target) - mv target/release/topgrade assets - cd assets - tar --format=ustar -czf $FILENAME.tar.gz topgrade - rm topgrade - ls . - if: ${{ matrix.platform != 'windows-latest' }} - shell: bash - - name: Rename Release (Windows) - run: | - cargo install default-target - mkdir assets - FILENAME=topgrade-${{github.event.release.tag_name}}-$(default-target) - mv target/release/topgrade.exe assets/topgrade.exe - cd assets - powershell Compress-Archive -Path * -Destination ${FILENAME}.zip - rm topgrade.exe - ls . - if: ${{ matrix.platform == 'windows-latest' }} - shell: bash - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: assets/* From dc5500e094f4807ca5ad6fea2532cff801c42719 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= <37108907+DottoDev@users.noreply.github.com> Date: Sun, 16 Oct 2022 16:22:54 +0000 Subject: [PATCH 24/30] Delete release-cross.yml --- .github/workflows/release-cross.yml | 66 ----------------------------- 1 file changed, 66 deletions(-) delete mode 100644 .github/workflows/release-cross.yml diff --git a/.github/workflows/release-cross.yml b/.github/workflows/release-cross.yml deleted file mode 100644 index 7d3d4ef0..00000000 --- a/.github/workflows/release-cross.yml +++ /dev/null @@ -1,66 +0,0 @@ -name: CD Cross - -on: - release: - types: [ created ] - -jobs: - build: - strategy: - fail-fast: false - matrix: - target: [ "aarch64-unknown-linux-gnu", "armv7-unknown-linux-gnueabihf", "x86_64-unknown-linux-musl" ] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.57.0 - profile: minimal - default: true - override: true - target: ${{ matrix.target }} - components: rustfmt, clippy - - uses: actions-rs/cargo@v1.0.1 - name: Check format - with: - use-cross: true - command: fmt - args: --all -- --check - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy - with: - command: clippy - use-cross: true - args: --all-targets --locked --target ${{matrix.target}} -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run clippy (All features) - with: - command: clippy - use-cross: true - args: --locked --all-features --target ${{matrix.target}} -- -D warnings - - uses: actions-rs/cargo@v1.0.1 - name: Run tests - with: - command: test - use-cross: true - args: --target ${{matrix.target}} - - uses: actions-rs/cargo@v1.0.1 - name: Build - with: - command: build - use-cross: true - args: --release --all-features --target ${{matrix.target}} - - name: Rename Release - run: | - mkdir assets - FILENAME=topgrade-${{github.event.release.tag_name}}-${{matrix.target}} - mv target/${{matrix.target}}/release/topgrade assets - cd assets - tar --format=ustar -czf $FILENAME.tar.gz topgrade - rm topgrade - ls . - - name: Release - uses: softprops/action-gh-release@v1 - with: - files: assets/* From 5d1f3ee8754945ae7f96e828feef5d29a9a500be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= Date: Sun, 16 Oct 2022 19:21:53 +0200 Subject: [PATCH 25/30] Added github workflows --- .github/workflows/check-and-lint.yaml | 55 +++++++++++++++++++++++ .github/workflows/release-packaging.yaml | 27 ++++++++++++ .github/workflows/test.yaml | 56 ++++++++++++++++++++++++ 3 files changed, 138 insertions(+) create mode 100644 .github/workflows/check-and-lint.yaml create mode 100644 .github/workflows/release-packaging.yaml create mode 100644 .github/workflows/test.yaml diff --git a/.github/workflows/check-and-lint.yaml b/.github/workflows/check-and-lint.yaml new file mode 100644 index 00000000..6eb45d48 --- /dev/null +++ b/.github/workflows/check-and-lint.yaml @@ -0,0 +1,55 @@ +on: + pull_request: + push: + branches: + - main + + +name: Check and Lint + +jobs: + check: + name: Check + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - uses: actions-rs/cargo@v1 + with: + command: check + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - run: rustup component add rustfmt + - uses: actions-rs/cargo@v1 + with: + command: fmt + args: --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + toolchain: stable + components: clippy + override: true + - uses: actions-rs/clippy-check@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + args: --all-features + name: Clippy Output diff --git a/.github/workflows/release-packaging.yaml b/.github/workflows/release-packaging.yaml new file mode 100644 index 00000000..be382457 --- /dev/null +++ b/.github/workflows/release-packaging.yaml @@ -0,0 +1,27 @@ +on: + push: + branches: + - main + +name: Release Packaging + +jobs: + release: + name: Release Packaging + env: + PROJECT_NAME_UNDERSCORE: rust_ci_github_actions_workflow + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + - name: Release Build + run: cargo build --release + - name: 'Upload Artifact' + uses: actions/upload-artifact@v2 + with: + name: ${{ env.PROJECT_NAME_UNDERSCORE }} + path: target/release/${{ env.PROJECT_NAME_UNDERSCORE }} diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml new file mode 100644 index 00000000..ee09868e --- /dev/null +++ b/.github/workflows/test.yaml @@ -0,0 +1,56 @@ +on: + pull_request: + push: + branches: + - main + +name: Test with Code Coverage + +jobs: + test: + name: Test + env: + PROJECT_NAME_UNDERSCORE: rust_ci_github_actions_workflow + CARGO_INCREMENTAL: 0 + RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort + RUSTDOCFLAGS: -Cpanic=abort + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: nightly + override: true + - name: Cache dependencies + uses: actions/cache@v2 + env: + cache-name: cache-dependencies + with: + path: | + ~/.cargo/.crates.toml + ~/.cargo/.crates2.json + ~/.cargo/bin + ~/.cargo/registry/index + ~/.cargo/registry/cache + target + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('Cargo.lock') }} + - name: Generate test result and coverage report + run: | + cargo install cargo2junit grcov; + cargo test $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml; + zip -0 ccov.zip `find . \( -name "$PROJECT_NAME_UNDERSCORE*.gc*" \) -print`; + grcov ccov.zip -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" -o lcov.info; + - name: Upload test results + uses: EnricoMi/publish-unit-test-result-action@v1 + with: + check_name: Test Results + github_token: ${{ secrets.GITHUB_TOKEN }} + files: results.xml + - name: Upload to CodeCov + uses: codecov/codecov-action@v1 + with: + # required for private repositories: + # token: ${{ secrets.CODECOV_TOKEN }} + files: ./lcov.info + fail_ci_if_error: true From 16566ea69712d3b4c7cbf8b26ff186e4a7bd5818 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= Date: Sun, 16 Oct 2022 19:25:46 +0200 Subject: [PATCH 26/30] Changed workflow values --- .github/workflows/release-packaging.yaml | 2 +- .github/workflows/test.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release-packaging.yaml b/.github/workflows/release-packaging.yaml index be382457..5db6e1ba 100644 --- a/.github/workflows/release-packaging.yaml +++ b/.github/workflows/release-packaging.yaml @@ -9,7 +9,7 @@ jobs: release: name: Release Packaging env: - PROJECT_NAME_UNDERSCORE: rust_ci_github_actions_workflow + PROJECT_NAME_UNDERSCORE: topgrade_rs runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index ee09868e..98bfa98a 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -10,7 +10,7 @@ jobs: test: name: Test env: - PROJECT_NAME_UNDERSCORE: rust_ci_github_actions_workflow + PROJECT_NAME_UNDERSCORE: topgrade_rs CARGO_INCREMENTAL: 0 RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort RUSTDOCFLAGS: -Cpanic=abort From ec6da2f18ca3c9eb5bb8d2d558c91ca8e758709b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= Date: Sun, 16 Oct 2022 19:55:08 +0200 Subject: [PATCH 27/30] added Documentation reference in Readme --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index f339f966..7337d677 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,10 @@ ![Topgrade](doc/topgrade.png) - -[![Travis](https://api.travis-ci.org/r-darwish/topgrade.svg?branch=master)](https://travis-ci.org/r-darwish/topgrade) -[![AppVeyor](https://ci.appveyor.com/api/projects/status/github/r-darwish/topgrade?svg=true)](https://ci.appveyor.com/project/r-darwish/topgrade) + +---> ![Demo](doc/screenshot.gif) @@ -23,6 +22,9 @@ The compiled binaries contain a self-upgrading feature. Topgrade requires Rust 1.51 or above. +## Documentation[WIP] +You can visit the documentation at [topgrade-rs.github.io](https://topgrade-rs.github.io/) . + ## Usage Just run `topgrade`. See [the wiki](https://github.com/r-darwish/topgrade/wiki/Step-list) for the list of things Topgrade supports. From 37dfad109c6335a929a3cd90ffae43cb5136951e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= Date: Mon, 17 Oct 2022 18:48:59 +0200 Subject: [PATCH 28/30] Added openMandriva support --- src/steps/os/linux.rs | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/steps/os/linux.rs b/src/steps/os/linux.rs index 19b17f68..96a35452 100644 --- a/src/steps/os/linux.rs +++ b/src/steps/os/linux.rs @@ -26,6 +26,7 @@ pub enum Distribution { Fedora, Debian, Gentoo, + OpenMandriva, Suse, Void, Solus, @@ -53,6 +54,7 @@ impl Distribution { Some("exherbo") => Distribution::Exherbo, Some("nixos") => Distribution::NixOS, Some("neon") => Distribution::KDENeon, + Some("openmandriva") => Distribution::OpenMandriva, _ => { if let Some(id_like) = id_like { if id_like.contains(&"debian") || id_like.contains(&"ubuntu") { @@ -105,6 +107,7 @@ impl Distribution { Distribution::NixOS => upgrade_nixos(ctx), Distribution::KDENeon => upgrade_neon(ctx), Distribution::Bedrock => update_bedrock(ctx), + Distribution::OpenMandriva => upgrade_openmandriva(ctx), } } @@ -218,6 +221,28 @@ fn upgrade_suse(ctx: &ExecutionContext) -> Result<()> { Ok(()) } +fn upgrade_openmandriva(ctx: &ExecutionContext) -> Result<()> { + if let Some(sudo) = &ctx.sudo() { + let mut command = ctx.run_type().execute(&sudo); + + command.arg(which("dnf").unwrap().to_path_buf()).arg("upgrade"); + + if let Some(args) = ctx.config().dnf_arguments() { + command.args(args.split_whitespace()); + } + + if ctx.config().yes(Step::System) { + command.arg("-y"); + } + + command.check_run()?; + } else { + print_warning("No sudo detected. Skipping system upgrade"); + } + + Ok(()) +} + fn upgrade_void(ctx: &ExecutionContext) -> Result<()> { if let Some(sudo) = ctx.sudo() { let mut command = ctx.run_type().execute(&sudo); From 741fd4f0e465544039574377d40bcaeb46dd6df2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= Date: Mon, 17 Oct 2022 22:25:28 +0200 Subject: [PATCH 29/30] Changed package details --- Cargo.toml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2a00c1ed..91e9893a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "topgrade" -description = "Upgrade all the things" +name = "topgrade-rs" +description = "Upgrade all the things, successor of topgrade" categories = ["os"] keywords = ["upgrade", "update"] license-file = "LICENSE" -repository = "https://github.com/r-darwish/topgrade" +repository = "https://github.com/topgrade-rs/topgrade" version = "9.1.0" -authors = ["Roey Darwish Dror "] +authors = ["Roey Darwish Dror ", "Thomas Schönauer "] exclude = ["doc/screenshot.gif"] edition = "2018" readme = "README.md" From 1667b3a8410d560fee7406812be91b42ef0424bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Sch=C3=B6nauer?= Date: Mon, 17 Oct 2022 22:26:45 +0200 Subject: [PATCH 30/30] Changed packages to automatically use latest bugfix --- Cargo.toml | 54 +++++++++++++++++++++++++++--------------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 91e9893a..80904eb4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,42 +12,42 @@ edition = "2018" readme = "README.md" [dependencies] -directories = "4.0.1" -serde = { version = "1.0.125", features = ["derive"] } -toml = "0.5.8" -which_crate = { version = "4.1.0", package = "which" } -shellexpand = "2.1.0" +directories = "4.0" +serde = { version = "1.0", features = ["derive"] } +toml = "0.5" +which_crate = { version = "4.1", package = "which" } +shellexpand = "2.1" clap = { version = "3.1", features = ["cargo", "derive"] } -log = "0.4.14" -walkdir = "2.3.2" -console = "0.15.0" -lazy_static = "1.4.0" -chrono = "0.4.19" -pretty_env_logger = "0.4.0" -glob = "0.3.0" -strum = { version = "0.24.0", features = ["derive"] } -thiserror = "1.0.24" -anyhow = "1.0.40" -tempfile = "3.2.0" -cfg-if = "1.0.0" -tokio = { version = "1.5.0", features = ["process", "rt-multi-thread"] } -futures = "0.3.14" -regex = "1.5.3" +log = "0.4" +walkdir = "2.3" +console = "0.15" +lazy_static = "1.4" +chrono = "0.4" +pretty_env_logger = "0.4" +glob = "0.3" +strum = { version = "0.24", features = ["derive"] } +thiserror = "1.0" +anyhow = "1.0" +tempfile = "3.2" +cfg-if = "1.0" +tokio = { version = "1.5", features = ["process", "rt-multi-thread"] } +futures = "0.3" +regex = "1.5" sys-info = "0.9" semver = "1.0" [target.'cfg(target_os = "macos")'.dependencies] -notify-rust = "4.5.0" +notify-rust = "4.5" [target.'cfg(unix)'.dependencies] -nix = "0.24.1" -rust-ini = "0.18.0" -self_update_crate = { version = "0.30.0", default-features = false, optional = true, package = "self_update", features = ["archive-tar", "compression-flate2", "rustls"] } +nix = "0.24" +rust-ini = "0.18" +self_update_crate = { version = "0.30", default-features = false, optional = true, package = "self_update", features = ["archive-tar", "compression-flate2", "rustls"] } [target.'cfg(windows)'.dependencies] -self_update_crate = { version = "0.30.0", default-features = false, optional = true, package = "self_update", features = ["archive-zip", "compression-zip-deflate", "rustls"] } -winapi = "0.3.9" -parselnk = "0.1.0" +self_update_crate = { version = "0.30", default-features = false, optional = true, package = "self_update", features = ["archive-zip", "compression-zip-deflate", "rustls"] } +winapi = "0.3" +parselnk = "0.1" [profile.release] lto = true