Skip to content

Commit

Permalink
[FIXES #922] properly check for -CURRENT in openbsd steps and pass t…
Browse files Browse the repository at this point in the history
…he correct flags
  • Loading branch information
Izder456 committed Oct 4, 2024
1 parent a021441 commit fb6e0e1
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions src/steps/os/openbsd.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,31 @@
use crate::command::CommandExt;
use crate::execution_context::ExecutionContext;
use crate::t;
use crate::terminal::print_separator;
use crate::utils::{get_require_sudo_string, require_option};
use color_eyre::eyre::Result;
use std::process::Command;

fn is_openbsd_current() -> bool {
let output = Command::new("uname")
.arg("-r")
.output()
.expect("Failed to execute uname command");

let version = String::from_utf8_lossy(&output.stdout);
version.trim().ends_with("-current")
}

pub fn upgrade_openbsd(ctx: &ExecutionContext) -> Result<()> {
let sudo = require_option(ctx.sudo().as_ref(), get_require_sudo_string())?;
print_separator(t!("OpenBSD Update"));
ctx.run_type()
.execute(sudo)
.args(["/usr/sbin/sysupgrade", "-n"])
.status_checked()

let mut args = vec!["/usr/sbin/sysupgrade", "-n"];
if is_openbsd_current() {
args.push("-s");
}

ctx.run_type().execute(sudo).args(&args).status_checked()
}

pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
Expand All @@ -24,10 +39,12 @@ pub fn upgrade_packages(ctx: &ExecutionContext) -> Result<()> {
.status_checked()?;
}

ctx.run_type()
.execute(sudo)
.args(["/usr/sbin/pkg_add", "-u"])
.status_checked()?;
let mut args = vec!["/usr/sbin/pkg_add", "-u"];
if is_openbsd_current() {
args.push("-Dsnap");
}

ctx.run_type().execute(sudo).args(&args).status_checked()?;

Ok(())
}

0 comments on commit fb6e0e1

Please sign in to comment.