diff options
-rw-r--r-- | Master/tlpkg/etc/multi-source-support.diff | 475 |
1 files changed, 324 insertions, 151 deletions
diff --git a/Master/tlpkg/etc/multi-source-support.diff b/Master/tlpkg/etc/multi-source-support.diff index ae2be972579..33852f66b3b 100644 --- a/Master/tlpkg/etc/multi-source-support.diff +++ b/Master/tlpkg/etc/multi-source-support.diff @@ -1,15 +1,6 @@ ---- /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 @@ +--- /src/TeX/texlive-svn/Master/texmf/scripts/texlive/tlmgr.pl 2008-08-30 09:54:32.000000000 +0200 ++++ texmf/scripts/texlive/tlmgr.pl 2008-08-30 09:53:32.000000000 +0200 +@@ -45,15 +45,19 @@ # used variables # the TLMedia from which we install/update @@ -20,6 +11,8 @@ +my %tlmediatlpdb; +# flag indicating that the tlmedia has been loaded +my $tlmedia_loaded = 0; ++# hash with *all* installable packages as keys and source as value ++my %media_packages; # the local tlpdb my $localtlpdb; # a hash for saving the options saved into the local tlpdb @@ -30,7 +23,7 @@ # option handling my $opt_location; -@@ -411,16 +413,14 @@ +@@ -411,15 +415,13 @@ } init_local_db(); foreach my $pkg (@ARGV) { @@ -39,91 +32,79 @@ my $installed = 0; if (!$tlp) { - if (!$tlmediatlpdb) { -- $tlmediasrc = TeXLive::TLMedia->new($location); -- die($loadmediasrcerror . $location) unless defined($tlmediasrc); +- init_tlmedia(); - $tlmediatlpdb = $tlmediasrc->tlpdb; + init_tlmedia(); -+ for my $tlpdb (values(%tlmediatlpdb)) { -+ $tlp = $tlpdb->get_package($pkg); -+ last if ($tlp); ++ if (defined($media_packages{$pkg})) { ++ $tlp = $tlmediatlpdb{$media_packages{$pkg}}->get_package($pkg); } - $tlp = $tlmediatlpdb->get_package($pkg); } else { $installed = 1; } -@@ -446,32 +446,33 @@ +@@ -429,6 +431,7 @@ + print "ShortDesc: ", $tlp->shortdesc, "\n" if ($tlp->shortdesc); + print "LongDesc: ", $tlp->longdesc, "\n" if ($tlp->longdesc); + print "Installed: ", ($installed?"Yes\n":"No\n"); ++ print "Source: ", $media_packages{$pkg}, "\n" if (!$installed); + print "\n"; + } else { + printf STDERR "Cannot find $pkg\n"; +@@ -445,17 +448,22 @@ "file" => \$opt_file) or pod2usage(2); my $r = shift @ARGV; my $ret = ""; - my $tlpdb; + my @tlpdbs; ++ my %packs; init_local_db(); if ($opt_global) { -- $tlmediasrc = TeXLive::TLMedia->new($location); -- die($loadmediasrcerror . $location) unless defined($tlmediasrc); + init_tlmedia(); - $tlpdb = $tlmediasrc->tlpdb; -+ init_tlmedia(); -+ @tlpdbs = values(%tlmediatlpdb); ++ for my $p (keys %media_packages) { ++ $packs{$p} = $tlmediatlpdb{$media_packages{$p}}; ++ } } else { - $tlpdb = $localtlpdb; -+ push @tlpdbs, $localtlpdb; ++ for my $p ($localtlpdb->list_packages) { ++ $packs{$p} = $localtlpdb; ++ } } - foreach my $pkg ($tlpdb->list_packages) { -- if ($opt_file) { ++ for my $pkg (keys %packs) { + 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 @ret = grep(m;$r;, $packs{$pkg}->get_package($pkg)->all_files); + if (@ret) { + print "$pkg:\n"; + foreach (@ret) { +@@ -464,9 +472,9 @@ + } + } else { + next if ($pkg =~ m/\./); - my $t = $tlpdb->get_package($pkg)->shortdesc; -- $t |= ""; ++ my $t = $packs{$pkg}->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, ++ my $lt = $packs{$pkg}->get_package($pkg)->longdesc; + $lt |= ""; + if (($pkg =~ m/$r/) || ($t =~ m/$r/) || ($lt =~ m/$r/)) { + $ret .= " $pkg - $t\n"; +@@ -611,7 +619,6 @@ "dry-run" => \$opt_dry) or pod2usage(2); my %ret; -- $tlmediasrc = TeXLive::TLMedia->new($location); -- die($loadmediasrcerror . $location) unless defined($tlmediasrc); + init_tlmedia(); - my $mediatlpdb = $tlmediasrc->tlpdb; -+ init_tlmedia(); my @todo; if ($opt_all || $opt_list) { @todo = $localtlpdb->list_packages; -@@ -634,18 +633,26 @@ +@@ -631,18 +638,22 @@ next; } my $rev = $tlp->revision; - my $mediatlp = $mediatlpdb->get_package($pkg); - if (!defined($mediatlp)) { -- print "$pkg cannot be found in $location\n"; +- debug("$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"); @@ -131,10 +112,6 @@ } - 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) { @@ -151,7 +128,7 @@ } else { # first remove the package, then reinstall it # this way we get rid of useless files -@@ -685,7 +692,7 @@ +@@ -682,7 +693,7 @@ # these packages cannot be upgrade on win32 # so we have to create a update program my $media = $tlmediasrc->media; @@ -160,7 +137,7 @@ my $root = $localtlpdb->root; my $temp = "$root/temp"; TeXLive::TLUtils::mkdirhier($temp); -@@ -719,8 +726,8 @@ +@@ -716,8 +727,8 @@ print "update: $pkg done\n"; } } @@ -171,7 +148,7 @@ next; } } -@@ -740,13 +747,23 @@ +@@ -737,13 +748,23 @@ ); tlwarn("UPDATER has been created, please execute tlpkg\\installer\\updater.bat\n"); } @@ -202,20 +179,12 @@ } 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) { +@@ -766,7 +787,12 @@ 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); ++ my ($maxsrc) = install_candidate($pkg); + if (defined($maxsrc)) { + merge_into(\%ret, $tlmediasrc{$maxsrc}->install_package($pkg, $localtlpdb, $opt_nodepends, 0)); + } else { @@ -224,64 +193,169 @@ } } if ($opt_dry) { -@@ -780,12 +801,17 @@ - return(\%ret); - } - -+# -+# TODO -+# needs to be fixed for multi source support!!! -+ - sub action_list { - init_local_db(); +@@ -781,13 +807,17 @@ 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; + init_tlmedia(); +- my @whattolist; ++ my @whattolist = (); if ($what =~ m/^collection/i) { - @whattolist = $tlmediasrc->tlpdb->collections; -@@ -814,6 +840,8 @@ +- @whattolist = $tlmediasrc->tlpdb->collections; ++ for my $s (values %tlmediatlpdb) { ++ push @whattolist, $s->collections; ++ } + } elsif ($what =~ m/^scheme/i) { +- @whattolist = $tlmediasrc->tlpdb->schemes; ++ for my $s (values %tlmediatlpdb) { ++ push @whattolist, $s->schemes; ++ } + } else { +- @whattolist = $tlmediasrc->tlpdb->list_packages; ++ @whattolist = keys(%media_packages); + } + foreach (@whattolist) { + if (defined($localtlpdb->get_package($_))) { +@@ -795,7 +825,7 @@ + } else { + print " "; + } +- my $foo = $tlmediasrc->tlpdb->get_package($_)->shortdesc; ++ my $foo = $tlmediatlpdb{$media_packages{$_}}->get_package($_)->shortdesc; + print "$_: ", defined($foo) ? $foo : "(shortdesc missing)" , "\n"; + } + return; +@@ -809,15 +839,53 @@ $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 +- # changes the default location +- my $loc = shift @ARGV; +- if ($loc) { +- print "Setting default installation source to $loc!\n"; +- $localtlpdb->option_location($loc); +- $localtlpdb->save; ++ # the location argument is treated as follows ++ # location loc1 loc2 loc3 ++ # location loc1,loc2,loc3 ++ # sets the list of locations to these three ++ # location add loc1 [loc2 ...] ++ # add the location loc to the list ++ # location remove loc1 [loc2 ...] ++ # remove the location from the list ++ my $first = shift @ARGV; ++ $first || ($first = "show"); ++ my $mode = "replace"; ++ my @locargs = (); ++ if ($first =~ m/^add$/i) { $mode = "add"; } ++ elsif ($first =~ m/^remove$/i) { $mode = "remove"; } ++ else { push @locargs, $first unless ($first eq "show"); } ++ push @locargs, @ARGV; ++ my @locs; ++ for my $a (@locargs) { ++ push @locs, split(/,/,$a); ++ } ++ if ($mode eq "add") { ++ if (@locs) { ++ print "Adding @locs to the list of installation sources!\n"; ++ $localtlpdb->add_locations(@locs); ++ } else { ++ tlwarn("Need some argument for location add!\n"); ++ exit(1); ++ } ++ } elsif ($mode eq "remove") { ++ if (@locs) { ++ print "Removing @locs from the list of installation sources!\n"; ++ $localtlpdb->remove_locations(@locs); ++ } else { ++ tlwarn("Need some argument for location remove!\n"); ++ exit(1); ++ } + } else { +- print "Default installation source: ", $localtlpdb->option_location, "\n"; ++ if (@locs) { ++ print "Settings @locs as list of installation sources!\n"; ++ $localtlpdb->option_locations(@locs); ++ } else { ++ for my $l ($localtlpdb->option_locations) { ++ print "Installation source: ", $l, "\n"; ++ } ++ } + } ++ $localtlpdb->save; + } elsif ($what =~ m/^docfiles$/i) { + # changes the default docfiles my $loc = shift @ARGV; - if ($loc) { -@@ -881,8 +909,11 @@ - if ($what =~ m/^list$/i) { +@@ -877,10 +945,16 @@ # 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; + init_tlmedia(); +- my $mediatlpdb = $tlmediasrc->tlpdb; ++ # collect all available architectures from all media sources ++ my %avail_archs; ++ for my $tlpdb (values %tlmediatlpdb) { ++ for my $a ($tlpdb->available_architectures) { ++ $avail_archs{$a} = 1; ++ } ++ } 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"; +- foreach my $a ($mediatlpdb->available_architectures) { ++ foreach my $a (keys %avail_archs) { + if (member($a,@already_installed_arch)) { + print "(i) $a\n"; + } else { +@@ -892,9 +966,15 @@ 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; + init_tlmedia(); +- my $mediatlpdb = $tlmediasrc->tlpdb; ++ # collect all available architectures from all media sources ++ my %avail_archs; ++ for my $tlpdb (values %tlmediatlpdb) { ++ for my $a ($tlpdb->available_architectures) { ++ $avail_archs{$a} = 1; ++ } ++ } my @already_installed_arch = $localtlpdb->available_architectures; - my @available_arch = $mediatlpdb->available_architectures; -@@ -1007,14 +1041,11 @@ +- my @available_arch = $mediatlpdb->available_architectures; ++ my @available_arch = keys %avail_archs; + my @todoarchs; + foreach my $a (@ARGV) { + if (TeXLive::TLUtils::member($a, @already_installed_arch)) { +@@ -917,7 +997,13 @@ + if ($opt_dry) { + print "Installing $pkg.$a\n"; + } else { +- merge_into(\%ret, $tlmediasrc->install_package("$pkg.$a", $localtlpdb, 0, 0)); ++ my ($maxsrc) = install_candidate("$pkg.$a"); ++ if (defined($maxsrc)) { ++ debug("pkg = $pkg, maxsrc = $maxsrc\n"); ++ merge_into(\%ret, $tlmediasrc{$maxsrc}->install_package("$pkg.$a", $localtlpdb, 0, 0)); ++ } else { ++ tlwarn("No installation candidate for $pkg on $a found!\n"); ++ } + } + } + } +@@ -925,9 +1011,14 @@ + } + if (TeXLive::TLUtils::member('win32', @todoarchs)) { + # install the necessary win32 stuff +- merge_into (\%ret, $tlmediasrc->install_package("bin-tlperl.win32", $localtlpdb, 1, 0)); +- merge_into (\%ret, $tlmediasrc->install_package("bin-tlgs.win32", $localtlpdb, 1, 0)); +- merge_into (\%ret, $tlmediasrc->install_package("bin-tlpsv.win32", $localtlpdb, 1, 0)); ++ for my $p (qw/bin-tlperl bin-tlgs bin-tlpsv/) { ++ my ($maxsrc) = install_candidate("bin-tlperl.win32"); ++ if (defined($maxsrc)) { ++ merge_into (\%ret, $tlmediasrc{$maxsrc}->install_package("$p.win32", $localtlpdb, 1, 0)); ++ } else { ++ tlwarn("No installation candidate for $p on win32 found!\n"); ++ } ++ } + } + # update the option_archs list of installed archs + my @larchs = $localtlpdb->option_available_architectures; +@@ -1000,14 +1091,11 @@ } } # let cmd line options override the settings in localtlpdb @@ -299,15 +373,18 @@ 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 { +@@ -1181,18 +1269,65 @@ + # initialize a tlmedia object and returns it, or dies + # + sub init_tlmedia { +- if (($location =~ m/$TeXLiveServerURL/) || +- ($location =~ m/^ctan$/i)) { +- $location = give_ctan_mirror(); +- info("Using mirror $location\n"); +- } +- # $tlmediasrc is a global function +- $tlmediasrc = TeXLive::TLMedia->new($location); +- die($loadmediasrcerror . $location) unless defined($tlmediasrc); + return if $tlmedia_loaded; + my $found = 0; + for my $l (@locations) { @@ -330,10 +407,22 @@ + # 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!"); + } ++ # now we initialize the %media_packages ++ my @allpkgs; ++ for my $s (keys %tlmediasrc) { ++ # will create duplicate entries, but who cares, we are doing hashing then ++ push @allpkgs, $tlmediatlpdb{$s}->list_packages; ++ } ++ for my $p (@allpkgs) { ++ next if defined($media_packages{$p}); ++ next if ($p =~ m/00texlive/); ++ ($media_packages{$p}) = install_candidate($p); ++ } + $tlmedia_loaded = 1; -+} -+ -+ + } + + +- +# +# +sub install_candidate { @@ -360,36 +449,120 @@ # # 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 @@ ++++ tlpkg/TeXLive/TLPDB.pm 2008-08-30 10:03:38.000000000 +0200 +@@ -819,26 +819,25 @@ + =cut + + sub _set_option_value { +- my ($self,$key,$value) = @_; ++ my ($self,$key,@values) = @_; + my $pkg = $self->{'tlps'}{'00texlive-installation.config'}; + my @newdeps; + if (!defined($pkg)) { + $pkg = new TeXLive::TLPOBJ; + $pkg->name("00texlive-installation.config"); + $pkg->category("TLCore"); +- push @newdeps, "$key:$value"; ++ for my $v (@values) { ++ push @newdeps, "$key:$v"; ++ } + } else { + my $found = 0; + foreach my $d ($pkg->depends) { +- if ($d =~ m!^$key:!) { +- $found = 1; +- push @newdeps, "$key:$value"; +- } else { ++ if ($d !~ m!^$key:!) { + push @newdeps, $d; + } + } +- if (!$found) { +- push @newdeps, "$key:$value"; ++ for my $v (@values) { ++ push @newdeps, "$key:$v"; + } + } + $pkg->depends(@newdeps); +@@ -847,13 +846,14 @@ + + sub _option_value { + my ($self,$key) = @_; ++ my @l = (); + if (defined($self->{'tlps'}{'00texlive-installation.config'})) { + foreach my $d ($self->{'tlps'}{'00texlive-installation.config'}->depends) { + if ($d =~ m!^$key:(.*)$!) { +- return "$1"; ++ push @l, "$1"; + } + } +- return ""; ++ return(wantarray ? @l : (@l ? $l[0] : "") ); + } + return; + } +@@ -889,15 +889,62 @@ 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"; -+ } ++ if (@_) { $self->_set_option_value("location", @_); } ++ my @locs = $self->_option_value("location"); ++ my @ret = (); ++ for my $l (@locs) { ++ if ($l eq "__MASTER__") { ++ push @ret, $self->root; ++ } else { ++ push @ret, $l; + } + } -+ return(@locs); ++ return(@ret); ++} ++ ++sub add_locations { ++ my ($self, @locs) = @_; ++ my %foo; ++ for my $l ($self->option_locations) { ++ $foo{$l} = 1; ++ } ++ for my $l (@locs) { ++ $foo{$l} = 1; ++ } ++ $self->option_locations(keys %foo); ++ return(keys %foo); +} + ++sub remove_locations { ++ my ($self, @locs) = @_; ++ my %foo; ++ for my $l ($self->option_locations) { ++ $foo{$l} = 1; ++ } ++ for my $l (@locs) { ++ delete $foo{$l} ++ } ++ $self->option_locations(keys %foo); ++ return(keys %foo); ++} ++ ++# ++# we keep that for backward compatibility ++# option_location is used in the installer, probably nothing else is ++# using it sub option_location { my $self = shift; -- if (@_) { $self->_set_option_value("location", 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]; ++ # since we are in scalar context that returns the first location in the list! ++ my $loc = $self->option_locations; if ($loc eq "__MASTER__") { return $self->root; } - return $self->_option_value("location"); + return $loc; } ++ sub option_sys_bin { my $self = shift; + if (@_) { $self->_set_option_value("opt_sys_bin", shift); } |