fix(openbsd): fix compilation on OpenBSD (#1473)
Co-authored-by: Gideon <87426140+GideonBear@users.noreply.github.com>
This commit is contained in:
@@ -1306,14 +1306,6 @@ _version: 2
|
||||
zh_CN: "Windows 更新"
|
||||
zh_TW: "Windows 更新"
|
||||
de: "Windows-Update"
|
||||
"Checking if /etc/motd contains -current or -beta":
|
||||
en: "Checking if /etc/motd contains -current or -beta"
|
||||
lt: "Tikrinimas, jei /etc/motd yra -current arba -beta"
|
||||
es: "Comprobación de si /etc/motd contiene -current o -beta"
|
||||
fr: "Vérification si /etc/motd contient -current ou -beta"
|
||||
zh_CN: "检查 /etc/motd 是否包含 -current 或 -beta"
|
||||
zh_TW: "檢查 /etc/motd 是否包含 -current 或 -beta"
|
||||
de: "Überprüfen, ob /etc/motd -current oder -beta enthält"
|
||||
"Microsoft Store":
|
||||
en: "Microsoft Store"
|
||||
lt: "Microsoft parduotuvė"
|
||||
|
||||
@@ -1,20 +1,17 @@
|
||||
use crate::command::CommandExt;
|
||||
use crate::execution_context::ExecutionContext;
|
||||
use crate::executor::RunType;
|
||||
use crate::terminal::print_separator;
|
||||
use color_eyre::eyre::Result;
|
||||
use rust_i18n::t;
|
||||
use std::fs;
|
||||
use tracing::debug;
|
||||
|
||||
fn is_openbsd_current(ctx: &ExecutionContext) -> Result<bool> {
|
||||
fn is_openbsd_current() -> Result<bool> {
|
||||
let motd_content = fs::read_to_string("/etc/motd")?;
|
||||
let is_current = ["-current", "-beta"].iter().any(|&s| motd_content.contains(s));
|
||||
match ctx.config.run_type() {
|
||||
RunType::Dry | RunType::Damp => {
|
||||
println!("{}", t!("Checking if /etc/motd contains -current or -beta"));
|
||||
}
|
||||
RunType::Wet => {}
|
||||
}
|
||||
|
||||
debug!("OpenBSD is -current/-beta: {is_current}");
|
||||
|
||||
Ok(is_current)
|
||||
}
|
||||
|
||||
@@ -23,12 +20,7 @@ pub fn upgrade_openbsd(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let sudo = ctx.require_sudo()?;
|
||||
|
||||
let is_current = is_openbsd_current(ctx)?;
|
||||
|
||||
if ctx.config().dry_run() {
|
||||
println!("{}", t!("Would upgrade the OpenBSD system"));
|
||||
return Ok(());
|
||||
}
|
||||
let is_current = is_openbsd_current()?;
|
||||
|
||||
if is_current {
|
||||
sudo.execute(ctx, "/usr/sbin/sysupgrade")?.arg("-sn").status_checked()
|
||||
@@ -42,7 +34,7 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
|
||||
|
||||
let sudo = ctx.require_sudo()?;
|
||||
|
||||
let is_current = is_openbsd_current(ctx)?;
|
||||
let is_current = is_openbsd_current()?;
|
||||
|
||||
if ctx.config().cleanup() {
|
||||
sudo.execute(ctx, "/usr/sbin/pkg_delete")?.arg("-ac").status_checked()?;
|
||||
|
||||
Reference in New Issue
Block a user