aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm41
-rwxr-xr-xsboconfig5
-rwxr-xr-xsboupgrade6
3 files changed, 18 insertions, 34 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
index 6bdd175..9db22b1 100644
--- a/SBO-Lib/lib/SBO/Lib.pm
+++ b/SBO-Lib/lib/SBO/Lib.pm
@@ -44,7 +44,7 @@ use File::Path qw(make_path remove_tree);
use Fcntl;
use File::Find;
-$< == 0 or print "This script requires root privileges.\n" and exit (1);
+$< == 0 or die "This script requires root privileges.\n";
our $conf_dir = '/etc/sbotools';
our $conf_file = "$conf_dir/sbotools.conf";
@@ -93,13 +93,10 @@ my $name_regex = '\ASLACKBUILD\s+NAME:\s+';
# this should be done a bit differently.
sub script_error {
unless (exists $_[0]) {
- print "A fatal script error has occured. Exiting.\n";
+ die "A fatal script error has occured. Exiting.\n";
} else {
- print "A fatal script error has occured:\n";
- print "$_[0]\n";
- print "Exiting.\n";
+ die "A fatal script error has occured:\n$_[0]\nExiting.\n";
}
- exit 1;
}
sub show_version {
@@ -120,12 +117,11 @@ sub get_slack_version {
if ($slk_version eq '13.37.0') {
$slk_version = '13.37';
} else {
- print "Unsupported Slackware version: $slk_version\n" and exit (1);
+ die "Unsupported Slackware version: $slk_version\n";
}
return $slk_version;
} else {
- print "I am unable to locate your /etc/slackware-version file.\n";
- exit 1;
+ die "I am unable to locate your /etc/slackware-version file.\n";
}
}
@@ -142,12 +138,10 @@ sub check_home {
opendir (my $home_handle, $sbo_home);
while (readdir $home_handle) {
next if /^\.[\.]{0,1}$/;
- print "$sbo_home exists and is not empty. Exiting.\n";
- exit 1;
+ die "$sbo_home exists and is not empty. Exiting.\n";
}
} else {
- make_path ($sbo_home) or print "Unable to create $sbo_home. Exiting.\n"
- and exit (1);
+ make_path ($sbo_home) or die "Unable to create $sbo_home. Exiting.\n";
}
}
@@ -186,8 +180,7 @@ sub slackbuilds_or_fetch {
if ($fetch =~ /^[Yy]/) {
fetch_tree ();
} else {
- print "Please run \"sbosnap fetch\"\n";
- exit 0;
+ print "Please run \"sbosnap fetch\"\n" and exit 0;
}
}
}
@@ -241,8 +234,7 @@ sub split_equal_one {
# search the tree for a given sbo's directory
sub get_sbo_location {
- script_error ('get_sbo_location requires an argument.Exiting.')
- unless exists $_[0];
+ script_error ('get_sbo_location requires an argument.') unless exists $_[0];
my $sbo = shift;
my $location;
my $regex = qr#$config{SBO_HOME}/[^/]+/\Q$sbo\E\z#;
@@ -413,8 +405,7 @@ sub get_distfile {
return unless $out == 0;
my $md5sum = compute_md5sum ($filename);
if ($md5sum ne $expected_md5sum) {
- print "md5sum failure for $filename.\n";
- exit 1;
+ die "md5sum failure for $filename.\n";
}
return 1;
}
@@ -650,25 +641,21 @@ sub do_slackbuild {
my $x32;
if ($compat32 eq 'TRUE') {
unless ($arch eq 'x86_64') {
- print 'You can only create compat32 packages on x86_64 systems.';
- exit 1;
+ die "You can only create compat32 packages on x86_64 systems.\n";
} else {
if (! check_multilib () ) {
- print "This system does not appear to be setup for multilib.\n";
- exit 1;
+ die "This system does not appear to be setup for multilib.\n";
}
if (! -f '/usr/sbin/convertpkg-compat32') {
- print "compat32 pkgs require /usr/sbin/convertpkg-compat32.\n";
- exit 1;
+ die "compat32 pkgs require /usr/sbin/convertpkg-compat32.\n";
}
}
} else {
if ($arch eq 'x86_64') {
$x32 = check_x32 ($sbo, $location);
if ($x32 && ! check_multilib () ) {
- print "$sbo is 32-bit only, however, this system does not appear
+ die "$sbo is 32-bit only, however, this system does not appear
to be setup for multilib.\n";
- exit 1;
}
}
}
diff --git a/sboconfig b/sboconfig
index b3260d3..83fdcea 100755
--- a/sboconfig
+++ b/sboconfig
@@ -74,8 +74,7 @@ while (my ($key, $value) = each %valid_confs) {
}
if (exists $changes{JOBS}) {
unless ($changes{JOBS} =~ /^\d+$/ || $changes{JOBS} eq 'FALSE') {
- print "You have provided an invalid parameter for -j\n";
- exit 1;
+ die "You have provided an invalid parameter for -j\n";
}
}
@@ -89,7 +88,7 @@ sub config_write {
my ($key, $val) = @_;
if (! -d $conf_dir) {
mkdir ($conf_dir)
- or print "Unable to create $conf_dir. Exiting.\n" and exit (1);
+ or die "Unable to create $conf_dir. Exiting.\n";
}
if (-f $conf_file) {
# get a temp file and fill it with the contents of our config file
diff --git a/sboupgrade b/sboupgrade
index 199535f..a0259ad 100755
--- a/sboupgrade
+++ b/sboupgrade
@@ -55,8 +55,7 @@ my $compat32 = exists $options{p} ? 'TRUE' : 'FALSE';
if (exists $options{j}) {
unless ($options{j} =~ /^\d+$/ || $options{j} == 'FALSE') {
- print "You have provided an invalid parameter for -j\n";
- exit 1;
+ die "You have provided an invalid parameter for -j\n";
}
}
my $jobs = exists $options{j} ? $options{j} : $config{JOBS};
@@ -72,8 +71,7 @@ my %locations;
for my $sbo_name (@ARGV) {
$locations{$sbo_name} = get_sbo_location ($sbo_name);
unless (defined $locations{$sbo_name}) {
- print "Unable to locate $sbo_name in the SlackBuilds.org tree.\n";
- exit 1;
+ die "Unable to locate $sbo_name in the SlackBuilds.org tree.\n";
}
}