diff options
author | xocel <xocel@iquidus.org> | 2012-10-07 21:26:29 +1300 |
---|---|---|
committer | xocel <xocel@iquidus.org> | 2012-10-07 21:26:29 +1300 |
commit | e5d7cf3a50a27a37434da8b3046681426aa25012 (patch) | |
tree | 4e4d932ad424581368a64ded3b19357745595838 | |
parent | b9036db1e5e965dc395d978397e8151ca9ab59fd (diff) | |
download | sbotools2-e5d7cf3a50a27a37434da8b3046681426aa25012.tar.xz |
sbofind --queue option
-rwxr-xr-x | sbofind | 56 |
1 files changed, 47 insertions, 9 deletions
@@ -23,13 +23,15 @@ Usage: $self (search_term) Options: -h|--help: - this screen. + this screen. -v|--verison: - version information. + version information. -i|--info: - show the .info for each found item. + show the .info for each found item. -r|--readme: - show the README for each found item. + show the README for each found item. + -q|--queue: + show the build queue for each found item. Example: $self libsexy @@ -37,13 +39,14 @@ Example: EOF } -my ($help, $vers, $show_info, $show_readme); +my ($help, $vers, $show_info, $show_readme, $show_queue); GetOptions ( - 'help|h' => \$help, - 'version|v' => \$vers, - 'info|i' => \$show_info, - 'readme|r' => \$show_readme, + 'help|h' => \$help, + 'version|v' => \$vers, + 'info|i' => \$show_info, + 'readme|r' => \$show_readme, + 'queue|q' => \$show_queue, ); show_usage and exit 0 if $help; @@ -90,6 +93,40 @@ sub get_file_contents ($) { return $contents; } +# get full build queue and prepare it for output. +sub get_build_queue ($) { + exists $_[0] or script_error 'get_build_queue requires an argument.'; + my @temp_queue = (); + my @build_queue = (); + my %seen = (); + &add_to_queue(\@temp_queue,"$_[0]",1); + @temp_queue = reverse(@temp_queue); + # Remove duplicate entries (leaving first occurance) + for my $sb( @temp_queue ) { + next if $seen{ $sb }++; + push @build_queue, $sb; + } + return join(" ", @build_queue); +} + +# add slackbuild to build queue. +# args: @queue(array), $sbname(string), $recursive(boolean) +sub add_to_queue () { + my $queue = \@{$_[0]}; + my $sbname = $_[1]; + my $recursive = $_[2]; + my $sbpath = get_sbo_location($sbname); + push(@{$queue}, $sbname); + return 1 unless $recursive; + for my $line (split("\n", get_file_contents("$sbpath/$sbname.info"))) { + if ($line =~ /REQUIRES="(.*?)"/) { + for my $req (split(" ", $1)) { + &add_to_queue($queue,"$req",1) unless ( $req eq "%README%" ); + } + } + } +} + my $findings = perform_search $search; # pretty formatting @@ -101,6 +138,7 @@ if (exists $$findings[0]) { say "Path: $val"; say "info: ". get_file_contents "$val/$key.info" if $show_info; say "README: ". get_file_contents "$val/README" if $show_readme; + say "Queue: ". get_build_queue "$key" if $show_queue; say ''; } } |