sbotools2

Maintenance fork of the original sbotools version 2
Log | Files | Refs | README

commit 822555d7e43653eb5a9b2c122a30e33af41c844b
parent ca238587fe160ca079c40289d5b514b55d28cf9a
Author: xocel <xocel@iquidus.org>
Date:   Tue,  1 Jan 2013 18:09:56 +1300

fixes #26

Diffstat:
MSBO-Lib/lib/SBO/Lib.pm | 10++++++++++
Msboremove | 6+-----
Msboupgrade | 6++----
Mt/test.t | 3+++
4 files changed, 16 insertions(+), 9 deletions(-)

diff --git 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 @@ -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 <STDIN> =~ /^[Yy\n]/; } diff --git 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 @@ -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();