aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm57
-rwxr-xr-xsboinstall8
-rwxr-xr-xsboupgrade6
-rwxr-xr-xt/test.t28
4 files changed, 46 insertions, 53 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
index fe61f70..c249793 100644
--- a/SBO-Lib/lib/SBO/Lib.pm
+++ b/SBO-Lib/lib/SBO/Lib.pm
@@ -245,19 +245,6 @@ sub get_installed_packages($) {
return \@installed;
}
-# pull an array of hashes, each hash containing the name and version of an sbo
-# currently installed.
-# sub get_installed_sbos() {
-# my @installed;
-# # $1 == name, $2 == version
-# my $regex = qr#/([^/]+)-([^-]+)-[^-]+-[^-]+$#;
-# for my $path (<$pkg_db/*_SBo>) {
-# my ($name, $version) = ($path =~ $regex)[0,1];
-# push @installed, {name => $name, version => $version};
-# }
-# return \@installed;
-# }
-
# for a ref to an array of hashes of installed packages, return an array ref
# consisting of just their names
sub get_inst_names($) {
@@ -393,7 +380,7 @@ sub get_download_info {
$md5s = get_from_info(LOCATION => $args{LOCATION}, GET => $get);
return unless $$md5s[0];
$return{$$downs[$_]} = $$md5s[$_] for (keys @$downs);
- return %return;
+ return \%return;
}
sub get_arch() {
@@ -412,14 +399,14 @@ sub get_sbo_downloads {
my $location = $args{LOCATION};
-d $location or script_error 'get_sbo_downloads given a non-directory.';
my $arch = get_arch;
- my %dl_info;
+ my $dl_info;
if ($arch eq 'x86_64') {
- %dl_info = get_download_info(LOCATION => $location) unless $args{32};
+ $dl_info = get_download_info(LOCATION => $location) unless $args{32};
}
- unless (keys %dl_info > 0) {
- %dl_info = get_download_info(LOCATION => $location, X64 => 0);
+ unless (keys %$dl_info > 0) {
+ $dl_info = get_download_info(LOCATION => $location, X64 => 0);
}
- return %dl_info;
+ return $dl_info;
}
# given a link, grab the filename from it and prepend $distfiles
@@ -549,11 +536,11 @@ sub rewrite_slackbuild {
# that the 32-bit source is untarred
if ($args{C32}) {
my $location = get_sbo_location($args{SBO});
- my %downloads = get_sbo_downloads(
+ my $downloads = get_sbo_downloads(
LOCATION => $location,
32 => 1,
);
- my $fns = get_dl_fns [keys %downloads];
+ my $fns = get_dl_fns [keys %$downloads];
for my $line (@sb_file) {
if ($line =~ $dc_regex) {
my ($regex, $initial) = get_dc_regex $line;
@@ -601,32 +588,32 @@ sub check_distfiles {
my $location = $args{LOCATION};
my $sbo = get_sbo_from_loc $location;
- my %downloads = get_sbo_downloads(
+ my $downloads = get_sbo_downloads(
LOCATION => $location,
32 => $args{COMPAT32}
);
die "Unable to get download information from $location/$sbo.info.\n" unless
- keys %downloads > 0;
- while (my ($link, $md5) = each %downloads) {
+ keys %$downloads > 0;
+ while (my ($link, $md5) = each %$downloads) {
get_distfile($link, $md5) unless verify_distfile($link, $md5);
}
- my @symlinks = create_symlinks($args{LOCATION}, %downloads);
- return \@symlinks;
+ my $symlinks = create_symlinks($args{LOCATION}, $downloads);
+ return $symlinks;
}
# given a location and a list of download links, assemble a list of symlinks,
# and create them.
sub create_symlinks {
exists $_[1] or script_error 'create_symlinks requires two arguments.';
- my ($location, %downloads) = @_;
+ my ($location, $downloads) = @_;
my @symlinks;
- for my $link (keys %downloads) {
+ for my $link (keys %$downloads) {
my $filename = get_filename_from_link $link;
my $symlink = get_symlink_from_filename($filename, $location);
push @symlinks, $symlink;
symlink $filename, $symlink;
}
- return @symlinks;
+ return \@symlinks;
}
# pull the created package name from the temp file we tee'd to
@@ -1038,8 +1025,13 @@ sub process_sbos {
eval { $temp_syms = check_distfiles(
LOCATION => $$locs{$sbo}, COMPAT32 => $compat32
); };
- $failures{$sbo} = $@ if $@;
- push @symlinks, @$temp_syms;
+ # if $@ is defined, $temp_syms will be empty and the script will error
+ # instead of having a proper failure message.
+ if ($@) {
+ $failures{$sbo} = $@;
+ } else {
+ push @symlinks, @$temp_syms;
+ }
}
# return now if we were unable to download/verify everything - might want
# to not do this. not sure.
@@ -1102,7 +1094,8 @@ sub process_sbos {
# subroutine to print out failures
sub print_failures {
- if (exists $_[0]) {
+ my $failures = shift;
+ if (keys %$failures > 0) {
my $failures = shift;
say 'Failures:';
say " $_: $$failures{$_}" for keys %$failures;
diff --git a/sboinstall b/sboinstall
index fe9c3ef..56e682e 100755
--- a/sboinstall
+++ b/sboinstall
@@ -93,7 +93,7 @@ if ($no_reqs or $non_int) {
}
# populate %locations and sanity check
-$locations = get_sbo_location($build_queue);
+%locations = get_sbo_location($build_queue);
for my $sbo (@$build_queue) {
usage_error "Unable to locate $sbo in the SlackBuilds.org tree." unless
defined $locations{$sbo};
@@ -162,7 +162,7 @@ unless ($non_int) {
exit 0 unless <STDIN> =~ /^[Yy\n]/;
}
-my %failures = process_sbos(
+my $failures = process_sbos(
TODO => $build_queue,
CMDS => \%commands,
OPTS => \%options,
@@ -172,6 +172,6 @@ my %failures = process_sbos(
NOCLEAN => $noclean,
DISTCLEAN => $distclean,
);
-print_failures(%failures);
+print_failures($failures);
-exit keys %failures > 0 ? 1 : 0;
+exit keys %$failures > 0 ? 1 : 0;
diff --git a/sboupgrade b/sboupgrade
index c1f242d..b38b456 100755
--- a/sboupgrade
+++ b/sboupgrade
@@ -213,7 +213,7 @@ unless ($non_int) {
exit 0 unless <STDIN> =~ /^[Yy\n]/;
}
-my %failures = process_sbos(
+my $failures = process_sbos(
TODO => $upgrade_queue,
CMDS => \%commands,
OPTS => \%options,
@@ -223,6 +223,6 @@ my %failures = process_sbos(
NOCLEAN => $noclean,
DISTCLEAN => $distclean,
);
-print_failures(%failures);
+print_failures($failures);
-exit keys %failures > 0 ? 1 : 0;
+exit keys %$failures > 0 ? 1 : 0;
diff --git a/t/test.t b/t/test.t
index 19297d9..b8bb7fc 100755
--- a/t/test.t
+++ b/t/test.t
@@ -133,25 +133,25 @@ for my $key (keys @$updates) {
is(get_arch, 'x86_64', 'get_arch is good');
# get_download_info tests
-my %dl_info = get_download_info(LOCATION => "$sbo_home/system/wine", X64 => 0);
+my $dl_info = get_download_info(LOCATION => "$sbo_home/system/wine", X64 => 0);
my $link = 'http://downloads.sf.net/wine/source/1.4/wine-1.4.1.tar.bz2';
-is($dl_info{$link}, '0c28702ed478df7a1c097f3a9c4cabd6',
+is($$dl_info{$link}, '0c28702ed478df7a1c097f3a9c4cabd6',
'get_download_info test 01 good.');
$link = 'http://www.unrealize.co.uk/source/dibeng-max-2010-11-12.zip';
-is($dl_info{$link}, '97159d77631da13952fe87e846cf1f3b',
+is($$dl_info{$link}, '97159d77631da13952fe87e846cf1f3b',
'get_download_info test 02 good.');
# get_sbo_downloads tests
-%dl_info = get_sbo_downloads(LOCATION => "$sbo_home/system/wine");
+$dl_info = get_sbo_downloads(LOCATION => "$sbo_home/system/wine");
$link = 'http://downloads.sf.net/wine/source/1.4/wine-1.4.1.tar.bz2';
-is($dl_info{$link}, '0c28702ed478df7a1c097f3a9c4cabd6',
+is($$dl_info{$link}, '0c28702ed478df7a1c097f3a9c4cabd6',
'get_sbo_downloads test 01 good.');
$link = 'http://www.unrealize.co.uk/source/dibeng-max-2010-11-12.zip';
-is($dl_info{$link}, '97159d77631da13952fe87e846cf1f3b',
+is($$dl_info{$link}, '97159d77631da13952fe87e846cf1f3b',
'get_sbo_downloads test 02 good.');
-my %downloads = get_sbo_downloads(LOCATION => "$sbo_home/system/ifuse");
+my $downloads = get_sbo_downloads(LOCATION => "$sbo_home/system/ifuse");
$link = 'http://www.libimobiledevice.org/downloads/ifuse-1.1.1.tar.bz2';
-is($downloads{$link}, '8d528a79de024b91f12f8ac67965c37c',
+is($$downloads{$link}, '8d528a79de024b91f12f8ac67965c37c',
'get_sbo_downloads test 03 good.');
# get_filename_from_link test
@@ -187,11 +187,11 @@ ok(!(check_x32("$sbo_home/system/ifuse")),
ok(check_multilib, 'check_multilib good');
# create_symlinks tests
-%downloads = get_sbo_downloads(LOCATION => "$sbo_home/system/wine", 32 => 1);
-my @symlinks = create_symlinks "$sbo_home/system/wine", %downloads;
-is($symlinks[0], "$sbo_home/system/wine/wine-1.4.1.tar.bz2",
+$downloads = get_sbo_downloads(LOCATION => "$sbo_home/system/wine", 32 => 1);
+my $symlinks = create_symlinks "$sbo_home/system/wine", $downloads;
+is($$symlinks[0], "$sbo_home/system/wine/wine-1.4.1.tar.bz2",
'$symlinks[0] good for create_symlinks');
-is($symlinks[1], "$sbo_home/system/wine/dibeng-max-2010-11-12.zip",
+is($$symlinks[1], "$sbo_home/system/wine/dibeng-max-2010-11-12.zip",
'$symlinks[1] good for create_symlinks');
# grok_temp_file, get_src_dir/get_pkg_name tests
@@ -225,7 +225,7 @@ is(get_pkg_name $tempfh, 'skype-2.2.0.35-i486-1_SBo.tgz', 'get_pkg_name good');
#rmdir '/tmp/SBo/test.2.d';
# check_distfiles test
-my $symlinks = check_distfiles(LOCATION => "$sbo_home/perl/perl-Sort-Versions");
+$symlinks = check_distfiles(LOCATION => "$sbo_home/perl/perl-Sort-Versions");
is($$symlinks[0], "$sbo_home/perl/perl-Sort-Versions/Sort-Versions-1.5.tar.gz",
'check_distfiles test 01');
@@ -447,7 +447,7 @@ is($count, 4, 'confirm_remove good for duplicate sbo');
ok((get_readme_contents "$sbo_home/network/nagios"), 'get_readme_contents is good');
# test get_dl_fns
-my $downloads = [
+$downloads = [
'http://developer.download.nvidia.com/cg/Cg_3.1/Cg-3.1_April2012_x86.tgz'
];
my $fns = get_dl_fns $downloads;