aboutsummaryrefslogtreecommitdiff
path: root/SBO-Lib/lib/SBO/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'SBO-Lib/lib/SBO/Lib')
-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
8 files changed, 109 insertions, 42 deletions
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