aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Guldstrand <andreas.guldstrand@gmail.com>2015-12-04 01:00:47 +0100
committerAndreas Guldstrand <andreas.guldstrand@gmail.com>2015-12-04 01:00:47 +0100
commitea914a834932b7f94379e5247d2788b4b1e47ceb (patch)
treec684e17decde5b11a24aa3295dff67bcbd05bc00
parent26c0796d4341c665fc8d67aecf350349201e8bbe (diff)
downloadsbotools2-ea914a834932b7f94379e5247d2788b4b1e47ceb.tar.xz
Add ability to set a directory of local overrides.
This fixes #8
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm14
-rw-r--r--man1/sboconfig.15
-rw-r--r--man5/sbotools.conf.55
-rwxr-xr-xsboconfig30
4 files changed, 43 insertions, 11 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
index f260006..40e976c 100644
--- a/SBO-Lib/lib/SBO/Lib.pm
+++ b/SBO-Lib/lib/SBO/Lib.pm
@@ -143,6 +143,7 @@ our %config = (
JOBS => 'FALSE',
PKG_DIR => 'FALSE',
SBO_HOME => 'FALSE',
+ LOCAL_OVERRIDES => 'FALSE',
);
# subroutine to suck in config in order to facilitate unit testing
@@ -342,6 +343,19 @@ sub get_sbo_locations {
seek $fh, 0, 0;
}
close $fh;
+
+ # after we've checked the regular sbo locations, we'll see if it needs to
+ # be overridden by a local change
+ my $local = $config{LOCAL_OVERRIDES};
+ unless ( $local eq 'FALSE' ) {
+ for my $sbo (@sbos) {
+ my $loc = "$local/$sbo";
+ next unless -d $loc;
+ $$store{$sbo} = $loc;
+ $locations{$sbo} = $loc;
+ }
+ }
+
return %locations;
}
}
diff --git a/man1/sboconfig.1 b/man1/sboconfig.1
index fbe7503..5ed8b47 100644
--- a/man1/sboconfig.1
+++ b/man1/sboconfig.1
@@ -49,6 +49,11 @@ PKG_DIR: If set to a path, packages will be stored at the given location after b
.RS
SBO_HOME: If set to a path, this is where the slackbuilds.org tree will live; by default, /usr/sbo will be used. If the tree should live elsewhere, this option can be set to the path where the tree should live. Note that if you set this option after fetching the tree to a different location (such as the default), you will need to fetch the tree again.
.RE
+.P
+-l|--local-overrides (FALSE|/path)
+.RS
+LOCAL_OVERRIDES: If set to a path, any directory name under that path that matches a slackbuild name will be used instead of anything found on SBo. This will even work if it isn't on SBo at all. It still requires all the usual files present in an SBo directory such as README, name.info, and name.SlackBuild.
+.RE
.SH EXIT CODES
.P
sboconfig can exit with the following codes:
diff --git a/man5/sbotools.conf.5 b/man5/sbotools.conf.5
index 93b6a23..f44865c 100644
--- a/man5/sbotools.conf.5
+++ b/man5/sbotools.conf.5
@@ -32,6 +32,11 @@ SBO_HOME=(/usr/sbo|/path)
.RS
If set to a path, this is where the slackbuilds.org tree will live; by default, /usr/sbo will be used. If the tree should live elsewhere, this option can be set to the path where the tree should live. Note that if you set this option after fetching the tree to a different location (such as the default), you will need to fetch the tree again.
.RE
+.P
+LOCAL_OVERRIDES=(FALSE|/path)
+.RS
+If set to a path, any directory name under that path that matches a slackbuild name will be used instead of anything found on SBo. This will even work if it isn't on SBo at all. It still requires all the usual files present in an SBo directory such as README, name.info, and name.SlackBuild.
+.RE
.SH SEE ALSO
.P
sbocheck(1), sboclean(1), sboconfig(1), sbofind(1), sboinstall(1), sboremove(1), sbosnap(1), sboupgrade(1)
diff --git a/sboconfig b/sboconfig
index 983abc7..740ecfd 100755
--- a/sboconfig
+++ b/sboconfig
@@ -41,6 +41,8 @@ Config options (defaults shown):
PKG_DIR: set a directory to store packages in.
-s|--sbo-home /usr/sbo:
SBO_HOME: set the SBo directory.
+ -l|--local-overrides FALSE:
+ LOCAL_OVERRIDES: a directory containing local overrides.
EOF
}
@@ -48,25 +50,28 @@ EOF
my %options;
GetOptions(\%options, 'help|h', 'version|v', 'list|l', 'noclean|c=s',
- 'distclean|d=s', 'jobs|j=s', 'pkg-dir|p=s', 'sbo-home|s=s');
+ 'distclean|d=s', 'jobs|j=s', 'pkg-dir|p=s', 'sbo-home|s=s',
+ 'local-overrides|l=s');
show_usage() and exit 0 if exists $options{help};
show_version() and exit 0 if exists $options{version};
my %valid_confs = (
- noclean => 'NOCLEAN',
- distclean => 'DISTCLEAN',
- jobs => 'JOBS',
- 'pkg-dir' => 'PKG_DIR',
- 'sbo-home' => 'SBO_HOME',
+ noclean => 'NOCLEAN',
+ distclean => 'DISTCLEAN',
+ jobs => 'JOBS',
+ 'pkg-dir' => 'PKG_DIR',
+ 'sbo-home' => 'SBO_HOME',
+ 'local-overrides' => 'LOCAL_OVERRIDES',
);
my %params = (
- NOCLEAN => 'c|--noclean',
- DISTCLEAN => 'd|--distclean',
- JOBS => 'j|--jobs',
- PKG_DIR => 'p|--pkg-dir',
- SBO_HOME => 's|--sbo-home',
+ NOCLEAN => 'c|--noclean',
+ DISTCLEAN => 'd|--distclean',
+ JOBS => 'j|--jobs',
+ PKG_DIR => 'p|--pkg-dir',
+ SBO_HOME => 's|--sbo-home',
+ LOCAL_OVERRIDES => 'l|--local-overrides',
);
if (exists $options{list}) {
@@ -101,6 +106,9 @@ if (exists $changes{PKG_DIR}) {
if (exists $changes{SBO_HOME}) {
usage_error("$warn -s") unless $changes{SBO_HOME} =~ qr#^/#;
}
+if (exists $changes{LOCAL_OVERRIDES}) {
+ usage_error("$warn -l") unless $changes{LOCAL_OVERRIDES} =~ qr#^(/|FALSE$)#;
+}
# safely modify our conf file; write its contents to a temp file, modify the
# temp file, write the contents of the temp file back to the conf file