aboutsummaryrefslogtreecommitdiff
path: root/SBO-Lib/lib/SBO
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2019-04-27 12:17:08 +0200
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2019-04-27 12:17:15 +0200
commitd4171aca2f5fe94700fb45726f91bd9436f221de (patch)
tree6b8b328d3ac48bcc1018f83c2c8d27fdafe5dc49 /SBO-Lib/lib/SBO
parentfec4daa64fe2cef85c40e3ff0c20cd2287cfdcab (diff)
downloadsbotools-d4171aca2f5fe94700fb45726f91bd9436f221de.tar.xz
SBO::Lib::{Repo,Util}: Change how versions translates to URLs
Closes #73.
Diffstat (limited to 'SBO-Lib/lib/SBO')
-rw-r--r--SBO-Lib/lib/SBO/Lib/Repo.pm5
-rw-r--r--SBO-Lib/lib/SBO/Lib/Util.pm41
2 files changed, 33 insertions, 13 deletions
diff --git a/SBO-Lib/lib/SBO/Lib/Repo.pm b/SBO-Lib/lib/SBO/Lib/Repo.pm
index e2c5bae..29d2ba6 100644
--- a/SBO-Lib/lib/SBO/Lib/Repo.pm
+++ b/SBO-Lib/lib/SBO/Lib/Repo.pm
@@ -6,7 +6,7 @@ use warnings;
our $VERSION = '2.5';
-use SBO::Lib::Util qw/ %config prompt usage_error get_slack_version script_error open_fh open_read in _ERR_DOWNLOAD /;
+use SBO::Lib::Util qw/ %config prompt usage_error get_slack_version get_slack_version_url script_error open_fh open_read in _ERR_DOWNLOAD /;
use Cwd;
use File::Copy;
@@ -288,8 +288,7 @@ or whatever you've set in the C<SLACKWARE_VERSION> configuration variable.
sub pull_sbo_tree {
my $url = $config{REPO};
if ($url eq 'FALSE') {
- my $slk_version = get_slack_version();
- $url = "rsync://slackbuilds.org/slackbuilds/$slk_version/";
+ $url = get_slack_version_url();
} else {
unlink($slackbuilds_txt);
}
diff --git a/SBO-Lib/lib/SBO/Lib/Util.pm b/SBO-Lib/lib/SBO/Lib/Util.pm
index 52f622a..f3fd69c 100644
--- a/SBO-Lib/lib/SBO/Lib/Util.pm
+++ b/SBO-Lib/lib/SBO/Lib/Util.pm
@@ -40,6 +40,7 @@ our @EXPORT_OK = (
get_kernel_version
get_sbo_from_loc
get_slack_version
+ get_slack_version_url
idx
in
indent
@@ -199,16 +200,18 @@ will exit.
=cut
-# %supported maps what's in /etc/slackware-version to what's at SBo
-# which is now not needed since this version drops support < 14.0
-# but it's already future-proofed, so leave it.
+# %supported maps what's in /etc/slackware-version to an rsync or https URL
+my %supported = (
+ '14.0' => 'rsync://slackbuilds.org/slackbuilds/14.0/',
+ '14.1' => 'rsync://slackbuilds.org/slackbuilds/14.1/',
+ '14.2' => 'rsync://slackbuilds.org/slackbuilds/14.2/',
+ '14.2+' => 'https://github.com/Ponce/slackbuilds.git',
+ '15.0' => 'https://github.com/Ponce/slackbuilds.git',
+ current => 'https://github.com/Ponce/slackbuilds.git',
+);
+
sub get_slack_version {
return $config{SLACKWARE_VERSION} unless $config{SLACKWARE_VERSION} eq 'FALSE';
- my %supported = (
- '14.0' => '14.0',
- '14.1' => '14.1',
- '14.2' => '14.2',
- );
my ($fh, $exit) = open_read('/etc/slackware-version');
if ($exit) {
warn $fh;
@@ -217,11 +220,29 @@ sub get_slack_version {
chomp(my $line = <$fh>);
close $fh;
my $version = ($line =~ /\s+(\d+[^\s]+)$/)[0];
- usage_error("Unsupported Slackware version: $version\n")
+ usage_error("Unsupported Slackware version: $version\n" .
+ "Suggest you set the sbotools REPO setting to $supported{current}\n")
unless $supported{$version};
- return $supported{$version};
+ return $version;
}
+=head2 get_slack_version_url
+
+ my $url = get_slack_version_url();
+
+C<get_slack_version_url()> returns the default URL for the given slackware
+version.
+
+If there is an error in getting the URL, or if it's not a supported version,
+an error message will be shown on STDERR, and the program will exit.
+
+=cut
+
+sub get_slack_version_url {
+ return $supported{get_slack_version()};
+}
+
+
=head2 idx
my $idx = idx($needle, @haystack);