aboutsummaryrefslogtreecommitdiff
path: root/SBO-Lib/lib/SBO
diff options
context:
space:
mode:
Diffstat (limited to 'SBO-Lib/lib/SBO')
-rw-r--r--SBO-Lib/lib/SBO/App/Remove.pm7
-rw-r--r--SBO-Lib/lib/SBO/App/Snap.pm7
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm5
-rw-r--r--SBO-Lib/lib/SBO/Lib/Build.pm10
-rw-r--r--SBO-Lib/lib/SBO/Lib/Repo.pm4
5 files changed, 16 insertions, 17 deletions
diff --git a/SBO-Lib/lib/SBO/App/Remove.pm b/SBO-Lib/lib/SBO/App/Remove.pm
index 4c7dd31..b97cdf8 100644
--- a/SBO-Lib/lib/SBO/App/Remove.pm
+++ b/SBO-Lib/lib/SBO/App/Remove.pm
@@ -10,7 +10,7 @@ package SBO::App::Remove;
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 SBO::Lib qw/ _ERR_USAGE 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';
@@ -41,6 +41,11 @@ sub run {
if ($self->{vers}) { $self->show_version(); return 0; }
if (!@{ $self->{args} }) { $self->show_usage(); return 1; }
+ unless ($< == 0) {
+ warn "This script requires root privileges.\n";
+ exit _ERR_USAGE;
+ }
+
# current workflow:
# * get names of all installed SBo packages
# * compare commandline args to SBo packages as well as installed SBo packages
diff --git a/SBO-Lib/lib/SBO/App/Snap.pm b/SBO-Lib/lib/SBO/App/Snap.pm
index d2b0f57..f9e44a6 100644
--- a/SBO-Lib/lib/SBO/App/Snap.pm
+++ b/SBO-Lib/lib/SBO/App/Snap.pm
@@ -13,7 +13,7 @@ package SBO::App::Snap;
use 5.16.0;
use strict;
use warnings FATAL => 'all';
-use SBO::Lib qw/ fetch_tree import_gpg_key update_tree %config show_version /;
+use SBO::Lib qw/ _ERR_USAGE fetch_tree import_gpg_key update_tree %config show_version /;
use Getopt::Long qw/ GetOptionsFromArray /;
use parent 'SBO::App';
@@ -64,6 +64,11 @@ sub run {
if ($self->{help}) { $self->show_usage(); return 0 }
if ($self->{vers}) { $self->show_version(); return 0 }
+ unless ($< == 0) {
+ warn "This script requires root privileges.\n";
+ exit _ERR_USAGE;
+ }
+
# check for a command and, if found, execute it
$args[0] //= '';
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
index edb418a..fe96cde 100644
--- a/SBO-Lib/lib/SBO/Lib.pm
+++ b/SBO-Lib/lib/SBO/Lib.pm
@@ -94,11 +94,6 @@ our %EXPORT_TAGS = (
config => $SBO::Lib::Util::EXPORT_TAGS{config},
);
-unless ($< == 0) {
- warn "This script requires root privileges.\n";
- exit _ERR_USAGE;
-}
-
'ok';
__END__
diff --git a/SBO-Lib/lib/SBO/Lib/Build.pm b/SBO-Lib/lib/SBO/Lib/Build.pm
index e6aa66b..ad760b7 100644
--- a/SBO-Lib/lib/SBO/Lib/Build.pm
+++ b/SBO-Lib/lib/SBO/Lib/Build.pm
@@ -37,7 +37,6 @@ our @EXPORT_OK = qw{
rewrite_slackbuild
run_tee
- $tempdir
$tmpd
$env_tmp
};
@@ -71,11 +70,6 @@ set.
Will be the same as C<$TMP> if it is set, otherwise it will be C</tmp/SBo>.
-=head2 $tempdir
-
-This is a temporary directory created for sbotools' use, and it should be
-cleaned up when sbotools exits.
-
=cut
# get $TMP from the env, if defined - we use two variables here because there
@@ -85,8 +79,6 @@ our $env_tmp = $ENV{TMP};
our $tmpd = $env_tmp ? $env_tmp : '/tmp/SBo';
make_path($tmpd) unless -d $tmpd;
-our $tempdir = tempdir(CLEANUP => 1, DIR => $tmpd);
-
=head1 SUBROUTINES
=cut
@@ -729,6 +721,8 @@ output will be C<undef> and the exit status will hold a true value.
sub run_tee {
my $cmd = shift;
+ my $tempdir = tempdir(CLEANUP => 1, DIR => $tmpd);
+
my $out_fh = tempfile(DIR => $tempdir);
my $out_fn = get_tmp_extfn($out_fh);
return undef, _ERR_F_SETFD if not defined $out_fn;
diff --git a/SBO-Lib/lib/SBO/Lib/Repo.pm b/SBO-Lib/lib/SBO/Lib/Repo.pm
index 6c7babb..5337ea8 100644
--- a/SBO-Lib/lib/SBO/Lib/Repo.pm
+++ b/SBO-Lib/lib/SBO/Lib/Repo.pm
@@ -442,10 +442,10 @@ C<$repo_path>, and if not, offer to run C<sbosnap fetch> for you.
sub slackbuilds_or_fetch {
unless (chk_slackbuilds_txt()) {
say 'It looks like you haven\'t run "sbosnap fetch" yet.';
- if (prompt("Would you like me to do this now?", default => 'yes')) {
+ if (($< == 0) && prompt("Would you like me to do this now?", default => 'yes')) {
fetch_tree();
} else {
- say 'Please run "sbosnap fetch"';
+ say 'Please run "sbosnap fetch" as root';
exit 0;
}
}