Add local build action.
parent
e15b0fd95e
commit
2c7389201b
@ -0,0 +1,71 @@
|
||||
use std::process::Command;
|
||||
use std::time::Duration;
|
||||
use std::time::SystemTime;
|
||||
|
||||
use crate::db::DbHandle;
|
||||
use crate::db::DbLocalAction;
|
||||
|
||||
pub(crate) const ACTION_BUILD: &str = "build";
|
||||
const ACTION_BUILD_INTERVAL: u64 = 1209600;
|
||||
const ACTION_BUILD_JOBS: u64 = 1;
|
||||
|
||||
pub(crate) fn build(
|
||||
db_conn: &mut DbHandle,
|
||||
action: &DbLocalAction,
|
||||
) -> Result<(), Box<dyn std::error::Error>> {
|
||||
println!(
|
||||
"Performing build for jail {} tree {} set {}.",
|
||||
action.jail_name.as_str(),
|
||||
action.tree.as_str(),
|
||||
action.set_name.as_str()
|
||||
);
|
||||
Command::new("poudriere")
|
||||
.arg("pkgclean")
|
||||
.arg("-v")
|
||||
.arg("-y")
|
||||
.arg("-j")
|
||||
.arg(action.jail_name.as_str())
|
||||
.arg("-p")
|
||||
.arg(action.tree.as_str())
|
||||
.arg("-z")
|
||||
.arg(action.set_name.as_str())
|
||||
.arg("-f")
|
||||
.arg(format!(
|
||||
"/usr/local/etc/poudriere.d/{}-{}-{}-pkglist",
|
||||
action.jail_name.as_str(),
|
||||
action.tree.as_str(),
|
||||
action.set_name.as_str()
|
||||
))
|
||||
.status()?
|
||||
.exit_ok()?;
|
||||
Command::new("poudriere")
|
||||
.arg("bulk")
|
||||
.arg("-J")
|
||||
.arg(ACTION_BUILD_JOBS.to_string())
|
||||
.arg("-j")
|
||||
.arg(action.jail_name.as_str())
|
||||
.arg("-p")
|
||||
.arg(action.tree.as_str())
|
||||
.arg("-z")
|
||||
.arg(action.set_name.as_str())
|
||||
.arg("-f")
|
||||
.arg(format!(
|
||||
"/usr/local/etc/poudriere.d/{}-{}-{}-pkglist",
|
||||
action.jail_name.as_str(),
|
||||
action.tree.as_str(),
|
||||
action.set_name.as_str()
|
||||
))
|
||||
.status()?
|
||||
.exit_ok()?;
|
||||
let next_run = (SystemTime::now() + Duration::from_secs(ACTION_BUILD_INTERVAL))
|
||||
.duration_since(SystemTime::UNIX_EPOCH)?
|
||||
.as_secs();
|
||||
|
||||
let tx = db_conn.conn.transaction()?;
|
||||
tx.execute(
|
||||
"UPDATE local_action SET next_run=$1 WHERE name=$2 AND jail_name=$3 AND tree=$4 AND set_name=$5",
|
||||
(next_run, ACTION_BUILD, action.jail_name.as_str(), action.tree.as_str(), action.set_name.as_str()),
|
||||
)?;
|
||||
tx.commit()?;
|
||||
Ok(())
|
||||
}
|
@ -1,5 +1,10 @@
|
||||
mod build;
|
||||
mod cleanup;
|
||||
mod ports_tree;
|
||||
|
||||
pub(crate) use build::build;
|
||||
pub(crate) use build::ACTION_BUILD;
|
||||
pub(crate) use cleanup::cleanup;
|
||||
pub(crate) use cleanup::ACTION_CLEANUP;
|
||||
pub(crate) use ports_tree::update_ports_tree;
|
||||
pub(crate) use ports_tree::ACTION_UPDATE_PORTS_TREE;
|
||||
|
Loading…
Reference in New Issue