diff options
author | xocel <xocel@iquidus.org> | 2012-10-15 17:59:10 +1300 |
---|---|---|
committer | xocel <xocel@iquidus.org> | 2012-10-15 17:59:10 +1300 |
commit | 901c1458ec200d341703bd92e79f35f5049c3368 (patch) | |
tree | fe02ae6b9531c98d50b8a27b6dd47906b053e608 /SBO-Lib/lib | |
parent | b58b73ea8a5686ecdc2d31acfba5999d32436619 (diff) | |
download | sbotools2-901c1458ec200d341703bd92e79f35f5049c3368.tar.xz |
sboremove: %README% support + general improvements
Diffstat (limited to 'SBO-Lib/lib')
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 54 |
1 files changed, 33 insertions, 21 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index d084b14..e90f1e1 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -15,6 +15,7 @@ use 5.16.0; use strict; use warnings FATAL => 'all'; + package SBO::Lib 1.1; my $version = '1.1'; @@ -55,6 +56,7 @@ use File::Copy; use File::Path qw(make_path remove_tree); use File::Temp qw(tempdir tempfile); use File::Find; +use File::Basename; use Fcntl qw(F_SETFD F_GETFD); our $tempdir = tempdir (CLEANUP => 1); @@ -718,38 +720,48 @@ sub do_upgradepkg ($) { return 1; } -# add slackbuild plus reqs to build queue. -sub add_to_queue (%); -sub add_to_queue (%) { - my %args = %{$_[0]}; - my $location = get_sbo_location($args{NAME}); - push(@{$_[0]}{QUEUE}, $args{NAME}); - return 1 unless $args{RECURSIVE}; + +# avoid being called to early to check prototype when add_to_queue calls itself +sub add_to_queue ($); +# used by get_build_queue. +sub add_to_queue ($) { + my $args = shift; + my $sbo = \${$args}{NAME}; + return unless $$sbo; + push(@{$args}{QUEUE}, $$sbo); + my @locations = get_sbo_location $$sbo; + my $location; + for my $loc (@locations) { + $location = $loc if basename($loc) eq $$sbo; + } + return unless $location; my $requires = get_from_info (LOCATION => $location, GET => 'REQUIRES'); - return unless $$requires[0]; for my $req (@$requires) { - unless (( $req eq "%README%") or ($req eq $args{NAME})) { - $args{NAME} = $req; - add_to_queue(\%args) + next if $req eq $$sbo; + if ($req eq "%README%") { + ${$args}{WARNINGS}{$$sbo}="%README%"; + } else { + $$sbo = $req; + add_to_queue($args); } } } -# get full build queue. -sub get_build_queue ($) { - exists $_[0] or script_error 'get_build_queue requires an argument.'; - my @temp_queue = (); - my @build_queue = (); +# recursively add a sbo's requirements to the build queue. +sub get_build_queue ($$) { + unless ($_[0] && $_[1]) { + script_error 'get_build_queue requires two arguments.'; + } + my (@temp_queue, @build_queue); my %args = ( QUEUE => \@temp_queue, NAME => $_[0], - RECURSIVE => 1 + WARNINGS => \%{$_[1]} ); add_to_queue(\%args); - @temp_queue = reverse(@temp_queue); - # Remove duplicate entries (leaving first occurance) - my %seen = (); - for my $sb( @temp_queue ) { + # Remove duplicate entries (leaving first occurrence) + my %seen; + for my $sb( reverse(@temp_queue) ) { next if $seen{ $sb }++; push @build_queue, $sb; } |