Created
November 19, 2012 17:48
-
-
Save mdekstrand/4112256 to your computer and use it in GitHub Desktop.
Script to scan for uninstalled docs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use warnings; | |
use strict; | |
use RPM2; | |
use Getopt::Std; | |
my %opts; | |
getopts("c", \%opts) or exit 1; | |
my $print_unavailable = $opts{c}; | |
# Load the list of available texlive packages | |
my %available; | |
open PKGS, "-|", "yum", "list", "available", "tex-*", "texlive-*" | |
or die "yum: $!\n"; | |
while (<PKGS>) { | |
if (m/^(tex(?:live)?-[a-zA-Z0-9-]+).(?:noarch|i[3456]86|x86_64)/) { | |
$available{$1} = 1; | |
} | |
} | |
close PKGS or die "yum: $!\n"; | |
my $db = RPM2->open_rpm_db(); | |
my %seen; | |
my $i = $db->find_all_iter(); | |
while (my $pkg = $i->next) { | |
my $name = $pkg->name; | |
next unless $name =~ m/^tex(live)?-(?!collection)/; | |
next if $name =~ m/-doc$/; | |
# drop some common suffixes | |
$name =~ s/-(?:bin|lib|fedora-fonts)$//; | |
my $docpkg = "$name-doc"; | |
next if $seen{$docpkg}; | |
$seen{$docpkg} = 1; | |
next if $db->find_by_name($docpkg); | |
if ($available{$docpkg}) { | |
print "$docpkg\n"; | |
} elsif ($print_unavailable) { | |
print "# $docpkg not available\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment