Add mas support for macOS (fix #307)

This commit is contained in:
Roey Darwish Dror
2020-01-28 16:22:17 +02:00
parent d2f038f6a6
commit b5e5cb0b32
3 changed files with 14 additions and 4 deletions

View File

@@ -130,13 +130,13 @@ Just run `topgrade`. It will run the following steps:
* **Linux**: Update snap packages * **Linux**: Update snap packages
* **Linux**: Run [fwupdmgr](https://github.com/hughsie/fwupd) to show firmware upgrade. (View * **Linux**: Run [fwupdmgr](https://github.com/hughsie/fwupd) to show firmware upgrade. (View
only. No upgrades will actually be performed) only. No upgrades will actually be performed)
* **Linux**: Run `rpi-update` to update Raspberry Pi Firmware
* **Linux**: Run [pihole](https://pi-hole.net/) updater * **Linux**: Run [pihole](https://pi-hole.net/) updater
* Run custom defined commands * Run custom defined commands
* Final stage * Final stage
* **Linux**: Run [needrestart](https://github.com/liske/needrestart) * **Linux**: Run [needrestart](https://github.com/liske/needrestart)
* **Windows**: Run Windows Update (You'll have to install [PSWindowsUpdate](https://marckean.com/2016/06/01/use-powershell-to-install-windows-updates/)) * **Windows**: Run Windows Update (You'll have to install [PSWindowsUpdate](https://marckean.com/2016/06/01/use-powershell-to-install-windows-updates/))
* **macOS**: Upgrade App Store applications * **macOS**: Upgrade App Store applications using [mas](https://github.com/mas-cli/mas)
* **macOS**: Upgrade the system
* **FreeBSD**: Run `freebsd-upgrade` * **FreeBSD**: Run `freebsd-upgrade`
## Customization ## Customization

View File

@@ -585,9 +585,11 @@ fn run() -> Result<()> {
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]
{ {
if config.should_run(Step::System) { if config.should_run(Step::System) {
execute(&mut report, "App Store", || macos::run_mas(run_type), config.no_retry())?;
execute( execute(
&mut report, &mut report,
"App Store", "System upgrade",
|| macos::upgrade_macos(run_type), || macos::upgrade_macos(run_type),
config.no_retry(), config.no_retry(),
)?; )?;

View File

@@ -1,9 +1,17 @@
use crate::executor::RunType; use crate::executor::RunType;
use crate::terminal::print_separator; use crate::terminal::print_separator;
use crate::utils::require;
use anyhow::Result; use anyhow::Result;
pub fn run_mas(run_type: RunType) -> Result<()> {
let mas = require("mas")?;
print_separator("macOS App Store");
run_type.execute(mas).arg("upgrade").check_run()
}
pub fn upgrade_macos(run_type: RunType) -> Result<()> { pub fn upgrade_macos(run_type: RunType) -> Result<()> {
print_separator("App Store"); print_separator("macOS system update");
run_type run_type
.execute("softwareupdate") .execute("softwareupdate")