aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm9
-rwxr-xr-xsboremove6
-rwxr-xr-xsboupgrade6
-rwxr-xr-xt/test.t3
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;
+}
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 <STDIN> =~ /^[Yy\n]/;
}
diff --git a/sboupgrade b/sboupgrade
index 3f9dcfe..daa6799 100755
--- a/sboupgrade
+++ b/sboupgrade
@@ -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;
diff --git a/t/test.t b/t/test.t
index 0bb36ce..220342d 100755
--- a/t/test.t
+++ b/t/test.t
@@ -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'