M src/cmds/build.rs => src/cmds/build.rs +17 -2
@@ 45,7 45,7 @@ fn build_package(name: &str, db: &Database, arch: &Option<String>, verbose:bool)
.arg("-c")
.arg(
&format!(
- "cd {} && echo $CBUILD_ARCH && echo $APORTSDIR && abuild rootbld",
+ "cd {} && echo $APORTSDIR && abuild rootbld",
pkg.path.to_str().expect("Unable to read path"),
));
} else {
@@ 77,7 77,7 @@ fn build_package(name: &str, db: &Database, arch: &Option<String>, verbose:bool)
/// builds a package including the dependencies
fn build_group(name: PackageName, db: &Database, arch: &Option<String>, verbose:bool) {
- let tasks = super::tree::topological_sort(&name, &db)
+ let tasks = super::tree::topological_sort(vec![name], &db)
.expect("Unable to resolve dependencies, as there is a cycle in the graph");
let num = tasks.len();
@@ 100,3 100,18 @@ pub fn build(name: PackageName, db: Option<PathBuf>, arch: Option<String>, build
build_package(&name, &db, &arch, verbose);
}
}
+/// attempts to build every package and its dependencies from the repo
+pub fn build_all(db: Option<PathBuf>, arch: Option<String>, verbose:bool) {
+ let db = Database::from_file(db.unwrap_or(PathBuf::from("db.yml")))
+ .expect("Unable to open database");
+
+ let tasks = super::tree::topological_sort(db.packages.keys().map(|s|s.to_string()).collect(), &db)
+ .expect("Unable to resolve dependencies, as there is a cycle in the graph");
+
+ let num = tasks.len();
+
+ for (i, task) in tasks.iter().enumerate() {
+ println!("Building {} ({}/{})", task, i+1, num);
+ build_package(task, &db, &arch, verbose);
+ }
+}
M src/cmds/mod.rs => src/cmds/mod.rs +1 -1
@@ 6,5 6,5 @@ mod tree;
pub use scan::scan;
pub use list::list;
pub use info::info;
-pub use build::build;
+pub use build::{build, build_all};
pub use tree::tree;
M src/cmds/tree.rs => src/cmds/tree.rs +5 -3
@@ 75,10 75,12 @@ fn list_all_deps(start: PackageName, db: &Database) -> HashSet<PackageName> {
/// topologically sorts all local dependencies
/// filters unknown dependencies
-pub fn topological_sort(start: &PackageName, db: &Database) -> Result<Vec<PackageName>, Vec<(PackageName, PackageName)>> {
+pub fn topological_sort(start: Vec<PackageName>, db: &Database) -> Result<Vec<PackageName>, Vec<(PackageName, PackageName)>> {
let mut stack = LinkedList::new();
let mut marker = HashSet::new();
- stack.push_front(start.to_string());
+ for node in start {
+ stack.push_front(node.to_string());
+ }
let mut edge_out = HashMap::new();
let mut edge_in = HashMap::new();
@@ 185,7 187,7 @@ pub fn tree(name: PackageName, db: Option<PathBuf>, local_only: bool) {
.expect("Unable to open database");
if local_only {
- match topological_sort(&name, &db) {
+ match topological_sort(vec![name], &db) {
Ok(sorted) => {
for dep in sorted {
println!("{}", dep);
M src/main.rs => src/main.rs +16 -0
@@ 19,6 19,21 @@ enum Commands {
/// package database path
db: Option<PathBuf>
},
+ /// Build all packages in repo
+ BuildAll {
+ /// build the package for a target architecture
+ /// requires abuild-rootbld to be installed,
+ /// and the .rootbld-repositories file to be configured correctly
+ /// (even if set to host architecture)
+ #[arg(short='a',long)]
+ arch: Option<String>,
+ /// package database path
+ #[arg(short='d',long)]
+ db: Option<PathBuf>,
+ /// allows the build log to be toggled on and off
+ #[arg(short='v', default_value="false")]
+ verbose: bool
+ },
/// Builds the package
Build {
/// the packagename
@@ 89,6 104,7 @@ fn main() {
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::Tree { package, db, only_local } => cmds::tree(package, db, only_local),
+ Commands::BuildAll { arch, db, verbose } => cmds::build_all(db, arch, verbose),
_ => panic!("Unimplemented")
}
}