From fd89c670b91e31dd41758448291750e045fd4594 Mon Sep 17 00:00:00 2001 From: madomado Date: Tue, 3 Oct 2023 20:29:57 +0800 Subject: [PATCH] feat: script dependency This adds a new feature where with the `needs:` attribute, other scripts can be specified as dependencies of this script. Let's just hope that the code works :3 --- Cargo.lock | 14 ++--- src/builder.rs | 143 ++++++++++++++++++++++++++++++------------------- src/config.rs | 4 +- 3 files changed, 97 insertions(+), 64 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0da6e4f..717966f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -854,9 +854,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.6.3" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f232d6ef707e1956a43342693d2a31e72989554d58299d7a88738cc95b0d35c" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "merge-struct" @@ -1162,13 +1162,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.9.5" +version = "1.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "697061221ea1b4a94a624f67d0ae2bfe4e22b8a17b6a192afb11046542cc8c47" +checksum = "ebee201405406dbf528b8b672104ae6d6d63e6d118cb10e4d51abbc7b58044ff" dependencies = [ "aho-corasick", "memchr", - "regex-automata 0.3.8", + "regex-automata 0.3.9", "regex-syntax 0.7.5", ] @@ -1183,9 +1183,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c2f401f4955220693b56f8ec66ee9c78abffd8d1c4f23dc41a23839eb88f0795" +checksum = "59b23e92ee4318893fa3fe3e6fb365258efbfe6ac6ab30f090cdcbb7aa37efa9" dependencies = [ "aho-corasick", "memchr", diff --git a/src/builder.rs b/src/builder.rs index f83bcf6..b73bfbd 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -1,7 +1,7 @@ -use color_eyre::Result; +use color_eyre::{eyre::eyre, Result}; use serde_derive::{Deserialize, Serialize}; use std::{ - collections::BTreeMap, + collections::{BTreeMap, HashMap}, fs, io::{Seek, Write}, path::PathBuf, @@ -67,7 +67,7 @@ impl RootBuilder for DnfRootBuilder { fn build(&self, chroot: PathBuf, manifest: &Manifest) -> Result<()> { info!("Running Pre-install scripts"); - run_scripts(manifest.scripts.pre.clone(), &chroot, false)?; + run_all_scripts(manifest.scripts.pre.clone(), &chroot, false)?; if let Some(disk) = manifest.clone().disk { let f = disk.fstab(&chroot)?; @@ -132,65 +132,96 @@ impl RootBuilder for DnfRootBuilder { info!("Running post-install scripts"); - run_scripts(manifest.scripts.post.clone(), &chroot, true)?; + run_all_scripts(manifest.scripts.post.clone(), &chroot, true)?; Ok(()) } } -pub fn run_scripts(scripts: Vec