diff options
author | Norbert Preining <preining@logic.at> | 2008-05-19 08:37:41 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2008-05-19 08:37:41 +0000 |
commit | 5177658bbbdaa8778cff3a2ac4fabb765bbcd8fe (patch) | |
tree | b00bfdb0be26f8f7ce3d626ac084b987c608c511 /Master/install-tl | |
parent | 58c870fa77e1ede0e7b21a7791d0fa5b8fd1542b (diff) |
big logging update, new logging facilities: info, debug, ddebug, tlwarn
and a way to automatically process the respective options -q and -v
via TeXLive::TLUtils::process_logging_options();
git-svn-id: svn://tug.org/texlive/trunk@8234 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/install-tl')
-rwxr-xr-x | Master/install-tl | 150 |
1 files changed, 60 insertions, 90 deletions
diff --git a/Master/install-tl b/Master/install-tl index 02fdbee30ba..58eb934724d 100755 --- a/Master/install-tl +++ b/Master/install-tl @@ -41,11 +41,13 @@ BEGIN { unshift (@INC, "$::installerdir/tlpkg"); } +use Getopt::Long qw(:config no_autoabbrev); + use TeXLive::TLUtils qw(initialize_installer media platform platform_desc - which getenv win32 unix program_exists - get_system_tmpdir member + which getenv win32 unix program_exists info debug tlwarn ddebug + get_system_tmpdir member process_logging_options mkdirhier make_var_skeleton make_local_skeleton install_package copy - install_packages dirname tllog setup_programs); + install_packages dirname setup_programs); use TeXLive::TLPOBJ; use TeXLive::TLPDB; use TeXLive::TLConfig; @@ -84,22 +86,15 @@ if (win32) { )); } -#use Getopt::Long; -#$Getopt::Long::autoabbrev=0; -use Getopt::Long qw(:config no_autoabbrev); use strict; # debugging/logging cmd lines options: -# -q shut up terminal output -# -qq shut up also log file output -# -d set $::LOGLEVELFILE to $::LOG_DEBUG -# -dd set $::LOGLEVELFILE to $::LOG_DDEBUG -# -ddd set $::LOGLEVELFILE to $::LOG_DDDEBUG +# -q shut up terminal output but warning messages +# -v do a bit of debugging to stdout and logfile +# repeated use increases the value of verbosity # -$::LOGLEVELFILE = $::LOG_NORMAL; -$::LOGLEVELTERMINAL = $::LOG_NORMAL; @::LOGLINES = (); # # $install{$packagename} == 1 if it should be installed @@ -138,17 +133,16 @@ our %vars=( # 'n_' means 'number of'. 'selected_scheme' => $default_scheme, ); +# +# first process verbosity/quiet options +process_logging_options(); + # option handling my $opt_media = ""; my $opt_url = ""; my $opt_profile = ""; my $opt_no_cls=0; my $opt_nogui = 0; -my $opt_debug = 0; -my $opt_ddebug = 0; -my $opt_dddebug = 0; -my $opt_quiet = 0; -my $opt_qquiet = 0; my $opt_nonadmin = 0; my $opt_arch = 0; our $opt_portable = 0; @@ -170,11 +164,6 @@ GetOptions("media=s" => \$opt_media, "lang=s" => \$::opt_lang, "print-arch" => \$opt_arch, "portable" => \$opt_portable, - "d" => \$opt_debug, - "dd" => \$opt_ddebug, - "ddd" => \$opt_dddebug, - "q" => \$opt_quiet, - "qq" => \$opt_qquiet, "url=s" => \$opt_url, "version" => \$opt_version, "help|?" => \$opt_help) or pod2usage(1); @@ -197,22 +186,6 @@ if (defined($::opt_lang)) { $::lang = $::opt_lang; } -if ($opt_quiet) { - $::LOGLEVELTERMINAL = $::LOG_ZERO; -} -if ($opt_qquiet) { - $::LOGLEVELTERMINAL = $::LOG_ZERO; - $::LOGLEVELFILE = $::LOG_ZERO; -} -if ($opt_debug) { - $::LOGLEVELFILE = $::LOG_DEBUG; -} -if ($opt_ddebug) { - $::LOGLEVELFILE = $::LOG_DDEBUG; -} -if ($opt_dddebug) { - $::LOGLEVELFILE = $::LOG_DDDEBUG; -} if ("$opt_media" =~ m/^CD/i) { $::_media_ = "CD"; } elsif ("$opt_media" =~ m/^NET/i) { @@ -223,10 +196,10 @@ if ("$opt_media" =~ m/^CD/i) { if ("$opt_profile" ne "") { if (-r "$opt_profile") { - tllog($::LOG_NORMAL, "Using automated installation using $opt_profile!"); + info("Using automated installation using $opt_profile!"); } else { $opt_profile = ""; - tllog($::LOG_NORMAL, "Profile $opt_profile not readable, continuing in interactive mode!"); + info("Profile $opt_profile not readable, continuing in interactive mode!"); } } @@ -255,7 +228,7 @@ if ($opt_arch) { print platform; exit 0; } elsif ($opt_portable) { - $::LOGLEVELTERMINAL = $::LOG_ZERO; + $::opt_verbosity = -1; # initialize_installer: $::_media_ = "DVD"; $::_platform_ = platform(); @@ -299,18 +272,18 @@ if ($opt_arch) { exit 0; } -tllog($::LOG_NORMAL, "Platform: ", platform, " => \'", platform_desc(platform), "\'\n"); +info("Platform: ", platform, " => \'", platform_desc(platform), "\'\n"); if (media() eq "DVD") { - tllog($::LOG_NORMAL, "Distribution: live (uncompressed)\n"); + info("Distribution: live (uncompressed)\n"); } elsif (media() eq "CD") { - tllog($::LOG_NORMAL, "Distribution: inst (compressed)\n"); + info("Distribution: inst (compressed)\n"); } elsif (media() eq "NET") { - tllog($::LOG_NORMAL, "Distribution: net (downloading)\n"); + info("Distribution: net (downloading)\n"); } else { - tllog($::LOG_NORMAL, "Distribution: ", media(), "\n"); + info("Distribution: ", media(), "\n"); } -tllog($::LOG_NORMAL, "Directory for Temporary Files: '", $system_tmpdir, "\'\n"); -tllog($::LOG_NORMAL, "Installer Directory: '$::installerdir'\n"); +info("Directory for Temporary Files: '", $system_tmpdir, "\'\n"); +info("Installer Directory: '$::installerdir'\n"); initialize_installer(); setup_programs("$::installerdir/tlpkg/installer", "$::_platform_"); @@ -349,10 +322,10 @@ if ($opt_profile eq "") { eval { require Tk; }; if ($@) { # that didn't work out, so warn the user and continue with text mode - tllog($::LOG_NORMAL, "Cannot load Tk, maybe something is missing!\n"); - tllog($::LOG_NORMAL, "Error message from loading Tk:\n"); - tllog($::LOG_NORMAL, "$@\n"); - tllog($::LOG_NORMAL, "Continuing in Text Mode...\n"); + tlwarn("Cannot load Tk, maybe something is missing!\n"); + tlwarn("Error message from loading Tk:\n"); + tlwarn("$@\n"); + tlwarn("Continuing in Text Mode...\n"); $opt_gui = 0; } } @@ -373,11 +346,11 @@ if ($opt_profile eq "") { exit(2); } if ($ret == $MENU_ALREADYDONE) { - tllog($::LOG_DEBUG, "run_menu has already done the work ... cleaning up!\n"); + debug("run_menu has already done the work ... cleaning up!\n"); $finished = 1; } if (!$finished && ($ret != $MENU_INSTALL)) { - tllog($::LOG_NORMAL, "Unknown return value of run_menu: $ret\n"); + warn("Unknown return value of run_menu: $ret\n"); exit(3); } } else { @@ -391,16 +364,13 @@ if (!$finished) { # now open the log file and write out the log lines # try to open a log file -if ($::LOGLEVELFILE > $::LOG_ZERO) { - if (open(LOGF,">$vars{'TEXDIR'}/install-tl.log")) { - $::LOGFILE = \*LOGF; - foreach my $line(@::LOGLINES) { - print $::LOGFILE "$line"; - } - } else { - warn("Cannot create log file $vars{'TEXDIR'}/install-tl.log: $!\nNot writing out log lines!\n"); - $::LOGLEVELFILE = $::LOG_ZERO; +if (open(LOGF,">$vars{'TEXDIR'}/install-tl.log")) { + $::LOGFILE = \*LOGF; + foreach my $line(@::LOGLINES) { + print $::LOGFILE "$line"; } +} else { + warn("Cannot create log file $vars{'TEXDIR'}/install-tl.log: $!\nNot writing out log lines!\n"); } # dump various things to the log file @@ -416,7 +386,7 @@ dump_vars("$system_tmpdir/texlive.vars"); # write the profile out create_profile("$vars{'TEXDIR'}/$InfraLocation/texlive.profile"); -tllog($::LOG_DEBUG, "Profile written to $vars{'TEXDIR'}/$InfraLocation/texlive.profile\n"); +debug("Profile written to $vars{'TEXDIR'}/$InfraLocation/texlive.profile\n"); # Close log file if present close($::LOGFILE) if defined($::LOGFILE); @@ -467,7 +437,7 @@ sub dump_vars { print $fh "$key $vars{$key}\n"; } close VARS if (!ref($filename)); - tllog($::LOG_DEBUG, "\n%vars dumped to '$filename'.\n"); + debug("\n%vars dumped to '$filename'.\n"); } @@ -576,11 +546,11 @@ sub calc_depends { # collect the already selected packages my @pre_selected = keys %install; - tllog($::LOG_DDEBUG, "initial number of installations: $#pre_selected\n"); + ddebug("initial number of installations: $#pre_selected\n"); # loop over all the pre_selected and add them foreach my $p (@pre_selected) { - tllog($::LOG_DDEBUG, "pre_selected $p\n"); + ddebug("pre_selected $p\n"); foreach my $p_dep ($tlpdb->get_package($p)->depends) { if ($p_dep =~ m/^(.*)\.ARCH$/) { my $foo = "$1"; @@ -601,7 +571,7 @@ sub calc_depends { # check for newly selected packages my @post_selected = keys %install; - tllog($::LOG_DDEBUG, "number of post installations: $#post_selected\n"); + ddebug("number of post installations: $#post_selected\n"); # set repeat condition if ($#pre_selected != $#post_selected) { @@ -634,7 +604,7 @@ sub load_tlpdb { } else { $master="$::installerdir"; } - tllog($::LOG_NORMAL, "Loading $master/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName ...\n"); + info("Loading $master/$TeXLive::TLConfig::InfraLocation/$TeXLive::TLConfig::DatabaseName ...\n"); $tlpdb=TeXLive::TLPDB->new(root => "$master"); if (!defined($tlpdb)) { die("Cannot load TeX Live Database from $master"); @@ -852,20 +822,20 @@ operations might be disturbed.\n\n"; my $perl_bindir="$TEXDIR/tlpkg/tlperl/bin"; my $perl_libdir="$TEXDIR/tlpkg/tlperl/lib"; - tllog($::LOG_DEBUG, "Prepending $plat_bindir to PATH\n"); + debug("Prepending $plat_bindir to PATH\n"); $ENV{'PATH'}="$plat_bindir" . "$pathsep" . "$ENV{'PATH'}"; if (win32) { - tllog($::LOG_DEBUG, "Prepending $perl_bindir to PATH\n"); + debug("Prepending $perl_bindir to PATH\n"); $ENV{'PATH'}="$perl_bindir" . "$pathsep" . "$ENV{'PATH'}"; } - tllog($::LOG_DEBUG, "\nNew PATH is now:\n"); + debug("\nNew PATH is now:\n"); foreach my $dir (split $pathsep, $ENV{'PATH'}) { - tllog($::LOG_DEBUG, " $dir\n"); + debug(" $dir\n"); } - tllog($::LOG_DEBUG, "\n"); + debug("\n"); if (win32) { #$ENV{'PATHEXT'}=".texlua;" . "$ENV{'PATHEXT'}"; @@ -883,7 +853,7 @@ operations might be disturbed.\n\n"; foreach my $package (sort keys %install) { if ($install{$package} && defined($PostInstall{$package})) { - tllog($::LOG_NORMAL, "running post install action for $package\n"); + info("running post install action for $package\n"); &{$PostInstall{$package}}($TEXDIR, $TEXMFSYSVAR, $TEXMFLOCAL); } } @@ -892,7 +862,7 @@ operations might be disturbed.\n\n"; # Step 4: run the programs if (!$opt_portable) { - tllog($::LOG_NORMAL, "running mktexlsr $TEXDIR/texmf-dist $TEXDIR/texmf\n"); + info("running mktexlsr $TEXDIR/texmf-dist $TEXDIR/texmf\n"); system('mktexlsr', "$TEXDIR/texmf-dist", "$TEXDIR/texmf"); } @@ -900,38 +870,38 @@ operations might be disturbed.\n\n"; # texconfig generate * but Win32 does not have texconfig. But we have # $localtlpdb and this is simple code, so do it directly, i.e., duplicate # the code from the various generate-*.pl scripts - tllog($::LOG_NORMAL, "writing fmtutil.cnf data to $TEXMFSYSVAR/web2c/fmtutil.cnf\n"); + info("writing fmtutil.cnf data to $TEXMFSYSVAR/web2c/fmtutil.cnf\n"); TeXLive::TLUtils::create_fmtutil($localtlpdb, "$TEXMFSYSVAR/web2c/fmtutil.cnf", "$TEXMFLOCAL/web2c/fmtutil-local.cnf"); - tllog($::LOG_NORMAL, "writing updmap.cfg to $TEXMFSYSVAR/web2c/updmap.cfg\n"); + info("writing updmap.cfg to $TEXMFSYSVAR/web2c/updmap.cfg\n"); TeXLive::TLUtils::create_updmap ($localtlpdb, "$TEXMFSYSVAR/web2c/updmap.cfg", "$TEXMFLOCAL/web2c/updmap-local.cfg"); - tllog($::LOG_NORMAL, "writing language.dat data to $TEXMFSYSVAR/tex/generic/config/language.dat\n"); + info("writing language.dat data to $TEXMFSYSVAR/tex/generic/config/language.dat\n"); TeXLive::TLUtils::create_language($localtlpdb, "$TEXMFSYSVAR/tex/generic/config/language.dat", "$TEXMFLOCAL/tex/generic/config/language-local.dat"); - tllog($::LOG_NORMAL, "running updmap-sys\n"); + info("running updmap-sys\n"); system('updmap-sys', '--nohash'); - tllog($::LOG_NORMAL, "re-running mktexlsr $TEXMFSYSVAR\n"); + info("re-running mktexlsr $TEXMFSYSVAR\n"); system('mktexlsr', "$TEXMFSYSVAR"); # now work through the options if specified at all # letter instead of a4 if ($vars{'option_letter'}) { - tllog($::LOG_NORMAL, "Setting default paper size to letter\n"); + info("Setting default paper size to letter\n"); system("texlua", "$TEXDIR/texmf/scripts/texlive/texconf.tlu", "--sys", "--noformat", "paper", "letter"); } # all formats option if ($vars{'option_fmt'}) { - tllog($::LOG_NORMAL, "pre-generation all format file (fmtutil-sys --all)\n"); + info("pre-generation all format file (fmtutil-sys --all)\n"); system('fmtutil-sys','--all'); } @@ -941,30 +911,30 @@ operations might be disturbed.\n\n"; my @files; mkdirhier $vars{'sys_bin'}; if (-w $vars{'sys_bin'}) { - tllog($::LOG_NORMAL, "linking binaries to $vars{'sys_bin'}\n"); + info("linking binaries to $vars{'sys_bin'}\n"); @files = `ls $plat_bindir`; chomp(@files); `cd "$vars{'sys_bin'}" && rm -f @files`; `ln -s "$plat_bindir/"* "$vars{'sys_bin'}"`; } else { - tllog($::LOG_NORMAL, "destination of bin symlink $vars{'sys_bin'} not writable, no linking of bin files done!\n"); + info("destination of bin symlink $vars{'sys_bin'} not writable, no linking of bin files done!\n"); } if ($vars{'option_doc'}) { # info files mkdirhier $vars{'sys_info'}; if (-w $vars{'sys_info'}) { - tllog($::LOG_NORMAL, "linking info pages to $vars{'sys_info'}\n"); + info("linking info pages to $vars{'sys_info'}\n"); @files = `ls "$TEXDIR/texmf/doc/info"`; chomp(@files); `cd "$vars{'sys_info'}" && rm -f @files`; `ln -s "$TEXDIR/texmf/doc/info/"*info* "$vars{'sys_info'}"`; } else { - tllog($::LOG_NORMAL, "destination of info symlink $vars{'sys_info'} not writable, no linking of info files done!\n"); + info("destination of info symlink $vars{'sys_info'} not writable, no linking of info files done!\n"); } # man files mkdirhier $vars{'sys_man'}; if (-w $vars{'sys_man'}) { - tllog($::LOG_NORMAL, "linking man pages to $vars{'sys_man'}\n"); + info("linking man pages to $vars{'sys_man'}\n"); my $foo = `(cd "$TEXDIR/texmf/doc/man" && echo *)`; my @mans = split ' ', $foo; chomp(@mans); @@ -979,7 +949,7 @@ operations might be disturbed.\n\n"; `ln -s "$mandir/"* "$vars{'sys_man'}/$m"`; } } else { - tllog($::LOG_NORMAL, "destination of man symlink $vars{'sys_man'} not writable, no linking of man files done!\n"); + info("destination of man symlink $vars{'sys_man'} not writable, no linking of man files done!\n"); } } } |