diff options
author | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2015-12-07 02:28:13 +0100 |
---|---|---|
committer | Andreas Guldstrand <andreas.guldstrand@gmail.com> | 2015-12-07 02:28:13 +0100 |
commit | a0e0d61f2ffa60943a396b4c390a159a518a6ad1 (patch) | |
tree | 37549683d512c3c3756c8c33aaeb9fa380ca3069 | |
parent | 7e32ff2bbdd632c8ba14c45ab91128c626047231 (diff) | |
download | sbotools2-a0e0d61f2ffa60943a396b4c390a159a518a6ad1.tar.xz |
Alert that a local override is being used
This fixes #13
This fixes #15
Yay, 2 fixes for the price of one commit!
-rw-r--r-- | SBO-Lib/lib/SBO/Lib.pm | 12 | ||||
-rwxr-xr-x | sbocheck | 8 |
2 files changed, 17 insertions, 3 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm index fcd0d39..ac551a3 100644 --- a/SBO-Lib/lib/SBO/Lib.pm +++ b/SBO-Lib/lib/SBO/Lib.pm @@ -54,6 +54,7 @@ our @EXPORT_OK = qw( print_failures usage_error uniq + is_local $tempdir $conf_dir $conf_file @@ -310,6 +311,7 @@ sub get_inst_names { { # a state variable for get_sbo_location and get_sbo_locations my $store = {}; + my %local; sub get_sbo_location { exists $_[0] or script_error('get_sbo_location requires an argument.'); @@ -360,11 +362,20 @@ sub get_sbo_locations { next unless -d $loc; $$store{$sbo} = $loc; $locations{$sbo} = $loc; + $local{$sbo} = $local; } } return %locations; } + +sub is_local { + exists $_[0] or script_error('is_local requires an argument.'); + my $sbo = shift; + # Make sure we have checked for the slackbuild in question: + get_sbo_location($sbo); + return !!$local{$sbo}; +} } # pull the sbo name from a $location: $config{SBO_HOME}/system/wine, etc. @@ -1125,6 +1136,7 @@ sub user_prompt { exists $_[1] or script_error('user_prompt requires two arguments.'); my ($sbo, $location) = @_; my ($readme, $exit) = get_readme_contents($location); + if (is_local($sbo)) { print "Found $sbo in local overrides.\n\n"; $exit = 0; } return $readme, undef, $exit if $exit; # check for user/group add commands, offer to run any found my $user_group = get_user_group($readme); @@ -12,7 +12,7 @@ use 5.16.0; use strict; use warnings FATAL => 'all'; -use SBO::Lib qw/ update_tree get_available_updates script_error open_fh /; +use SBO::Lib qw/ update_tree get_available_updates script_error open_fh is_local /; use Getopt::Long; use File::Basename; use List::Util 'max'; @@ -53,7 +53,7 @@ sub get_update_list { push @up_lengths, length $$updates[$_]{update} for keys @$updates; my $up_length = max @up_lengths; # "needs updating" bit without version is 30 characters - my $remaining = 80 - ($up_length + 30); + my $remaining = 80 - ($up_length + 44); my @lengths; push @lengths, length "$$updates[$_]{name}-$$updates[$_]{installed}" for keys @$updates; @@ -70,7 +70,9 @@ sub get_update_list { my @listing; for my $update (@$updates) { my $name = sprintf "%s %s", $$update{name}, $$update{installed}; - push(@listing, sprintf "%-${min}s < needs updating (SBo has %s)", + my $upd = "SBo has %s"; + if (is_local($$update{name})) { $upd = "%s from local overrides"; } + push(@listing, sprintf "%-${min}s < needs updating ($upd)", $name, $$update{update}); } return \@listing; |