aboutsummaryrefslogtreecommitdiff
path: root/find_installed_removed
blob: ad088ccf5cf571511ff71b223b1a0fc5a3495475 (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
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/perl -w

($SELF = $0) =~ s,.*/,,;
if(@ARGV) {
	print <<EOF;
$SELF - find installed SBo packages that are not in the SBo repo

Usage: $SELF

Output is a list of installed SBo packages that are not listed on the
SBo site. Usually this means the builds were removed from the repo,
but if you are a SBo developer, it could also find builds that you
never got around to submitting to SBo.

Exit status is 0 (success) if no removed packages are installed
(if there is no output), or 1 (failure) if any removed packages are
installed.

By default, the 15.0 repo is searched, but you can export
SLACKVER in the environment to check a different version.

To use an alternate package database directory (other than
/var/log/packages), set PKGDIR in the environment.
EOF
	exit 0;
}

# TODO: get this from /etc/slackware-version or /etc/os-release
$SLACKVER = $ENV{SLACKVER} || "15.0";

# use the .gz version, saves a lot of bandwidth
$URL = "https://slackbuilds.org/slackbuilds/$SLACKVER/SLACKBUILDS.TXT.gz";

$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 | gzip -dc |" or die $!;
while(<$pipe>) {
	chomp;
	next unless m{^SLACKBUILD NAME: (.*)$};
	$in_repo{$1}++;
}
close $pipe;

$count = 0;
for(sort keys %installed) {
	$count++, print "$_\n" unless $in_repo{$_};
}

exit ($count != 0);