aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2019-04-27 13:30:13 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2019-04-27 14:42:36 +0200
commitdc2911fc741e36311db8134a2adedb56802f1aa5 (patch)
tree777af638f82c6466397525d2b82690032f306ead
parent389d715aecb0f647aef813d1fc9f201d1b47b9ed (diff)
downloadsbotools-dc2911fc741e36311db8134a2adedb56802f1aa5.tar.xz
sboinstall, Build, Info: Allow ignoring of SBo from reqs that doesn't exist
-rw-r--r--SBO-Lib/lib/SBO/Lib/Build.pm3
-rw-r--r--SBO-Lib/lib/SBO/Lib/Info.pm2
-rwxr-xr-xsboinstall20
-rwxr-xr-xsboupgrade18
-rwxr-xr-xt/04-install.t2
-rwxr-xr-xt/05-upgrade.t6
6 files changed, 39 insertions, 12 deletions
diff --git a/SBO-Lib/lib/SBO/Lib/Build.pm b/SBO-Lib/lib/SBO/Lib/Build.pm
index f6911a9..7587836 100644
--- a/SBO-Lib/lib/SBO/Lib/Build.pm
+++ b/SBO-Lib/lib/SBO/Lib/Build.pm
@@ -780,6 +780,9 @@ sub _build_queue {
$warnings->{$sbo}="%README%" if $req eq "%README%";
}
}
+ else {
+ $warnings->{$sbo} = "nonexistent";
+ }
push @result, $sbo;
}
diff --git a/SBO-Lib/lib/SBO/Lib/Info.pm b/SBO-Lib/lib/SBO/Lib/Info.pm
index b79c7fd..dd5b55f 100644
--- a/SBO-Lib/lib/SBO/Lib/Info.pm
+++ b/SBO-Lib/lib/SBO/Lib/Info.pm
@@ -180,7 +180,7 @@ C<get_requires()> returns the requirements for a given C<$sbo>.
# wrapper to pull the list of requirements for a given sbo
sub get_requires {
my $location = get_sbo_location(shift);
- return [] unless $location;
+ return undef unless $location;
my $info = get_from_info(LOCATION => $location, GET => 'REQUIRES');
return $info;
}
diff --git a/sboinstall b/sboinstall
index b7dc536..50798d8 100755
--- a/sboinstall
+++ b/sboinstall
@@ -13,7 +13,7 @@
use 5.16.0;
use strict;
use warnings FATAL => 'all';
-use SBO::Lib qw/ %config _ERR_OPENFH get_arch get_build_queue get_installed_cpans get_installed_packages get_sbo_location get_sbo_locations merge_queues open_fh print_failures process_sbos prompt show_version slackbuilds_or_fetch slurp usage_error user_prompt /;
+use SBO::Lib qw/ %config _ERR_OPENFH get_arch get_build_queue get_installed_cpans get_installed_packages get_sbo_location get_sbo_locations in merge_queues open_fh print_failures process_sbos prompt show_version slackbuilds_or_fetch slurp usage_error user_prompt /;
use Getopt::Long qw(:config bundling);
use File::Basename;
use JSON::PP;
@@ -98,7 +98,7 @@ if ($compat32) {
# if we can't find SLACKBUILDS.TXT in $config{HOME}, prompt to fetch the tree
slackbuilds_or_fetch();
-my (%warnings, $build_queue, %locations, $template);
+my (%warnings, $build_queue, $template);
if (length $utemp) {
my $json = JSON::PP->new->latin1;
@@ -130,12 +130,13 @@ my %inst_names;
$inst_names{$_->{name}} = $_ for @$inst_pkgs;
# populate %locations and sanity check
-%locations = get_sbo_locations($build_queue);
+my %locations = get_sbo_locations($build_queue);
for my $sbo (@$build_queue) {
next if $inst_names{$sbo};
- usage_error("Unable to locate $sbo in the SlackBuilds.org tree.") unless
- $locations{$sbo};
+ if (not $locations{$sbo} and in(@ARGV, $sbo)) {
+ usage_error("Unable to locate $sbo in the SlackBuilds.org tree.")
+ }
if ($compat32) {
usage_error("-p|--compat32 is not supported with Perl SBos.")
if $locations{$sbo} =~ qr|/perl/[^/]+$|;
@@ -175,6 +176,15 @@ FIRST: for my $sbo (@$build_queue) {
}
}
+ # Make sure the slackbuild exists on SBo
+ if (defined $warnings{$sbo} and $warnings{$sbo} eq 'nonexistent') {
+ say "Unable to locate $sbo in the SlackBuilds.org tree.";
+ if (not $non_int) {
+ exit 0 unless prompt "Do you want to ignore it and continue?", default => 'no';
+ }
+ next FIRST;
+ }
+
$locations{$name} = get_sbo_location($sbo) if $compat32;
unless ($non_int) {
# if compat32 is TRUE, we need to see if the non-compat version exists.
diff --git a/sboupgrade b/sboupgrade
index 043c567..20fcf1c 100755
--- a/sboupgrade
+++ b/sboupgrade
@@ -13,7 +13,7 @@
use 5.16.0;
use strict;
use warnings FATAL => 'all';
-use SBO::Lib qw/ get_available_updates prompt usage_error slackbuilds_or_fetch uniq get_sbo_location get_inst_names get_installed_packages get_build_queue get_sbo_locations merge_queues user_prompt process_sbos print_failures %config show_version /;
+use SBO::Lib qw/ get_available_updates prompt usage_error slackbuilds_or_fetch uniq get_sbo_location get_inst_names get_installed_packages get_build_queue get_sbo_locations in merge_queues user_prompt process_sbos print_failures %config show_version /;
use Getopt::Long qw(:config bundling);
use File::Basename;
use File::Copy;
@@ -110,8 +110,9 @@ for my $sbo (@sbos) {
my $name = $sbo;
$name =~ s/-compat32//;
$locations{$sbo} = get_sbo_location($name);
- usage_error("Unable to locate $sbo in the SlackBuilds.org tree.") unless
- $locations{$sbo};
+ if (not $locations{$sbo} and in(@ARGV, $sbo)) {
+ usage_error("Unable to locate $sbo in the SlackBuilds.org tree.");
+ }
if ($sbo =~ /-compat32$/) {
usage_error("compat32 Perl SBos are not supported.")
if $locations{$sbo} =~ qr|/perl/[^/]+$|;
@@ -129,6 +130,7 @@ if (not $non_int or not $force) {
}
my $upgrade_queue = [];
+my %warnings;
# doesn't matter what's updatable and what's not if force is specified,
# but without force, we only want to update what there are updates for
@@ -146,7 +148,7 @@ if ($non_int) {
for my $sbo (@sbos) {
my $name = $sbo;
$name =~ s/-compat32$//;
- my $queue = get_build_queue([$name], my $warnings);
+ my $queue = get_build_queue([$name], \%warnings);
if (not $force_reqs) {
@$queue = grep { !$inst_names{$_} or $updates{$_} } @$queue;
}
@@ -177,6 +179,14 @@ my (@temp_queue, %commands, %options);
FIRST: for my $sbo (@$upgrade_queue) {
next FIRST if $std_names{$sbo};
+ if (defined $warnings{$sbo} and $warnings{$sbo} eq 'nonexistent') {
+ say "Unable to locate $sbo in the SlackBuilds.org tree.";
+ if (not $non_int) {
+ exit 0 unless prompt("Do you want to ignore it and continue?", default => 'no');
+ }
+ next FIRST;
+ }
+
unless ($non_int) {
my ($cmds, $opts, $exit) = user_prompt($sbo, $locations{$sbo});
if ($exit) {
diff --git a/t/04-install.t b/t/04-install.t
index f1f922f..b318d60 100755
--- a/t/04-install.t
+++ b/t/04-install.t
@@ -50,7 +50,7 @@ ok (-e "/usr/sbo/repo/SLACKBUILDS.TXT", "SLACKBUILDS.TXT has been migrated back
sboremove 'nonexistentslackbuild', { input => "y\ny", test => 0 };
# 4: sboinstall nonexistentslackbuild2
-sboinstall 'nonexistentslackbuild2', { exit => 1, expected => "Unable to locate nonexistentslackbuild3 in the SlackBuilds.org tree.\n" };
+sboinstall 'nonexistentslackbuild2', { exit => 0, expected => "Unable to locate nonexistentslackbuild3 in the SlackBuilds.org tree.\nDo you want to ignore it and continue? [n] ", input => "n" };
# 5: sboinstall nonexistentslackbuild3
sboinstall 'nonexistentslackbuild3', { exit => 1, expected => "Unable to locate nonexistentslackbuild3 in the SlackBuilds.org tree.\n" };
diff --git a/t/05-upgrade.t b/t/05-upgrade.t
index 44037c6..1d7d541 100755
--- a/t/05-upgrade.t
+++ b/t/05-upgrade.t
@@ -11,7 +11,7 @@ use Test::Sbotools qw/ make_slackbuilds_txt set_lo sboconfig sboinstall sboupgra
use File::Temp 'tempdir';
if ($ENV{TEST_INSTALL}) {
- plan tests => 21;
+ plan tests => 22;
} else {
plan skip_all => 'Only run these tests if TEST_INSTALL=1';
}
@@ -149,6 +149,10 @@ sboupgrade qw/ -r nonexistentslackbuild /, { expected => "" };
install('LO2', 'nonexistentslackbuild', 'nonexistentslackbuild5');
sboupgrade qw/nonexistentslackbuild nonexistentslackbuild5/, { input => "foo\n\nn\nn\n", expected => qr/Proceed with nonexistentslackbuild\?.*Proceed with nonexistentslackbuild\?.*Proceed with nonexistentslackbuild5\?.*Upgrade queue: nonexistentslackbuild$/sm };
+# 22: sboupgrade on something installed with no-longer-existing dep
+install('LO', 'nonexistentslackbuild2');
+sboupgrade qw/ -f -z nonexistentslackbuild2 /, { input => "n", expected => "Unable to locate nonexistentslackbuild3 in the SlackBuilds.org tree.\nDo you want to ignore it and continue? [n] " };
+
# Cleanup
END {
cleanup();