aboutsummaryrefslogtreecommitdiff
path: root/SBO-Lib/lib
diff options
context:
space:
mode:
Diffstat (limited to 'SBO-Lib/lib')
-rw-r--r--SBO-Lib/lib/SBO/App.pm26
-rw-r--r--SBO-Lib/lib/SBO/App/Remove.pm219
-rw-r--r--SBO-Lib/lib/SBO/App/Snap.pm81
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm4
-rw-r--r--SBO-Lib/lib/SBO/Lib/Build.pm6
-rw-r--r--SBO-Lib/lib/SBO/Lib/Download.pm8
-rw-r--r--SBO-Lib/lib/SBO/Lib/Info.pm52
-rw-r--r--SBO-Lib/lib/SBO/Lib/Pkgs.pm8
-rw-r--r--SBO-Lib/lib/SBO/Lib/Readme.pm33
-rw-r--r--SBO-Lib/lib/SBO/Lib/Repo.pm12
-rw-r--r--SBO-Lib/lib/SBO/Lib/Tree.pm8
-rw-r--r--SBO-Lib/lib/SBO/Lib/Util.pm24
12 files changed, 437 insertions, 44 deletions
diff --git a/SBO-Lib/lib/SBO/App.pm b/SBO-Lib/lib/SBO/App.pm
new file mode 100644
index 0000000..c9e0fdf
--- /dev/null
+++ b/SBO-Lib/lib/SBO/App.pm
@@ -0,0 +1,26 @@
+package SBO::App;
+
+# vim: ts=2:et
+#
+# authors: Luke Williams <xocel@iquidus.org>
+# Jacob Pipkin <j@dawnrazor.net>
+# Andreas Guldstrand <andreas.guldstrand@gmail.com>
+# license: WTFPL <http://sam.zoy.org/wtfpl/COPYING>
+
+use 5.16.0;
+use strict;
+use warnings FATAL => 'all';
+use File::Basename;
+
+our $VERSION = '2.5';
+
+sub new {
+ my $class = shift;
+
+ my $self = $class->_parse_opts(@_);
+ $self->{fname} = basename( (caller(0))[1] );
+
+ return bless $self, $class;
+}
+
+1;
diff --git a/SBO-Lib/lib/SBO/App/Remove.pm b/SBO-Lib/lib/SBO/App/Remove.pm
new file mode 100644
index 0000000..9747a6a
--- /dev/null
+++ b/SBO-Lib/lib/SBO/App/Remove.pm
@@ -0,0 +1,219 @@
+package SBO::App::Remove;
+
+# vim: ts=2:et
+#
+# authors: Luke Williams <xocel@iquidus.org>
+# Jacob Pipkin <j@dawnrazor.net>
+# Andreas Guldstrand <andreas.guldstrand@gmail.com>
+# license: WTFPL <http://sam.zoy.org/wtfpl/COPYING>
+
+use 5.16.0;
+use strict;
+use warnings FATAL => 'all';
+use SBO::Lib qw/ get_inst_names get_installed_packages get_sbo_location get_build_queue merge_queues get_requires get_readme_contents prompt show_version in /;
+use Getopt::Long qw(GetOptionsFromArray :config bundling);
+
+use parent 'SBO::App';
+
+our $VERSION = '2.5';
+
+sub _parse_opts {
+ my $class = shift;
+ my @ARGS = @_;
+
+ my ($help, $vers, $non_int, $alwaysask);
+
+ GetOptionsFromArray(
+ \@ARGS,
+ 'help|h' => \$help,
+ 'version|v' => \$vers,
+ 'nointeractive' => \$non_int,
+ 'alwaysask|a' => \$alwaysask,
+ );
+
+ return { help => $help, vers => $vers, non_int => $non_int, alwaysask => $alwaysask, args => \@ARGS, };
+}
+
+sub run {
+ my $self = shift;
+
+ if ($self->{help}) { $self->show_usage(); return 0; }
+ if ($self->{vers}) { $self->show_version(); return 0; }
+ if (!@{ $self->{args} }) { $self->show_usage(); return 1; }
+
+ # current workflow:
+ # * get names of all installed SBo packages
+ # * compare commandline args to SBo packages as well as installed SBo packages
+ # * add reverse deps to list if they're not a dep of something else (which is not also already on the list)
+ # * confirm removal of each package on the list
+ # - while taking into account the options passed in such as $non_int, and $alwaysask
+ # - also offering to display README if %README% is passed
+ # * remove the confirmed packages
+
+ my @args = @{ $self->{args} };
+
+ my @installed = @{ get_installed_packages('SBO') };
+ my $installed = +{ map {; $_->{name}, $_->{pkg} } @installed };
+
+ @args = grep { check_sbo($_, $installed) } @args;
+ exit 1 unless @args;
+ my %sbos = map { $_ => 1 } @args;
+
+ my @remove = get_full_queue($installed, @args);
+
+ my @confirmed;
+
+ if ($self->{non_int}) {
+ @confirmed = @remove;
+ } else {
+ my $required_by = get_reverse_reqs($installed);
+ for my $remove (@remove) {
+ # if $remove was on the commandline, mark it as not needed,
+ # otherwise check if it is needed by something else.
+ my @required_by = get_required_by($remove->{name}, [map { $_->{name} } @confirmed], $required_by);
+ my $needed = $sbos{$remove->{name}} ? 0 : @required_by;
+
+ next if $needed and not $self->{alwaysask};
+
+ push @confirmed, $remove if confirm($remove, $needed ? @required_by : ());
+ }
+ }
+
+ if (@confirmed) {
+ $self->remove(@confirmed);
+ } else {
+ say "Nothing to remove.";
+ }
+
+ return 0;
+}
+
+sub show_usage {
+ my $self = shift;
+ my $fname = $self->{fname};
+
+ print <<"EOF";
+Usage: $fname [options] sbo
+
+Options (defaults shown first where applicable):
+ -h|--help:
+ this screen.
+ -v|--version:
+ version information.
+ -a|--alwaysask:
+ always ask to remove, even if required by other packages on system.
+
+Note: optional dependencies need to be removed separately.
+
+EOF
+ return 1;
+}
+
+sub check_sbo {
+ my ($sbo, $installed) = @_;
+
+ if (not get_sbo_location($sbo)) {
+ say "Unable to locate $sbo in the SlackBuilds.org tree.";
+ return 0;
+ }
+
+ if (not exists $installed->{$sbo}) {
+ say "$sbo is not installed from SlackBuilds.org.";
+ return 0;
+ }
+
+ return 1;
+}
+
+sub get_full_queue {
+ my ($installed, @sbos) = @_;
+
+ my $remove_queue = [];
+ my %warnings;
+ for my $sbo (@sbos) {
+ my $queue = get_build_queue([$sbo], \%warnings);
+ @$queue = reverse @$queue;
+ $remove_queue = merge_queues($remove_queue, $queue);
+ }
+
+ return map {; +{
+ name => $_,
+ pkg => $installed->{$_},
+ defined $warnings{$_} ? (warning => $warnings{$_}) : ()
+ } }
+ grep { exists $installed->{$_} }
+ @$remove_queue;
+}
+
+sub get_reverse_reqs {
+ my $installed = shift;
+ my %required_by;
+
+ for my $inst (keys %$installed) {
+ for my $req (@{ get_requires($inst) }) {
+ $required_by{$req}{$inst} = 1 if exists $installed->{$req};
+ }
+ }
+
+ return \%required_by;
+}
+
+sub get_required_by {
+ my ($sbo, $confirmed, $required_by) = @_;
+ my @dep_of;
+
+ if ( $required_by->{$sbo} ) {
+ for my $req_by (keys %{$required_by->{$sbo}}) {
+ push @dep_of, $req_by unless in($req_by => @$confirmed);
+ }
+ }
+ return @dep_of;
+}
+
+sub confirm {
+ my ($remove, @required_by) = @_;
+
+ if (@required_by) {
+ say sprintf "%s : required by %s", $remove->{name}, join ' ', @required_by;
+ } else {
+ say $remove->{name};
+ }
+
+ if ($remove->{warning}) {
+ say "It is recommended that you view the README before continuing.";
+ if (prompt("Display README now?", default => 'yes')) {
+ my $readme = get_readme_contents(get_sbo_location($remove->{name}));
+ if (not defined $readme) {
+ warn "Unable to open README for $remove->{name}.\n";
+ } else {
+ print "\n" . $readme;
+ }
+ }
+ }
+
+ if (prompt("Remove $remove->{name}?", default => @required_by ? 'no' : 'yes')) {
+ say " * Added to remove queue\n";
+ return 1;
+ }
+ say " * Ignoring\n";
+ return 0;
+}
+
+sub remove {
+ my $self = shift;
+ my $non_int = $self->{non_int};
+ my @confirmed = @_;
+
+ say sprintf "Removing %d package(s)", scalar @confirmed;
+ say join " ", map { $_->{name} } @confirmed;
+
+ if (!$non_int and !prompt("\nAre you sure you want to continue?", default => 'no')) {
+ return say 'Exiting.';
+ }
+
+ system("/sbin/removepkg", $_->{pkg}) for @confirmed;
+
+ say "All operations have completed successfully.";
+}
+
+1;
diff --git a/SBO-Lib/lib/SBO/App/Snap.pm b/SBO-Lib/lib/SBO/App/Snap.pm
new file mode 100644
index 0000000..bfa80b4
--- /dev/null
+++ b/SBO-Lib/lib/SBO/App/Snap.pm
@@ -0,0 +1,81 @@
+package SBO::App::Snap;
+
+# vim: ts=2:et
+#
+# sbosnap
+# script to pull down / update a local copy of the slackbuilds.org tree.
+#
+# authors: Jacob Pipkin <j@dawnrazor.net>
+# Luke Williams <xocel@iquidus.org>
+# Andreas Guldstrand <andreas.guldstrand@gmail.com>
+# license: WTFPL <http://sam.zoy.org/wtfpl/COPYING>
+
+use 5.16.0;
+use strict;
+use warnings FATAL => 'all';
+use SBO::Lib qw/ fetch_tree update_tree %config show_version /;
+use Getopt::Long qw/ GetOptionsFromArray /;
+
+use parent 'SBO::App';
+
+our $VERSION = '2.5';
+
+sub _parse_opts {
+ my $class = shift;
+ my @ARGS = @_;
+
+ my ($help, $vers);
+
+ GetOptionsFromArray(
+ \@ARGS,
+ 'help|h' => \$help,
+ 'version|v' => \$vers,
+ );
+
+ return { help => $help, vers => $vers, args => \@ARGS, };
+}
+
+sub show_usage {
+ my $self = shift;
+ my $fname = $self->{fname};
+ print <<"EOF";
+Usage: $fname [options|command]
+
+Options:
+ -h|--help:
+ this screen.
+ -v|--version:
+ version information.
+
+Commands:
+ fetch: initialize a local copy of the slackbuilds.org tree.
+ update: update an existing local copy of the slackbuilds.org tree.
+ (generally, you may prefer "sbocheck" over "$fname update")
+
+EOF
+ return 1;
+}
+
+sub run {
+ my $self = shift;
+ my @args = @{ $self->{args} };
+
+ if ($self->{help}) { $self->show_usage(); return 0 }
+ if ($self->{vers}) { $self->show_version(); return 0 }
+
+ # check for a command and, if found, execute it
+ $args[0] //= '';
+
+ if ($args[0] eq 'fetch') {
+ fetch_tree()
+ } elsif ($args[0] eq 'update') {
+ update_tree()
+ } else {
+ $self->show_usage();
+ return 1;
+ }
+
+ return 0;
+}
+
+1;
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
index 25f39a3..42eb313 100644
--- a/SBO-Lib/lib/SBO/Lib.pm
+++ b/SBO-Lib/lib/SBO/Lib.pm
@@ -15,7 +15,7 @@ use strict;
use warnings FATAL => 'all';
package SBO::Lib;
-our $VERSION = '2.1';
+our $VERSION = '2.5';
=pod
@@ -109,7 +109,7 @@ Guldstrand <andreas.guldstrand@gmail.com>.
The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>.
-Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
+Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
=cut
diff --git a/SBO-Lib/lib/SBO/Lib/Build.pm b/SBO-Lib/lib/SBO/Lib/Build.pm
index 9323f16..f6911a9 100644
--- a/SBO-Lib/lib/SBO/Lib/Build.pm
+++ b/SBO-Lib/lib/SBO/Lib/Build.pm
@@ -4,7 +4,7 @@ use 5.016;
use strict;
use warnings;
-our $VERSION = '2.1';
+our $VERSION = '2.5';
use SBO::Lib::Util qw/ :const prompt script_error get_sbo_from_loc get_arch check_multilib uniq %config in /;
use SBO::Lib::Tree qw/ get_sbo_location /;
@@ -241,7 +241,7 @@ sub get_dc_regex {
# convert any instances of command substitution to [^-]+
$line =~ s/\$\([^)]+\)/[^-]+/g;
# convert any bash variables to [^-]+
- $line =~ s/\$({|)[A-Za-z0-9_]+(}|)/[^-]+/g;
+ $line =~ s/\$(\{|)[A-Za-z0-9_]+(}|)/[^-]+/g;
# get rid of anything excess at the end
$line =~ s/\s+.*$//;
# fix .?z* at the end
@@ -762,7 +762,7 @@ Guldstrand <andreas.guldstrand@gmail.com>.
The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>.
-Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
+Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
=cut
diff --git a/SBO-Lib/lib/SBO/Lib/Download.pm b/SBO-Lib/lib/SBO/Lib/Download.pm
index 0f6d40a..264067a 100644
--- a/SBO-Lib/lib/SBO/Lib/Download.pm
+++ b/SBO-Lib/lib/SBO/Lib/Download.pm
@@ -4,7 +4,7 @@ use 5.016;
use strict;
use warnings;
-our $VERSION = '2.1';
+our $VERSION = '2.5';
use SBO::Lib::Util qw/ :const script_error get_sbo_from_loc open_read get_arch /;
use SBO::Lib::Repo qw/ $distfiles /;
@@ -161,7 +161,7 @@ sub get_distfile {
# if wget $link && verify, return
# else wget sbosrcarch && verify
- if (system('wget', '--no-check-certificate', $link) != 0) {
+ if (system('wget', '--no-check-certificate', '--tries=5', $link) != 0) {
$fail->{msg} = "Unable to wget $link.\n";
$fail->{err} = _ERR_DOWNLOAD;
}
@@ -179,7 +179,7 @@ sub get_distfile {
substr($info_md5, 0, 1), substr($info_md5, 1, 1), $info_md5, _get_fname($link));
return 1 if
- system('wget', '--no-check-certificate', $sbosrcarch) == 0 and
+ system('wget', '--no-check-certificate', '--tries=5', $sbosrcarch) == 0 and
verify_distfile(@_);
return $fail->{msg}, $fail->{err};
@@ -296,7 +296,7 @@ Guldstrand <andreas.guldstrand@gmail.com>.
The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>.
-Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
+Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
=cut
diff --git a/SBO-Lib/lib/SBO/Lib/Info.pm b/SBO-Lib/lib/SBO/Lib/Info.pm
index 3f20497..b79c7fd 100644
--- a/SBO-Lib/lib/SBO/Lib/Info.pm
+++ b/SBO-Lib/lib/SBO/Lib/Info.pm
@@ -4,7 +4,7 @@ use 5.016;
use strict;
use warnings;
-our $VERSION = '2.1';
+our $VERSION = '2.5';
use SBO::Lib::Util qw/ get_arch get_sbo_from_loc open_read script_error slurp usage_error /;
use SBO::Lib::Tree qw/ get_orig_location get_sbo_location is_local /;
@@ -18,6 +18,7 @@ our @EXPORT_OK = qw{
get_orig_version
get_requires
get_sbo_version
+ parse_info
};
our %EXPORT_TAGS = (
@@ -132,18 +133,13 @@ sub get_from_info {
usage_error("get_from_info: could not read $args{LOCATION}/$sbo.info.") unless
defined $contents;
- $contents =~ s/("|\\\n)//g;
- my $last_key = '';
+ my %parse = parse_info($contents);
+ script_error("error when parsing $sbo.info file.") unless %parse;
+
$store = {};
$store->{LOCATION} = [$args{LOCATION}];
- foreach my $line (split /\n/, $contents) {
- my ($key, $val) = $last_key;
- if ($line =~ /^([^=\s]+)=(.*)$/) { $key = $1; $val = $2; }
- elsif ($line =~ /^\s+([^\s].+)$/) { $val = $1; }
- else { script_error("error when parsing $sbo.info file. Line: $line") }
- push @{ $store->{$key} }, ($val ? split(' ', $val) : $val);
- $last_key = $key;
- }
+ foreach my $k (keys %parse) { $store->{$k} = $parse{$k}; }
+
# allow local overrides to get away with not having quite all the fields
if (is_local($sbo)) {
for my $key (qw/DOWNLOAD_x86_64 MD5SUM_x86_64 REQUIRES/) {
@@ -184,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 [] unless $location;
my $info = get_from_info(LOCATION => $location, GET => 'REQUIRES');
return $info;
}
@@ -205,6 +201,36 @@ sub get_sbo_version {
return $version->[0];
}
+=head2 parse_info
+
+ my %parse = parse_info($str);
+
+C<parse_info()> parses the contents of an .info file from C<$str> and returns
+a key-value list of it.
+
+=cut
+
+sub parse_info {
+ script_error('parse_info requires an argument.') unless @_ == 1;
+ my $info_str = shift;
+ my $pos = 0;
+ my %ret;
+
+ while ($info_str =~ /\G([A-Za-z0-9_]+)="([^"]*)"\s*(?:\n|\z)/g) {
+ my ($key, $val) = ($1, $2);
+ $val =~ s/\\[ \t]*$/ /mg;
+ my @val = split " ", $val;
+ @val = '' unless @val;
+ $ret{$key} = \@val;
+ $pos = pos($info_str);
+ }
+
+ return if $pos != length($info_str);
+
+ return %ret;
+
+}
+
=head1 AUTHORS
SBO::Lib was originally written by Jacob Pipkin <j@dawnrazor.net> with
@@ -215,7 +241,7 @@ Guldstrand <andreas.guldstrand@gmail.com>.
The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>.
-Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
+Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
=cut
diff --git a/SBO-Lib/lib/SBO/Lib/Pkgs.pm b/SBO-Lib/lib/SBO/Lib/Pkgs.pm
index 6975a7f..be3507e 100644
--- a/SBO-Lib/lib/SBO/Lib/Pkgs.pm
+++ b/SBO-Lib/lib/SBO/Lib/Pkgs.pm
@@ -4,7 +4,7 @@ use 5.016;
use strict;
use warnings;
-our $VERSION = '2.1';
+our $VERSION = '2.5';
use SBO::Lib::Util qw/ %config script_error open_read version_cmp /;
use SBO::Lib::Tree qw/ get_sbo_location get_sbo_locations is_local /;
@@ -128,8 +128,8 @@ C<get_installed_packages()> returns an array reference to a list of packages in
C</var/log/packages> that match the specified C<$type>. The available types are
C<STD> for non-SBo packages, C<SBO> for SBo packages, and C<ALL> for both.
-The returned array reference will hold a list of hashes representing both names
-and versions of the returned packages.
+The returned array reference will hold a list of hash references representing
+both names, versions, and full installed package name of the returned packages.
=cut
@@ -205,7 +205,7 @@ Guldstrand <andreas.guldstrand@gmail.com>.
The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>.
-Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
+Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
=cut
diff --git a/SBO-Lib/lib/SBO/Lib/Readme.pm b/SBO-Lib/lib/SBO/Lib/Readme.pm
index b29558b..e46c557 100644
--- a/SBO-Lib/lib/SBO/Lib/Readme.pm
+++ b/SBO-Lib/lib/SBO/Lib/Readme.pm
@@ -4,7 +4,7 @@ use 5.016;
use strict;
use warnings;
-our $VERSION = '2.1';
+our $VERSION = '2.5';
use SBO::Lib::Util qw/ prompt script_error slurp open_read _ERR_OPENFH usage_error /;
use SBO::Lib::Tree qw/ is_local /;
@@ -13,6 +13,7 @@ use Exporter 'import';
our @EXPORT_OK = qw{
ask_opts
+ ask_other_readmes
ask_user_group
get_opts
get_readme_contents
@@ -77,6 +78,31 @@ sub ask_opts {
return();
}
+=head2 ask_other_readmes
+
+ ask_other_readmes($sbo, $location);
+
+C<ask_other_readmes()> checks if there are other readmes for the C<$sbo> in
+C<$location>, and if so, asks the user if they should be displayed, and then
+displays them if the user didn't decline.
+
+=cut
+
+sub ask_other_readmes {
+ my ($sbo, $location) = @_;
+ my @readmes = sort grep { ! m!/README$! } glob "$location/README*";
+
+ return unless @readmes;
+
+ return unless prompt("\nIt looks like $sbo has additional README files. Would you like to see those too?", default => 'yes');
+
+ for my $fn (@readmes) {
+ my ($display_fn) = $fn =~ m!/(README.*)$!;
+ say "\n$display_fn:";
+ say slurp $fn;
+ }
+}
+
=head2 ask_user_group
my $bool = ask_user_group($cmds, $readme);
@@ -144,7 +170,7 @@ C<groupadd> commands, and returns them in an array reference.
sub get_user_group {
script_error('get_user_group requires an argument') unless @_ == 1;
my $readme = shift;
- my @cmds = $readme =~ /^\s*#*\s*(useradd.*|groupadd.*)/mg;
+ my @cmds = $readme =~ /^\s*#*\s*(useradd.*?|groupadd.*?)(?<!\\)\n/msg;
return \@cmds;
}
@@ -183,6 +209,7 @@ sub user_prompt {
my $opts = 0;
$opts = ask_opts($sbo, $readme) if get_opts($readme);
print "\n". $readme unless $opts;
+ ask_other_readmes($sbo, $location);
# we have to return something substantial if the user says no so that we
# can check the value of $cmds on the calling side. we should be able to
# assume that 'N' will never be a valid command to run.
@@ -200,7 +227,7 @@ Guldstrand <andreas.guldstrand@gmail.com>.
The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>.
-Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
+Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
=cut
diff --git a/SBO-Lib/lib/SBO/Lib/Repo.pm b/SBO-Lib/lib/SBO/Lib/Repo.pm
index e920b6b..e2c5bae 100644
--- a/SBO-Lib/lib/SBO/Lib/Repo.pm
+++ b/SBO-Lib/lib/SBO/Lib/Repo.pm
@@ -4,9 +4,9 @@ use 5.016;
use strict;
use warnings;
-our $VERSION = '2.1';
+our $VERSION = '2.5';
-use SBO::Lib::Util qw/ %config prompt usage_error get_slack_version script_error open_fh open_read in /;
+use SBO::Lib::Util qw/ %config prompt usage_error get_slack_version script_error open_fh open_read in _ERR_DOWNLOAD /;
use Cwd;
use File::Copy;
@@ -242,7 +242,7 @@ sub git_sbo_tree {
} else {
chdir $config{SBO_HOME} or return 0;
remove_tree($repo_path) if -d $repo_path;
- $res = system(qw/ git clone /, $url, $repo_path) == 0;
+ $res = system(qw/ git clone --no-local /, $url, $repo_path) == 0;
}
_race::cond '$cwd could be deleted here';
return 1 if chdir $cwd and $res;
@@ -300,6 +300,8 @@ sub pull_sbo_tree {
$res = git_sbo_tree($url);
}
+ if ($res == 0) { warn "Could not sync from $url.\n"; exit _ERR_DOWNLOAD; }
+
my $wanted = sub { chown 0, 0, $File::Find::name; };
find($wanted, $repo_path) if -d $repo_path;
if ($res and not chk_slackbuilds_txt()) {
@@ -324,7 +326,7 @@ sub rsync_sbo_tree {
my @info;
# only slackware versions above 14.1 have an rsync that supports --info=progress2
if (versioncmp(get_slack_version(), '14.1') == 1) { @info = ('--info=progress2'); }
- my @args = ('rsync', @info, '-a', '--exclude=*.tar.gz', '--exclude=*.tar.gz.asc', '--delete', $url);
+ my @args = ('rsync', @info, '-a', '--delete', $url);
return system(@args, $repo_path) == 0;
}
@@ -378,7 +380,7 @@ Guldstrand <andreas.guldstrand@gmail.com>.
The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>.
-Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
+Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
=cut
diff --git a/SBO-Lib/lib/SBO/Lib/Tree.pm b/SBO-Lib/lib/SBO/Lib/Tree.pm
index e8d17fb..2e75de0 100644
--- a/SBO-Lib/lib/SBO/Lib/Tree.pm
+++ b/SBO-Lib/lib/SBO/Lib/Tree.pm
@@ -4,7 +4,7 @@ use 5.016;
use strict;
use warnings;
-our $VERSION = '2.1';
+our $VERSION = '2.5';
use SBO::Lib::Util qw/ script_error open_read idx %config /;
use SBO::Lib::Repo qw/ $repo_path $slackbuilds_txt /;
@@ -76,7 +76,7 @@ filesystem once when searching, and populating the internal cache.
=cut
sub get_sbo_location {
- my @sbos = defined $_[0] && ref $_[0] eq 'ARRAY' ? @{ $_[0] } : @_;
+ my @sbos = map { s/-compat32$//r } defined $_[0] && ref $_[0] eq 'ARRAY' ? @{ $_[0] } : @_;
script_error('get_sbo_location requires an argument.') unless @sbos;
# if we already have the location, return it now.
@@ -95,7 +95,7 @@ package name to its location.
=cut
sub get_sbo_locations {
- my @sbos = defined $_[0] && ref $_[0] eq 'ARRAY' ? @{ $_[0] } : @_;
+ my @sbos = map { s/-compat32$//r } defined $_[0] && ref $_[0] eq 'ARRAY' ? @{ $_[0] } : @_;
script_error('get_sbo_locations requires an argument.') unless @_;
my %locations;
@@ -168,7 +168,7 @@ Guldstrand <andreas.guldstrand@gmail.com>.
The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>.
-Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
+Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
=cut
diff --git a/SBO-Lib/lib/SBO/Lib/Util.pm b/SBO-Lib/lib/SBO/Lib/Util.pm
index c4128af..52f622a 100644
--- a/SBO-Lib/lib/SBO/Lib/Util.pm
+++ b/SBO-Lib/lib/SBO/Lib/Util.pm
@@ -4,7 +4,7 @@ use 5.016;
use strict;
use warnings;
-our $VERSION = '2.1';
+our $VERSION = '2.5';
use Exporter 'import';
use Sort::Versions;
@@ -350,7 +350,7 @@ sub print_failures {
exit unless prompt "Should we continue?", default => "yes";
-C<prompt()> prompts the user for an answer, optinally specifying a default of
+C<prompt()> prompts the user for an answer, optionally specifying a default of
C<yes> or C<no>. If the default has been specified it returns a true value in
case 'yes' was selected, and a false value if 'no' was selected. Otherwise it
returns whatever the user answered.
@@ -506,20 +506,32 @@ sub usage_error {
C<version_cmp()> will compare C<$ver1> with C<$ver2> to try to determine which
is bigger than the other, and returns 1 if C<$ver1> is bigger, -1 if C<$ver2>
is bigger, and 0 if they are just as big. Before making the comparison, it will
-strip off the version of your running kernel if it happens to be appended to
-the version string being compared.
+strip off the version of your running kernel as well as any locale information
+if it happens to be appended to the version string being compared.
=cut
# wrapper around versioncmp for checking if versions have kernel version
-# appended to them
+# or locale info appended to them
sub version_cmp {
my ($v1, $v2) = @_;
my $kv = get_kernel_version();
+ # strip off kernel version
if ($v1 =~ /(.+)_\Q$kv\E$/) { $v1 = $1 }
if ($v2 =~ /(.+)_\Q$kv\E$/) { $v2 = $1 }
+ # if $v2 doesn't end in the same thing, strip off locale info from $v1
+ if ($v1 =~ /(.*)_([a-z]{2})_([A-Z]{2})$/) {
+ my $v = $1;
+ if ($v2 !~ /_$2_$3$/) { $v1 = $v; }
+ }
+ # and vice versa...
+ if ($v2 =~ /(.*)_([a-z]{2})_([A-Z]{2})$/) {
+ my $v = $1;
+ if ($v1 !~ /_$2_$3$/) { $v2 = $v; }
+ }
+
versioncmp($v1, $v2);
}
@@ -537,7 +549,7 @@ Guldstrand <andreas.guldstrand@gmail.com>.
The sbotools are licensed under the WTFPL <http://sam.zoy.org/wtfpl/COPYING>.
-Copyright (C) 2012-2016, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
+Copyright (C) 2012-2017, Jacob Pipkin, Luke Williams, Andreas Guldstrand.
=cut