diff options
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr.pl | 198 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLMedia.pm | 38 | ||||
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 21 |
3 files changed, 149 insertions, 108 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr.pl b/Master/texmf/scripts/texlive/tlmgr.pl index dee1e083eaf..e575319a613 100755 --- a/Master/texmf/scripts/texlive/tlmgr.pl +++ b/Master/texmf/scripts/texlive/tlmgr.pl @@ -44,7 +44,7 @@ use TeXLive::TLConfig; use TeXLive::TLMedia; use TeXLive::TLUtils; use TeXLive::TLWinGoo; -TeXLive::TLUtils->import( qw(kpsewhich member win32) ); +TeXLive::TLUtils->import( qw(kpsewhich member win32 merge_into) ); use Cwd qw/abs_path/; use Pod::Usage; use Getopt::Long qw(:config no_autoabbrev require_order); @@ -94,50 +94,51 @@ if ($opt_debug) { $::LOGLEVELTERMINAL = $::LOG_DDDEBUG; } -my $ret = 0; +my %ret; if ($action =~ m/^generate$/i) { - $ret = action_generate(); - # should we do postinstall stuff? - exit(0); + merge_into(\%ret, action_generate()); } elsif ($action =~ m/^arch$/i) { - $ret = action_arch(); + merge_into(\%ret, action_arch()); } elsif ($action =~ m/^default$/i) { - $ret = action_default(); + merge_into(\%ret, action_default()); # should we do postinstall stuff? exit(0); } elsif ($action =~ m/^list$/i) { - $ret = action_list(); + merge_into(\%ret, action_list()); # should we do postinstall stuff? exit(0); } elsif ($action =~ m/^install$/i) { - $ret = action_install(); + merge_into(\%ret, action_install()); } elsif ($action =~ m/^update$/i) { - $ret = action_update(); + merge_into(\%ret, action_update()); } elsif ($action =~ m/^(global)?search$/i) { - $ret = action_search($action); + merge_into(\%ret, action_search($action)); exit(0); } elsif ($action =~ m/^show$/i) { - $ret = action_show(); + merge_into(\%ret, action_show()); exit(0); } elsif ($action =~ m/^remove$/i) { - $ret = action_remove(); + merge_into(\%ret, action_remove()); } elsif (($action eq "paper") || ($action eq "dvips") || ($action eq "xdvi") || ($action eq "pdftex") || ($action eq "dvipdfm") || ($action eq "dvipdfmx")) { my $TEXMFMAIN = `kpsewhich -var-value=TEXMFMAIN`; chomp $TEXMFMAIN; system("texlua", "$TEXMFMAIN/scripts/texlive/texconf.tlu", "--prog", "tlmgr", "--sys", $action, @ARGV); - $ret = 0; } elsif ($action =~ m/^uninstall$/i) { - $ret = action_uninstall(); + merge_into(\%ret, action_uninstall()); exit(0); } else { die "Unknown action: $action"; } -if ($ret & 0x0001) { +###################################### + +# +# checking the %ret hash +if (defined($ret{'mktexlsr'})) { print "running mktexlsr\n"; system("mktexlsr"); } @@ -145,16 +146,15 @@ my $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`; chomp $TEXMFSYSVAR; my $TEXMFLOCAL = `kpsewhich -var-value=TEXMFLOCAL`; chomp $TEXMFLOCAL; -if ($ret & 0x0010) { - print "regenerating updmap.cfg\n"; - TeXLive::TLUtils::create_updmap ($localtlpdb, - "$TEXMFSYSVAR/web2c/updmap.cfg", - "$TEXMFLOCAL/web2c/updmap-local.cfg"); - # system("texconfig-sys", "generate", "updmap"); - print "running updmap-sys\n"; +if (defined($ret{'map'})) { + foreach my $m (@{$ret{'map'}}) { + print "$m\n"; + system("updmap-sys --nomkmap --nohash --$m"); + } + system("mktexlsr"); system("updmap-sys"); } -if ($ret & 0x0100) { +if (defined($ret{'format'})) { print "regenerating fmtutil.cnf\n"; TeXLive::TLUtils::create_fmtutil($localtlpdb, "$TEXMFSYSVAR/web2c/fmtutil.cnf", @@ -167,7 +167,7 @@ if ($ret & 0x0100) { system("fmtutil-sys", "--missing"); } } -if ($ret & 0x1000) { +if (defined($ret{'language'})) { print "regenerating language.dat\n"; TeXLive::TLUtils::create_language($localtlpdb, "$TEXMFSYSVAR/tex/generic/config/language.dat", @@ -193,7 +193,7 @@ exit(0); sub remove_package { my ($pkg, $localtlpdb, $force) = @_; my $tlp = $localtlpdb->get_package($pkg); - my $ret = 0; + my %ret; if (!defined($tlp)) { print "Package $pkg not present, cannot remove it!\n"; } else { @@ -202,7 +202,7 @@ sub remove_package { my @needed = $localtlpdb->needed_by($pkg); if (@needed) { print "Not removing $pkg, is referenced in @needed!\n"; - return $ret; + return; } } print "remove package $pkg\n"; @@ -227,23 +227,28 @@ sub remove_package { rmdir $entry; } $localtlpdb->remove_package($pkg); - $ret |= 0x0001; # call mktexlsr + my (@maps, @formats, @dats); + $ret{'mktexlsr'} = 1; foreach my $e ($tlp->executes) { - if ($e =~ m/^add/) { - $ret |= 0x0010; - } elsif ($e =~ m/^BuildFormat/) { - $ret |= 0x0100; - } elsif ($e =~ m/^BuildLanguageDat/) { - $ret |= 0x1000; + if ($e =~ m/^add((Mixed)?Map)\s+([^\s]+)\s*$/) { + push @maps, "disable $3"; + } elsif ($e =~ m/^BuildFormat\s+([^\s]+)\s*$/) { + push @formats, $1; + } elsif ($e =~ m/^BuildLanguageDat\s+([^\s]+)\s*$/) { + push @dats, $1; } else { warn("Unknown execute $e in $pkg"); } } + $ret{'map'} = [ @maps ] if (@maps); + $ret{'format'} = [ @formats ] if (@formats); + $ret{'language'} = [ @dats ] if (@dats); # remove those bin dependencies .ARCH foreach my $d ($tlp->depends) { if ($d eq "$pkg.ARCH") { foreach my $a ($localtlpdb->available_architectures) { - $ret |= &remove_package("$pkg.$a", $localtlpdb, $force); + merge_into(\%ret, + &remove_package("$pkg.$a", $localtlpdb, $force)); } } } @@ -253,7 +258,7 @@ sub remove_package { # still I consider it better that the tlpdb is in a consistent state $localtlpdb->save; } - return $ret; + return \%ret; } sub action_remove { @@ -272,7 +277,7 @@ sub action_remove { # . check that no collection/scheme still depends on this package # . remove the package # - my $ret = 0; + my %ret; my $opt_nodepends = 0; my $opt_force = 0; my $opt_dry = 0; @@ -296,19 +301,19 @@ sub action_remove { if ($tlp->category eq "Collection") { # for collections we also remove all dependencies which are # not Collections or Schemes - my $foo; + my %foo; if ($opt_dry) { print "Removing $pkg\n"; # we need to set $foo to something positive otherwise # the rest will not be run in dry_run mode - $foo = 0x0001; + $foo{'mktexlsr'} = 1; } else { - $foo = &remove_package($pkg, $localtlpdb, $opt_force); + merge_into(\%foo, &remove_package($pkg, $localtlpdb, $opt_force)); } - if ($foo) { + if (keys %foo) { # removal was successful, so the return is at least 0x0001 mktexlsr # remove dependencies, too - $ret |= $foo; + merge_into(\%ret, \%foo); $already_removed{$pkg} = 1; if (!$opt_nodepends) { foreach my $d ($tlp->depends) { @@ -318,7 +323,7 @@ sub action_remove { if ($opt_dry) { print "Removing $d\n"; } else { - $ret |= &remove_package($d, $localtlpdb, $opt_force); + merge_into(\%ret, &remove_package($d, $localtlpdb, $opt_force)); } $already_removed{$d} = 1; } @@ -340,16 +345,16 @@ sub action_remove { if ($opt_dry) { print "Removing $pkg\n"; } else { - $ret |= &remove_package($pkg, $localtlpdb, $opt_force); + merge_into(\%ret, &remove_package($pkg, $localtlpdb, $opt_force)); } } } if ($opt_dry) { # stop here, don't do any postinstall actions - return(0); + return; } else { $localtlpdb->save; - return($ret); + return(\%ret); } } @@ -379,7 +384,7 @@ sub action_show { printf STDERR "Cannot find $pkg\n"; } } - return(0); + return; } sub action_search { @@ -420,7 +425,7 @@ sub action_search { } } print "$ret"; - return(0); + return; } sub action_update { @@ -431,7 +436,7 @@ sub action_update { Getopt::Long::Configure(qw(no_pass_through)); GetOptions("no-depends" => \$opt_nodepends, "dry-run" => \$opt_dry) or pod2usage(1); - my $ret = 0; + my %ret; $tlmediasrc = TeXLive::TLMedia->new($location); my $mediatlpdb = $tlmediasrc->tlpdb; foreach my $pkg ($localtlpdb->list_packages) { @@ -451,15 +456,15 @@ sub action_update { # first remove the package, then reinstall it # this way we get rid of useless files # force the deinstallation since we will reinstall it - $ret |= &remove_package($pkg, $localtlpdb, 1); - $ret |= $tlmediasrc->install_package($pkg, $localtlpdb, $opt_nodepends, 1); + merge_into(\%ret, &remove_package($pkg, $localtlpdb, 1)); + merge_into(\%ret, $tlmediasrc->install_package($pkg, $localtlpdb, $opt_nodepends, 1)); } } elsif ($rev > $mediarev) { print "revision in $location is less then local revision, not updating!\n"; next; } } - return($ret); + return(\%ret); } sub action_install { @@ -470,21 +475,21 @@ sub action_install { Getopt::Long::Configure(qw(no_pass_through)); GetOptions("no-depends" => \$opt_nodepends, "dry-run" => \$opt_dry) or pod2usage(1); - my $ret = 0; + my %ret; $tlmediasrc = TeXLive::TLMedia->new($location); foreach my $pkg (@ARGV) { if ($opt_dry) { print "Installing $pkg\n"; } else { # install the packages and run postinstall actions (that is the 1) - $ret |= $tlmediasrc->install_package($pkg, $localtlpdb, $opt_nodepends, 1); + merge_into(\%ret, $tlmediasrc->install_package($pkg, $localtlpdb, $opt_nodepends, 1)); } } if ($opt_dry) { # stop here, don't do any postinstall actions return(0); } - return($ret); + return(\%ret); } sub action_list { @@ -509,7 +514,7 @@ sub action_list { my $foo = $tlmediasrc->tlpdb->get_package($_)->shortdesc; print "$_: ", defined($foo) ? $foo : "(shortdesc missing)" , "\n"; } - return(0); + return; } sub action_default { @@ -564,12 +569,12 @@ sub action_default { } else { warn "Setting other options currently not supported, please edit texlive.tlpdb!"; } - return(0); + return; } sub action_arch { my $what = shift @ARGV; - my $ret = 0; + my %ret; my $opt_dry = 0; Getopt::Long::Configure(qw(no_pass_through)); GetOptions("dry-run" => \$opt_dry) or pod2usage(1); @@ -618,7 +623,7 @@ sub action_arch { if ($opt_dry) { print "Installing $pkg.$a\n"; } else { - $ret |= $tlmediasrc->install_package("$pkg.$a", $localtlpdb, 0, 1); + merge_into(\%ret, $tlmediasrc->install_package("$pkg.$a", $localtlpdb, 0, 1)); } } } @@ -626,13 +631,13 @@ sub action_arch { } if (TeXLive::TLUtils::member('win32', @todoarchs)) { # install the necessary win32 stuff - $ret |= $tlmediasrc->install_package("bin-tlperl.win32", $localtlpdb, 1, 1); - $ret |= $tlmediasrc->install_package("bin-tlgs.win32", $localtlpdb, 1, 1); + merge_into (\%ret, $tlmediasrc->install_package("bin-tlperl.win32", $localtlpdb, 1, 1)); + merge_into (\%ret, $tlmediasrc->install_package("bin-tlgs.win32", $localtlpdb, 1, 1)); } } else { die "Unknown option for arch: $what"; } - return($ret); + return(\%ret); } sub action_generate { @@ -660,7 +665,7 @@ sub action_generate { } else { die "Unknown option for generate: $what"; } - return(0); + return; } sub init_local_db { @@ -684,12 +689,17 @@ sub action_uninstall { printf STDERR "Please use \"Add/Remove Programs\" from the Control Panel to removing TeX Live!\n"; exit(1); } - print("If you answer yes here the whole TeX Live installation will be removed!\n"); - print "Remove TeX Live (y/N): "; - my $yesno = <STDIN>; - if ($yesno !~ m/^y(es)?$/i) { - print "Ok, cancelling the removal!\n"; - exit(0); + my $force = 0; + Getopt::Long::Configure(qw(no_pass_through)); + GetOptions("force" => \$force) or pod2usage(1); + if (!$force) { + print("If you answer yes here the whole TeX Live installation will be removed!\n"); + print "Remove TeX Live (y/N): "; + my $yesno = <STDIN>; + if ($yesno !~ m/^y(es)?$/i) { + print "Ok, cancelling the removal!\n"; + exit(0); + } } print ("Ok, removing the whole installation:\n"); init_local_db; @@ -893,18 +903,18 @@ Gives this help page. =item B<install [options] pkg1 [pkg2 [pkg3 ...]]> Install all packages given on the cmdline. By default this installs all -dependencies, too. See below for the option B<-no-depends>. +dependencies, too. See below for the option B<--no-depends>. B<Supported options> =over 16 -=item B<-no-depends> +=item B<--no-depends> Do not install dependencies. If this option is not given installing a package will check that all dependencies of this package are fulfilled. -=item B<-dry-run> +=item B<--dry-run> Enables the chicken mode, i.e., nothing is actually installed but the actions to be performed @@ -920,7 +930,7 @@ B<Supported options> =over 16 -=item B<-dry-run> +=item B<--dry-run> Enables the chicken mode, i.e., nothing is actually installed but the actions to be performed @@ -932,27 +942,27 @@ are written to the terminal. =item B<remove [options] pkg1 [pkg2 [pkg3 ...]]> Remove all packages given on the cmdline. Removing a collection will -remove all dependencies, too, unless with option B<-no-depends>. +remove all dependencies, too, unless with option B<--no-depends>. Removing a package which is referenced as a dependency in another -collection or scheme will not succeed unless the B<-force> option is given. +collection or scheme will not succeed unless the B<--force> option is given. B<Supported options> =over 16 -=item B<-no-depends> +=item B<--no-depends> Do not remove depending packages. -=item B<-force> +=item B<--force> When removing a package or collection would invalidate a dependency of another collection/scheme, the package will not be removed and a warning issued. With this options the package will be removed unconditionally. Use with care. -=item B<-dry-run> +=item B<--dry-run> Enables the chicken mode, i.e., nothing is actually removed but the actions to be performed @@ -997,7 +1007,7 @@ B<Supported options> =over 16 -=item B<-dry-run> +=item B<--dry-run> For installation and removal of packages, this options enables the chicken mode, i.e., nothing is actually installed but the actions to be performed @@ -1008,20 +1018,20 @@ this options does B<NOT> work! =back -=item B<search [-file] what> +=item B<search [--file] what> Search the names, short and long descriptions of all locally installed packages for the given argument (interpreted as regexp). -With the B<-file> argument searches for files containing C<what> somewhere +With the B<--file> argument searches for files containing C<what> somewhere in the path, and returning each package with the respective hit. -=item B<globalsearch [-file] what> +=item B<globalsearch [--file] what> Search the names, short and long descriptions of all packages available on the install media. -With the B<-file> argument searches for files containing C<what> somewhere +With the B<--file> argument searches for files containing C<what> somewhere in the path, and returning each package with the respective hit. =item B<show [pkg [pkg [...]]]> @@ -1042,7 +1052,15 @@ With arguments lists only collections or schemes. Uninstalls the TeX Live installation. -(This options is implemented in the texlua script and uninstall-tl.pl) +B<Supported options> + +=over 16 + +=item B<--force> + +Do not ask for confirmation, remove immediately. + +=back =item B<generate language> @@ -1058,11 +1076,11 @@ B<Supported options> =over 16 -=item C<-dest> I<output file> +=item C<--dest> I<output file> specifies the output file (defaults to the respective location in TEXMFSYSVAR). -=item C<-localcfg> I<local conf file> +=item C<--localcfg> I<local conf file> specifies the (optional) local additions (defaults to the respective location in TEXMFSYSVAR). @@ -1076,22 +1094,22 @@ in TEXMFSYSVAR). =over 8 -=item B<-location> I<location> +=item B<--location> I<location> Overrides the location as found in the tlpdb of the installation. Specifies the location from which packages should be installed or updated. -=item B<-netarchive> I<dir> +=item B<--netarchive> I<dir> Overrides the default settings for netarchive. Should be used with care. -=item B<-diskarchive> I<dir> +=item B<--diskarchive> I<dir> Overrides the default settings for diskarchive. Should be used with care. =back -The standard options C<-help/-h/-?> and C<-debug> are also accepted. +The standard options C<--help/-h/-?> and C<--debug> are also accepted. =head1 DESCRIPTION diff --git a/Master/tlpkg/TeXLive/TLMedia.pm b/Master/tlpkg/TeXLive/TLMedia.pm index ff98271e0dc..89ef0737684 100644 --- a/Master/tlpkg/TeXLive/TLMedia.pm +++ b/Master/tlpkg/TeXLive/TLMedia.pm @@ -10,7 +10,7 @@ package TeXLive::TLMedia; use TeXLive::TLConfig; use TeXLive::TLPostInstall; -use TeXLive::TLUtils qw(tllog copy win32 dirname mkdirhier conv_to_win_path basename download_file); +use TeXLive::TLUtils qw(tllog copy win32 dirname mkdirhier conv_to_win_path basename download_file merge_into); use TeXLive::TLPDB; use Cwd qw/abs_path/; @@ -74,12 +74,6 @@ sub new return $self; } -# returns 0 for error -# otherwise a bitmap which specifies what commands have to be run -# always: 0x0001 mktexlsr -# addMap: 0x0010 updmap-sys -# BuildFormat: 0x0100 fmtutil-sys --missing -# BuildLanguageDat: 0x1000 fmtutil-sys --by-hyphen language.dat # sub install_package { my ($self, $pkg, $totlpdb, $nodepends, $nopostinstall, $fallbackmedia) = @_; @@ -190,18 +184,23 @@ sub install_package { $totlpdb->add_tlpobj($tlpobj); $totlpdb->save; # compute the return value - $ret |= 0x0001; # mktexlsr + my %ret; + my (@maps, @formats, @dats); + $ret{'mktexlsr'} = 1; foreach my $e ($tlpobj->executes) { - if ($e =~ m/^add/) { - $ret |= 0x0010; - } elsif ($e =~ m/^BuildFormat/) { - $ret |= 0x0100; - } elsif ($e =~ m/^BuildLanguageDat/) { - $ret |= 0x1000; + if ($e =~ m/^add((Mixed)?Map)\s+([^\s]+)\s*$/) { + push @maps, "enable $1 $3"; + } elsif ($e =~ m/^BuildFormat\s+([^\s]+)\s*$/) { + push @formats, $1; + } elsif ($e =~ m/^BuildLanguageDat\s+([^\s]+)\s*$/) { + push @dats, $1; } else { warn("Unknown execute $e in $pkg"); } } + $ret{'map'} = [ @maps ] if (@maps); + $ret{'format'} = [ @formats ] if (@formats); + $ret{'language'} = [ @dats ] if (@dats); # now install all the depends if they are not already present if (!$nodepends) { foreach my $d ($tlpobj->depends) { @@ -209,18 +208,21 @@ sub install_package { my $foo = $1; foreach my $a ($totlpdb->available_architectures) { if (!defined($totlpdb->get_package("$foo.$a"))) { - $ret |= $self->install_package("$foo.$a", $totlpdb, $nodepends, $fallbackmedia); + merge_into(\%ret, + $self->install_package("$foo.$a", $totlpdb, $nodepends, $fallbackmedia)); } } } elsif ($d =~ m/^(.*).win32$/) { # install only of win32 is under the available archs if (TeXLive::TLUtils::member("win32",$totlpdb->available_architectures)) { - $ret |= $self->install_package($d, $totlpdb, $nodepends, $fallbackmedia); + merge_into(\%ret, + $self->install_package($d, $totlpdb, $nodepends, $fallbackmedia)); } } else { if (!defined($totlpdb->get_package($d))) { # we have to install it! - $ret |= $self->install_package($d, $totlpdb, $nodepends, $fallbackmedia); + merge_into(\%ret, + $self->install_package($d, $totlpdb, $nodepends, $fallbackmedia)); } } } @@ -232,7 +234,7 @@ sub install_package { &{$PostInstall{$pkg}}($totlpdb->root); } } - return $ret; + return \%ret; } } diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index 767a4e87b72..1f55b21796c 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -60,6 +60,7 @@ C<TeXLive::TLUtils> -- utilities used in the TeX Live infrastructure TeXLive::TLUtils::push_uniq(\@list, @items); TeXLive::TLUtils::member($item, @list); TeXLive::TLUtils::tllog($level, $string); + TeXLive::TLUtils::merge_into(\%to, \%from); TeXLive::TLUtils::texdir_check($texdir); TeXLive::TLUtils::kpsewhich; TeXLive::TLUtils::conv_to_win_path($path); @@ -105,6 +106,7 @@ BEGIN { &conv_to_win_path &setup_programs &download_file + &merge_into ); @EXPORT = qw(tllog setup_programs download_file); } @@ -1118,6 +1120,25 @@ sub member { =pod +=item C<merge_into(\%to, \%from)> + +Merges the keys of %from into %to. + +=cut + +sub merge_into { + my ($to, $from) = @_; + foreach my $k (keys %$from) { + if (defined($to->{$k})) { + push @{$to->{$k}}, @{$from->{$k}}; + } else { + $to->{$k} = [ @{$from->{$k}} ]; + } + } +} + +=pod + =item C<texdir_check($texdir)> Test whether installation with TEXDIR set to $texdir would succeed due to |