diff options
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 87 |
1 files changed, 86 insertions, 1 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index d94ecf9950c..5b25dbf6e05 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -131,7 +131,8 @@ my %actionoptions = ( "generate" => { "localcfg" => "=s", "dest" => "=s" }, "uninstall"=> { "force" => 1 }, - "check" => { "use-svn" => 1 } + "check" => { "use-svn" => 1 }, + "recreate-tlpdb" => { "arch" => "=s" } ); my %optarg; @@ -372,6 +373,9 @@ sub execute_action { } elsif ($action =~ m/^uninstall$/i) { merge_into(\%ret, action_uninstall()); finish(0); + } elsif ($action =~ m/^recreate-tlpdb$/i) { + merge_into(\%ret, action_recreate_tlpdb()); + finish(0); } else { die "$0: unknown action: $action; try --help if you need it.\n"; } @@ -2253,6 +2257,87 @@ sub action_uninstall { system("rmdir", "--ignore-fail-on-non-empty", "$Master"); } +# RECREATE TLPDB +# +sub action_recreate_tlpdb { + my $tlpdb = TeXLive::TLPDB->new; + $tlpdb->root($Master); + my $inst = TeXLive::TLPOBJ->new; + $inst->name("00texlive-installation.config"); + $inst->category("TLCore"); + my @deps; + push @deps, "location:$TeXLive::TLConfig::TeXLiveURL"; + push @deps, "opt_create_formats:0"; + push @deps, "opt_create_symlinks:0"; + push @deps, "opt_sys_bin:/usr/local/bin"; + push @deps, "opt_sys_info:/usr/local/info"; + push @deps, "opt_sys_man:/usr/local/man"; + push @deps, "opt_install_docfiles:0"; + push @deps, "opt_install_srcfiles:0"; + # find list of available archs + my @archs; + opendir (DIR, "$Master/bin") || die "opendir($Master/bin) failed: $!"; + my @dirents = readdir (DIR); + closedir (DIR) || warn "closedir($Master/bin) failed: $!"; + for my $dirent (@dirents) { + next if $dirent eq "."; + next if $dirent eq ".."; + next unless -d "$Master/bin/$dirent"; + if (-r "$Master/bin/$dirent/kpsewhich" || -r "$Master/bin/$dirent/kpsewhich.exe") { + push @archs, $dirent; + debug("Skipping directory $Master/bin/$dirent, no kpsewhich there\n"); + } + } + push @deps, "available_architectures:" . join(" ",@archs); + # we have to find out the default arch + # if there is only one dir in $Master/bin then we are settled, + # otherwise we expect the user to pass a correct arch string + if ($^O =~ /^MSWin(32|64)$/i) { + push @deps, "platform:win32"; + } else { + if ($#archs == 0) { + # only one arch available, fine, use it as default + push @deps, "platform:$archs[0]"; + } else { + if (defined($opts{"arch"})) { + if (member($opts{"arch"}, @archs)) { + push @deps, "platform:" . $opts{"arch"}; + } else { + tlwarn("The architecture you passed in with --arch is not present in $Master/bin\n"); + tlwarn("Please specify one from the available ones: @archs\n"); + exit(1); + } + } else { + tlwarn("More than one architecture available: @archs\n"); + tlwarn("Please pass one as the default you are running on with --arch=...\n"); + exit(1); + } + } + } + $inst->depends(@deps); + # now we have all the stuff for 00texlive-installation.config done + $tlpdb->add_tlpobj($inst); + # add the other stuff in $Master/tlpkg/tlpobj/*.tlpobj + # we can ignore *.{source,doc}.tlpobj because they are already + # included in the *.tlpobj parent one at install time + # (TODO: we should actually REMOVE the *.{source,doc}.tlpobj files + # at package install time) + opendir (DIR, "$Master/tlpkg/tlpobj") or die "opendir($Master/tlpkg/tlpobj) failed: $!"; + my @tlps = readdir(DIR); + closedir (DIR) || warn "closedir($Master/tlpkg/tlpobj) failed: $!"; + for my $t (@tlps) { + next if -d $t; # also does . and .. + next if ($t !~ m/\.tlpobj$/i); + # ignore .source and .doc tlpobjs + next if ($t =~ m/\.(source|doc)\.tlpobj$/i); + my $tlp = TeXLive::TLPOBJ->new; + $tlp->from_file("$Master/tlpkg/tlpobj/$t"); + $tlpdb->add_tlpobj($tlp); + } + # writeout the re-created tlpdb to stdout + $tlpdb->writeout; + return; +} # CHECK # |