summaryrefslogtreecommitdiff
path: root/Master/texmf
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2008-12-19 16:55:16 +0000
committerKarl Berry <karl@freefriends.org>2008-12-19 16:55:16 +0000
commitb2710f561308242d8fdd0779e1377da9d299d118 (patch)
tree5c2f4448dcd4c25a3fc72f643a332ee203378096 /Master/texmf
parent941feb78960cd48da53253f4979d732e4f0a27ee (diff)
rearrange functions and comments a bit, no
functional changes. git-svn-id: svn://tug.org/texlive/trunk@11656 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf')
-rwxr-xr-xMaster/texmf/scripts/texlive/tlmgr2.pl188
1 files changed, 95 insertions, 93 deletions
diff --git a/Master/texmf/scripts/texlive/tlmgr2.pl b/Master/texmf/scripts/texlive/tlmgr2.pl
index 5ec09c5cb47..dc6ae55ffa7 100755
--- a/Master/texmf/scripts/texlive/tlmgr2.pl
+++ b/Master/texmf/scripts/texlive/tlmgr2.pl
@@ -60,7 +60,6 @@ $datrev =~ s/^.*Date: //;
$datrev =~ s/ \(.*$//;
$tlmgrrevision .= " ($datrev)";
-
our $Master;
BEGIN {
@@ -71,26 +70,27 @@ BEGIN {
unshift (@INC, "$Master/texmf/scripts/texlive");
}
-use TeXLive::TLPOBJ;
-use TeXLive::TLPDB;
+use Cwd qw/abs_path/;
+use Pod::Usage;
+use Getopt::Long qw(:config no_autoabbrev permute);
+use strict;
+
use TeXLive::TLConfig;
use TeXLive::TLMedia;
+use TeXLive::TLPDB;
+use TeXLive::TLPOBJ;
+use TeXLive::TLPostActions;
use TeXLive::TLUtils;
use TeXLive::TLWinGoo;
-use TeXLive::TLPostActions;
TeXLive::TLUtils->import(qw(member info give_ctan_mirror win32 dirname
mkdirhier merge_into copy log debug));
-use Cwd qw/abs_path/;
-use Pod::Usage;
-use Getopt::Long qw(:config no_autoabbrev permute);
-use strict;
require("papersize-setting.pl");
+our %papersetting_subs;
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
-#
# global variable that specifies if a call to finish() should actually
# finish the program or immediately return
$::gui_mode = 0;
@@ -106,10 +106,6 @@ my %options;
# the location from where we install
our $location;
-#
-# stubs for setting paper sizes
-our %papersetting_subs;
-
# flags for machine readable form
our $FLAG_REMOVE = "d";
our $FLAG_FORCIBLE_REMOVED = "f";
@@ -193,9 +189,8 @@ $::machinereadable = $opts{"machine-readable"}
if (defined($opts{"machine-readable"}));
my $action = shift;
-
-if (!defined($action) && $opts{"gui"}) {
- $action = "gui";
+if (!defined($action)) {
+ $action = $opts{"gui"} ? "gui" : "";
}
ddebug("action = $action\n");
@@ -222,7 +217,6 @@ sub give_version {
return $::version_string;
}
-
if ($opts{"version"} || (defined $action && $action eq "version")) {
info( give_version() );
finish(0);
@@ -247,7 +241,6 @@ if ($opts{"help"}) {
}
}
-#
# check on supported arguments
#
my %suppargs;
@@ -299,7 +292,10 @@ if (!open(PACKAGELOG, ">>$packagelogfile")) {
my $loadmediasrcerror = "Cannot load TeX Live database from ";
execute_action($action, @ARGV);
+# end of main program.
+
+
sub execute_action {
my ($action, @argv) = @_;
my %ret;
@@ -385,13 +381,11 @@ sub execute_action {
finish(0);
} elsif ($action =~ m/^remove$/i) {
merge_into(\%ret, action_remove());
- } elsif (($action eq "paper") || ($action eq "dvips") || ($action eq "xdvi") ||
- ($action eq "pdftex") || ($action eq "dvipdfm") ||
- ($action eq "dvipdfmx") || ($action eq "context")) {
+ } elsif ($action =~ /paper|dvips|xdvi|pdftex|dvipdfmx?|context/) {
if ($opts{"gui"}) {
action_gui("config");
}
- @ARGV = ( $action, @ARGV);
+ @ARGV = ($action, @ARGV);
merge_into(\%ret, action_paper());
} elsif ($action =~ m/^uninstall$/i) {
merge_into(\%ret, action_uninstall());
@@ -476,6 +470,7 @@ sub handle_ret_hash
return $errors / 256; # we were accumulating wait statuses
}
+
#
# remove_package removes a single package with all files (including the
# tlpobj files) and the entry from the tlpdb.
@@ -557,6 +552,7 @@ sub remove_package {
return \%ret;
}
+
# REMOVE
#
# tlmgr remove foo bar baz
@@ -726,17 +722,13 @@ sub action_remove {
#
sub action_paper {
my %ret;
- if ($opts{"gui"}) {
- action_gui("config");
- }
+ action_gui("config") if $opts{"gui"};
tlwarn("machine-readable output not supported for paper\n")
if $::machinereadble;
+
init_local_db();
- my $texmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR`;
- chomp($texmfsysvar);
- my $texmfsysconfig = `kpsewhich -var-value=TEXMFSYSCONFIG`;
- chomp($texmfsysconfig);
-
+ chomp(my $texmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR`);
+ chomp(my $texmfsysconfig = `kpsewhich -var-value=TEXMFSYSCONFIG`);
# we are doing -sys variants
$ENV{"TEXMFVAR"} = $texmfsysvar;
@@ -894,6 +886,7 @@ sub action_search {
return;
}
+
# RESTORE
#
sub action_restore {
@@ -1706,6 +1699,7 @@ sub action_update {
return(\%ret);
}
+
# INSTALL
#
# tlmgr install foo bar baz
@@ -2025,6 +2019,9 @@ sub action_arch {
return(\%ret);
}
+
+# GENERATE
+#
sub action_generate {
my $dest = defined($opts{"dest"}) ? $opts{"dest"} : "";
my $localconf = defined($opts{"localcfg"}) ? $opts{"localcfg"} : "";
@@ -2070,60 +2067,9 @@ sub action_generate {
return;
}
-# set global $location variable.
-# if we cannot read tlpdb, die if arg SHOULD_I_DIE is true.
-#
-sub init_local_db {
- my ($should_i_die) = @_;
- $localtlpdb = TeXLive::TLPDB->new ("root" => $Master);
- die("cannot find tlpdb in $Master") unless (defined($localtlpdb));
- # setup the programs, for w32 we need the shipped wget/lzma etc, so we
- # pass the location of these files to setup_programs.
- my $ret = setup_programs("$Master/tlpkg/installer",
- $localtlpdb->option_platform);
- if ($ret == -1) {
- tlwarn("no binary of lzmadec for $::_platform_ detected.\n");
- if (defined($should_i_die) && $should_i_die) {
- exit 1;
- } else {
- tlwarn("Continuing anyway ...\n");
- }
- }
- if (!$ret) {
- tlwarn("Couldn't set up the necessary programs.\nInstallation of packages is not supported.\nPlease report to texlive\@tug.org.\n");
- if (defined($should_i_die) && $should_i_die) {
- finish(1);
- } else {
- tlwarn("Continuing anyway ...\n");
- }
- }
- # let cmd line options override the settings in localtlpdb
- my $loc = $localtlpdb->option_location;
- if (defined($loc)) {
- $location = $loc;
- }
- if (defined($opts{"location"})) {
- $location = $opts{"location"};
- }
- if (!defined($location)) {
- die("No installation source found, nor in the texlive.tlpdb nor on the cmd line.\nPlease specify one!");
- }
- if ($location =~ m/^ctan$/i) {
- $location = "$TeXLive::TLConfig::TeXLiveURL";
- }
- # we normalize the path only if it is
- # - neither a URL starting with http or ftp
- # - if we are on windows it does not start with Drive:
- if (! ( $location =~ m!^(http|ftp)://!i ||
- (win32() && $location =~ m!^.:!) ) ) {
- # seems to be a local path, try to normalize it
- my $testloc = abs_path($location);
- # however, if we were given a url, that will get "normalized" to the
- # empty string, it not being a path. Restore the original value if so.
- $location = $testloc if $testloc;
- }
-}
+# GUI
+#
sub action_gui {
my ($guiscreen) = @_;
# yes, two times to make perl warnings shut up ...
@@ -2182,6 +2128,9 @@ Error message from creating MainWindow:
exit(1);
}
+
+# UNINSTALL
+#
sub action_uninstall {
if (win32()) {
printf STDERR "Please use \"Add/Remove Programs\" from the Control Panel to removing TeX Live!\n";
@@ -2201,7 +2150,7 @@ sub action_uninstall {
}
}
print ("Ok, removing the whole installation:\n");
- init_local_db;
+ init_local_db();
my $tlpdb = $localtlpdb;
my $opt_symlinks = 0;
my ($sys_bin,$sys_info,$sys_man);
@@ -2311,6 +2260,8 @@ sub action_uninstall {
}
+# CHECK
+#
sub action_check {
my $svn = defined($opts{"use-svn"}) ? $opts{"use-svn"} : 0;
my $what = shift @ARGV;
@@ -2330,7 +2281,6 @@ sub action_check {
finish($ret);
}
-#
# check file coverage, roughly equivalent to tlpkg/bin/check-file-coverage
#
sub check_files {
@@ -2385,7 +2335,6 @@ sub check_files {
my $arch = $localtlpdb->option_platform;
return $ret if ($arch eq "win32" || $arch eq "universal-darwin");
- #
# do check that all files in the trees are covered
#
my @IgnorePatterns = qw!
@@ -2445,7 +2394,6 @@ sub check_files {
return($ret);
}
-#
# check collections
#
sub check_collections {
@@ -2465,7 +2413,64 @@ sub check_collections {
}
-#
+
+# Subroutines galore.
+#
+# set global $location variable.
+# if we cannot read tlpdb, die if arg SHOULD_I_DIE is true.
+#
+sub init_local_db {
+ my ($should_i_die) = @_;
+ $localtlpdb = TeXLive::TLPDB->new ("root" => $Master);
+ die("cannot find tlpdb in $Master") unless (defined($localtlpdb));
+ # setup the programs, for w32 we need the shipped wget/lzma etc, so we
+ # pass the location of these files to setup_programs.
+ my $ret = setup_programs("$Master/tlpkg/installer",
+ $localtlpdb->option_platform);
+ if ($ret == -1) {
+ tlwarn("no binary of lzmadec for $::_platform_ detected.\n");
+ if (defined($should_i_die) && $should_i_die) {
+ exit 1;
+ } else {
+ tlwarn("Continuing anyway ...\n");
+ }
+ }
+ if (!$ret) {
+ tlwarn("Couldn't set up the necessary programs.\nInstallation of packages is not supported.\nPlease report to texlive\@tug.org.\n");
+ if (defined($should_i_die) && $should_i_die) {
+ finish(1);
+ } else {
+ tlwarn("Continuing anyway ...\n");
+ }
+ }
+ # let cmd line options override the settings in localtlpdb
+ my $loc = $localtlpdb->option_location;
+ if (defined($loc)) {
+ $location = $loc;
+ }
+ if (defined($opts{"location"})) {
+ $location = $opts{"location"};
+ }
+ if (!defined($location)) {
+ die("No installation source found, nor in the texlive.tlpdb nor on the cmd line.\nPlease specify one!");
+ }
+ if ($location =~ m/^ctan$/i) {
+ $location = "$TeXLive::TLConfig::TeXLiveURL";
+ }
+ # we normalize the path only if it is
+ # - neither a URL starting with http or ftp
+ # - if we are on windows it does not start with Drive:
+ if (! ( $location =~ m!^(http|ftp)://!i ||
+ (win32() && $location =~ m!^.:!) ) ) {
+ # seems to be a local path, try to normalize it
+ my $testloc = abs_path($location);
+ # however, if we were given a url, that will get "normalized" to the
+ # empty string, it not being a path. Restore the original value if so.
+ $location = $testloc if $testloc;
+ }
+}
+
+
# initialize the global $tlmediasrc object, or die.
# uses the global $location.
#
@@ -2489,7 +2494,6 @@ sub init_tlmedia {
}
}
-#
# the logpackage function
# if the packagelog variable is set then write to PACKAGELOG filehandle
#
@@ -2501,9 +2505,9 @@ sub logpackage {
}
}
-#
# finish # evaluates only the -pause option, and then exits
# if the global $::gui_mode is set to 1 then the not exit, but return is called
+#
sub finish {
my ($ret) = @_;
@@ -2512,7 +2516,7 @@ sub finish {
}
if ($opts{"pause"}) {
- print "Please press <ENTER> to exit the program.\n";
+ print "Press Enter to exit the program.\n";
<STDIN>;
}
@@ -2554,7 +2558,6 @@ sub clear_old_backups
}
}
-#
# check for updates to tlcritical packages
#
sub check_for_critical_updates
@@ -2602,7 +2605,6 @@ sub check_for_critical_updates
}
-#
# return all the directories from which all content will be removed
#
# idea: