Don't run fwupdmgr in WSL (#430)

This commit is contained in:
Roey Darwish Dror
2020-06-11 19:11:57 +03:00
committed by GitHub
parent 8aba2741c0
commit 2afabfa1a6

View File

@@ -1,6 +1,6 @@
use crate::error::{SkipStep, TopgradeError}; use crate::error::{SkipStep, TopgradeError};
use crate::execution_context::ExecutionContext; use crate::execution_context::ExecutionContext;
use crate::executor::{ExecutorExitStatus, RunType}; use crate::executor::{CommandExt, ExecutorExitStatus, RunType};
use crate::terminal::{print_separator, print_warning}; use crate::terminal::{print_separator, print_warning};
use crate::utils::{require, require_option, which, PathExt}; use crate::utils::{require, require_option, which, PathExt};
use anyhow::Result; use anyhow::Result;
@@ -10,6 +10,7 @@ use serde::Deserialize;
use std::env::var_os; use std::env::var_os;
use std::ffi::OsString; use std::ffi::OsString;
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::process::Command;
use walkdir::WalkDir; use walkdir::WalkDir;
static OS_RELEASE_PATH: &str = "/etc/os-release"; static OS_RELEASE_PATH: &str = "/etc/os-release";
@@ -107,6 +108,12 @@ impl Distribution {
} }
} }
fn is_wsl() -> Result<bool> {
let output = Command::new("uname").arg("-r").check_output()?;
debug!("Uname output: {}", output);
Ok(output.contains("microsoft"))
}
pub fn show_pacnew() { pub fn show_pacnew() {
let mut iter = WalkDir::new("/etc") let mut iter = WalkDir::new("/etc")
.into_iter() .into_iter()
@@ -429,6 +436,10 @@ pub fn run_needrestart(sudo: Option<&PathBuf>, run_type: RunType) -> Result<()>
pub fn run_fwupdmgr(run_type: RunType) -> Result<()> { pub fn run_fwupdmgr(run_type: RunType) -> Result<()> {
let fwupdmgr = require("fwupdmgr")?; let fwupdmgr = require("fwupdmgr")?;
if is_wsl()? {
return Err(SkipStep.into());
}
print_separator("Firmware upgrades"); print_separator("Firmware upgrades");
for argument in vec!["refresh", "get-updates"].into_iter() { for argument in vec!["refresh", "get-updates"].into_iter() {