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/TLPDB.pm | |
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/TLPDB.pm')
-rw-r--r-- | Master/tlpkg/TeXLive/TLPDB.pm | 89 |
1 files changed, 89 insertions, 0 deletions
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 |