Index: tlmgr.pl =================================================================== --- tlmgr.pl (revision 11008) +++ tlmgr.pl (working copy) @@ -79,6 +79,7 @@ use Cwd qw/abs_path/; use Pod::Usage; use Getopt::Long qw(:config no_autoabbrev require_order); +use Digest::MD5 qw(md5_hex); use strict; # used variables @@ -1864,14 +1865,52 @@ # uses the global $location. # sub init_tlmedia { + # compute the md5 digest for the location + my $locmdv = md5_hey($location); if (($location =~ m/$TeXLiveServerURL/) || ($location =~ m/^ctan$/i)) { $location = give_ctan_mirror(); } info("tlmgr: installation location $location\n"); + if ($location =~ m/^(http|ftp):/i) { + # try to download the md5hash from the location + my $root = $localtlpdb->root; + my $temp = "$root/temp"; + my $remotefilemdvfile = "$temp/md5.$locmdv"; + my $remote_tlpdb_copy = "$root/$InfraLocation/texlive.tlpdb.$locmdv"; + my $ret = TeXLive::TLUtils::download_file("$location/$InfraLocation/${DatabaseName}.md5", "$remotefilemdvfile"); + if ($ret && (-r "$lzmafile")) { + # we found a md5 hash + # we have to check the md5hash against the md5 hash of the local file + my $local_digest = TeXLive::TLUtils::tlmd5("$remote_tlpdb_copy"); + if (open (FOO, "<$remotefilemdvfile")) { + my $remote_digest = ; + close(FOO); + if ($remote_digest eq $local_digest) { + # that is fine, we have the same database, don't re-download it + $tlmediasrc = TeXLive::TLMedia->new($location, $remote_tlpdb_copy, "good"); + die ("NOT KNOW WHY") unless defined($tlmediasrc); + } + } else { + debug("Cannot read md5 sum from downloaded file $remotefilemdvfile\n"); + # we will read it again + } + } else { + tlwarn("We seem to be off line.\n"); + if (-r "$remote_tlpdb_copy") { + tlwarn("Using local copy of remote database, installation may not succeed.\n"); + $tlmediasrc = TeXLive::TLMedia->new($location, $remote_tlpdb_copy, "maybe_good"); + die ("NOT KNOW WHY") unless defined($tlmediasrc); + } else { + # do nothing, we will try below to download the tlpdb ... + } + } + } # $tlmediasrc is a global variable - $tlmediasrc = TeXLive::TLMedia->new($location); + $tlmediasrc = TeXLive::TLMedia->new($location) unless defined($tlmediasrc); die($loadmediasrcerror . $location) unless defined($tlmediasrc); + # save the md5hash of + tlwarn("TODO TODO TODO ...."); } #