aboutsummaryrefslogtreecommitdiff
path: root/find_installed_orphans
blob: 1b1b1d9577640132a3bb00bdd9a8b830bc669016 (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
#!/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);