Skip to content

Instantly share code, notes, and snippets.

@mdekstrand
Created November 19, 2012 17:48
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdekstrand/4112256 to your computer and use it in GitHub Desktop.
Save mdekstrand/4112256 to your computer and use it in GitHub Desktop.
Script to scan for uninstalled docs
#!/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