aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfind_installed_orphans41
1 files changed, 41 insertions, 0 deletions
diff --git a/find_installed_orphans b/find_installed_orphans
new file mode 100755
index 0000000..1b1b1d9
--- /dev/null
+++ b/find_installed_orphans
@@ -0,0 +1,41 @@
+#!/usr/bin/perl -w
+
+($SELF = $0) =~ s,.*/,,;
+if(@ARGV) {
+ print <<EOF;
+$SELF - find installed SBo orphan packages
+
+Usage: $SELF
+
+Output is a list of installed SBo packages that are listed as
+orphans on the SBo site.
+
+Exit status is 0 (success) if no orphans are installed (if there
+is no output), or 1 (failure) if any orphans are installed.
+
+To use an alternate package database directory (other than
+/var/log/packages), set PKGDIR in the environment.
+EOF
+ exit 0;
+}
+
+$URL = 'https://slackbuilds.org/advsearch.php?stype=maint&q=NOEMAIL';
+
+$PKGDIR = $ENV{PKGDIR} || "/var/log/packages";
+chdir $PKGDIR || die "can't cd to $PKGDIR: $!\n";
+
+for(<*_SBo>) {
+ my $r = reverse;
+ my @a = split /-/, $r, 4;
+ my $pkg = reverse $a[3];
+ $installed{$pkg}++;
+}
+
+open my $pipe, "-|", "wget", "-qO-", "$URL" or die $!;
+while(<$pipe>) {
+ next unless m{a href="/repository/[\d.]+/\w+/(\S+)/">};
+ $count++;
+ print "$1\n" if $installed{$1};
+}
+
+exit ($count != 0);