2018-12-15 21:52:21 +02:00
|
|
|
use crate::error::{Error, ErrorKind};
|
2018-12-31 14:05:15 +02:00
|
|
|
use crate::executor::RunType;
|
2019-03-13 11:46:32 +02:00
|
|
|
use crate::terminal::print_separator;
|
|
|
|
|
use crate::utils::require_option;
|
2018-12-11 16:43:26 +02:00
|
|
|
use failure::ResultExt;
|
2018-11-12 11:13:43 +02:00
|
|
|
use std::path::PathBuf;
|
2018-11-15 11:37:08 +02:00
|
|
|
use std::process::Command;
|
2018-11-12 11:13:43 +02:00
|
|
|
|
2019-03-13 11:46:32 +02:00
|
|
|
pub fn upgrade_freebsd(sudo: Option<&PathBuf>, run_type: RunType) -> Result<(), Error> {
|
2019-03-10 21:48:49 +02:00
|
|
|
let sudo = require_option(sudo)?;
|
2018-12-05 11:34:08 +02:00
|
|
|
print_separator("FreeBSD Update");
|
2019-03-10 21:48:49 +02:00
|
|
|
run_type
|
|
|
|
|
.execute(sudo)
|
|
|
|
|
.args(&["/usr/sbin/freebsd-update", "fetch", "install"])
|
|
|
|
|
.check_run()
|
2018-11-12 11:13:43 +02:00
|
|
|
}
|
|
|
|
|
|
2019-03-13 11:46:32 +02:00
|
|
|
pub fn upgrade_packages(sudo: Option<&PathBuf>, run_type: RunType) -> Result<(), Error> {
|
2019-03-10 21:48:49 +02:00
|
|
|
let sudo = require_option(sudo)?;
|
2018-12-05 11:34:08 +02:00
|
|
|
print_separator("FreeBSD Packages");
|
2019-03-10 21:48:49 +02:00
|
|
|
run_type.execute(sudo).args(&["/usr/sbin/pkg", "upgrade"]).check_run()
|
2018-11-12 11:13:43 +02:00
|
|
|
}
|
2018-11-15 11:37:08 +02:00
|
|
|
|
2018-12-11 16:43:26 +02:00
|
|
|
pub fn audit_packages(sudo: &Option<PathBuf>) -> Result<(), Error> {
|
2018-11-15 15:54:24 +02:00
|
|
|
if let Some(sudo) = sudo {
|
|
|
|
|
println!();
|
|
|
|
|
Command::new(sudo)
|
|
|
|
|
.args(&["/usr/sbin/pkg", "audit", "-Fr"])
|
2018-12-11 16:43:26 +02:00
|
|
|
.spawn()
|
|
|
|
|
.context(ErrorKind::ProcessExecution)?
|
|
|
|
|
.wait()
|
|
|
|
|
.context(ErrorKind::ProcessExecution)?;
|
2018-11-15 15:54:24 +02:00
|
|
|
}
|
2018-11-15 11:37:08 +02:00
|
|
|
Ok(())
|
|
|
|
|
}
|