diff options
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 9 | ||||
-rwxr-xr-x | sboremove | 6 | ||||
-rwxr-xr-x | sboupgrade | 6 | ||||
-rwxr-xr-x | 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 bc396d4..e06f124 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 @@ -841,3 +842,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; +} @@ -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]/; } @@ -171,10 +171,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; @@ -393,6 +393,9 @@ 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'); + # test get_dl_fns my $downloads = [ 'http://developer.download.nvidia.com/cg/Cg_3.1/Cg-3.1_April2012_x86.tgz' |