aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--SBO-Lib/lib/SBO/Lib.pm23
-rw-r--r--man1/sboclean.14
-rwxr-xr-xsboclean37
3 files changed, 42 insertions, 22 deletions
diff --git a/SBO-Lib/lib/SBO/Lib.pm b/SBO-Lib/lib/SBO/Lib.pm
index f3c9f3d..2e8497a 100644
--- a/SBO-Lib/lib/SBO/Lib.pm
+++ b/SBO-Lib/lib/SBO/Lib.pm
@@ -260,16 +260,17 @@ sub get_installed_packages($) {
my $regex = qr#/([^/]+)-([^-]+)-[^-]+-([^-]+)$#;
for my $path (<$pkg_db/*>) {
- my ($name, $version, $build) = ($path =~ $regex)[0,1,2];
- # valid types: STD, SBO
- my $type = 'STD';
- if ($build =~ m/_SBo(|compat32)$/) {
- my $sbo = $name;
- $sbo =~ s/-compat32//g if $name =~ /-compat32$/;
- $type = 'SBO' if get_sbo_location($sbo);
- }
- if ($filter eq $type or $filter eq 'ALL') {
- push @installed, {name => $name, version => $version};
+ if (my ($name, $version, $build) = ($path =~ $regex)[0,1,2]) {
+ # valid types: STD, SBO
+ my $type = 'STD';
+ if ($build =~ m/_SBo(|compat32)$/) {
+ my $sbo = $name;
+ $sbo =~ s/-compat32//g if $name =~ /-compat32$/;
+ $type = 'SBO' if get_sbo_location($sbo);
+ }
+ if ($filter eq $type or $filter eq 'ALL') {
+ push @installed, {name => $name, version => $version};
+ }
}
}
return \@installed;
@@ -485,7 +486,7 @@ sub get_distfile {
mkdir $distfiles unless -d $distfiles;
chdir $distfiles;
unlink $filename if -f $filename;
- if (system("wget --no-check-certificate $link") != 0) {
+ if (system("wget --no-check-certificate \"$link\"") != 0) {
return "Unable to wget $link.\n", _ERR_DOWNLOAD;
}
# can't do anything if the link in the .info doesn't lead to a good d/l
diff --git a/man1/sboclean.1 b/man1/sboclean.1
index 6e9e38e..0cb308c 100644
--- a/man1/sboclean.1
+++ b/man1/sboclean.1
@@ -7,7 +7,7 @@ sboclean - clean files left around by sbotools.
sboclean [-h|-v] [-dwi]
.SH DESCRIPTION
.P
-sboclean is used to clean files left around by sbotools, such as downloaded source files ("distfiles"), or work directories under /tmp/SBo. Note that if not run with the -i flag, sboclean will remove anything in the distfiles or /tmp/SBo folders with extreme prejudice. One of either -d or -w must be specified for this script to do anything.
+sboclean is used to clean files left around by sbotools, such as downloaded source files ("distfiles"), or work directories under /tmp/SBo and, for compat32 installs, under /tmp. Note that if not run with the -i flag, sboclean will remove anything in the distfiles or /tmp/SBo folders and any /tmp/package-*-compat32 directories with extreme prejudice. One of either -d or -w must be specified for this script to do anything.
.SH OPTIONS
.P
-h|--help
@@ -27,7 +27,7 @@ Clean distfiles, by default located at /usr/sbo/distfiles.
.P
-w|--clean-work
.RS
-Clean working directories, located under /tmp/SBo.
+Clean working directories, located under /tmp/SBo and, for compat32 installs, /tmp.
.RE
.P
-i|--interactive
diff --git a/sboclean b/sboclean
index 3835de7..c9ee8c0 100755
--- a/sboclean
+++ b/sboclean
@@ -54,24 +54,43 @@ show_version and exit 0 if $vers;
usage_error "You must specify at least one of -d or -w." unless
($clean_dist || $clean_work);
+sub rm_full($) {
+ exists $_[0] or script_error 'rm_full requires an argument.';
+ my $full = shift;
+ if ($interactive) {
+ print "Remove $full? [n] ";
+ return unless <STDIN> =~ /^[Yy]/;
+ }
+ unlink $full if -f $full;
+ remove_tree($full) if -d $full;
+ return 1;
+}
+
sub remove_stuff($) {
- exists $_[0] or script_error 'remove_stuff requires an argument';
+ exists $_[0] or script_error 'remove_stuff requires an argument.';
-d $_[0] or say 'Nothing to do.' and return 1;
my $dir = shift;
opendir(my $dh, $dir);
FIRST: while (my $ls = readdir $dh) {
next FIRST if $ls =~ /^(\.){1,2}$/;
- my $full = "$dir/$ls";
- if ($interactive) {
- print "Remove $full? [n] ";
- next FIRST unless <STDIN> =~ /^[Yy]/;
- }
- unlink $full if -f $full;
- remove_tree($full) if -d $full;
+ rm_full "$dir/$ls";
+ }
+}
+
+sub clean_c32() {
+ my $dir = '/tmp';
+ opendir(my $dh, $dir);
+ FIRST: while (my $ls = readdir $dh) {
+ next FIRST unless $ls =~ /^package-.+-compat32$/;
+ rm_full "$dir/$ls";
}
}
remove_stuff $config{SBO_HOME} .'/distfiles' if $clean_dist;
-remove_stuff '/tmp/SBo' if $clean_work;
+
+if ($clean_work) {
+ remove_stuff '/tmp/SBo';
+ clean_c32;
+}
exit 0;