From 82e05bb88b2350e500dcccd1ea0b10c4c7c3d8bd Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Sat, 16 Dec 2023 18:03:25 +0800 Subject: [PATCH 1/3] refactor: use sudo softwareupdate --install --all --restart to update macOS --- src/steps/os/macos.rs | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/steps/os/macos.rs b/src/steps/os/macos.rs index b835d5b8c..c7f50af2b 100644 --- a/src/steps/os/macos.rs +++ b/src/steps/os/macos.rs @@ -56,8 +56,14 @@ pub fn upgrade_macos(ctx: &ExecutionContext) -> Result<()> { } } - let mut command = ctx.run_type().execute("softwareupdate"); - command.args(["--install", "--all"]); + // We don't know what the proper command to use here cause the macOS man + // page is poor. + // + // man: https://keith.github.io/xcode-man-pages/softwareupdate.8.html + // issue: https://github.com/topgrade-rs/topgrade/issues/546 + let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO)?; + let mut command = ctx.run_type().execute(sudo); + command.args(["softwareupdate", "--install", "--all", "--restart"]); if should_ask { command.arg("--no-scan"); @@ -92,4 +98,4 @@ pub fn run_sparkle(ctx: &ExecutionContext) -> Result<()> { } } Ok(()) -} +} \ No newline at end of file From 7ad377b00a560dbdce769f9aba99ac91c966d75f Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Sat, 16 Dec 2023 18:06:46 +0800 Subject: [PATCH 2/3] fmt --- src/steps/os/macos.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/steps/os/macos.rs b/src/steps/os/macos.rs index c7f50af2b..6fe8cbfeb 100644 --- a/src/steps/os/macos.rs +++ b/src/steps/os/macos.rs @@ -98,4 +98,4 @@ pub fn run_sparkle(ctx: &ExecutionContext) -> Result<()> { } } Ok(()) -} \ No newline at end of file +} From fa4b0ffb861152f4f835128a2ad60afa4f2af394 Mon Sep 17 00:00:00 2001 From: Steve Lau Date: Sat, 16 Dec 2023 19:07:35 +0800 Subject: [PATCH 3/3] fix macOS build --- src/steps/os/macos.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/steps/os/macos.rs b/src/steps/os/macos.rs index 6fe8cbfeb..9df58993e 100644 --- a/src/steps/os/macos.rs +++ b/src/steps/os/macos.rs @@ -61,7 +61,7 @@ pub fn upgrade_macos(ctx: &ExecutionContext) -> Result<()> { // // man: https://keith.github.io/xcode-man-pages/softwareupdate.8.html // issue: https://github.com/topgrade-rs/topgrade/issues/546 - let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO)?; + let sudo = require_option(ctx.sudo().as_ref(), REQUIRE_SUDO.to_string())?; let mut command = ctx.run_type().execute(sudo); command.args(["softwareupdate", "--install", "--all", "--restart"]);