aboutsummaryrefslogtreecommitdiff
path: root/find_installed_orphans
blob: 4a9f3c0e70f65f027ef2ef9643b1de19d6eb26e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/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.

If any orphans are found, and they're software you actually use
and care about, you should take over maintenance of the builds.
See: https://slackbuilds.org/orphaned_builds_faq/#7

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);