@@ 104,7 104,7 @@ pub fn build(name: PackageName, db: Option<PathBuf>, arch: Option<String>, build
}
/// attempts to build every package from the list
/// tries to autodetect the order in which the packages need to be build
-pub fn build_multi(names: Vec<PackageName>, db: Option<PathBuf>, arch: Option<String>, verbose: bool) {
+pub fn build_multi(names: Vec<PackageName>, db: Option<PathBuf>, arch: Option<String>, verbose: bool, run_after: Option<String>) {
let db = Database::from_file(db.unwrap_or(PathBuf::from("db.yml")))
.expect("Unable to open database");
@@ 115,13 115,20 @@ pub fn build_multi(names: Vec<PackageName>, db: Option<PathBuf>, arch: Option<St
for (i, task) in tasks.iter().enumerate() {
println!("Building {} ({}/{})", task, i+1, num);
build_package(task, &db, &arch, verbose);
+ // run command after building a package
+ if let Some(cmd) = &run_after {
+ Command::new(cmd.to_string())
+ .arg(task)
+ .output()
+ .expect("failed to execute process");
+ }
}
}
/// attempts to build every package and its dependencies from the repo
-pub fn build_all(db: Option<PathBuf>, arch: Option<String>, verbose:bool) {
+pub fn build_all(db: Option<PathBuf>, arch: Option<String>, verbose:bool, run_after: Option<String>) {
let dbpath = db.clone();
let db = Database::from_file(db.unwrap_or(PathBuf::from("db.yml")))
.expect("Unable to open database");
- build_multi(db.packages.keys().map(|s|s.to_string()).collect(), dbpath, arch, verbose);
+ build_multi(db.packages.keys().map(|s|s.to_string()).collect(), dbpath, arch, verbose, run_after);
}
@@ 35,7 35,11 @@ enum Commands {
db: Option<PathBuf>,
/// allows the build log to be toggled on and off
#[arg(short='v', default_value="false")]
- verbose: bool
+ verbose: bool,
+ /// run command after building a package
+ /// calls $cmd $pkgname
+ #[arg(long)]
+ run_after: Option<String>
},
/// Builds multiple packages from a list
BuildGroup {
@@ 53,7 57,11 @@ enum Commands {
#[arg(short='v', default_value="false")]
verbose: bool,
/// list of packages to be build
- packages: Vec<String>
+ packages: Vec<String>,
+ /// run command after building a package
+ /// calls $cmd $pkgname
+ #[arg(long)]
+ run_after: Option<String>
},
/// Builds the package
Build {
@@ 125,15 133,15 @@ fn main() {
Commands::List { db } => cmds::list(db),
Commands::Info { package, db, show_depends, show_provides } => cmds::info(package, db, show_provides, show_depends),
Commands::Build { package, db, arch, no_build_dependencies, verbose } => cmds::build(package, db, arch, !no_build_dependencies, verbose),
- Commands::BuildGroup { packages, db, arch, verbose } => {
+ Commands::BuildGroup { packages, db, arch, verbose, run_after } => {
if packages.len() == 0 {
println!("Nothing do be done");
} else {
- cmds::build_multi(packages, db, arch, verbose);
+ cmds::build_multi(packages, db, arch, verbose, run_after);
}
},
Commands::Tree { package, db, only_local } => cmds::tree(package, db, only_local),
- Commands::BuildAll { arch, db, verbose } => cmds::build_all(db, arch, verbose),
+ Commands::BuildAll { arch, db, verbose, run_after } => cmds::build_all(db, arch, verbose, run_after),
Commands::Search { query, db } => cmds::search(query, db)
}
}