diff options
author | Norbert Preining <preining@logic.at> | 2008-10-14 23:44:34 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2008-10-14 23:44:34 +0000 |
commit | c3ce695ac49f0f71de36edb0cb85b79f91109929 (patch) | |
tree | ade65bcb62f3509c2e058665387800ddf9b1fc8c /Master/tlpkg/bin/check-tlnet-consistency | |
parent | c2bd86645090ced3e990da753cf7b7740f444283 (diff) |
add a check-tlnet-consistency script
git-svn-id: svn://tug.org/texlive/trunk@10979 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/bin/check-tlnet-consistency')
-rwxr-xr-x | Master/tlpkg/bin/check-tlnet-consistency | 161 |
1 files changed, 161 insertions, 0 deletions
diff --git a/Master/tlpkg/bin/check-tlnet-consistency b/Master/tlpkg/bin/check-tlnet-consistency new file mode 100755 index 00000000000..6a9bcef09c1 --- /dev/null +++ b/Master/tlpkg/bin/check-tlnet-consistency @@ -0,0 +1,161 @@ +#!/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"); + 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<option>]... + +=head1 OPTIONS + +=over 4 + +=item B<-location> I</container/dir> + +The location to find the previously generated containers; +default is C<./tlnet>. + +=item B<-no-setup> + +Does not try to setup the various programs, but uses I<lzma> and I<tar> +from path. + +=item B<-help> + +Print this documentation and exit. + +=back + +The standard options B<-q>, B<-v>, and B<-logfile>=I<file> are also +accepted; see the C<process_logging_options> function in +L<TeXLive::TLUtils> for details. + +=head1 DESCRIPTION + +This program compares the revisions as found in the C<texlive.tlpdb> of +the tlnet distributions with the revisions as specified in the included +C<tlpobj> files in each package. In case there is a discrepancy this is +reported to stdout. + +=head1 AUTHORS AND COPYRIGHT + +This script and its documentation were written for the TeX Live +distribution (L<http://tug.org/texlive>) and both are licensed under the +GNU General Public License Version 2 or later. + +=cut + +### Local Variables: +### perl-indent-level: 2 +### tab-width: 2 +### indent-tabs-mode: nil +### End: +# vim:set tabstop=2 expandtab: # |