diff options
Diffstat (limited to 'Master/texmf')
-rwxr-xr-x | Master/texmf/scripts/texlive/tlmgr2.pl | 118 |
1 files changed, 72 insertions, 46 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr2.pl b/Master/texmf/scripts/texlive/tlmgr2.pl index 4828226870b..336b15a5174 100755 --- a/Master/texmf/scripts/texlive/tlmgr2.pl +++ b/Master/texmf/scripts/texlive/tlmgr2.pl @@ -117,12 +117,16 @@ my $opt_gui = 0; our $opt_gui_lang; my $opt_packagelogfile; my $opt_pause = 0; +$::machinereadable = 0; TeXLive::TLUtils::process_logging_options(); GetOptions("location=s" => \$opt_location, "gui" => \$opt_gui, "gui-lang=s" => \$opt_gui_lang, "package-logfile=s" => \$opt_packagelogfile, + # for machine readable we use a global variable so that + # the perl modules can check for that, too, more easily + "machine-readable" => \$::machinereadable, "version" => \$opt_version, "pause" => \$opt_pause, "h|help|?" => \$opt_help) or pod2usage(2); @@ -241,6 +245,10 @@ sub execute_action { $localtlpdb->save; } finish(0); + } elsif ($action =~ m/^get-mirror$/i) { + my $loc = give_ctan_mirror(); + print("$loc\n"); + finish(0); } elsif ($action =~ m/^generate$/i) { merge_into(\%ret, action_generate()); } elsif ($action =~ m/^gui$/i) { @@ -469,6 +477,8 @@ sub action_remove { if ($opt_gui) { action_gui("remove"); } + tlwarn("machine-readable output not supported for remove\n") + if $::machinereadble; # we do the following: # - (not implemented) order collections such that those depending on # other collections are first removed, and then those which only @@ -624,6 +634,8 @@ sub action_paper { if ($opt_gui) { action_gui("config"); } + tlwarn("machine-readable output not supported for paper\n") + if $::machinereadble; init_local_db(); my $texmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR`; chomp($texmfsysvar); @@ -670,6 +682,8 @@ sub action_show { if ($opt_gui) { action_gui("config"); } + tlwarn("machine-readable output not supported for show\n") + if $::machinereadble; my $opt_list = 0; Getopt::Long::Configure(@getopt_configure_subopts); GetOptions("list" => \$opt_list) or pod2usage(2); @@ -754,6 +768,8 @@ sub action_search { my $opt_global = 0; my $opt_file = 0; my %ret; + tlwarn("machine-readable output not supported for search\n") + if $::machinereadble; Getopt::Long::Configure(@getopt_configure_subopts); GetOptions("global" => \$opt_global, "file" => \$opt_file) or pod2usage(2); @@ -800,6 +816,8 @@ sub action_restore { # lists all revisions of pkg # tlmgr restore --backupdir dir pkg rev # restores pkg to revision rev + tlwarn("machine-readable output not supported for restore\n") + if $::machinereadble; my $opt_backupdir; my $opt_force; my $opt_dry = 0; @@ -899,6 +917,8 @@ sub action_restore { } sub action_backup { + tlwarn("machine-readable output not supported for backup\n") + if $::machinereadble; init_local_db(1); my $opt_dry = 0; my $opt_all = 0; @@ -1185,7 +1205,6 @@ sub action_update { my $opt_dry = 0; my $opt_all = 0; my $opt_list = 0; - my $opt_machinereadablelist = 0; my $opt_noremove = 0; my $opt_backupdir; my $opt_backup = 0; @@ -1195,7 +1214,6 @@ sub action_update { "no-depends-at-all" => \$opt_reallynodepends, "all" => \$opt_all, "list" => \$opt_list, - "machinereadablelist" => \$opt_machinereadablelist, "no-remove" => \$opt_noremove, "force" => \$opt_force, "backupdir=s" => \$opt_backupdir, @@ -1205,12 +1223,6 @@ sub action_update { my $nrupdated = 0; my %ret; - if ($opt_machinereadablelist) { - # this global setting makes info lines go to STDERR so that on STDOUT - # there is only material we actually want to see - $::machinereadable = 1; - } - init_tlmedia(); my $mediatlpdb = $tlmediasrc->tlpdb; info("update: dry run, no changes will be made\n") if $opt_dry; @@ -1376,7 +1388,7 @@ sub action_update { debug ("tlmgr: deleted : " . join("\n\t",keys %removals) . "\n"); debug ("tlmgr: forced : " . join("\n\t",keys %forcermpkgs) . "\n"); - if ($opt_all || $opt_list || $opt_machinereadablelist) { + if ($opt_all || $opt_list) { @todo = $localtlpdb->list_packages; } else { @todo = @ARGV; @@ -1387,19 +1399,19 @@ sub action_update { # to support moving of files from one package to another. # remove the packages that have disappeared: for my $p (keys %removals) { - if ($opt_machinereadablelist) { - # TODO version numbers - machine_line($p, $FLAG_REMOVE, "-", "-"); + if ($opt_noremove) { + info("not removing $p due to -no-remove (removed on server)\n"); } else { - if ($opt_noremove) { - info("not removing $p due to -no-remove (removed on server)\n"); + if ($::machinereadable) { + # TODO version numbers + machine_line($p, $FLAG_REMOVE, "-", "-"); } else { info("remove $p (removed on server)\n"); } - if (!($opt_dry or $opt_list or $opt_noremove)) { - merge_into(\%ret, &remove_package($p, $localtlpdb)); - logpackage("remove: $p"); - } + } + if (!($opt_dry or $opt_list or $opt_noremove)) { + merge_into(\%ret, &remove_package($p, $localtlpdb)); + logpackage("remove: $p"); } } @@ -1430,7 +1442,7 @@ sub action_update { # will be in the dependency expansion, and we want it. my $newpkg_coll = $newpkgs{$pkg} || $newpkgs{$pkg_noarch}; if ($forcerm_coll) { - if ($opt_machinereadablelist) { + if ($::machinereadable) { # TODO should we add a revision number machine_line($pkg, $FLAG_FORCIBLE_REMOVED, "-", "-"); } else { @@ -1453,12 +1465,12 @@ sub action_update { next; } my $mediarev = $mediatlp->revision; - if ($opt_machinereadablelist) { + if ($::machinereadable) { machine_line($pkg, $FLAG_AUTOINSTALL, "-", $mediatlp->revision); } else { info("auto-install: $pkg\n"); } - next if ($opt_dry || $opt_list || $opt_machinereadablelist); + next if ($opt_dry || $opt_list); my $foo = $tlmediasrc->install_package($pkg, $localtlpdb); if (ref $foo) { # installation succeeded because we got a reference @@ -1483,9 +1495,11 @@ sub action_update { if ($rev < $mediarev) { $nrupdated++; if ($opt_list) { - info("$pkg: local: $rev, source: $mediarev\n"); - } elsif ($opt_machinereadablelist) { - machine_line($pkg, $FLAG_UPDATE, $rev, $mediarev); + if ($::machinereadable) { + machine_line($pkg, $FLAG_UPDATE, $rev, $mediarev); + } else { + info("$pkg: local: $rev, source: $mediarev\n"); + } } else { if ($opt_backup && !$opt_dry) { $tlp->make_container("lzma", $root, @@ -1578,7 +1592,7 @@ sub action_update { } } } elsif ($rev > $mediarev) { - if ($opt_machinereadablelist) { + if ($::machinereadable) { machine_line($pkg, $FLAG_REVERSED_UPDATE, $rev, $mediarev); } else { info("$pkg: local revision ($rev) is newer than revision in $location" @@ -1634,6 +1648,8 @@ sub action_install { if ($opt_gui) { action_gui("install"); } + tlwarn("machine-readable output not supported for install\n") + if $::machinereadble; init_local_db(1); # initialize the TLMedia from $location my $opt_nodepends = 0; @@ -1702,6 +1718,8 @@ sub action_install { } sub action_list { + tlwarn("machine-readable output not supported for list\n") + if $::machinereadble; init_local_db(); # make sure that the @ARGV hash is not changed in case we switch to # show mode @@ -1738,15 +1756,31 @@ sub action_list { return; } - sub action_option { if ($opt_gui) { action_gui("config"); } + tlwarn("machine-readable output not supported for option\n") + if $::machinereadble; my $what = shift @ARGV; $what = "show" unless defined($what); init_local_db(); - if ($what =~ m/^location$/i) { + if ($what =~ m/^show$/i) { + print "Default installation location (location): ", + $localtlpdb->option_location, "\n"; + print "Create formats on installation (formats): ", + ($localtlpdb->option_create_formats ? "yes" : "no"), "\n"; + print "Install documentation files (docfiles): ", + ($localtlpdb->option_install_docfiles ? "yes": "no"), "\n"; + print "Install source files (srcfiles): ", + ($localtlpdb->option_install_srcfiles ? "yes": "no"), "\n"; + print "Directory for backups (backupdir): ", + $localtlpdb->option("backupdir"), "\n" + if $localtlpdb->option("backupdir"); + print "Number of backups to keep (autobackup): ", + $localtlpdb->option("autobackup"), "\n" + if $localtlpdb->option("autobackup"); + } elsif ($what =~ m/^location$/i) { # changes the default location my $loc = shift @ARGV; if ($loc) { @@ -1804,22 +1838,10 @@ sub action_option { print "Create formats on installation: ", $localtlpdb->option_create_formats, "\n"; } - } elsif ($what =~ m/^show$/i) { - print "Default installation location (location): ", - $localtlpdb->option_location, "\n"; - print "Create formats on installation (formats): ", - ($localtlpdb->option_create_formats ? "yes" : "no"), "\n"; - print "Install documentation files (docfiles): ", - ($localtlpdb->option_install_docfiles ? "yes": "no"), "\n"; - print "Install source files (srcfiles): ", - ($localtlpdb->option_install_srcfiles ? "yes": "no"), "\n"; - print "Directory for backups (backupdir): ", - $localtlpdb->option("backupdir"), "\n" - if $localtlpdb->option("backupdir"); - print "Number of backups to keep (autobackup): ", - $localtlpdb->option("autobackup"), "\n" - if $localtlpdb->option("autobackup"); - } else { + } elsif (member($what, @AllowedConfigOptions)) { + # for all further options not handled till now we check that they + # appear in the list of allowed options and if they do, we set/read + # the values, otherwise we warn my $val = shift @ARGV; if (defined($val)) { print "Setting option $what to $val.\n"; @@ -1828,7 +1850,8 @@ sub action_option { } else { print "Option $what = ", $localtlpdb->option($what), "\n";; } - #warn "Setting other options currently not supported, please edit texlive.tlpdb!"; + } else { + tlwarn "Option $what is currently not supported.\n"; } return; } @@ -1843,6 +1866,8 @@ sub action_arch { if ($opt_gui) { action_gui("arch"); } + tlwarn("machine-readable output not supported for arch\n") + if $::machinereadble; my %ret; my $opt_dry = 0; Getopt::Long::Configure(@getopt_configure_subopts); @@ -1928,6 +1953,8 @@ sub action_generate { Getopt::Long::Configure(@getopt_configure_subopts); GetOptions("localcfg=s" => \$localconf, "dest=s" => \$dest,) or pod2usage(2); my $what = shift @ARGV; + tlwarn("machine-readable output not supported for generate\n") + if $::machinereadble; init_local_db(); chomp (my $TEXMFSYSVAR = `kpsewhich -var-value=TEXMFSYSVAR`); @@ -2371,8 +2398,7 @@ sub check_collections { # uses the global $location. # sub init_tlmedia { - my $newroot = $location; - if (defined($tlmediatlpdb) && ($tlmediatlpdb->root eq $newroot)) { + if (defined($tlmediatlpdb) && ($tlmediatlpdb->root eq $location)) { # nothing to be done } else { if ($location =~ m/^($TeXLiveServerURL|ctan$)/) { |