From add737980e72ca6f330367ea7556bc52392456bb Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 29 Aug 2008 11:05:27 +0000 Subject: initial multi source support patch git-svn-id: svn://tug.org/texlive/trunk@10408 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/etc/multi-source-support.diff | 395 +++++++++++++++++++++++++++++ 1 file changed, 395 insertions(+) create mode 100644 Master/tlpkg/etc/multi-source-support.diff diff --git a/Master/tlpkg/etc/multi-source-support.diff b/Master/tlpkg/etc/multi-source-support.diff new file mode 100644 index 00000000000..ae2be972579 --- /dev/null +++ b/Master/tlpkg/etc/multi-source-support.diff @@ -0,0 +1,395 @@ +--- /src/TeX/texlive-svn/Master/texmf/scripts/texlive/tlmgr.pl 2008-08-21 18:50:32.000000000 +0200 ++++ texmf/scripts/texlive/tlmgr.pl 2008-08-29 12:21:45.000000000 +0200 +@@ -37,7 +37,7 @@ + use TeXLive::TLUtils; + use TeXLive::TLWinGoo; + use TeXLive::TLPostActions; +-TeXLive::TLUtils->import( qw(kpsewhich member win32 merge_into copy log) ); ++TeXLive::TLUtils->import( qw(kpsewhich member info give_ctan_mirror win32 merge_into copy log debug) ); + use Cwd qw/abs_path/; + use Pod::Usage; + use Getopt::Long qw(:config no_autoabbrev require_order); +@@ -45,15 +45,17 @@ + + # used variables + # the TLMedia from which we install/update +-my $tlmediasrc; ++my %tlmediasrc; + # the tlpdb of the install media +-my $tlpdb; ++my %tlmediatlpdb; ++# flag indicating that the tlmedia has been loaded ++my $tlmedia_loaded = 0; + # the local tlpdb + my $localtlpdb; + # a hash for saving the options saved into the local tlpdb + my %options; + # the location from where we install +-my $location; ++my @locations; + + # option handling + my $opt_location; +@@ -411,16 +413,14 @@ + } + init_local_db(); + foreach my $pkg (@ARGV) { +- my $tlmediatlpdb; + my $tlp = $localtlpdb->get_package($pkg); + my $installed = 0; + if (!$tlp) { +- if (!$tlmediatlpdb) { +- $tlmediasrc = TeXLive::TLMedia->new($location); +- die($loadmediasrcerror . $location) unless defined($tlmediasrc); +- $tlmediatlpdb = $tlmediasrc->tlpdb; ++ init_tlmedia(); ++ for my $tlpdb (values(%tlmediatlpdb)) { ++ $tlp = $tlpdb->get_package($pkg); ++ last if ($tlp); + } +- $tlp = $tlmediatlpdb->get_package($pkg); + } else { + $installed = 1; + } +@@ -446,32 +446,33 @@ + "file" => \$opt_file) or pod2usage(2); + my $r = shift @ARGV; + my $ret = ""; +- my $tlpdb; ++ my @tlpdbs; + init_local_db(); + if ($opt_global) { +- $tlmediasrc = TeXLive::TLMedia->new($location); +- die($loadmediasrcerror . $location) unless defined($tlmediasrc); +- $tlpdb = $tlmediasrc->tlpdb; ++ init_tlmedia(); ++ @tlpdbs = values(%tlmediatlpdb); + } else { +- $tlpdb = $localtlpdb; ++ push @tlpdbs, $localtlpdb; + } +- foreach my $pkg ($tlpdb->list_packages) { +- if ($opt_file) { +- my @ret = grep(m;$r;, $tlpdb->get_package($pkg)->all_files); +- if (@ret) { +- print "$pkg:\n"; +- foreach (@ret) { +- print "\t$_\n"; ++ for my $tlpdb (@tlpdbs) { ++ for my $pkg ($tlpdb->list_packages) { ++ if ($opt_file) { ++ my @ret = grep(m;$r;, $tlpdb->get_package($pkg)->all_files); ++ if (@ret) { ++ print "$pkg:\n"; ++ foreach (@ret) { ++ print "\t$_\n"; ++ } ++ } ++ } else { ++ next if ($pkg =~ m/\./); ++ my $t = $tlpdb->get_package($pkg)->shortdesc; ++ $t |= ""; ++ my $lt = $tlpdb->get_package($pkg)->longdesc; ++ $lt |= ""; ++ if (($pkg =~ m/$r/) || ($t =~ m/$r/) || ($lt =~ m/$r/)) { ++ $ret .= " $pkg - $t\n"; + } +- } +- } else { +- next if ($pkg =~ m/\./); +- my $t = $tlpdb->get_package($pkg)->shortdesc; +- $t |= ""; +- my $lt = $tlpdb->get_package($pkg)->longdesc; +- $lt |= ""; +- if (($pkg =~ m/$r/) || ($t =~ m/$r/) || ($lt =~ m/$r/)) { +- $ret .= " $pkg - $t\n"; + } + } + } +@@ -612,9 +613,7 @@ + "backupdir=s" => \$opt_backupdir, + "dry-run" => \$opt_dry) or pod2usage(2); + my %ret; +- $tlmediasrc = TeXLive::TLMedia->new($location); +- die($loadmediasrcerror . $location) unless defined($tlmediasrc); +- my $mediatlpdb = $tlmediasrc->tlpdb; ++ init_tlmedia(); + my @todo; + if ($opt_all || $opt_list) { + @todo = $localtlpdb->list_packages; +@@ -634,18 +633,26 @@ + next; + } + my $rev = $tlp->revision; +- my $mediatlp = $mediatlpdb->get_package($pkg); +- if (!defined($mediatlp)) { +- print "$pkg cannot be found in $location\n"; ++ my ($maxsrc, $maxrev) = install_candidate($pkg); ++ if (!defined($maxsrc)) { ++ debug("$pkg cannot be found in any of @locations\n"); + next; + } +- my $mediarev = $mediatlp->revision; +- if ($rev < $mediarev) { ++ if (!$maxsrc) { ++ print "$pkg: no installation candidate found!\n"; ++ next; ++ } ++ # if $maxsrc is defined then there is an installation candidate with ++ # an higher revision number ++ if ($rev < $maxrev) { ++ my $tlmediasrc = $tlmediasrc{$maxsrc}; ++ my $tlmediatlpdb = $tlmediatlpdb{$maxsrc}; ++ my $mediarev = $maxrev; + $nrupdated++; + if ($opt_list) { +- print "$pkg: local: $rev, source: $mediarev\n"; ++ print "$pkg: local: $rev, source: $mediarev ($maxsrc)\n"; + } elsif ($opt_dry) { +- print "Installing $pkg\n"; ++ print "Installing $pkg ($maxsrc)\n"; + } else { + # first remove the package, then reinstall it + # this way we get rid of useless files +@@ -685,7 +692,7 @@ + # these packages cannot be upgrade on win32 + # so we have to create a update program + my $media = $tlmediasrc->media; +- my $remoteroot = $mediatlpdb->root; ++ my $remoteroot = $tlmediatlpdb->root; + my $root = $localtlpdb->root; + my $temp = "$root/temp"; + TeXLive::TLUtils::mkdirhier($temp); +@@ -719,8 +726,8 @@ + print "update: $pkg done\n"; + } + } +- } elsif ($rev > $mediarev) { +- print "$pkg: revision in $location is less then local revision, not updating!\n"; ++ } else { ++ debug("$pkg: no installation candidate with higher rev found!\n"); + next; + } + } +@@ -740,13 +747,23 @@ + ); + tlwarn("UPDATER has been created, please execute tlpkg\\installer\\updater.bat\n"); + } +- if (($nrupdated == 0) && ($tlmediasrc->media ne "NET") && $opt_all) { +- # for all but net updates we warn if nothing is updated +- tlwarn("\nYour installation is set up to look on the disk for updates.\n"); +- tlwarn("If you want to install from the Internet for this one time only, run\n"); +- tlwarn(" tlmgr -location $TeXLiveURL\n"); +- tlwarn("\nIf you want to change the default for all future updates, run\n"); +- tlwarn(" tlmgr option location $TeXLiveURL\n\n"); ++ if (($nrupdated == 0) && $opt_all) { ++ my $any_net = 0; ++ for my $tm (values(%tlmediasrc)) { ++ if ($tm->media eq "NET") { ++ $any_net = 1; ++ last; ++ } ++ } ++ if (!$any_net) { ++ # for all but net updates we warn if nothing is updated ++ tlwarn("\nTEXT OUTDATED NEEDS REMARK FOR MULTIPLE LOCATIONS!!!\n"); ++ tlwarn("\nYour installation is set up to look on the disk for updates.\n"); ++ tlwarn("If you want to install from the Internet for this one time only, run\n"); ++ tlwarn(" tlmgr -location $TeXLiveURL\n"); ++ tlwarn("\nIf you want to change the default for all future updates, run\n"); ++ tlwarn(" tlmgr option location $TeXLiveURL\n\n"); ++ } + } + return(\%ret); + } +@@ -763,14 +780,18 @@ + GetOptions("no-depends" => \$opt_nodepends, + "dry-run" => \$opt_dry) or pod2usage(2); + my %ret; +- $tlmediasrc = TeXLive::TLMedia->new($location); +- die($loadmediasrcerror . $location) unless defined($tlmediasrc); ++ init_tlmedia(); + foreach my $pkg (@ARGV) { + if ($opt_dry) { + print "install: $pkg\n"; + } else { + # install the packages and run postinstall actions (that is the 0) +- merge_into(\%ret, $tlmediasrc->install_package($pkg, $localtlpdb, $opt_nodepends, 0)); ++ my ($maxsrc, $maxrev) = install_candidate($pkg); ++ if (defined($maxsrc)) { ++ merge_into(\%ret, $tlmediasrc{$maxsrc}->install_package($pkg, $localtlpdb, $opt_nodepends, 0)); ++ } else { ++ tlwarn("No installation candidate for $pkg found!\n"); ++ } + } + } + if ($opt_dry) { +@@ -780,12 +801,17 @@ + return(\%ret); + } + ++# ++# TODO ++# needs to be fixed for multi source support!!! ++ + sub action_list { + init_local_db(); + my $what = shift @ARGV; + $what || ($what = ""); +- $tlmediasrc = TeXLive::TLMedia->new($location); +- die($loadmediasrcerror . $location) unless defined($tlmediasrc); ++ init_tlmedia(); ++ # check an *ARBITRARY* TLPDB at the moment ++ my $tlmediasrc = (values %tlmediasrc)[0]; + my @whattolist; + if ($what =~ m/^collection/i) { + @whattolist = $tlmediasrc->tlpdb->collections; +@@ -814,6 +840,8 @@ + $what = "show" unless defined($what); + init_local_db(); + if ($what =~ m/^location$/i) { ++ # TODO ++ # needs to be fixed for multi source locations!!! + # changes the default location + my $loc = shift @ARGV; + if ($loc) { +@@ -881,8 +909,11 @@ + if ($what =~ m/^list$/i) { + # list the available architectures + # initialize the TLMedia from $location +- $tlmediasrc = TeXLive::TLMedia->new($location); +- die($loadmediasrcerror . $location) unless defined($tlmediasrc); ++ init_tlmedia(); ++ # TODO ++ # needs to be fixed for multi source support ++ # currently we are checking an arbitrary source!!! ++ my $tlmediasrc = (values %tlmediasrc)[0]; + my $mediatlpdb = $tlmediasrc->tlpdb; + my @already_installed_arch = $localtlpdb->available_architectures; + print "Available architectures:\n"; +@@ -897,8 +928,11 @@ + print "You can add new architectures with tlmgr arch add arch1 arch2\n"; + exit(0); + } elsif ($what =~ m/^add$/i) { +- $tlmediasrc = TeXLive::TLMedia->new($location); +- die($loadmediasrcerror . $location) unless defined($tlmediasrc); ++ init_tlmedia(); ++ # TODO ++ # needs to be fixed for multi source support ++ # currently we are checking an arbitrary source!!! ++ my $tlmediasrc = (values %tlmediasrc)[0]; + my $mediatlpdb = $tlmediasrc->tlpdb; + my @already_installed_arch = $localtlpdb->available_architectures; + my @available_arch = $mediatlpdb->available_architectures; +@@ -1007,14 +1041,11 @@ + } + } + # let cmd line options override the settings in localtlpdb +- my $loc = $localtlpdb->option_location; +- if (defined($loc)) { +- $location = $loc; +- } ++ @locations = $localtlpdb->option_locations; + if (defined($opt_location)) { +- $location = $opt_location; ++ @locations = split /,/, $opt_location; + } +- if (!defined($location)) { ++ if (!@locations) { + die("No installation source found, nor in the texlive.tlpdb nor on the cmd line.\nPlease specify one!"); + } + } +@@ -1183,6 +1214,59 @@ + system("rmdir", "--ignore-fail-on-non-empty", "$texdir"); + } + ++# ++# init_tlmedia ++# initialize a tlmedia object and returns it, or dies ++# ++sub init_tlmedia { ++ return if $tlmedia_loaded; ++ my $found = 0; ++ for my $l (@locations) { ++ my $location = $l; ++ if (($location =~ m/$TeXLiveServerURL/) || ++ ($location =~ m/^ctan$/i)) { ++ $location = give_ctan_mirror(); ++ info("Using mirror $location\n"); ++ } ++ # $tlmediasrc is a global function ++ $tlmediasrc{$l} = TeXLive::TLMedia->new($location); ++ if (defined($tlmediasrc{$l})) { ++ $found++; ++ $tlmediatlpdb{$l} = $tlmediasrc{$l}->tlpdb; ++ } else { ++ info($loadmediasrcerror . $location); ++ } ++ } ++ if (!$found) { ++ # we didn't find any useable installation media, die here! ++ die("Cannot find any useable installation source in one of the following locations:\n@locations\nStopping here!"); ++ } ++ $tlmedia_loaded = 1; ++} ++ ++ ++# ++# ++sub install_candidate { ++ my $pkg = shift; ++ my $maxrev = -1; ++ my $maxsrc; ++ for my $s (keys %tlmediasrc) { ++ my $tlp = $tlmediatlpdb{$s}->get_package($pkg); ++ if ($tlp) { ++ my $r = $tlp->revision; ++ if ($maxrev < $r) { ++ $maxrev = $r; ++ $maxsrc = $s; ++ } ++ } ++ } ++ if ($maxsrc) { ++ # something was found ($maxsrc, $maxrev, $maxtlp, $maxtlmedia) ++ return ($maxsrc, $maxrev, $tlmediatlpdb{$maxsrc}->get_package($pkg), $tlmediasrc{$maxsrc}); ++ } ++ return; ++} + + # + # return all the directories from which all content will be removed +--- /src/TeX/texlive-svn/Master/tlpkg/TeXLive/TLPDB.pm 2008-08-22 14:52:11.000000000 +0200 ++++ tlpkg/TeXLive/TLPDB.pm 2008-08-29 12:17:40.000000000 +0200 +@@ -889,14 +889,28 @@ + if (@_) { $self->_set_option_value("opt_paper", shift); } + return $self->_option_value("opt_paper"); + } ++sub option_locations { ++ my $self = shift; ++ my @locs = (); ++ if (defined($self->{'tlps'}{'00texlive-installation.config'})) { ++ foreach my $d ($self->{'tlps'}{'00texlive-installation.config'}->depends) { ++ if ($d =~ m!^location:(.*)$!) { ++ push @locs, "$1"; ++ } ++ } ++ } ++ return(@locs); ++} ++ + sub option_location { + my $self = shift; +- if (@_) { $self->_set_option_value("location", shift); } +- my $loc = $self->_option_value("location"); ++ if (@_) { tlwarn("Ignoring the setting of location, that has to be fixed for multi source support!\n"); } ++ my @locs = $self->option_locations; ++ my $loc = $locs[0]; + if ($loc eq "__MASTER__") { + return $self->root; + } +- return $self->_option_value("location"); ++ return $loc; + } + sub option_sys_bin { + my $self = shift; -- cgit v1.2.3