From 822555d7e43653eb5a9b2c122a30e33af41c844b Mon Sep 17 00:00:00 2001 From: xocel Date: Tue, 1 Jan 2013 18:09:56 +1300 Subject: fixes #26 --- SBO-Lib/lib/SBO/Lib.pm | 9 +++++++++ sboremove | 6 +----- sboupgrade | 6 ++---- t/test.t | 3 +++ 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 811243b..fe21cd7 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -31,6 +31,7 @@ our @EXPORT = qw( get_inst_names get_available_updates get_requires + get_readme_contents do_slackbuild make_clean make_distclean @@ -785,3 +786,11 @@ sub merge_queues { } return $queue_a; } + +sub get_readme_contents($) { + exists $_[0] or script_error 'get_readme_contents requires an argument.'; + my $fh = open_read(shift .'/README'); + my $readme = do {local $/; <$fh>}; + close $fh; + return $readme; +} \ No newline at end of file diff --git a/sboremove b/sboremove index 3b92099..7e4ddfc 100755 --- a/sboremove +++ b/sboremove @@ -156,11 +156,7 @@ FIRST: for my $remove (@$remove_queue) { if ( "%README%" ~~ @reqz ) { say "It is recommended that you view the README before continuing."; print "Display README now? [y]: "; - my $location = get_sbo_location($remove); - my $fh = open_read($location .'/README'); - my $readme = do {local $/; <$fh>}; - close $fh; - + my $readme = get_readme_contents get_sbo_location($remove); print "\n" . $readme if =~ /^[Yy\n]/; } diff --git a/sboupgrade b/sboupgrade index 43ad2c5..6900302 100755 --- a/sboupgrade +++ b/sboupgrade @@ -176,10 +176,8 @@ sub ask_opts { sub user_prompt { exists $_[1] or script_error 'user_prompt requires two arguments.'; my ($sbo, $location) = @_; - my $fh = open_read($location .'/README'); - my $readme = do {local $/; <$fh>}; - close $fh; - + my $readme = get_readme_contents $location; + # check for user/group add commands, offer to run any found my $user_group = get_user_group $readme; my $cmds; diff --git a/t/test.t b/t/test.t index d69ef34..fc5bb03 100755 --- a/t/test.t +++ b/t/test.t @@ -389,5 +389,8 @@ confirm_remove('zdoom'); $count = @SBO::Lib::confirmed; is($count, 4, 'confirm_remove good for duplicate sbo'); +# test get_readme_contents +ok((get_readme_contents "$sbo_home/network/nagios"), 'get_readme_contents is good'); + # end of tests. done_testing(); -- cgit v1.2.3