From c17d9f591918db35ea6974335cb0cbd062a81fa1 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 21:47:33 -0500 Subject: change sbo_home back to default since no longer developing against sbo git repo --- t/test.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/test.t b/t/test.t index 97b15cc..72d7d14 100755 --- a/t/test.t +++ b/t/test.t @@ -10,7 +10,7 @@ use Text::Diff; use lib "."; use SBO::Lib; -my $sbo_home = '/home/d4wnr4z0r/sbo.git/slackbuilds'; +my $sbo_home = '/usr/sbo'; # 1, open_read, open_fh tests my $fh = open_read ('./test.t'); -- cgit v1.2.3 From 64fe43f714525ee054e33bc8ff6ac51d539931ab Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 21:51:51 -0500 Subject: zdoom version 2.5.0 -> 2.6.0 --- t/test.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/test.t b/t/test.t index 72d7d14..f2b7463 100755 --- a/t/test.t +++ b/t/test.t @@ -58,7 +58,7 @@ for my $key (keys @$installed) { 'libmodplug'; is ($$installed[$key]{version}, '3.12.4') if $$installed[$key]{name} eq 'mozilla-nss'; - is ($$installed[$key]{version}, '2.5.0') if $$installed[$key]{name} eq + is ($$installed[$key]{version}, '2.6.0') if $$installed[$key]{name} eq 'zdoom'; } print "completed pseudo-random testing of get_installed_sbos \n"; -- cgit v1.2.3 From 41fc4d35c0fbd6f27899aecf2405f854a892f102 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 21:56:35 -0500 Subject: in get_filename_from_link, added only do the substitution if $filename --- SBO-Lib/lib/SBO/Lib.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 7b9dff7..c7c186b 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -366,7 +366,7 @@ sub get_filename_from_link ($) { my $fn = shift; my $regex = qr#/([^/]+)$#; my $filename = $fn =~ $regex ? $distfiles .'/'. ($fn =~ $regex)[0] : undef; - $filename =~ s/%2B/+/g; + $filename =~ s/%2B/+/g if $filename; return $filename; } @@ -771,4 +771,4 @@ sub get_build_queue ($$) { push @build_queue, $sb; } return \@build_queue; -} \ No newline at end of file +} -- cgit v1.2.3 From ce4925b1318dff6170f6c3047e68ce47dc0d1798 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 21:59:42 -0500 Subject: work out of xocel branch --- t/prep.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/prep.pl b/t/prep.pl index ebffd40..bbc1272 100755 --- a/t/prep.pl +++ b/t/prep.pl @@ -8,7 +8,7 @@ use Tie::File; chomp (my $pwd = `pwd`); mkdir "$pwd/SBO" unless -d "$pwd/SBO"; -copy ('/home/d4wnr4z0r/projects/slack14/sbotools/SBO-Lib/lib/SBO/Lib.pm', "$pwd/SBO"); +copy ('/home/d4wnr4z0r/projects/xocel/sbotools/SBO-Lib/lib/SBO/Lib.pm', "$pwd/SBO"); open my $write, '>>', "$pwd/SBO/Lib.pm"; -- cgit v1.2.3 From d1c0abdd300e1006cd9c07704095ac2c05911474 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 22:02:45 -0500 Subject: comment out no-longer-valid circular requirement test --- t/test.t | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/t/test.t b/t/test.t index f2b7463..14c6503 100755 --- a/t/test.t +++ b/t/test.t @@ -301,8 +301,9 @@ ok ('zdoom' ~~ @$inst_names, 'get_inst_names is good'); # 76-81, get_reqs tests $SBO::Lib::no_reqs = 0; -ok (! (get_requires 'zarafa', "$sbo_home/network/zarafa"), - 'get_requires good for circular requirements'); +# no longer valid - there are no longer any circular requirements. +#ok (! (get_requires 'zarafa', "$sbo_home/network/zarafa"), +# 'get_requires good for circular requirements'); ok (! (get_requires 'smc', "$sbo_home/games/smc"), 'get_requires good for REQUIRES="%README%"'); ok (! (get_requires 'krb5', "$sbo_home/network/krb5"), -- cgit v1.2.3 From ce77b5798ecea670c2bb58aff40a1d709bf33a0d Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 22:09:19 -0500 Subject: reinstate clean_reqs test for installed reqs, set compat32 = 0 beforehand, use zdoom instead of wine --- t/test.t | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/t/test.t b/t/test.t index 14c6503..86470cf 100755 --- a/t/test.t +++ b/t/test.t @@ -342,11 +342,10 @@ close $fh; ok (! (get_opts $readme), 'get_opts good where README does not define opts'); # 88-90, clean_reqs tests -#$reqs = get_requires "wine", "$sbo_home/system/wine"; -#$reqs = clean_reqs $reqs; -#print $_,"\n" for @$reqs; -#ok (! $$reqs[0], 'clean_reqs good for already installed reqs'); $SBO::Lib::compat32 = 0; +$reqs = get_requires "zdoom", "$sbo_home/games/zdoom"; +$reqs = clean_reqs $reqs; +ok (! $$reqs[0], 'clean_reqs good for already installed reqs'); $reqs = get_requires 'gmpc', "$sbo_home/audio/gmpc"; $reqs = clean_reqs $reqs; ok ($$reqs[0] eq 'gob2', 'clean_reqs good for un/installed reqs.'); -- cgit v1.2.3 From cb042eb7a7dcca1fa46859af29a6544cf76294fd Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 22:14:10 -0500 Subject: tests for get_build_queue --- t/test.t | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/test.t b/t/test.t index 86470cf..8617fe7 100755 --- a/t/test.t +++ b/t/test.t @@ -351,3 +351,11 @@ $reqs = clean_reqs $reqs; ok ($$reqs[0] eq 'gob2', 'clean_reqs good for un/installed reqs.'); ok ($$reqs[1] eq 'libmpd', 'clean_reqs good for un/installed reqs.'); +my %warnings; +my $queue = get_build_queue 'zdoom', \%warnings; +my $count = @$queue; +ok ($count == 5, 'get_build_queue returns correct amount of sbos'); +ok ($$queue[0] eq 'p7zip', 'get_build_queue first entry correct'); +ok ($$queue[1] eq 'fmodapi', 'get_build_queue second entry correct'); +ok ($$queue[4] eq 'zdoom', 'get_build_queue last entry correct'); + -- cgit v1.2.3 From 942bfa63aec5bd4cc229f44ffe2e2437374cb091 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 22:22:18 -0500 Subject: get_build_queue: take an array ref as first arg, make the temp_queue keep state, changes for clarity --- SBO-Lib/lib/SBO/Lib.pm | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index c7c186b..ae827de 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -754,16 +754,18 @@ sub add_to_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.'; + exists $_[1] or script_error 'get_build_queue requires two arguments.'; + my ($sbos, $warnings) = @_; + state $temp_queue = ['']; + my @build_queue; + for my $sbo (@$sbos) { + my %args = ( + QUEUE => \@temp_queue, + NAME => $sbo, + WARNINGS => $warnings + ); + add_to_queue(\%args); } - my (@temp_queue, @build_queue); - my %args = ( - QUEUE => \@temp_queue, - NAME => $_[0], - WARNINGS => \%{$_[1]} - ); - add_to_queue(\%args); # Remove duplicate entries (leaving first occurrence) my %seen; for my $sb( reverse(@temp_queue) ) { -- cgit v1.2.3 From 8918833a741fb9c9d8331574bd805267276bb211 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 22:23:31 -0500 Subject: remove extraneous locations stuff from add_to_queue - get_sbo_location does not return a list --- SBO-Lib/lib/SBO/Lib.pm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index ae827de..c8b844c 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -734,11 +734,7 @@ sub add_to_queue ($) { 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; - } + my $location = get_sbo_location $$sbo; return unless $location; my $requires = get_from_info (LOCATION => $location, GET => 'REQUIRES'); for my $req (@$requires) { -- cgit v1.2.3 From 8f208049f7d28c03ac64a9a0246a75767b03e065 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 22:56:53 -0500 Subject: extend get_build_queue test for three sbos at once --- t/test.t | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/t/test.t b/t/test.t index 8617fe7..fcc0171 100755 --- a/t/test.t +++ b/t/test.t @@ -351,11 +351,14 @@ $reqs = clean_reqs $reqs; ok ($$reqs[0] eq 'gob2', 'clean_reqs good for un/installed reqs.'); ok ($$reqs[1] eq 'libmpd', 'clean_reqs good for un/installed reqs.'); -my %warnings; -my $queue = get_build_queue 'zdoom', \%warnings; +my $warnings = {()};; +my $queue = get_build_queue ['zdoom', 'bsnes', 'spring'], $warnings; my $count = @$queue; -ok ($count == 5, 'get_build_queue returns correct amount of sbos'); -ok ($$queue[0] eq 'p7zip', 'get_build_queue first entry correct'); -ok ($$queue[1] eq 'fmodapi', 'get_build_queue second entry correct'); -ok ($$queue[4] eq 'zdoom', 'get_build_queue last entry correct'); +ok ($count == 10, 'get_build_queue returns correct amount of sbos'); +ok ($$queue[0] eq 'jdk', 'get_build_queue first entry correct'); +ok ($$queue[2] eq 'OpenAL', 'get_build_queue third entry correct'); +ok ($$queue[4] eq 'spring', 'get_build_queue fifth entry correct'); +ok ($$queue[6] eq 'fmodapi', 'get_build_queue seventh entry correct'); +ok ($$queue[8] eq 'TiMidity++', 'get_build_queue ninth entry correct'); + -- cgit v1.2.3 From da74382cb1def30948c8170ccc1ff5da47f05a66 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 22:58:58 -0500 Subject: but fix to state $temp_queue where had an empty element at end, label for loop in get_build_queue, use unshift in add_to_queue instead of reversing array in get_build_queue, label for loop in add_to_queue --- SBO-Lib/lib/SBO/Lib.pm | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index c8b844c..24fae5f 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -733,12 +733,12 @@ sub add_to_queue ($) { my $args = shift; my $sbo = \${$args}{NAME}; return unless $$sbo; - push(@{$args}{QUEUE}, $$sbo); + unshift @$args{QUEUE}, $$sbo; my $location = get_sbo_location $$sbo; return unless $location; my $requires = get_from_info (LOCATION => $location, GET => 'REQUIRES'); - for my $req (@$requires) { - next if $req eq $$sbo; + FIRST: for my $req (@$requires) { + next FIRST if $req eq $$sbo; if ($req eq "%README%") { ${$args}{WARNINGS}{$$sbo}="%README%"; } else { @@ -752,20 +752,19 @@ sub add_to_queue ($) { sub get_build_queue ($$) { exists $_[1] or script_error 'get_build_queue requires two arguments.'; my ($sbos, $warnings) = @_; - state $temp_queue = ['']; - my @build_queue; + state $temp_queue = [()]; for my $sbo (@$sbos) { my %args = ( - QUEUE => \@temp_queue, + QUEUE => $temp_queue,, NAME => $sbo, WARNINGS => $warnings ); add_to_queue(\%args); } # Remove duplicate entries (leaving first occurrence) - my %seen; - for my $sb( reverse(@temp_queue) ) { - next if $seen{ $sb }++; + my (%seen, @build_queue); + FIRST: for my $sb (@$temp_queue) { + next FIRST if $seen{$sb}++; push @build_queue, $sb; } return \@build_queue; -- cgit v1.2.3 From b73343f9cd0936748b6fe5ecd19a42965bfa52f7 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 23:07:18 -0500 Subject: add ability to empty $temp_queue in order to facilitate unit testing --- SBO-Lib/lib/SBO/Lib.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 24fae5f..1087fb4 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -749,10 +749,11 @@ sub add_to_queue ($) { } # recursively add a sbo's requirements to the build queue. -sub get_build_queue ($$) { +sub get_build_queue ($$;$) { exists $_[1] or script_error 'get_build_queue requires two arguments.'; - my ($sbos, $warnings) = @_; - state $temp_queue = [()]; + my ($sbos, $warnings, $empty) = @_; + state $temp_queue = []; + $temp_queue = [] if $empty; for my $sbo (@$sbos) { my %args = ( QUEUE => $temp_queue,, -- cgit v1.2.3 From 106895a334244fc0e63c71305410a8d21a4447f3 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 23:17:07 -0500 Subject: more test for get_build_queue --- t/test.t | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/t/test.t b/t/test.t index fcc0171..3ddbe06 100755 --- a/t/test.t +++ b/t/test.t @@ -354,11 +354,15 @@ ok ($$reqs[1] eq 'libmpd', 'clean_reqs good for un/installed reqs.'); my $warnings = {()};; my $queue = get_build_queue ['zdoom', 'bsnes', 'spring'], $warnings; my $count = @$queue; -ok ($count == 10, 'get_build_queue returns correct amount of sbos'); -ok ($$queue[0] eq 'jdk', 'get_build_queue first entry correct'); -ok ($$queue[2] eq 'OpenAL', 'get_build_queue third entry correct'); -ok ($$queue[4] eq 'spring', 'get_build_queue fifth entry correct'); -ok ($$queue[6] eq 'fmodapi', 'get_build_queue seventh entry correct'); -ok ($$queue[8] eq 'TiMidity++', 'get_build_queue ninth entry correct'); - - +ok ($count == 10, 'get_build_queue returns correct amount for multiple sbos'); +ok ($$queue[0] eq 'jdk', 'get_build_queue first entry correct for multiple sbos'); +ok ($$queue[2] eq 'OpenAL', 'get_build_queue third entry correct for multiple sbos'); +ok ($$queue[4] eq 'spring', 'get_build_queue fifth entry correct for multiple sbos'); +ok ($$queue[6] eq 'fmodapi', 'get_build_queue seventh entry correct for multiple sbos'); +ok ($$queue[8] eq 'TiMidity++', 'get_build_queue ninth entry correct for multiple sbos'); +$queue = get_build_queue ['zdoom'], $warnings, 1; +$count = @$queue; +ok ($count == 5, 'get_build_queue returns correct amount for single sbo'); +ok ($$queue[0] eq 'p7zip', 'get_build_queue first entry correct for single sbo'); +ok ($$queue[2] eq 'eawpats', 'get_build_queue third entry correct for single sbo'); +ok ($$queue[4] eq 'zdoom', 'get_build_queue fifth entry correct for single sbo'); -- cgit v1.2.3 From ff2c85003c3e64b8f145b6f558b3d63b8e6541bb Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 23:22:07 -0500 Subject: use my instead of state for $temp_queue, rip out $empty junk --- SBO-Lib/lib/SBO/Lib.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 1087fb4..e9f10d9 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -749,11 +749,10 @@ sub add_to_queue ($) { } # recursively add a sbo's requirements to the build queue. -sub get_build_queue ($$;$) { +sub get_build_queue ($$) { exists $_[1] or script_error 'get_build_queue requires two arguments.'; - my ($sbos, $warnings, $empty) = @_; - state $temp_queue = []; - $temp_queue = [] if $empty; + my ($sbos, $warnings) = @_; + my $temp_queue = []; for my $sbo (@$sbos) { my %args = ( QUEUE => $temp_queue,, -- cgit v1.2.3 From 66a19217ed6b778fbfba9d95ae2d5ceab5775f9f Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 1 Nov 2012 23:22:42 -0500 Subject: dont try to empty queue since that no longer applies --- t/test.t | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/test.t b/t/test.t index 3ddbe06..8ff06f8 100755 --- a/t/test.t +++ b/t/test.t @@ -360,7 +360,7 @@ ok ($$queue[2] eq 'OpenAL', 'get_build_queue third entry correct for multiple sb ok ($$queue[4] eq 'spring', 'get_build_queue fifth entry correct for multiple sbos'); ok ($$queue[6] eq 'fmodapi', 'get_build_queue seventh entry correct for multiple sbos'); ok ($$queue[8] eq 'TiMidity++', 'get_build_queue ninth entry correct for multiple sbos'); -$queue = get_build_queue ['zdoom'], $warnings, 1; +$queue = get_build_queue ['zdoom'], $warnings; $count = @$queue; ok ($count == 5, 'get_build_queue returns correct amount for single sbo'); ok ($$queue[0] eq 'p7zip', 'get_build_queue first entry correct for single sbo'); -- cgit v1.2.3 From 3ee3882b89ea051a0851edf369fd8adafa2944d2 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 07:15:35 -0600 Subject: use relative path to Lib.pm --- t/prep.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/prep.pl b/t/prep.pl index bbc1272..9c99682 100755 --- a/t/prep.pl +++ b/t/prep.pl @@ -8,7 +8,7 @@ use Tie::File; chomp (my $pwd = `pwd`); mkdir "$pwd/SBO" unless -d "$pwd/SBO"; -copy ('/home/d4wnr4z0r/projects/xocel/sbotools/SBO-Lib/lib/SBO/Lib.pm', "$pwd/SBO"); +copy ('../SBO-Lib/lib/SBO/Lib.pm', "$pwd/SBO"); open my $write, '>>', "$pwd/SBO/Lib.pm"; -- cgit v1.2.3 From 115d15c04a36dd01af39ae99e0ce9016fbba1551 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 08:18:04 -0600 Subject: get_sbo_download - no prototype, keep state, deal with either a single scalar or array passed in, return based on wantarray --- SBO-Lib/lib/SBO/Lib.pm | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index e9f10d9..21f62c6 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -219,17 +219,29 @@ sub get_inst_names ($) { } # search the SLACKBUILDS.TXT for a given sbo's directory -sub get_sbo_location ($) { +sub get_sbo_location { exists $_[0] or script_error 'get_sbo_location requires an argument.'; - my $sbo = shift; - my $regex = qr#LOCATION:\s+\.(/[^/]+/\Q$sbo\E)$#; + my @sbos = @_; + state $loc_store = {}; + # if scalar context and we've already have the location, return it now. + unless (wantarray) { + return $loc_store{$sbos[0]} if exists $loc_store{$sbos[0]}; + } + my %locations; my $fh = open_read $slackbuilds_txt; - while (my $line = <$fh>) { - if (my $loc = ($line =~ $regex)[0]) { - return "$config{SBO_HOME}$loc"; + for my $sbo (@$sbos) { + my $regex = qr#LOCATION:\s+\.(/[^/]+/\Q$sbo\E)$#; + while (my $line = <$fh>) { + if (my $loc = ($line =~ $regex)[0]) { + $loc_store{$sbo} = "$config{SBO_HOME}$loc"; + return $loc_store{$sbo} unless wantarray; + $locations{$sbo} = $loc_store{$sbo}; + } } + seek $fh, 0, 0; } - return; + close $fh; + return %locations; } # pull the sbo name from a $location: $config{SBO_HOME}/system/wine, etc. -- cgit v1.2.3 From 23751d7cf1774684214ce7f210456d74f5eb683a Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 08:32:03 -0600 Subject: also handle being passed an array ref --- SBO-Lib/lib/SBO/Lib.pm | 2 ++ 1 file changed, 2 insertions(+) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 21f62c6..4ad01e5 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -222,6 +222,7 @@ sub get_inst_names ($) { sub get_sbo_location { exists $_[0] or script_error 'get_sbo_location requires an argument.'; my @sbos = @_; + @sbos = $sbos[0] if ref $sbos[0] eq 'ARRAY'; state $loc_store = {}; # if scalar context and we've already have the location, return it now. unless (wantarray) { @@ -233,6 +234,7 @@ sub get_sbo_location { my $regex = qr#LOCATION:\s+\.(/[^/]+/\Q$sbo\E)$#; while (my $line = <$fh>) { if (my $loc = ($line =~ $regex)[0]) { + # save what we found for later requests $loc_store{$sbo} = "$config{SBO_HOME}$loc"; return $loc_store{$sbo} unless wantarray; $locations{$sbo} = $loc_store{$sbo}; -- cgit v1.2.3 From a7adf75786aa7496db52998ff0f918bfb99a685e Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 08:33:54 -0600 Subject: changes to support get_sbo_location changes --- sboupgradex | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sboupgradex b/sboupgradex index 178adee..83128e1 100644 --- a/sboupgradex +++ b/sboupgradex @@ -82,7 +82,6 @@ my $rootpkg = $ARGV[0]; my %warnings; my %options; my $build_queue; -my %locations; if ($no_reqs) { @$build_queue = (); @@ -91,9 +90,7 @@ if ($no_reqs) { $build_queue = get_build_queue($rootpkg, \%warnings); } -for my $sbo (@$build_queue) { - $locations{$sbo} = get_sbo_location $sbo; -} +my %locations = get_sbo_location ($build_queue); sub get_readme_path ($) { exists $_[0] or script_error 'get_readme_path requires an argument.'; @@ -327,7 +324,7 @@ goto BEGIN_BUILD unless $install_new; for my $sbo (@$build_queue) { my $name = $compat32 ? "$sbo-compat32" : $sbo; warn "$name already installed.\n" and next if $name ~~ @$inst_names; - $locations{$name} = get_sbo_location $sbo if $compat32; + $locations{$name} = get_sbo_location ($sbo) if $compat32; unless ($non_int) { # if compat32 is TRUE, we need to see if the non-compat version exists. if ($compat32) { @@ -370,4 +367,4 @@ print_failures %failures; %failures = process_sbos $build_queue if exists $$build_queue[0]; print_failures %failures; -exit 0; \ No newline at end of file +exit 0; -- cgit v1.2.3 From 023d35c0c112c59cae7b32292c66343ea64311d9 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 08:45:27 -0600 Subject: changes to support get_sbo_location changes --- sboremove | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sboremove b/sboremove index f399fd9..c11e4c4 100755 --- a/sboremove +++ b/sboremove @@ -50,7 +50,7 @@ show_version and exit 0 if $vers; show_usage and exit 0 unless exists $ARGV[0]; my $rootpkg = $ARGV[0]; -my $test = get_sbo_location $rootpkg; +my $test = get_sbo_location ($rootpkg); die "Unable to locate $rootpkg in the SlackBuilds.org tree.\n" unless defined $test; @@ -146,7 +146,7 @@ for my $pkg (@$remove_queue) { chomp(my $viewrm = ); if ($viewrm =~ /^[Yy]/) { print "\n"; - my $locrm = get_sbo_location $pkg; + my $locrm = get_sbo_location ($pkg); $locrm .= '/README'; open(README, '<', $locrm) or die "could not open $locrm"; for my $line () { @@ -191,4 +191,4 @@ for my $instpkg (@confirmed) { say "All operations have completed successfully."; -exit 0; \ No newline at end of file +exit 0; -- cgit v1.2.3 From 35db9c2aaea8d7f7b211bc12609840ea2ef5ac64 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 08:48:49 -0600 Subject: use MAKEOPTS for -j instead of hacking the SlackBuild --- SBO-Lib/lib/SBO/Lib.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 4ad01e5..2eb996d 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -599,8 +599,6 @@ sub perform_sbo (%) { # set any changes we need to make to the .SlackBuild, setup the command $args{JOBS} = 0 if $args{JOBS} eq 'FALSE'; - $changes{make} = "-j $args{JOBS}" if $args{JOBS}; - if ($args{ARCH} eq 'x86_64' and ($args{C32} || $args{X32})) { if ($args{C32}) { @@ -610,8 +608,9 @@ sub perform_sbo (%) { } $cmd = '. /etc/profile.d/32dev.sh &&'; } - $cmd .= "/bin/sh $location/$sbo.SlackBuild"; - $cmd = "$args{OPTS} $cmd" if $args{OPTS}; + $cmd .= " $args{OPTS}" if $args{OPTS}; + $cmd .= " MAKEOPTS=\"-j$args{JOBS}\"" if $args{JOBS}; + $cmd .= " /bin/sh $location/$sbo.SlackBuild"; my $tempfh = tempfile (DIR => $tempdir); my $fn = get_tmp_extfn $tempfh; rewrite_slackbuild ( -- cgit v1.2.3 From b34346c933cee1a01a3df854becffea2d6f6333b Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 08:53:47 -0600 Subject: tee the running of the slackbuild instead of the tar and makepkg via editing the slackbuild --- SBO-Lib/lib/SBO/Lib.pm | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 2eb996d..d3ba865 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -457,30 +457,19 @@ sub check_multilib () { sub rewrite_slackbuild (%) { my %args = ( SLACKBUILD => '', - TEMPFN => '', CHANGES => {}, @_ ); - unless ($args{SLACKBUILD} && $args{TEMPFN}) { - script_error 'rewrite_slackbuild requires SLACKBUILD and TEMPFN.'; - } + $args{SLACKBUILD} or script_error 'rewrite_slackbuild requires SLACKBUILD.'; my $slackbuild = $args{SLACKBUILD}; my $changes = $args{CHANGES}; copy ($slackbuild, "$slackbuild.orig") or die "Unable to backup $slackbuild to $slackbuild.orig\n"; - my $tar_regex = qr/(un|)tar .*$/; - my $makepkg_regex = qr/makepkg/; my $libdir_regex = qr/^\s*LIBDIRSUFFIX="64"\s*$/; - my $make_regex = qr/^\s*make(| \Q||\E exit 1)$/; my $arch_regex = qr/\$VERSION-\$ARCH-\$BUILD/; # tie the slackbuild, because this is the easiest way to handle this. tie my @sb_file, 'Tie::File', $slackbuild; for my $line (@sb_file) { - # get the output of the tar and makepkg commands. hope like hell that v - # is specified among tar's arguments - if ($line =~ $tar_regex || $line =~ $makepkg_regex) { - $line = "$line | tee -a $args{TEMPFN}"; - } # then check for and apply any other %$changes if (exists $$changes{libdirsuffix}) { $line =~ s/64/$$changes{libdirsuffix}/ if $line =~ $libdir_regex; @@ -613,9 +602,9 @@ sub perform_sbo (%) { $cmd .= " /bin/sh $location/$sbo.SlackBuild"; my $tempfh = tempfile (DIR => $tempdir); my $fn = get_tmp_extfn $tempfh; + $cmd .= " | tee -a $fn"; rewrite_slackbuild ( SLACKBUILD => "$location/$sbo.SlackBuild", - TEMPFN => $fn, CHANGES => \%changes, ); chdir $location, my $out = system $cmd; -- cgit v1.2.3 From 04363616393265d572fb59181a1957f15a1124c1 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:20:44 -0600 Subject: $loc_store is a reference, call it correctly --- SBO-Lib/lib/SBO/Lib.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index d3ba865..92c3f4d 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -226,7 +226,7 @@ sub get_sbo_location { state $loc_store = {}; # if scalar context and we've already have the location, return it now. unless (wantarray) { - return $loc_store{$sbos[0]} if exists $loc_store{$sbos[0]}; + return $$loc_store{$sbos[0]} if exists $$loc_store{$sbos[0]}; } my %locations; my $fh = open_read $slackbuilds_txt; @@ -235,9 +235,9 @@ sub get_sbo_location { while (my $line = <$fh>) { if (my $loc = ($line =~ $regex)[0]) { # save what we found for later requests - $loc_store{$sbo} = "$config{SBO_HOME}$loc"; - return $loc_store{$sbo} unless wantarray; - $locations{$sbo} = $loc_store{$sbo}; + $$loc_store{$sbo} = "$config{SBO_HOME}$loc"; + return $$loc_store{$sbo} unless wantarray; + $locations{$sbo} = $$loc_store{$sbo}; } } seek $fh, 0, 0; -- cgit v1.2.3 From a486cef99ec7ad33329e1671533b28cf06980bae Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:21:38 -0600 Subject: @sbos is an array, dont call it as an array ref --- SBO-Lib/lib/SBO/Lib.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 92c3f4d..adea1b3 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -230,7 +230,7 @@ sub get_sbo_location { } my %locations; my $fh = open_read $slackbuilds_txt; - for my $sbo (@$sbos) { + for my $sbo (@sbos) { my $regex = qr#LOCATION:\s+\.(/[^/]+/\Q$sbo\E)$#; while (my $line = <$fh>) { if (my $loc = ($line =~ $regex)[0]) { -- cgit v1.2.3 From d7c8d7672c954550a59074382413f89aa3586134 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:22:24 -0600 Subject: remove last bit of leftover crud from the make -j# thing --- SBO-Lib/lib/SBO/Lib.pm | 3 --- 1 file changed, 3 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index adea1b3..b829a3c 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -474,9 +474,6 @@ sub rewrite_slackbuild (%) { if (exists $$changes{libdirsuffix}) { $line =~ s/64/$$changes{libdirsuffix}/ if $line =~ $libdir_regex; } - if (exists $$changes{make}) { - $line =~ s/make/make $$changes{make}/ if $line =~ $make_regex; - } if (exists $$changes{arch_out}) { $line =~ s/\$ARCH/$$changes{arch_out}/ if $line =~ $arch_regex; } -- cgit v1.2.3 From 32a918f88842deab5fedaa7671d5c343faacd26c Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:23:22 -0600 Subject: fixes for changes to get_sbo_location --- t/test.t | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/t/test.t b/t/test.t index 8ff06f8..972602c 100755 --- a/t/test.t +++ b/t/test.t @@ -64,9 +64,9 @@ for my $key (keys @$installed) { print "completed pseudo-random testing of get_installed_sbos \n"; # 19-20, get_sbo_location tests -is (get_sbo_location 'nginx', "$sbo_home/network/nginx", +is (get_sbo_location ('nginx'), "$sbo_home/network/nginx", 'get_sbo_location is good'); -is (get_sbo_location 'omgwtfbbq', undef, +is (get_sbo_location ('omgwtfbbq'), undef, 'get_sbo_location returns false with not-an-sbo input'); # 21-22, get_available_updates tests -- cgit v1.2.3 From 0513f8c31e01f9696c11babcaf44c55a0fe9199c Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:25:53 -0600 Subject: get_sbo_location should return undef if it finds nothing --- SBO-Lib/lib/SBO/Lib.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index b829a3c..b34ba8f 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -243,7 +243,7 @@ sub get_sbo_location { seek $fh, 0, 0; } close $fh; - return %locations; + return %locations > 0 ? %locations : undef; } # pull the sbo name from a $location: $config{SBO_HOME}/system/wine, etc. -- cgit v1.2.3 From f32a8fb3fbab6ea530335e4437632c66ace06d8b Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:27:19 -0600 Subject: fix to last fix --- SBO-Lib/lib/SBO/Lib.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index b34ba8f..e7c8424 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -243,7 +243,7 @@ sub get_sbo_location { seek $fh, 0, 0; } close $fh; - return %locations > 0 ? %locations : undef; + return keys %locations > 0 ? %locations : undef; } # pull the sbo name from a $location: $config{SBO_HOME}/system/wine, etc. -- cgit v1.2.3 From c32526202bb0870e1c9fc2402f303f695777eec1 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:30:38 -0600 Subject: fix to support changes in rewrite_slackbuild --- t/test.t | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/t/test.t b/t/test.t index 972602c..f556643 100755 --- a/t/test.t +++ b/t/test.t @@ -226,18 +226,6 @@ $expected_out = "55c55 < LIBDIRSUFFIX=\"64\" --- > LIBDIRSUFFIX=\"\" -67c67 -< tar xvf \$CWD/\$PRGNAM-\$VERSION.tar.bz2 ---- -> tar xvf \$CWD/\$PRGNAM-\$VERSION.tar.bz2 | tee -a $tempfn -87c87 -< make ---- -> make -j 5 -103c103 -< /sbin/makepkg -l y -c n \$OUTPUT/\$PRGNAM-\$VERSION-\$ARCH-\$BUILD\$TAG.\${PKGTYPE:-tgz} ---- -> /sbin/makepkg -l y -c n \$OUTPUT/\$PRGNAM-\$VERSION-i486-\$BUILD\$TAG.\${PKGTYPE:-tgz} | tee -a $tempfn "; is (diff ("$slackbuild.orig", $slackbuild, {STYLE => 'OldStyle'}), $expected_out, 'all changed lines rewritten correctly'); -- cgit v1.2.3 From a7657a05aa4bd3fa649cbcf557b772fb6cf71e00 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:34:55 -0600 Subject: more fixes for changes in rewrite_slackbuild --- t/test.t | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/t/test.t b/t/test.t index f556643..b224e47 100755 --- a/t/test.t +++ b/t/test.t @@ -204,17 +204,6 @@ my %changes = (); is (rewrite_slackbuild (SLACKBUILD => $slackbuild, TEMPFN => $tempfn, CHANGES => \%changes), 1, 'rewrite_slackbuild with no %changes good'); ok (-f "$slackbuild.orig", 'rewrite_slackbuild backing up original is good.'); -my $expected_out = "67c67 -< tar xvf \$CWD/\$PRGNAM-\$VERSION.tar.bz2 ---- -> tar xvf \$CWD/\$PRGNAM-\$VERSION.tar.bz2 | tee -a $tempfn -103c103 -< /sbin/makepkg -l y -c n \$OUTPUT/\$PRGNAM-\$VERSION-\$ARCH-\$BUILD\$TAG.\${PKGTYPE:-tgz} ---- -> /sbin/makepkg -l y -c n \$OUTPUT/\$PRGNAM-\$VERSION-\$ARCH-\$BUILD\$TAG.\${PKGTYPE:-tgz} | tee -a $tempfn -"; -is (diff ("$slackbuild.orig", $slackbuild, {STYLE => 'OldStyle'}), - $expected_out, 'tar line rewritten correctly'); is (revert_slackbuild $slackbuild, 1, 'revert_slackbuild is good'); $changes{libdirsuffix} = ''; $changes{make} = '-j 5'; @@ -222,10 +211,14 @@ $changes{arch_out} = 'i486'; is (rewrite_slackbuild (SLACKBUILD => $slackbuild, TEMPFN => $tempfn, CHANGES => \%changes), 1, 'rewrite_slackbuild with all %changes good'); ok (-f "$slackbuild.orig", 'rewrite_slackbuild backing up original is good.'); -$expected_out = "55c55 +my $expected_out = "55c55 < LIBDIRSUFFIX=\"64\" --- > LIBDIRSUFFIX=\"\" +103c103 +< /sbin/makepkg -l y -c n \$OUTPUT/\$PRGNAM-\$VERSION-\$ARCH-\$BUILD\$TAG.\${PKGTYPE:-tgz} +--- +> /sbin/makepkg -l y -c n \$OUTPUT/\$PRGNAM-\$VERSION-i486-\$BUILD\$TAG.\${PKGTYPE:-tgz} "; is (diff ("$slackbuild.orig", $slackbuild, {STYLE => 'OldStyle'}), $expected_out, 'all changed lines rewritten correctly'); -- cgit v1.2.3 From a636f1ac70ad26f4b547b58c3916ca11f2d0ebbe Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:50:16 -0600 Subject: call get_sbo_location correctly for new changes --- SBO-Lib/lib/SBO/Lib.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index e7c8424..9774bc9 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -297,7 +297,7 @@ sub get_available_updates () { my @updates; my $pkg_list = get_installed_sbos; FIRST: for my $key (keys @$pkg_list) { - my $location = get_sbo_location $$pkg_list[$key]{name}; + my $location = get_sbo_location ($$pkg_list[$key]{name}); # if we can't find a location, assume invalid and skip next FIRST unless defined $location; my $version = get_sbo_version $location; @@ -733,7 +733,7 @@ sub add_to_queue ($) { my $sbo = \${$args}{NAME}; return unless $$sbo; unshift @$args{QUEUE}, $$sbo; - my $location = get_sbo_location $$sbo; + my $location = get_sbo_location ($$sbo); return unless $location; my $requires = get_from_info (LOCATION => $location, GET => 'REQUIRES'); FIRST: for my $req (@$requires) { -- cgit v1.2.3 From 9731880d4c536ed0d5d4d5df15caf2912ede85cf Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:50:57 -0600 Subject: re-order get_requires tests --- t/test.t | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/t/test.t b/t/test.t index b224e47..92dc410 100755 --- a/t/test.t +++ b/t/test.t @@ -285,16 +285,15 @@ $SBO::Lib::no_reqs = 0; # no longer valid - there are no longer any circular requirements. #ok (! (get_requires 'zarafa', "$sbo_home/network/zarafa"), # 'get_requires good for circular requirements'); -ok (! (get_requires 'smc', "$sbo_home/games/smc"), - 'get_requires good for REQUIRES="%README%"'); -ok (! (get_requires 'krb5', "$sbo_home/network/krb5"), - 'get_requires good for REQUIRES=""'); -my $reqs = get_requires 'matchbox-desktop', - "$sbo_home/audio/gmpc"; +my $reqs = get_requires 'gmpc', "$sbo_home/audio/gmpc"; my $say = 'get_requires good for normal req list'; is ($$reqs[0], 'gob2', $say); is ($$reqs[1], 'libmpd', $say); is ($$reqs[2], 'vala', $say); +ok (! (get_requires 'smc', "$sbo_home/games/smc"), + 'get_requires good for REQUIRES="%README%"'); +ok (! (get_requires 'krb5', "$sbo_home/network/krb5"), + 'get_requires good for REQUIRES=""'); # 82-85, get_user_group tests $fh = open_read "$sbo_home/network/nagios/README"; -- cgit v1.2.3 From ab50ab7cba6054047f51b196b6bc8d9bc359e854 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 10:51:26 -0600 Subject: fix for get_sbo_location changes, all unit tests now pass --- sboupgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sboupgrade b/sboupgrade index fae66ab..87c9fce 100755 --- a/sboupgrade +++ b/sboupgrade @@ -95,7 +95,7 @@ slackbuilds_or_fetch; # time verifying each item is a valid slackbuild my %locations; for my $sbo_name (@ARGV) { - $locations{$sbo_name} = get_sbo_location $sbo_name; + $locations{$sbo_name} = get_sbo_location ($sbo_name); die "Unable to locate $sbo_name in the SlackBuilds.org tree.\n" unless defined $locations{$sbo_name}; } @@ -118,8 +118,8 @@ sub get_requires ($$) { return if '%README%' ~~ @$requires; # do nothing if there's a circular requirement FIRST: for my $req (@$requires) { - my $req_req = get_from_info (LOCATION => get_sbo_location $req, - GET => 'REQUIRES'); + my $location = get_sbo_location ($req); + my $req_req = get_from_info (LOCATION => $location, GET => 'REQUIRES'); if ($sbo ~~ @$req_req) { say "I am seeing circular requirements between $sbo and $req."; say "Therefore, I am not going to handle requirements for $sbo."; -- cgit v1.2.3 From 9d47b96f516e9418edf2ed2db39c56faff62fd02 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 11:02:10 -0600 Subject: tests added for new get_sbo_location capabilities (all fail) --- t/test.t | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/t/test.t b/t/test.t index 92dc410..d3e2017 100755 --- a/t/test.t +++ b/t/test.t @@ -63,11 +63,21 @@ for my $key (keys @$installed) { } print "completed pseudo-random testing of get_installed_sbos \n"; -# 19-20, get_sbo_location tests +# get_sbo_location tests is (get_sbo_location ('nginx'), "$sbo_home/network/nginx", 'get_sbo_location is good'); is (get_sbo_location ('omgwtfbbq'), undef, 'get_sbo_location returns false with not-an-sbo input'); +my @finds = qw(nginx gmpc); +my @locs = get_sbo_location (@finds); +is ($locs[0], "$sbo_home/network/nginx", + 'get_sbo_location passed array #1 good'); +is ($locs[1], "$sbo_home/audio/gmpc", 'get_sbo_location passed array #2 good'); +@locs = get_sbo_location (\@finds); +is ($locs[0], "$sbo_home/network/nginx", + 'get_sbo_location passed array ref #1 good'); +is ($locs[1], "$sbo_home/audio/gmpc", + 'get_sbo_location passed array ref #2 good'); # 21-22, get_available_updates tests my $updates = get_available_updates; -- cgit v1.2.3 From 3e13816918e42d1a2946f2bd2b6f9b93e865eb16 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 11:06:40 -0600 Subject: fix so that new get_sbo_location tests are actually done correctly - fixes two of the four --- t/test.t | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/t/test.t b/t/test.t index d3e2017..c52669d 100755 --- a/t/test.t +++ b/t/test.t @@ -69,14 +69,14 @@ is (get_sbo_location ('nginx'), "$sbo_home/network/nginx", is (get_sbo_location ('omgwtfbbq'), undef, 'get_sbo_location returns false with not-an-sbo input'); my @finds = qw(nginx gmpc); -my @locs = get_sbo_location (@finds); -is ($locs[0], "$sbo_home/network/nginx", +my %locs = get_sbo_location (@finds); +is ($locs{nginx}, "$sbo_home/network/nginx", 'get_sbo_location passed array #1 good'); -is ($locs[1], "$sbo_home/audio/gmpc", 'get_sbo_location passed array #2 good'); -@locs = get_sbo_location (\@finds); -is ($locs[0], "$sbo_home/network/nginx", +is ($locs{gmpc}, "$sbo_home/audio/gmpc", 'get_sbo_location passed array #2 good'); +%locs = get_sbo_location (\@finds); +is ($locs{nginx}, "$sbo_home/network/nginx", 'get_sbo_location passed array ref #1 good'); -is ($locs[1], "$sbo_home/audio/gmpc", +is ($locs{gmpc}, "$sbo_home/audio/gmpc", 'get_sbo_location passed array ref #2 good'); # 21-22, get_available_updates tests -- cgit v1.2.3 From d65db2b251e09a1f56bec3aa09ac764e7c7f9d6f Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 11:11:58 -0600 Subject: fix to check-and-dereference-array-ref logic. passes tests. --- SBO-Lib/lib/SBO/Lib.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 9774bc9..c579e67 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -222,7 +222,10 @@ sub get_inst_names ($) { sub get_sbo_location { exists $_[0] or script_error 'get_sbo_location requires an argument.'; my @sbos = @_; - @sbos = $sbos[0] if ref $sbos[0] eq 'ARRAY'; + if (ref $sbos[0] eq 'ARRAY') { + my $tmp = $sbos[0]; + @sbos = @$tmp; + } state $loc_store = {}; # if scalar context and we've already have the location, return it now. unless (wantarray) { -- cgit v1.2.3 From 7697c34d09d9e8d225e9be4a9a7efabd16e3306c Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 12:37:45 -0600 Subject: ditch prototype for compare_md5s --- SBO-Lib/lib/SBO/Lib.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index c579e67..3968c66 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -398,7 +398,7 @@ sub compute_md5sum ($) { return $md5sum; } -sub compare_md5s ($$) { +sub compare_md5s { exists $_[1] or script_error 'compare_md5s requires two arguments.'; my ($first, $second) = @_; return $first eq $second ? 1 : undef; @@ -413,7 +413,7 @@ sub verify_distfile ($$) { return unless -d $distfiles; return unless -f $filename; my $md5sum = compute_md5sum $filename; - return compare_md5s $info_md5sum, $md5sum; + return compare_md5s ($info_md5sum, $md5sum); } # for a given distfile, attempt to retrieve it and, if successful, check its @@ -428,7 +428,7 @@ sub get_distfile ($$) { die "Unable to wget $link\n"; my $md5sum = compute_md5sum $filename; # can't do anything if the link in the .info doesn't lead to a good d/l - compare_md5s $md5sum, $exp_md5 or die "md5sum failure for $filename.\n"; + compare_md5s ($md5sum, $exp_md5) or die "md5sum failure for $filename.\n"; return 1; } -- cgit v1.2.3 From 1c0c886cfd56905e44fa87095ba53e854df6895c Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 12:41:40 -0600 Subject: rename $multi variable to more descriptive $multilib --- SBO-Lib/lib/SBO/Lib.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 3968c66..3190ad1 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -641,18 +641,18 @@ sub do_slackbuild (%) { my $location = $args{LOCATION}; my $sbo = get_sbo_from_loc $location; my $arch = get_arch; - my $multi = check_multilib; + my $multilib = check_multilib; my $version = get_sbo_version $location; my $x32; # ensure x32 stuff is set correctly, or that we're setup for it if ($args{COMPAT32}) { - die "compat32 requires multilib.\n" unless $multi; + die "compat32 requires multilib.\n" unless $multilib; die "compat32 requires /usr/sbin/convertpkg-compat32.\n" unless -f '/usr/sbin/convertpkg-compat32'; } else { if ($arch eq 'x86_64') { $x32 = check_x32 $args{LOCATION}; - if ($x32 && ! $multi) { + if ($x32 && ! $multilib) { die "$sbo is 32-bit which requires multilib on x86_64.\n"; } } -- cgit v1.2.3 From 9000e498363367a97e01f5e116df6be20c82c497 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 12:53:44 -0600 Subject: remove compare_md5s sub, call verify_distfile from get_distfile instead of comparing in both places --- SBO-Lib/lib/SBO/Lib.pm | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 3190ad1..b1aa75c 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -398,12 +398,6 @@ sub compute_md5sum ($) { return $md5sum; } -sub compare_md5s { - exists $_[1] or script_error 'compare_md5s requires two arguments.'; - my ($first, $second) = @_; - return $first eq $second ? 1 : undef; -} - # for a given distfile, see whether or not it exists, and if so, if its md5sum # matches the sbo's .info file sub verify_distfile ($$) { @@ -413,14 +407,14 @@ sub verify_distfile ($$) { return unless -d $distfiles; return unless -f $filename; my $md5sum = compute_md5sum $filename; - return compare_md5s ($info_md5sum, $md5sum); + return $info_md5 eq $md5sum ? 1 : 0; } # for a given distfile, attempt to retrieve it and, if successful, check its # md5sum against that in the sbo's .info file sub get_distfile ($$) { exists $_[1] or script_error 'get_distfile requires an argument'; - my ($link, $exp_md5) = @_; + my ($link, $info_md5) = @_; my $filename = get_filename_from_link $link; mkdir $distfiles unless -d $distfiles; chdir $distfiles; @@ -428,7 +422,8 @@ sub get_distfile ($$) { die "Unable to wget $link\n"; my $md5sum = compute_md5sum $filename; # can't do anything if the link in the .info doesn't lead to a good d/l - compare_md5s ($md5sum, $exp_md5) or die "md5sum failure for $filename.\n"; + verify_distfile ($link, $info_md5) ? return 1 + : die "md5sum failure for $filename.\n"; return 1; } -- cgit v1.2.3 From fcfc0827c11403f92657e0f279d17646cef213ed Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 12:54:55 -0600 Subject: remove compare_md5s tests --- t/test.t | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/t/test.t b/t/test.t index c52669d..1c73822 100755 --- a/t/test.t +++ b/t/test.t @@ -168,11 +168,11 @@ is (get_src_dir $tempfh, 'laptop-mode-tools_1.60', 'get_src_dir good'); is (get_pkg_name $tempfh, 'skype-2.2.0.35-i486-1_SBo.tgz', 'get_pkg_name good'); close $tempfh; -# 42, check_distfiles test +# check_distfiles test %downloads = get_sbo_downloads (LOCATION => "$sbo_home/system/wine", 32 => 1); is ((check_distfiles %downloads), 1, 'check_distfiles good'); -# 43-45, check_home tests +# check_home tests system ('sudo /usr/sbin/sboconfig -s /home/d4wnr4z0r/opt_sbo') == 0 or die "unable to set sboconfig -s\n"; read_config; @@ -184,19 +184,13 @@ system ("sudo /usr/sbin/sboconfig -s $sbo_home") == 0 or die read_config; rmdir "/home/d4wnr4z0r/opt_sbo"; -# 46-47 get_sbo_from_loc tests +# get_sbo_from_loc tests is (get_sbo_from_loc '/home/d4wnr4z0r/sbo.git/system/ifuse', 'ifuse', 'get_sbo_from_loc returns correctly with valid input'); ok (! get_sbo_from_loc 'omg_wtf_bbq', 'get_sbo_from_loc returns false with invalid input'); -# 48-49, compare_md5s tests -is (compare_md5s ('omgwtf123456789', 'omgwtf123456789'), 1, - 'compare_md5s returns true for matching parameters'); -is (compare_md5s ('omgwtf123456788', 'somethingelsebbq'), undef, - 'compare_md5s returns false for not-matching parameters'); - -# 50, get_distfile tests +# get_distfile tests my $distfile = "$sbo_home/distfiles/Sort-Versions-1.5.tar.gz"; unlink $distfile if -f $distfile; is (get_distfile @@ -204,7 +198,7 @@ is (get_distfile '5434f948fdea6406851c77bebbd0ed19'), 1, 'get_distfile is good'); unlink $distfile; -# 51-58, rewrite_slackbuilds/revert_slackbuild tests +# rewrite_slackbuilds/revert_slackbuild tests my $rewrite_dir = tempdir (CLEANUP => 1); copy ("$sbo_home/system/ifuse/ifuse.SlackBuild", $rewrite_dir); my $slackbuild = "$rewrite_dir/ifuse.SlackBuild"; -- cgit v1.2.3 From e8d07426f592040e945709c1bc574ea3283343f2 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 12:55:53 -0600 Subject: rename $info_md5sum to equally clear but more concise $info_md5 --- SBO-Lib/lib/SBO/Lib.pm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index b1aa75c..2f5eac6 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -402,7 +402,7 @@ sub compute_md5sum ($) { # matches the sbo's .info file sub verify_distfile ($$) { exists $_[1] or script_error 'verify_distfile requires two arguments.'; - my ($link, $info_md5sum) = @_; + my ($link, $info_md5) = @_; my $filename = get_filename_from_link $link; return unless -d $distfiles; return unless -f $filename; @@ -420,7 +420,6 @@ sub get_distfile ($$) { chdir $distfiles; system ("wget --no-check-certificate $link") == 0 or die "Unable to wget $link\n"; - my $md5sum = compute_md5sum $filename; # can't do anything if the link in the .info doesn't lead to a good d/l verify_distfile ($link, $info_md5) ? return 1 : die "md5sum failure for $filename.\n"; -- cgit v1.2.3 From 89e350f22d044f8073670db354832e3043e710e6 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 13:30:41 -0600 Subject: removed superfluous "return unless -d $distfiles;" from verify_distfile subroutine --- SBO-Lib/lib/SBO/Lib.pm | 1 - 1 file changed, 1 deletion(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 2f5eac6..b1ce1b7 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -404,7 +404,6 @@ sub verify_distfile ($$) { exists $_[1] or script_error 'verify_distfile requires two arguments.'; my ($link, $info_md5) = @_; my $filename = get_filename_from_link $link; - return unless -d $distfiles; return unless -f $filename; my $md5sum = compute_md5sum $filename; return $info_md5 eq $md5sum ? 1 : 0; -- cgit v1.2.3 From 9ba90c245c82b5ff12fd0a9301440c17339fe4c0 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 13:34:14 -0600 Subject: comment typo fix: computer -> compute --- SBO-Lib/lib/SBO/Lib.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index b1ce1b7..3b1e2a5 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -387,7 +387,7 @@ sub get_filename_from_link ($) { return $filename; } -# for a given file, computer its md5sum +# for a given file, compute its md5sum sub compute_md5sum ($) { -f $_[0] or script_error 'compute_md5sum requires a file argument.'; my $fh = open_read shift; -- cgit v1.2.3 From 5b00d84752b3d3ad32933afcf6a2a84461fb13af Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 13:44:03 -0600 Subject: stop pretending its feasible to keep track of the number of tests, prefer is to ok wherever possible --- t/test.t | 90 +++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 47 insertions(+), 43 deletions(-) diff --git a/t/test.t b/t/test.t index 1c73822..4170ef0 100755 --- a/t/test.t +++ b/t/test.t @@ -4,7 +4,7 @@ use 5.16.0; use strict; use warnings FATAL => 'all'; use File::Temp qw(tempdir tempfile); -use Test::More tests => 90; +use Test::More; use File::Copy; use Text::Diff; use lib "."; @@ -12,12 +12,12 @@ use SBO::Lib; my $sbo_home = '/usr/sbo'; -# 1, open_read, open_fh tests +# open_read, open_fh tests my $fh = open_read ('./test.t'); is (ref $fh, 'GLOB', 'open_read works'); close $fh; -# 2-7, config settings tests; +# config settings tests; ok (defined $SBO::Lib::tempdir, '$tempdir is defined'); is ($SBO::Lib::config{DISTCLEAN}, 'FALSE', 'config{DISTCLEAN} is good'); is ($SBO::Lib::config{JOBS}, 2, 'config{JOBS} is good'); @@ -25,13 +25,13 @@ is ($SBO::Lib::config{NOCLEAN}, 'FALSE', 'config{NOCLEAN} is good'); is ($SBO::Lib::config{PKG_DIR}, 'FALSE', 'config{PKG_DIR} is good'); is ($SBO::Lib::config{SBO_HOME}, "$sbo_home", 'config{SBO_HOME} is good'); -# 8, show_version test +# show_version test is (show_version, 1, 'show_version is good'); -# 9, get_slack_version test +# get_slack_version test is (get_slack_version, '14.0', 'get_slack_version is good'); -# 10-11, chk_slackbuilds_txt tests +# chk_slackbuilds_txt tests is (chk_slackbuilds_txt, 1, 'chk_slackbuilds_txt is good'); move ("$sbo_home/SLACKBUILDS.TXT", "$sbo_home/SLACKBUILDS.TXT.moved"); is (chk_slackbuilds_txt, undef, @@ -41,10 +41,10 @@ move ("$sbo_home/SLACKBUILDS.TXT.moved", "$sbo_home/SLACKBUILDS.TXT"); #ok (rsync_sbo_tree == 1, 'rsync_sbo_tree is good'); #ok (update_tree == 1, 'update_tree is good'); -# 12, slackbuilds_or_fetch test +# slackbuilds_or_fetch test is (slackbuilds_or_fetch, 1, 'slackbuilds_or_fetch is good'); -# 13-18, get_installed_sbos test +# get_installed_sbos test print "pseudo-random sampling of get_installed_sbos output...\n"; my $installed = get_installed_sbos; for my $key (keys @$installed) { @@ -79,7 +79,7 @@ is ($locs{nginx}, "$sbo_home/network/nginx", is ($locs{gmpc}, "$sbo_home/audio/gmpc", 'get_sbo_location passed array ref #2 good'); -# 21-22, get_available_updates tests +# get_available_updates tests my $updates = get_available_updates; for my $key (keys @$updates) { is ($$updates[$key]{installed}, '1.15', @@ -90,10 +90,10 @@ for my $key (keys @$updates) { 'mutagen'; } -# 23, get_arch test +# get_arch test is (get_arch, 'x86_64', 'get_arch is good'); -# 24-25, get_download_info tests +# get_download_info tests my %dl_info = get_download_info (LOCATION => "$sbo_home/system/wine", X64 => 0); my $link = 'http://downloads.sf.net/wine/source/1.4/wine-1.4.1.tar.bz2'; is ($dl_info{$link}, '0c28702ed478df7a1c097f3a9c4cabd6', @@ -102,7 +102,7 @@ $link = 'http://www.unrealize.co.uk/source/dibeng-max-2010-11-12.zip'; is ($dl_info{$link}, '97159d77631da13952fe87e846cf1f3b', 'get_download_info test 02 good.'); -# 26-28, get_sbo_downloads tests +# get_sbo_downloads tests %dl_info = get_sbo_downloads (LOCATION => "$sbo_home/system/wine"); $link = 'http://downloads.sf.net/wine/source/1.4/wine-1.4.1.tar.bz2'; is ($dl_info{$link}, '0c28702ed478df7a1c097f3a9c4cabd6', @@ -115,40 +115,40 @@ $link = 'http://www.libimobiledevice.org/downloads/ifuse-1.1.1.tar.bz2'; is ($downloads{$link}, '8d528a79de024b91f12f8ac67965c37c', 'get_sbo_downloads test 03 good.'); -# 29, get_filename_from_link test +# get_filename_from_link test is (get_filename_from_link 'http://www.libimobiledevice.org/downloads/ifuse-1.1.1.tar.bz2', "$sbo_home/distfiles/ifuse-1.1.1.tar.bz2", 'get_file_from_link good'); is (get_filename_from_link 'adf;lkajsdfaksjdfalsdjfalsdkfjdsfj', undef, 'get_filename_from_link good with invalid input'); -# 31, compute_md5sum test +# compute_md5sum test is (compute_md5sum "$sbo_home/distfiles/laptop-mode-tools_1.61.tar.gz", '6685af5dbb34c3d51ca27933b58f484e', 'compute_md5sum good'); -# 32, verify_distfile test +# verify_distfile test is ((verify_distfile "$sbo_home/distfiles/laptop-mode-tools_1.61.tar.gz", '6685af5dbb34c3d51ca27933b58f484e'), 1, 'verify_distfile good'); -# 33, get_sbo_version test +# get_sbo_version test is (get_sbo_version "$sbo_home/system/wine", '1.4.1', 'get_sbo_version good'); -# 34, get_symlink_from_filename test +# get_symlink_from_filename test is ((get_symlink_from_filename "$sbo_home/distfiles/laptop-mode-tools_1.61.tar.gz", "$sbo_home/system/laptop-mode-tools"), "$sbo_home/system/laptop-mode-tools/laptop-mode-tools_1.61.tar.gz", 'get_symlink_from_filename good'); -# 35-36, check_x32 tests +# check_x32 tests ok (check_x32 "$sbo_home/system/wine", 'check_x32 true for 32-bit only wine'); ok (!(check_x32 "$sbo_home/system/ifuse"), 'check_x32 false for not-32-bit-only ifuse'); -# 37, check_multilib tests +# check_multilib tests ok (check_multilib, 'check_multilib good'); -# 38-39, create_symlinks tests +# create_symlinks tests %downloads = get_sbo_downloads (LOCATION => "$sbo_home/system/wine", 32 => 1); my @symlinks = create_symlinks "$sbo_home/system/wine", %downloads; is ($symlinks[0], "$sbo_home/system/wine/wine-1.4.1.tar.bz2", @@ -156,7 +156,7 @@ is ($symlinks[0], "$sbo_home/system/wine/wine-1.4.1.tar.bz2", is ($symlinks[1], "$sbo_home/system/wine/dibeng-max-2010-11-12.zip", '$symlinks[1] good for create_symlinks'); -# 40-41, grok_temp_file, get_src_dir/get_pkg_name tests +# grok_temp_file, get_src_dir/get_pkg_name tests my $tempdir = tempdir (CLEANUP => 1); my $tempfh = tempfile (DIR => $tempdir); my $lmt = 'laptop-mode-tools_1.60'; @@ -228,7 +228,7 @@ is (diff ("$slackbuild.orig", $slackbuild, {STYLE => 'OldStyle'}), $expected_out, 'all changed lines rewritten correctly'); is (revert_slackbuild $slackbuild, 1, 'revert_slackbuild is good again'); -# 59-61, get_from_info tests +# get_from_info tests my $test_loc = "$sbo_home/system/ifuse"; my %params = (LOCATION => $test_loc); my $info = get_from_info (%params, GET => 'VERSION'); @@ -239,7 +239,7 @@ is ($$info[0], 'http://www.libimobiledevice.org', $info = get_from_info (%params, GET => 'DOWNLOAD_x86_64'); is ($$info[0], "", 'get_from_info GET => DOWNLOAD_x86_64 is good'); -# 62-64, get_update_list tests +# get_update_list tests my $listing = get_update_list; s/\s//g for @$listing; for my $item (@$listing) { @@ -251,14 +251,14 @@ for my $item (@$listing) { 'get_update_list output good for atkmm') if $item =~ /^atkmm/; } -# 65, remove_stuff test - can only really test for invalid input +# remove_stuff test - can only really test for invalid input is (remove_stuff '/omg/wtf/bbq', 1, 'remove_stuff good for invalid input'); -# 66, config_write test +# config_write test is (config_write ('OMG', 'WTF'), undef, 'config_write returned undef correctly'); -# 67-74, perform_search tests +# perform_search tests my $findings = perform_search 'desktop'; for my $found (@$findings) { for my $key (keys %$found) { @@ -279,12 +279,12 @@ for my $found (@$findings) { } } -# 75, get_inst_names test +# get_inst_names test $installed = get_installed_sbos; my $inst_names = get_inst_names $installed; ok ('zdoom' ~~ @$inst_names, 'get_inst_names is good'); -# 76-81, get_reqs tests +# get_reqs tests $SBO::Lib::no_reqs = 0; # no longer valid - there are no longer any circular requirements. #ok (! (get_requires 'zarafa', "$sbo_home/network/zarafa"), @@ -299,7 +299,7 @@ ok (! (get_requires 'smc', "$sbo_home/games/smc"), ok (! (get_requires 'krb5', "$sbo_home/network/krb5"), 'get_requires good for REQUIRES=""'); -# 82-85, get_user_group tests +# get_user_group tests $fh = open_read "$sbo_home/network/nagios/README"; my $readme = do {local $/; <$fh>}; close $fh; @@ -315,7 +315,7 @@ is ($$cmds[0], 'groupadd -g 210 clamav', 'get_user_group good for groupadd'); is ($$cmds[1], 'useradd -u 256 -d /dev/null -s /bin/false -g clamav havp', 'get_user_group good for useradd'); -# 86-87, get_opts test +# get_opts test $fh = open_read "$sbo_home/games/vbam/README"; $readme = do {local $/; <$fh>}; close $fh; @@ -325,28 +325,32 @@ $readme = do {local $/; <$fh>}; close $fh; ok (! (get_opts $readme), 'get_opts good where README does not define opts'); -# 88-90, clean_reqs tests +# clean_reqs tests $SBO::Lib::compat32 = 0; $reqs = get_requires "zdoom", "$sbo_home/games/zdoom"; $reqs = clean_reqs $reqs; ok (! $$reqs[0], 'clean_reqs good for already installed reqs'); $reqs = get_requires 'gmpc', "$sbo_home/audio/gmpc"; $reqs = clean_reqs $reqs; -ok ($$reqs[0] eq 'gob2', 'clean_reqs good for un/installed reqs.'); -ok ($$reqs[1] eq 'libmpd', 'clean_reqs good for un/installed reqs.'); +is ($$reqs[0], 'gob2', 'clean_reqs good for un/installed reqs.'); +is ($$reqs[1], 'libmpd', 'clean_reqs good for un/installed reqs.'); my $warnings = {()};; my $queue = get_build_queue ['zdoom', 'bsnes', 'spring'], $warnings; my $count = @$queue; -ok ($count == 10, 'get_build_queue returns correct amount for multiple sbos'); -ok ($$queue[0] eq 'jdk', 'get_build_queue first entry correct for multiple sbos'); -ok ($$queue[2] eq 'OpenAL', 'get_build_queue third entry correct for multiple sbos'); -ok ($$queue[4] eq 'spring', 'get_build_queue fifth entry correct for multiple sbos'); -ok ($$queue[6] eq 'fmodapi', 'get_build_queue seventh entry correct for multiple sbos'); -ok ($$queue[8] eq 'TiMidity++', 'get_build_queue ninth entry correct for multiple sbos'); +is ($count, 10, 'get_build_queue returns correct amount for multiple sbos'); +is ($$queue[0], 'jdk', 'get_build_queue first entry correct for multiple sbos'); +is ($$queue[2], 'OpenAL', 'get_build_queue third entry correct for multiple sbos'); +is ($$queue[4], 'spring', 'get_build_queue fifth entry correct for multiple sbos'); +is ($$queue[6], 'fmodapi', 'get_build_queue seventh entry correct for multiple sbos'); +is ($$queue[8], 'TiMidity++', 'get_build_queue ninth entry correct for multiple sbos'); $queue = get_build_queue ['zdoom'], $warnings; $count = @$queue; -ok ($count == 5, 'get_build_queue returns correct amount for single sbo'); -ok ($$queue[0] eq 'p7zip', 'get_build_queue first entry correct for single sbo'); -ok ($$queue[2] eq 'eawpats', 'get_build_queue third entry correct for single sbo'); -ok ($$queue[4] eq 'zdoom', 'get_build_queue fifth entry correct for single sbo'); +is ($count, 5, 'get_build_queue returns correct amount for single sbo'); +is ($$queue[0], 'p7zip', 'get_build_queue first entry correct for single sbo'); +is ($$queue[2], 'eawpats', 'get_build_queue third entry correct for single sbo'); +is ($$queue[4], 'zdoom', 'get_build_queue fifth entry correct for single sbo'); + + +# end of tests. +done_testing(); -- cgit v1.2.3 From b44271a81f96a195c2f7540b86899e00f5028b89 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 13:50:02 -0600 Subject: clean up a comment and remove so superfluous code --- SBO-Lib/lib/SBO/Lib.pm | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 3b1e2a5..ba7eb19 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -329,13 +329,7 @@ sub get_download_info (%) { $downs = get_from_info (LOCATION => $args{LOCATION}, GET => $get); # did we get nothing back, or UNSUPPORTED/UNTESTED? if ($args{X64}) { - my $nothing; - if (! $$downs[0]) { - $nothing++; - } elsif ($$downs[0] =~ qr/^UN(SUPPOR|TES)TED$/) { - $nothing++; - } - if ($nothing) { + if (! $$downs[0] || $$downs[0] =~ qr/^UN(SUPPOR|TES)TED$/) { $args{X64} = 0; $downs = get_from_info (LOCATION => $args{LOCATION}, GET => 'DOWNLOAD'); @@ -377,7 +371,7 @@ sub get_sbo_downloads (%) { return %dl_info; } -# given a link, grab the filename from the end of it +# given a link, grab the filename from it and prepend $distfiles sub get_filename_from_link ($) { exists $_[0] or script_error 'get_filename_from_link requires an argument'; my $fn = shift; -- cgit v1.2.3 From 1f448412a2dadf308689e40d9694a109e510e835 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 14:01:12 -0600 Subject: make get_sbo_location state-keeping more correct, rename $loc_store to $store --- SBO-Lib/lib/SBO/Lib.pm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index ba7eb19..e33296c 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -226,21 +226,22 @@ sub get_sbo_location { my $tmp = $sbos[0]; @sbos = @$tmp; } - state $loc_store = {}; + state $store = {}; # if scalar context and we've already have the location, return it now. unless (wantarray) { - return $$loc_store{$sbos[0]} if exists $$loc_store{$sbos[0]}; + return $$store{$sbos[0]} if exists $$store{$sbos[0]}; } my %locations; my $fh = open_read $slackbuilds_txt; - for my $sbo (@sbos) { + FIRST: for my $sbo (@sbos) { + $locations{$sbo} = $store{$sbo}, next FIRST if exists $$store{$sbo}; my $regex = qr#LOCATION:\s+\.(/[^/]+/\Q$sbo\E)$#; while (my $line = <$fh>) { if (my $loc = ($line =~ $regex)[0]) { # save what we found for later requests - $$loc_store{$sbo} = "$config{SBO_HOME}$loc"; - return $$loc_store{$sbo} unless wantarray; - $locations{$sbo} = $$loc_store{$sbo}; + $$store{$sbo} = "$config{SBO_HOME}$loc"; + return $$store{$sbo} unless wantarray; + $locations{$sbo} = $$store{$sbo}; } } seek $fh, 0, 0; -- cgit v1.2.3 From 94c934d913a4ac9e282f0b681cec6fc246eff360 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 14:03:29 -0600 Subject: bug fix to last thing, and rename $vars to $store in get_from_info for consistency with get_sbo_location state variable --- SBO-Lib/lib/SBO/Lib.pm | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index e33296c..dfe0c60 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -234,7 +234,7 @@ sub get_sbo_location { my %locations; my $fh = open_read $slackbuilds_txt; FIRST: for my $sbo (@sbos) { - $locations{$sbo} = $store{$sbo}, next FIRST if exists $$store{$sbo}; + $locations{$sbo} = $$store{$sbo}, next FIRST if exists $$store{$sbo}; my $regex = qr#LOCATION:\s+\.(/[^/]+/\Q$sbo\E)$#; while (my $line = <$fh>) { if (my $loc = ($line =~ $regex)[0]) { @@ -266,26 +266,26 @@ sub get_from_info (%) { unless ($args{LOCATION} && $args{GET}) { script_error 'get_from_info requires LOCATION and GET.'; } - state $vars = {PRGNAM => ['']}; + state $store = {PRGNAM => ['']}; my $sbo = get_sbo_from_loc $args{LOCATION}; - return $$vars{$args{GET}} if $$vars{PRGNAM}[0] eq $sbo; + return $$store{$args{GET}} if $$store{PRGNAM}[0] eq $sbo; # if we're here, we haven't read in the .info file yet. my $fh = open_read "$args{LOCATION}/$sbo.info"; - # suck it all in, clean it all up, stuff it all in $vars. + # suck it all in, clean it all up, stuff it all in $store. my $contents = do {local $/; <$fh>}; $contents =~ s/("|\\\n)//g; - $vars = {$contents =~ /^(\w+)=(.*)$/mg}; + $store = {$contents =~ /^(\w+)=(.*)$/mg}; # fill the hash with array refs - even for single values, # since consistency here is a lot easier than sorting it out later - for my $key (keys %$vars) { - if ($$vars{$key} =~ /\s/) { - my @array = split ' ', $$vars{$key}; - $$vars{$key} = \@array; + for my $key (keys %$store) { + if ($$store{$key} =~ /\s/) { + my @array = split ' ', $$store{$key}; + $$store{$key} = \@array; } else { - $$vars{$key} = [$$vars{$key}]; + $$store{$key} = [$$store{$key}]; } } - return exists $$vars{$args{GET}} ? $$vars{$args{GET}} : undef; + return exists $$store{$args{GET}} ? $$store{$args{GET}} : undef; } # find the version in the tree for a given sbo (provided a location) -- cgit v1.2.3 From 974bead83585ebb14ded73b043506a86d1160a0b Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Sun, 4 Nov 2012 22:55:24 -0600 Subject: remove prototype from verify_distfile, cleanups/perl golf --- SBO-Lib/lib/SBO/Lib.pm | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index dfe0c60..9583a4f 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -395,7 +395,7 @@ sub compute_md5sum ($) { # for a given distfile, see whether or not it exists, and if so, if its md5sum # matches the sbo's .info file -sub verify_distfile ($$) { +sub verify_distfile { exists $_[1] or script_error 'verify_distfile requires two arguments.'; my ($link, $info_md5) = @_; my $filename = get_filename_from_link $link; @@ -415,8 +415,7 @@ sub get_distfile ($$) { system ("wget --no-check-certificate $link") == 0 or die "Unable to wget $link\n"; # can't do anything if the link in the .info doesn't lead to a good d/l - verify_distfile ($link, $info_md5) ? return 1 - : die "md5sum failure for $filename.\n"; + verify_distfile (@_) ? return 1 : die "md5sum failure for $filename.\n"; return 1; } @@ -489,9 +488,8 @@ sub revert_slackbuild ($) { sub check_distfiles (%) { exists $_[0] or script_error 'check_distfiles requires an argument.'; my %dists = @_; - for my $link (keys %dists) { - my $md5sum = $dists{$link}; - get_distfile $link, $md5sum unless verify_distfile $link, $md5sum; + while (my ($link, $md5) = each %dists) { + get_distfile $link, $md5 unless verify_distfile ($link, $md5) } return 1; } -- cgit v1.2.3 From 62b6156406606a18e9cdbc4fdc52bedae4f21835 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 03:19:39 -0600 Subject: git rid of prototype for open_fh. all tests pass. --- SBO-Lib/lib/SBO/Lib.pm | 6 +++--- sboconfig | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 9583a4f..07e3975 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -68,7 +68,7 @@ sub script_error (;$) { } # sub for opening files, second arg is like '<','>', etc -sub open_fh ($$) { +sub open_fh { exists $_[1] or script_error 'open_fh requires two arguments'; unless ($_[1] eq '>') { -f $_[0] or script_error 'open_fh first argument not a file'; @@ -79,7 +79,7 @@ sub open_fh ($$) { } sub open_read ($) { - return open_fh shift, '<'; + return open_fh (shift, '<'); } # global config variables @@ -227,7 +227,7 @@ sub get_sbo_location { @sbos = @$tmp; } state $store = {}; - # if scalar context and we've already have the location, return it now. + # if scalar context and we already have the location, return it now. unless (wantarray) { return $$store{$sbos[0]} if exists $$store{$sbos[0]}; } diff --git a/sboconfig b/sboconfig index 892279c..f969cbd 100755 --- a/sboconfig +++ b/sboconfig @@ -131,13 +131,13 @@ sub config_write ($$) { seek $tempfh, 0, 0; my $contents = do {local $/; <$tempfh>}; close $conffh; - eval { $conffh = open_fh $conf_file, '>' }; + eval { $conffh = open_fh ($conf_file, '>') }; warn "Cannot write configuration: $@\n" and return if $@; print {$conffh} $contents or return; close $conffh, close $tempfh; } else { # no config file, easiest case of all. - my $fh = open_fh $conf_file, '>' or return; + my $fh = open_fh ($conf_file, '>') or return; print {$fh} "$key=$val\n"; close $fh; } -- cgit v1.2.3 From 63db7af11265967d0111c8224aa07c040fb438b9 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 03:21:13 -0600 Subject: git rid of prototype for get_distfile. all tests pass. --- SBO-Lib/lib/SBO/Lib.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 07e3975..b6acd49 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -406,7 +406,7 @@ sub verify_distfile { # for a given distfile, attempt to retrieve it and, if successful, check its # md5sum against that in the sbo's .info file -sub get_distfile ($$) { +sub get_distfile { exists $_[1] or script_error 'get_distfile requires an argument'; my ($link, $info_md5) = @_; my $filename = get_filename_from_link $link; @@ -489,7 +489,7 @@ sub check_distfiles (%) { exists $_[0] or script_error 'check_distfiles requires an argument.'; my %dists = @_; while (my ($link, $md5) = each %dists) { - get_distfile $link, $md5 unless verify_distfile ($link, $md5) + get_distfile ($link, $md5) unless verify_distfile ($link, $md5); } return 1; } -- cgit v1.2.3 From 726522b533984f1b9652b580153a65d4c12b3ae9 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 03:23:35 -0600 Subject: git rid of prototype for get_build_queue. all tests pass. --- SBO-Lib/lib/SBO/Lib.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index b6acd49..09a1822 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -737,7 +737,7 @@ sub add_to_queue ($) { } # recursively add a sbo's requirements to the build queue. -sub get_build_queue ($$) { +sub get_build_queue { exists $_[1] or script_error 'get_build_queue requires two arguments.'; my ($sbos, $warnings) = @_; my $temp_queue = []; -- cgit v1.2.3 From 7830eacceca75d099dacb1ea1362465042f9cc2f Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 03:26:31 -0600 Subject: git rid of prototype for get_symlink_from_filename. all tests pass. --- SBO-Lib/lib/SBO/Lib.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 09a1822..95da0d7 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -420,7 +420,7 @@ sub get_distfile { } # for a given distfile, figure out what the full path to its symlink will be -sub get_symlink_from_filename ($$) { +sub get_symlink_from_filename { exists $_[1] or script_error 'get_symlink_from_filename requires two arguments'; -f $_[0] or script_error @@ -502,7 +502,7 @@ sub create_symlinks ($%) { my @symlinks; for my $link (keys %downloads) { my $filename = get_filename_from_link $link; - my $symlink = get_symlink_from_filename $filename, $location; + my $symlink = get_symlink_from_filename ($filename, $location); push @symlinks, $symlink; symlink $filename, $symlink; } -- cgit v1.2.3 From ca4560befa9477822940c8cfb0a2378171acb2ee Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 03:29:31 -0600 Subject: get rid of useless (%) prototypes. all tests pass. --- SBO-Lib/lib/SBO/Lib.pm | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 95da0d7..fb3fdf9 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -257,7 +257,7 @@ sub get_sbo_from_loc ($) { } # pull piece(s) of data, GET, from the $sbo.info file under LOCATION. -sub get_from_info (%) { +sub get_from_info { my %args = ( LOCATION => '', GET => '', @@ -318,7 +318,7 @@ sub get_available_updates () { # get downloads and md5sums from an sbo's .info file, first # checking for x86_64-specific info if we are told to -sub get_download_info (%) { +sub get_download_info { my %args = ( LOCATION => 0, X64 => 1, @@ -352,7 +352,7 @@ sub get_arch () { } # TODO: should probably combine this with get_download_info -sub get_sbo_downloads (%) { +sub get_sbo_downloads { my %args = ( LOCATION => '', 32 => 0, @@ -444,7 +444,7 @@ sub check_multilib () { } # make a backup of the existent SlackBuild, and rewrite the original as needed -sub rewrite_slackbuild (%) { +sub rewrite_slackbuild { my %args = ( SLACKBUILD => '', CHANGES => {}, @@ -485,7 +485,7 @@ sub revert_slackbuild ($) { # for each $download, see if we have it, and if the copy we have is good, # otherwise download a new copy -sub check_distfiles (%) { +sub check_distfiles { exists $_[0] or script_error 'check_distfiles requires an argument.'; my %dists = @_; while (my ($link, $md5) = each %dists) { @@ -511,7 +511,7 @@ sub create_symlinks ($%) { # pull the untarred source directory or created package name from the temp # file (the one we tee'd to) -sub grok_temp_file (%) { +sub grok_temp_file { my %args = ( FH => '', REGEX => '', @@ -554,7 +554,7 @@ sub get_tmp_extfn ($) { } # prep and run .SlackBuild -sub perform_sbo (%) { +sub perform_sbo { my %args = ( OPTS => 0, JOBS => 0, @@ -615,7 +615,7 @@ sub do_convertpkg ($) { } # "public interface", sort of thing. -sub do_slackbuild (%) { +sub do_slackbuild { my %args = ( OPTS => 0, JOBS => 0, @@ -665,7 +665,7 @@ sub do_slackbuild (%) { } # remove work directories (source and packaging dirs under /tmp/SBo) -sub make_clean (%) { +sub make_clean { my %args = ( SBO => '', SRC => '', @@ -684,7 +684,7 @@ sub make_clean (%) { } # remove distfiles -sub make_distclean (%) { +sub make_distclean { my %args = ( SRC => '', VERSION => '', -- cgit v1.2.3 From 333aeb20abc623bb3badae4b09ca8a78bfa2360e Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 04:05:26 -0600 Subject: get rid of prototype for config_write. all tests pass --- sboconfig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sboconfig b/sboconfig index f969cbd..cfa8921 100755 --- a/sboconfig +++ b/sboconfig @@ -105,7 +105,7 @@ if (exists $changes{SBO_HOME}) { # TODO: if multiple options are provided to this script, this sub should write # them all at once, instead of only a single one and having to call it once for # each option specified to the script. -sub config_write ($$) { +sub config_write { exists $_[1] or script_error 'config_write requires two arguments.'; my ($key, $val) = @_; if (! -d $conf_dir) { @@ -146,7 +146,7 @@ sub config_write ($$) { while (my ($key, $value) = each %changes) { say "Setting $key to $value..."; - config_write $key, $value or warn "Unable to write to $conf_file\n"; + config_write ($key, $value) or warn "Unable to write to $conf_file\n"; } exit 0; -- cgit v1.2.3 From 9f653e629ca6027b577e07eea2f64876da8da587 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 04:09:32 -0600 Subject: get rid of prototype for ask_user_group, all tests pass --- sboupgrade | 6 +++--- sboupgradex | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/sboupgrade b/sboupgrade index 87c9fce..7a5502d 100755 --- a/sboupgrade +++ b/sboupgrade @@ -145,7 +145,7 @@ sub clean_reqs ($) { } # ask to install any requirements found -sub ask_requires (%) { +sub ask_requires { my %args = ( REQUIRES => '', README => '', @@ -187,7 +187,7 @@ sub get_user_group ($) { } # offer to run any user/group add commands -sub ask_user_group ($$) { +sub ask_user_group { exists $_[1] or script_error 'ask_user_group requires two arguments'; my ($cmds, $readme) = @_; say "\n". $readme; @@ -248,7 +248,7 @@ sub readme_prompt ($$) { ref $requires eq 'ARRAY'; # check for user/group add commands, offer to run any found my $user_group = get_user_group $readme; - ask_user_group $user_group, $readme if $$user_group[0]; + ask_user_group ($user_group, $readme) if $$user_group[0]; # check for options mentioned in the README my $opts; $opts = ask_opts $readme if get_opts $readme; diff --git a/sboupgradex b/sboupgradex index 83128e1..c20774b 100644 --- a/sboupgradex +++ b/sboupgradex @@ -107,7 +107,7 @@ sub get_user_group ($) { } # offer to run any user/group add commands -sub ask_user_group ($$) { +sub ask_user_group { exists $_[1] or script_error 'ask_user_group requires two arguments'; my ($cmds, $readme) = @_; say "\n". $readme; @@ -165,7 +165,7 @@ sub user_prompt ($$) { # check for user/group add commands, offer to run any found my $user_group = get_user_group $readme; - ask_user_group $user_group, $readme if $$user_group[0]; + ask_user_group ($user_group, $readme) if $$user_group[0]; # check for options mentioned in the README my $opts = 0; -- cgit v1.2.3 From ee3be93c8b42928a5d6edb2b763c209eeda4d643 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 04:13:29 -0600 Subject: get rid of prototypes for (readme|user)_prompt, all tests pass (tests are incomplete here) --- sboupgrade | 4 ++-- sboupgradex | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sboupgrade b/sboupgrade index 7a5502d..0645709 100755 --- a/sboupgrade +++ b/sboupgrade @@ -236,7 +236,7 @@ sub ask_opts ($) { } # prompt for the readme -sub readme_prompt ($$) { +sub readme_prompt { exists $_[0] or script_error 'readme_prompt requires an argument.'; my ($sbo, $location) = @_; my $fh = open_read (get_readme_path $sbo); @@ -267,7 +267,7 @@ sub process_sbos ($) { my %failures; FIRST: for my $sbo (@$todo) { my $opts = 0; - $opts = readme_prompt $sbo, $locations{$sbo} unless $non_int; + $opts = readme_prompt ($sbo, $locations{$sbo}) unless $non_int; # switch compat32 on if upgrading a -compat32 $compat32 = 1 if $sbo =~ /-compat32$/; my ($version, $pkg, $src); diff --git a/sboupgradex b/sboupgradex index c20774b..9612771 100644 --- a/sboupgradex +++ b/sboupgradex @@ -156,7 +156,7 @@ sub ask_opts ($) { return; } -sub user_prompt ($$) { +sub user_prompt { exists $_[1] or script_error 'user_prompt requires two arguments.'; my ($sbo, $location) = @_; my $fh = open_read ($location .'/README'); -- cgit v1.2.3 From 75e942f3d49edd7fd0c58c0c5f2a3c382632feac Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 04:17:21 -0600 Subject: get rid of prototype for print_failures, all tests pass --- sboupgrade | 10 ++++------ sboupgradex | 10 ++++------ 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/sboupgrade b/sboupgrade index 0645709..1cfa7aa 100755 --- a/sboupgrade +++ b/sboupgrade @@ -313,13 +313,11 @@ sub process_sbos ($) { return %failures; } -sub print_failures (;%) { +sub print_failures { if (exists $_[0]) { my %failures = @_; say 'Failures:'; - while (my ($key, $val) = each %failures) { - say " $key: $val"; - } + say " $_: $failures{$_}" for keys %failures; exit 1; } } @@ -365,7 +363,7 @@ unless ($force) { } } my %failures = process_sbos $todo_upgrade if exists $$todo_upgrade[0]; -print_failures %failures; +print_failures (%failures); INSTALL_NEW: exit 0 unless $install_new; @@ -397,6 +395,6 @@ FIRST: for my $sbo (@ARGV) { push @$todo_install, $sbo; } %failures = process_sbos $todo_install if exists $$todo_install[0]; -print_failures %failures; +print_failures (%failures); exit 0; diff --git a/sboupgradex b/sboupgradex index 9612771..1eb325b 100644 --- a/sboupgradex +++ b/sboupgradex @@ -236,13 +236,11 @@ sub process_sbos ($) { return %failures; } -sub print_failures (;%) { +sub print_failures { if (exists $_[0]) { my %failures = @_; say 'Failures:'; - while (my ($key, $val) = each %failures) { - say " $key: $val"; - } + say " $_: $failures{$_}" for keys %failures; exit 1; } } @@ -362,9 +360,9 @@ unless ($non_int) { } my %failures = process_sbos $upgrade_queue if exists $$upgrade_queue[0]; -print_failures %failures; +print_failures (%failures); %failures = process_sbos $build_queue if exists $$build_queue[0]; -print_failures %failures; +print_failures (%failures); exit 0; -- cgit v1.2.3 From 336d4150f10389ddd0fa30c0327ddf3efc72d79f Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Mon, 5 Nov 2012 04:21:14 -0600 Subject: get rid of prototype for create_symlinks, all tests pass --- SBO-Lib/lib/SBO/Lib.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index fb3fdf9..dbc7ca2 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -496,7 +496,7 @@ sub check_distfiles { # given a location and a list of download links, assemble a list of symlinks, # and create them. -sub create_symlinks ($%) { +sub create_symlinks { exists $_[1] or script_error 'create_symlinks requires two arguments.'; my ($location, %downloads) = @_; my @symlinks; @@ -649,7 +649,7 @@ sub do_slackbuild { 32 => $args{COMPAT32} ); check_distfiles %downloads; - my @symlinks = create_symlinks $args{LOCATION}, %downloads; + my @symlinks = create_symlinks ($args{LOCATION}, %downloads); # setup and run the .SlackBuild itself my ($pkg, $src) = perform_sbo ( OPTS => $args{OPTS}, -- cgit v1.2.3 From 51b62ac5d35bc6a8987dd34ab896a0308a49dec4 Mon Sep 17 00:00:00 2001 From: Jacob Pipkin Date: Thu, 8 Nov 2012 06:50:25 -0600 Subject: use --delete when running rsync_tree --- SBO-Lib/lib/SBO/Lib.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index dbc7ca2..921496b 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -160,7 +160,7 @@ sub check_home () { sub rsync_sbo_tree () { my $slk_version = get_slack_version; my @arg = ('rsync', '-a', '--exclude=*.tar.gz', '--exclude=*.tar.gz.asc'); - push @arg, "rsync://slackbuilds.org/slackbuilds/$slk_version/*"; + push @arg, '--delete', "rsync://slackbuilds.org/slackbuilds/$slk_version/*"; my $out = system @arg, $config{SBO_HOME}; my $wanted = sub { $File::Find::name ? chown 0, 0, $File::Find::name -- cgit v1.2.3