diff options
author | Norbert Preining <preining@logic.at> | 2008-10-01 17:26:02 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2008-10-01 17:26:02 +0000 |
commit | e758d5db577a87bfb7544b1b53f0221bfc928498 (patch) | |
tree | 0e07e875601b0c5171fdb3e59c2bb0ea4057531b /Master/tlpkg/TeXLive | |
parent | 595a59f25219699deb4372ed7ce67ce8831f22af (diff) |
rework of the tlmgr functioning as described
git-svn-id: svn://tug.org/texlive/trunk@10816 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive')
-rw-r--r-- | Master/tlpkg/TeXLive/TLMedia.pm | 35 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLPDB.pm | 89 |
2 files changed, 91 insertions, 33 deletions
diff --git a/Master/tlpkg/TeXLive/TLMedia.pm b/Master/tlpkg/TeXLive/TLMedia.pm index 3d172abfd7b..60138d7eb93 100644 --- a/Master/tlpkg/TeXLive/TLMedia.pm +++ b/Master/tlpkg/TeXLive/TLMedia.pm @@ -89,14 +89,14 @@ sub new # returns a scalar (0) on error # returns a reference to a hash with actions on success sub install_package { - my ($self, $pkg, $totlpdb, $nodepends, $nopostinstall, $fallbackmedia) = @_; + my ($self, $pkg, $totlpdb, $nopostinstall, $fallbackmedia) = @_; my $fromtlpdb = $self->tlpdb; my $ret; die("TLMedia not initialized, cannot find tlpdb!") unless (defined($fromtlpdb)); my $tlpobj = $fromtlpdb->get_package($pkg); if (!defined($tlpobj)) { if (defined($fallbackmedia)) { - if ($ret = $fallbackmedia->install_package($pkg,$totlpdb, $nodepends, $nopostinstall)) { + if ($ret = $fallbackmedia->install_package($pkg,$totlpdb, $nopostinstall)) { debug("installed $pkg from fallback"); return $ret; } else { @@ -204,37 +204,6 @@ sub install_package { # compute the return value my %ret; merge_into(\%ret, $tlpobj->make_return_hash_from_executes("enable")); - # now install all the depends if they are not already present - # NOTE: installation of .ARCH dependencies is done in *ANY*CASE*, regardless - # of the $nodepends setting - foreach my $d ($tlpobj->depends) { - if ($d =~ m/^(.*)\.ARCH$/) { - # we only want to try to install a .ARCH package if it actually contains - # files - my $foo = $1; - foreach my $a ($totlpdb->available_architectures) { - if (defined($fromtlpdb->get_package("$foo.$a")) && - !defined($totlpdb->get_package("$foo.$a"))) { - merge_into(\%ret, - $self->install_package("$foo.$a", $totlpdb, $nodepends, $fallbackmedia, 0)); - } - } - } elsif ($d =~ m/^(.*).win32$/) { - # install only of win32 is under the available archs - if (TeXLive::TLUtils::member("win32",$totlpdb->available_architectures)) { - merge_into(\%ret, - $self->install_package($d, $totlpdb, $nodepends, $nopostinstall, $fallbackmedia)); - } - } else { - if (!$nodepends) { - if (!defined($totlpdb->get_package($d))) { - # we have to install it! - merge_into(\%ret, - $self->install_package($d, $totlpdb, $nodepends, $nopostinstall, $fallbackmedia)); - } - } - } - } if (!$nopostinstall) { # do the postinstallation actions if (defined($PostInstall{$pkg})) { diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm index 27685233428..e3fa244396b 100644 --- a/Master/tlpkg/TeXLive/TLPDB.pm +++ b/Master/tlpkg/TeXLive/TLPDB.pm @@ -33,6 +33,8 @@ C<TeXLive::TLPDB> -- A database of TeX Live Packages $tlpdb->remove_package($pkg); $tlpdb->get_package("packagename"); $tlpdb->list_packages; + $tlpdb->expand_dependencies(["-only-arch",] $totlpdb, @list); + $tlpdb->expand_dependencies(["-no-collections",] $totlpdb, @list); $tlpdb->find_file("filename"); $tlpdb->collections; $tlpdb->schemes; @@ -446,6 +448,93 @@ sub list_packages { =pod +=item C<< $tlpdb->expand_dependencies >> + +This function takes as first argument the target TLPDB and then a list of +packages and returns the closure of this +list with respect to the depends operator. (Sorry, that was for +mathematicians) + +If the very first argument is "-only-arch" then it expands only dependencies +of the form .ARCH. + +=cut + +sub expand_dependencies { + my $self = shift; + my $only_arch = 0; + my $no_collections = 0; + my $first = shift; + my $totlpdb; + if ($first eq "-only-arch") { + $only_arch = 1; + $totlpdb = shift; + } elsif ($first eq "-no-collections") { + $no_collections = 1; + $totlpdb = shift; + } else { + $totlpdb = $first; + } + my %install = (); + my @archs = $totlpdb->available_architectures; + for my $p (@_) { + $install{$p} = 1; + } + my $changed = 1; + while ($changed) { + $changed = 0; + my @pre_select = keys %install; + ddebug("pre_select = @pre_select\n"); + for my $p (@pre_select) { + next if ($p =~ m/^00texlive/); + my $pkg = $self->get_package($p); + if (!defined($pkg)) { + debug("W: $p is mentioned somewhere but not available, disabling it!\n"); + $install{$p} = 0; + next; + } + for my $p_dep ($pkg->depends) { + ddebug("checking $p_dep in $p\n"); + my $tlpdd = $self->get_package($p_dep); + if (defined($tlpdd)) { + if ($tlpdd->category =~ m/$MetaCategoriesRegexp/) { + # we are taking a look at a dependency which is a collection + # or scheme, and if the option "-no-collections" is given + # we skip that one + ddebug("expand_deps: skipping $p_dep in $p due to -no-collections\n"); + next if $no_collections; + } + } + if ($p_dep =~ m/^(.*)\.ARCH$/) { + my $foo = "$1"; + foreach $a (@archs) { + $install{"$foo.$a"} = 1 if defined($self->get_package("$foo.$a")); + } + } elsif ($p_dep =~ m/^(.*)\.win32$/) { + # a win32 package should *only* be installed if we are installing + # the win32 arch + if (grep(/^win32$/,@archs)) { + $install{$p_dep} = 1; + } + } else { + $install{$p_dep} = 1 unless $only_arch; + } + } + } + + # check for newly selected packages + my @post_select = keys %install; + ddebug("post_select = @post_select\n"); + ddebug("nr pre select $#pre_select, nr post select $#post_select\n"); + if ($#pre_select != $#post_select) { + $changed = 1; + } + } + return(keys %install); +} + +=pod + =item C<< $tlpdb->find_file("filename") >> The C<find_file> returns a list of packages:filename |