diff options
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 12 | ||||
-rwxr-xr-x | sboupgrade | 26 |
2 files changed, 18 insertions, 20 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 3db3133..8d3441b 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -48,7 +48,6 @@ use File::Path qw(make_path remove_tree); use Fcntl; use File::Find; use File::Temp qw(tempdir tempfile); -use Data::Dumper; use Fcntl qw(F_SETFD F_GETFD); our $tempdir = tempdir (CLEANUP => 1); @@ -157,13 +156,13 @@ sub rsync_sbo_tree () { sub fetch_tree () { check_home; say 'Pulling SlackBuilds tree...'; - rsync_sbo_tree, return $?; + rsync_sbo_tree, return 1; } sub update_tree () { fetch_tree, return unless chk_slackbuilds_txt; say 'Updating SlackBuilds tree...'; - rsync_sbo_tree, return $?; + rsync_sbo_tree, return 1; } # if the SLACKBUILDS.TXT is not in $config{SBO_HOME}, we assume the tree has @@ -448,7 +447,7 @@ sub revert_slackbuild ($) { my $slackbuild = shift; if (-f "$slackbuild.orig") { unlink $slackbuild if -f $slackbuild; - rename ("$slackbuild.orig", $slackbuild); + rename "$slackbuild.orig", $slackbuild; } return 1; } @@ -503,7 +502,6 @@ sub grok_temp_file (%) { last FIRST; } } -# close $fh; return $out; } @@ -519,6 +517,7 @@ sub get_pkg_name ($) { REGEX => qr/^Slackware\s+package\s+([^\s]+)\s+created\.$/); } +# clear the close-on-exec bit from a temp file handle sub clear_coe_bit ($) { exists $_[0] or script_error 'clear_coe_bit requires an argument'; my $fh = shift; @@ -526,12 +525,14 @@ sub clear_coe_bit ($) { return $fh; } +# return a filename from a temp fh for use externally sub get_tmp_extfn ($) { exists $_[0] or script_error 'get_tmp_extfn requires an argument.'; my $fh = clear_coe_bit shift; return '/dev/fd/'. fileno $fh; } +# return a filename from a temp fh for use internally sub get_tmp_perlfn ($) { exists $_[0] or script_error 'get_tmp_perlfn requires an argument.'; my $fh = clear_coe_bit shift; @@ -681,3 +682,4 @@ sub do_upgradepkg ($) { system ('/sbin/upgradepkg', '--reinstall', '--install-new', shift); return 1; } + @@ -89,9 +89,7 @@ sub get_readme_path ($) { sub get_inst_names ($) { exists $_[0] or script_error 'get_inst_names requires an argument.'; my $inst = shift; - my $installed; - push @$installed, $$_{name} for @$inst; - return $installed; + return [$$_{name} for @$inst]; } # pull list of requirements, offer to install them @@ -184,13 +182,13 @@ sub readme_prompt ($$) { } # do the things with the provided sbos - whether upgrades or new installs. -sub process_sbos { +sub process_sbos ($) { exists $_[0] or script_error 'process_sbos requires an argument.'; my $todo = shift; my @failures; - FIRST: for my $sbo (keys %$todo) { + FIRST: for my $sbo (@$todo) { my $opts = 0; - $opts = readme_prompt $sbo, $$todo{$sbo} unless $no_readme; + $opts = readme_prompt $sbo, $locations{$sbo} unless $no_readme; # switch compat32 on if upgrading a -compat32 $compat32 = 1 if $sbo =~ /-compat32$/; my ($version, $pkg, $src); @@ -226,7 +224,7 @@ sub process_sbos { warn "$pkg left in /tmp\n"; } } elsif ($distclean eq 'TRUE') { - unlink ($pkg); + unlink $pkg; } } } @@ -255,18 +253,16 @@ my $todo_upgrade; # but without force, we only want to update what there are updates for unless ($force) { for my $sbo (@ARGV) { - $$todo_upgrade{$sbo} = $locations{$sbo} if $sbo ~~ @updates; + push $$todo_upgrades, $sbo if $sbo ~~ @updates; } } else { my $inst = get_installed_sbos; - my $inst_names= get_inst_names $inst;; + my $inst_names= get_inst_names $inst; FIRST: for my $sbo (@ARGV) { - if ($sbo ~~ @$inst_names) { - $$todo_upgrade{$sbo} = $locations{$sbo}; - } + push $todo_upgrade, $sbo if $sbo ~~ @$inst_names; } } -my @failures = process_sbos $todo_upgrade if keys %$todo_upgrade > 0; +my @failures = process_sbos $todo_upgrade if exists $todo_upgrade[0]; print_failures @failures; INSTALL_NEW: @@ -292,9 +288,9 @@ FIRST: for my $sbo (@ARGV) { } } } - $$todo_install{$sbo} = $locations{$sbo}; + push $todo_install, $sbo; } -@failures = process_sbos $todo_install if keys %$todo_install > 0; +@failures = process_sbos $todo_install if exists $todo_install[0]; print_failures @failures; exit 0; |