aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-08-29 00:08:59 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2016-08-29 00:08:59 +0200
commit6e8187c0a64c138149868c867ea6e4ddafed5c87 (patch)
treef8683120730afaec314e19503f6d7c44d2207c0c
parent223ad71044440c87257d8dfa5d43d1ade78bc764 (diff)
downloadsbotools2-6e8187c0a64c138149868c867ea6e4ddafed5c87.tar.xz
SBO::Lib::Info: let get_from_info use slurp() too
-rw-r--r--SBO-Lib/lib/SBO/Lib/Info.pm11
-rwxr-xr-xt/07-fail.t2
2 files changed, 7 insertions, 6 deletions
diff --git a/SBO-Lib/lib/SBO/Lib/Info.pm b/SBO-Lib/lib/SBO/Lib/Info.pm
index b4efc2a..e89ef8f 100644
--- a/SBO-Lib/lib/SBO/Lib/Info.pm
+++ b/SBO-Lib/lib/SBO/Lib/Info.pm
@@ -6,7 +6,7 @@ use warnings;
our $VERSION = '2.0';
-use SBO::Lib::Util qw/ get_arch get_sbo_from_loc open_read script_error /;
+use SBO::Lib::Util qw/ get_arch get_sbo_from_loc open_read script_error slurp usage_error /;
use SBO::Lib::Tree qw/ get_orig_location get_sbo_location is_local /;
use Exporter 'import';
@@ -122,11 +122,12 @@ sub get_from_info {
state $store = {LOCATION => ['']};
my $sbo = get_sbo_from_loc($args{LOCATION});
return $store->{$args{GET}} if $store->{LOCATION}[0] eq $args{LOCATION};
+
# if we're here, we haven't read in the .info file yet.
- my ($fh, $exit) = open_read("$args{LOCATION}/$sbo.info");
- return() if $exit;
- # suck it all in, clean it all up, stuff it all in $store.
- my $contents = do {local $/; <$fh>};
+ my $contents = slurp("$args{LOCATION}/$sbo.info");
+ usage_error("get_from_info: could not read $args{LOCATION}/$sbo.info.") unless
+ defined $contents;
+
$contents =~ s/("|\\\n)//g;
my $last_key = '';
$store = {};
diff --git a/t/07-fail.t b/t/07-fail.t
index 16113d8..38569ed 100755
--- a/t/07-fail.t
+++ b/t/07-fail.t
@@ -121,7 +121,7 @@ SKIP: {
}
# 10: Malformed slackbuild - no .info
-sboinstall 'malformed-noinfo', { expected => "A fatal script error has occurred:\nopen_fh, $RealBin/LO-fail/malformed-noinfo/malformed-noinfo.info is not a file\nExiting.\n", exit => 2 };
+sboinstall 'malformed-noinfo', { expected => "get_from_info: could not read $RealBin/LO-fail/malformed-noinfo/malformed-noinfo.info.\n", exit => 1 };
# 11-13: Malformed slackbuild - malformed .info
sboinstall 'malformed-info', { input => "y\ny\nn", expected => qr!Failures:\n malformed-info: Unable to get download info from $RealBin/LO-fail/malformed-info/malformed-info[.]info\n!, exit => 7 };