diff options
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 1 | ||||
-rwxr-xr-x | sboremove | 135 | ||||
-rwxr-xr-x[-rw-r--r--] | sboupgradex | 26 |
3 files changed, 86 insertions, 76 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index 921496b..0a693e3 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -1,3 +1,4 @@ + #!/usr/bin/env perl # # vim: set ts=4:noet @@ -41,7 +41,8 @@ my ($help, $vers, $non_int, $no_reqs, $alwaysask, @excluded); GetOptions ( 'help|h' => \$help, 'version|v' => \$vers, - 'norequirements|R' => \$no_reqs, + 'norequirements|R' => \$no_reqs, + 'nointeractive' => \$non_int, 'alwaysask|a' => \$alwaysask, ); @@ -49,10 +50,22 @@ show_usage and exit 0 if $help; show_version and exit 0 if $vers; show_usage and exit 0 unless exists $ARGV[0]; -my $rootpkg = $ARGV[0]; -my $test = get_sbo_location ($rootpkg); -die "Unable to locate $rootpkg in the SlackBuilds.org tree.\n" unless - defined $test; +my $installed = get_installed_sbos; +my $inst_names = get_inst_names $installed; + +my @remove; +for my $sbo (@ARGV) { + my $test = get_sbo_location ($sbo); + if ( defined $test ) { + if ($sbo ~~ @$inst_names) { + push @remove, $sbo + } else { + say "$sbo is not installed"; + } + } else { + say "Unable to locate $sbo in the SlackBuilds.org tree." + } +} my $remove_queue; my %required_by; @@ -60,7 +73,7 @@ my %warnings; my @confirmed; sub get_requires ($) { - my $location = get_sbo_location(shift); + my $location = get_sbo_location shift; my $requires = get_from_info (LOCATION => $location, GET => 'REQUIRES'); return $requires; } @@ -71,7 +84,7 @@ sub get_required_by ($) { if ( $required_by{$sbo} ) { for my $req_by (@{$required_by{$sbo}}) { unless ($req_by ~~ @confirmed) { - push (@dep_of, $req_by); + push @dep_of, $req_by; } } } @@ -81,28 +94,25 @@ sub get_required_by ($) { sub confirm_remove ($) { my $sbo = shift; unless ($sbo ~~ @confirmed) { - push(@confirmed, $sbo); + push @confirmed, $sbo; } } -# Determine dependencies & warnings of root package -$remove_queue = get_build_queue($rootpkg, \%warnings); +# Determine dependencies & warnings sbo's +$remove_queue = get_build_queue(\@remove, \%warnings); @$remove_queue = reverse(@$remove_queue); if ($no_reqs) { - @$remove_queue = (); - push(@$remove_queue, $rootpkg); + $remove_queue = \@remove; } # Determine required by for all installed sbo's -my $installed = get_installed_sbos; -my $inst_names = get_inst_names $installed; for my $inst (@$inst_names) { my $requires = get_requires "$inst"; next unless $$requires[0]; for my $req (@$requires) { unless ( $req eq "%README%" ) { if ( $req ~~ $inst_names ) { - push(@{$required_by{$req}}, $inst); + push @{$required_by{$req}}, $inst; } } } @@ -113,56 +123,62 @@ my @temp; if ($inst_names) { for my $sbo (@$remove_queue) { if ($sbo ~~ $inst_names) { - push(@temp, $sbo); + push @temp, $sbo; } } $remove_queue = \@temp; } # Gather instructions from user -my ($req_by_line, @req_by, $req_count, $cnf_count); -my $is_rootpkg = 1; -for my $pkg (@$remove_queue) { - $req_by_line = get_required_by $pkg; - @req_by = split(" ", $req_by_line); - $req_count = @req_by; - $cnf_count = 0; - for my $val (@req_by) { - if ( $val ~~ @confirmed ) { $cnf_count++; } - } - if ($cnf_count == $req_count or $is_rootpkg or $alwaysask) { - say $pkg; - if ( $req_by_line ) { - say "Required by: $req_by_line"; - } else { - unless ($is_rootpkg) { - say "It appears $pkg will no longer be required on your system"; - } +unless ($non_int) { + my ($req_by_line, @req_by, $req_count, $cnf_count); + my $is_rootpkg = 1; + for my $pkg (@$remove_queue) { + $req_by_line = get_required_by $pkg; + @req_by = split(" ", $req_by_line); + $req_count = @req_by; + $cnf_count = 0; + for my $val (@req_by) { + if ( $val ~~ @confirmed ) { $cnf_count++; } } - $is_rootpkg = 0; - if ( exists $warnings{$pkg} ) { - say "$pkg suggests you view its README before proceeding,"; - print "view now? [y] : "; - chomp(my $viewrm = <STDIN>); - if ($viewrm =~ /^[Yy]/) { - print "\n"; - my $locrm = get_sbo_location ($pkg); - $locrm .= '/README'; - open(README, '<', $locrm) or die "could not open $locrm"; - for my $line (<README>) { - print $line; + if ($cnf_count == $req_count or $is_rootpkg or $alwaysask) { + say $pkg; + if ( $req_by_line ) { + say "Required by: $req_by_line"; + } else { + unless ($is_rootpkg) { + say "It appears $pkg will no longer be required on your system"; } } - } - print "Remove $pkg? [n] : "; - chomp(my $userin = <STDIN>); - if ($userin =~ /^[Yy]/) { - confirm_remove $pkg; - say "* added $pkg to remove queue\n"; - } else { - say "* ignoring $pkg\n" + $is_rootpkg = 0; + if ( exists $warnings{$pkg} ) { + say "$pkg suggests you view its README before proceeding,"; + print "view now? [y] : "; + chomp(my $viewrm = <STDIN>); + if ($viewrm =~ /^[Yy]/) { + print "\n"; + my $locrm = get_sbo_location $pkg; + $locrm .= '/README'; + open(README, '<', $locrm) or die "could not open $locrm"; + for my $line (<README>) { + print $line; + } + } + } + print "Remove $pkg? [n] : "; + chomp(my $userin = <STDIN>); + if ($userin =~ /^[Yy]/) { + confirm_remove $pkg; + say "* added $pkg to remove queue\n"; + } else { + say "* ignoring $pkg\n" + } } } +} else { + for my $sbo (@$remove_queue) { + confirm_remove $sbo; + } } # Show remove queue @@ -178,12 +194,13 @@ if ($remove_count) { exit 0; } -print 'Are you sure you want to continue? [n] : '; -unless (<STDIN> =~ /^[Yy]/) { - say 'Exiting.'; - exit 0; +unless ($non_int) { + print 'Are you sure you want to continue? [n] : '; + unless (<STDIN> =~ /^[Yy]/) { + say 'Exiting.'; + exit 0; + } } - for my $instpkg (@confirmed) { system("/sbin/removepkg $instpkg"); diff --git a/sboupgradex b/sboupgradex index 1eb325b..fee8a30 100644..100755 --- a/sboupgradex +++ b/sboupgradex @@ -77,17 +77,17 @@ show_usage and exit 0 unless exists $ARGV[0]; $noclean = $noclean eq 'TRUE' ? 1 : 0; $distclean = $distclean eq 'TRUE' ? 1 : 0; - my $rootpkg = $ARGV[0]; my %warnings; my %options; my $build_queue; +my %locations; +my $build = 0; if ($no_reqs) { - @$build_queue = (); - push(@$build_queue, $rootpkg); + $build_queue = \@ARGV; } else { - $build_queue = get_build_queue($rootpkg, \%warnings); + $build_queue = get_build_queue(\@ARGV, \%warnings); } my %locations = get_sbo_location ($build_queue); @@ -245,14 +245,9 @@ sub print_failures { } } -#if (@$build_queue gt 1) { -# my $reqline = join(' ', @$build_queue); -# $reqline =~ s/$rootpkg//; -# say "Requires: " . $reqline; -#} - my $installed = get_installed_sbos; my $inst_names = get_inst_names $installed; +my $upgrade_queue; # deal with any updates prior to any new installs. # no reason to bother if only_new is specified, ie running from sboinstall. @@ -264,21 +259,18 @@ unless ($force) { my $updates = get_available_updates; push @updates, $$_{name} for @$updates; } -my $upgrade_queue; + # but without force, we only want to update what there are updates for -my @remove; unless ($force) { for my $sbo (@$build_queue) { if ($sbo ~~ @updates) { push @$upgrade_queue, $sbo; - push @remove, $sbo; } } } else { for my $sbo (@$build_queue) { if ($sbo ~~ @$inst_names) { push @$upgrade_queue, $sbo; - push @remove, $sbo; } } } @@ -300,7 +292,6 @@ for my $sbo (@$upgrade_queue) { } # Remove upgrades from build queue - for my $sbo (@$upgrade_queue) { if ($sbo ~~ @$build_queue) { my $count = 0; @@ -313,8 +304,8 @@ for my $sbo (@$upgrade_queue) { } } } - @$upgrade_queue = @temp_queue; +$build = 1 if exists $$upgrade_queue[0]; INSTALL_NEW: goto BEGIN_BUILD unless $install_new; @@ -347,10 +338,11 @@ for my $sbo (@$build_queue) { } } @$build_queue = @temp_queue; +$build = 1 if exists $$build_queue[0]; BEGIN_BUILD: @$build_queue = () unless $install_new; -exit 0 unless @$build_queue gt 0 or @$upgrade_queue gt 0; +exit 0 unless $build; print "\n"; say "Upgrade queue: " . join(' ', @$upgrade_queue) if exists $$upgrade_queue[0]; say "Install queue: " . join(' ', @$build_queue) if exists $$build_queue[0]; |