#!/usr/bin/env perl # Copyright 2008 Norbert Preining # This file is licensed under the GNU General Public License version 2 # or any later version. # # checks the consistency of a tlnet tlpkg/texlive.tlpdb and the .tlpobj # included in the packages. Takes quite some time. BEGIN { $vc_id = '$Id$'; $^W = 1; ($mydir = $0) =~ s,/[^/]*$,,; unshift (@INC, "$mydir/.."); } use strict; use TeXLive::TLConfig; use TeXLive::TLPOBJ; use TeXLive::TLPDB; use TeXLive::TLUtils; use Getopt::Long; use Pod::Usage; use File::Path; our ($mydir, $vc_id); my $opt_location = "./tlnet"; my $opt_nosetup = 0; my $opt_version = 0; my $opt_help = 0; TeXLive::TLUtils::process_logging_options(); GetOptions( "location=s" => \$opt_location, "no-setup" => \$opt_nosetup, "version" => \$opt_version, "help|?" => \$opt_help) or pod2usage(1); pod2usage("-exitstatus" => 0, "-verbose" => 2) if $opt_help; if ($opt_version) { print "$vc_id\n"; exit 0; } exit (&main()); sub main { chomp(my $Master = `cd $mydir/../.. && pwd`); # set up the programs ... if ($opt_nosetup) { # do a minimal setup $::progs{'lzma'} = "lzma"; $::progs{'tar'} = "tar"; } else { # do a full setup my $ret = &TeXLive::TLUtils::setup_programs("$Master/tlpkg/installer"); if ($ret == -1) { tlwarn("no binary of lzmadec for $::_platform_ detected, aborting.\n"); exit 1; } if (!$ret) { tlwarn("binaries could not be set up, aborting.\n"); exit 1; } } # get our db, same hierarchy from which we are being run. my $tlpdb = TeXLive::TLPDB->new("root" => $opt_location); die "Cannot init tlpdb from $opt_location ..." unless defined($tlpdb); my $temp = "$opt_location/temp"; if (! -d $temp) { mkdir($temp) or die "Cannot create $temp directory: $!"; } my @notlpobj; my @revisionerror; foreach my $pkg ($tlpdb->list_packages()) { next if ($pkg =~ m/^00texlive/); my $tlpdbtlpobj = $tlpdb->get_package($pkg); system("cat $opt_location/archive/$pkg.tar.lzma | $::progs{lzmadec} | $::progs{tar} -C \"$temp\" -xf - tlpkg/tlpobj"); if (! -r "$temp/tlpkg/tlpobj/$pkg.tlpobj") { push @notlpobj, $pkg; } else { my $tartlpobj = TeXLive::TLPOBJ->new; $tartlpobj->from_file("$temp/tlpkg/tlpobj/$pkg.tlpobj"); die "Cannot load tlpobj from $temp/$pkg.tlpobj: $!" unless defined($tartlpobj); if ($tlpdbtlpobj->revision != $tartlpobj->revision) { push @revisionerror, "$pkg (tlpdb: " . $tlpdbtlpobj->revision . ", tar: " . $tartlpobj->revision . ")"; } # should we do more checks? unlink("$temp/tlpkg/tlpobj/$pkg.tlpobj"); } } system("rmdir --ignore-fail-on-non-empty $temp/tlpkg/tlpobj"); system("rmdir --ignore-fail-on-non-empty $temp/tlpkg"); system("rmdir --ignore-fail-on-non-empty $temp"); if (@notlpobj) { print "packages without containing tlpobj file:\n"; for my $p (@notlpobj) { print "$p\n"; } } if (@revisionerror) { print "packages with revision discrepancy:\n"; for my $p (@revisionerror) { print "$p\n"; } } } __END__ =head1 NAME check-tlnet-consistency - check the consistency of the tlnet distribution =head1 SYNOPSIS check-tlnet-consistency [I