diff options
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 237 |
1 files changed, 165 insertions, 72 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index 0bd4a9e49b0..51f45796fdf 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -138,7 +138,38 @@ if ($action =~ m/^_include_tlpobj$/) { init_local_db(); my $tlpobj = TeXLive::TLPOBJ->new; $tlpobj->from_file($ARGV[0]); - $localtlpdb->add_tlpobj($tlpobj); + # we now have to check whether that is a .doc or .src package, so shipping + # src or doc files from a different package. + # We *really* should have that package already installed ... + my $pkg = $tlpobj->name; + if ($pkg =~ m/^(.*)\.(src|doc)$/) { + # got a .src or .doc package + my $type = $2; + my $mothership = $1; + my $mothertlp = $localtlpdb->get_package($mothership); + if (!defined($mothertlp)) { + tlwarn("We are trying to add ${type}files to a not existing package $mothership!\n"); + tlwarn("Trying to continue!\n"); + # the best we can do is rename that package to $mothername and add it! + $tlpobj->name($mothership); + # add the src/docfiles tlpobj under the mothership name + $localtlpdb->add_tlpobj($tlpobj); + } else { + if ($type eq "src") { + $mothertlp->srcfiles($tlpobj->srcfiles); + $mothertlp->srcsize($tlpobj->srcsize); + } else { + # must be "doc" + $mothertlp->docfiles($tlpobj->docfiles); + $mothertlp->docsize($tlpobj->docsize); + } + # that make sure that the original entry is overwritten + $localtlpdb->add_tlpobj($mothertlp); + } + } else { + # completely normal package, just add it + $localtlpdb->add_tlpobj($tlpobj); + } $localtlpdb->save; exit(0); } elsif ($action =~ m/^generate$/i) { @@ -642,7 +673,136 @@ sub action_backup { return(\%ret); } - +sub start_win32_updater { + my $root = shift; + open UPDATER, ">" . $root . "/tlpkg/installer/updater.bat" + or die "Cannot create updater.bat: $!"; + print UPDATER <<'EOF'; +rem update program, can savely removed after it has been done +set tlupdate=%~dp0 +set tldrive=%~d0 + +%tldrive% +cd %tlupdate% +rem now we are in .../tlpkg/installer +rem create tar.exe backup +copy tar.exe tarsave.exe +cd .. +cd .. +rem now we are in the root + +EOF +; + $::UPDATER = \*UPDATER; +} + +$::updater_started = 0; + +# +# TODO TODO TODO +# Creating a win32 updater does currently NOT include the doc files since +# they are in a separate container and are thus not installed. +# +sub add_win32_updater { + my ($tlp, $opt_dry) = @_; + sub do_one { + my $pkg = shift; + print $::UPDATER <<EOF; +tlpkg\\installer\\lzma\\lzmadec.win32.exe < temp\\$pkg.tar.lzma > temp\\$pkg.tar +tlpkg\\installer\\tarsave.exe -x -f temp\\$pkg.tar +call tlmgr _include_tlpobj tlpkg\\tlpobj\\$pkg.tlpobj +del temp\\$pkg.tar.lzma +EOF +; + } + + my $pkg = $tlp->name; + # that could be more intelligent for decent $opt_dry output + my $root = $localtlpdb->root; + my $temp = "$root/temp"; + next if $opt_dry; + if (!$::updater_started) { + open_win32_updater($root); + $::updater_started = 1; + } + # these packages cannot be upgrade on win32 + # so we have to create a update program + my $media = $tlmediasrc->media; + my $mediatlpdb = $tlmediasrc->tlpdb; + my $remoteroot = $mediatlpdb->root; + # + # we have to download/copy also the src/doc files if necessary! + my $container_src_split = $mediatlpdb->config_src_container; + my $container_doc_split = $mediatlpdb->config_doc_container; + # get options about src/doc splitting from $totlpdb + my $opt_src = $localtlpdb->option_install_srcfiles; + my $opt_doc = $localtlpdb->option_install_docfiles; + my $real_opt_doc = $opt_doc; + if ($tlp->category =~ m/documentation/i) { + # we do install documenation files for category Documentation + # even if opt_doc is false + $real_opt_doc = 1; + } + my $do_src = 0; + my $do_doc = 0; + $do_src = 1 if ($container_src_split && $opt_src && $tlp->srcfiles); + $do_doc = 1 if ($container_doc_split && $real_opt_doc && $tlp->docfiles); + TeXLive::TLUtils::mkdirhier($temp); + if ($media eq 'DVD') { + tlwarn ("Creating updater from DVD currently not implemented!\n"); + tlwarn ("But that should not be necessary!\n"); + } else { + if ($media eq 'CD') { + copy("$remoteroot/$Archive/$pkg.tar.lzma", "$temp"); + copy("$remoteroot/$Archive/$pkg.doc.tar.lzma", "$temp") if $do_doc; + copy("$remoteroot/$Archive/$pkg.src.tar.lzma", "$temp") if $do_src; + } else { # net + TeXLive::TLUtils::download_file("$remoteroot/$Archive/$pkg.tar.lzma", "$temp/$pkg.tar.lzma"); + TeXLive::TLUtils::download_file("$remoteroot/$Archive/$pkg.doc.tar.lzma", "$temp/$pkg.doc.tar.lzma") if $do_doc; + TeXLive::TLUtils::download_file("$remoteroot/$Archive/$pkg.src.tar.lzma", "$temp/$pkg.src.tar.lzma") if $do_src; + } + # now we should have the file present + if (! -r "$temp/$pkg.tar.lzma") { + tlwarn ("Couldn't get $pkg.tar.lzma, that is bad\n"); + } else { + # add lines to the un-archiver + do_one ($pkg); + } + if ($do_src && ! -r "$temp/$pkg.src.tar.lzma") { + tlwarn ("Couldn't get $pkg.src.tar.lzma, that is bad\n"); + } else { + # add lines to the un-archiver + do_one ("$pkg.src"); + } + if ($do_doc && ! -r "$temp/$pkg.doc.tar.lzma") { + tlwarn ("Couldn't get $pkg.doc.tar.lzma, that is bad\n"); + } else { + # add lines to the un-archiver + do_one ("$pkg.doc"); + } + } +} + +sub close_win32_updater { + if ($::updater_started) { + print $::UPDATER "del tlpkg\\installer\\tarsave.exe\n"; + print $::UPDATER "rem del /s /q temp\n"; + print $::UPDATER "rem rmdir temp\n"; + close ($::UPDATER); + # create a desktop shortcut + add_desktop_shortcut( + $localtlpdb->root, + 'TeX Live Updater Final Step', + '', # the icon + $localtlpdb->root.'/tlpkg/installer/updater.bat', + '', # no args + '', # any non-null value to hide command-prompt + ); + tlwarn("UPDATER has been created, please execute\n"); + tlwarn(" " . $localtlpdb->root . "\\tlpkg\\installer\\updater.bat\n"); + } +} + # UPDATE # # tlmgr update foo @@ -758,7 +918,6 @@ sub action_update { if (!@todo) { tlwarn ("tlmgr update: please specify a list of packages or --all.\n"); } - my $updater_started = 0; my $nrupdated = 0; # update all .ARCH dependencies, too, unless $opt_reallynodepends @todo = $mediatlpdb->expand_dependencies("-only-arch", $localtlpdb, @todo) unless $opt_reallynodepends; @@ -793,64 +952,13 @@ sub action_update { if (! -d $opt_backupdir) { tlwarn("backupdir argument must be an existing directory!\n"); } else { - my $tlp = $localtlpdb->get_package($pkg); $tlp->make_container("lzma", $root, $opt_backupdir, "${pkg}.r" . $tlp->revision); $unwind_package = "$opt_backupdir/${pkg}.r" . $tlp->revision . ".tar.lzma"; } } if (win32() && ($pkg =~ m/$WinSpecialUpdatePackagesRegexp/)) { - # that could be more intelligent for decent $opt_dry output - next if $opt_dry; - if (!$updater_started) { - open UPDATER, ">" . $root . "/tlpkg/installer/updater.bat" - or die "Cannot create updater.bat: $!"; - print UPDATER <<'EOF'; -rem update program, can savely removed after it has been done -set tlupdate=%~dp0 -set tldrive=%~d0 - -%tldrive% -cd %tlupdate% -rem now we are in .../tlpkg/installer -rem create tar.exe backup -copy tar.exe tarsave.exe -cd .. -cd .. -rem now we are in the root - -EOF -; - $updater_started = 1; - } - # these packages cannot be upgrade on win32 - # so we have to create a update program - my $media = $tlmediasrc->media; - my $remoteroot = $mediatlpdb->root; - TeXLive::TLUtils::mkdirhier($temp); - if ($media eq 'DVD') { - tlwarn ("Creating updater from DVD currently not implemented!\n"); - } else { - if ($media eq 'CD') { - copy("$remoteroot/$Archive/$pkg.tar.lzma", "$temp"); - } else { # net - TeXLive::TLUtils::download_file("$remoteroot/$Archive/$pkg.tar.lzma", "$temp/$pkg.tar.lzma"); - } - # now we should have the file present - if (! -r "$temp/$pkg.tar.lzma") { - tlwarn ("Couldn't get $pkg.tar.lzma, that is bad\n"); - } else { - # add lines to the un-archiver - print UPDATER <<EOF; -tlpkg\\installer\\lzma\\lzmadec.win32.exe < temp\\$pkg.tar.lzma > temp\\$pkg.tar -tlpkg\\installer\\tarsave.exe -x -f temp\\$pkg.tar -call tlmgr _include_tlpobj tlpkg\\tlpobj\\$pkg.tlpobj -rem for now disable the removal of the downloads, we could need it for testing -rem del temp\\$pkg.tar.lzma -EOF -; - } - } + add_win32_updater($tlp, $opt_dry); } else { info("update: $pkg ($rev -> $mediarev) ... "); if ($opt_dry) { @@ -937,23 +1045,8 @@ EOF logpackage("remove: $p"); } } - if ($updater_started) { - print UPDATER "del tlpkg\\installer\\tarsave.exe\n"; - print UPDATER "rem del /s /q temp\n"; - print UPDATER "rem rmdir temp\n"; - close (UPDATER); - # create a desktop shortcut - add_desktop_shortcut( - $localtlpdb->root, - 'TeX Live Updater Final Step', - '', # $vars{'TEXDIR'}.'/tlpkg/doc/notes.ico', # the icon - $localtlpdb->root.'/tlpkg/installer/updater.bat', - '', # no args - '', # any non-null value to hide command-prompt - ); - tlwarn("UPDATER has been created, please execute\n"); - tlwarn(" " . $localtlpdb->root . "\\tlpkg\\installer\\updater.bat\n"); - } + # that already checks whether we actually have to do something + close_win32_updater(); 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"); |