From e19aadfa3678794d1a655f36f1c67ecf8cd78a56 Mon Sep 17 00:00:00 2001 From: Karl Berry Date: Mon, 28 Nov 2011 23:43:15 +0000 Subject: latexml 4.28 (28nov11) git-svn-id: svn://tug.org/texlive/trunk@24678 c570f23f-e606-0410-a88d-b1316a301751 --- .../texk/texlive/linked_scripts/latexmk/latexmk.pl | 156 ++++++++++++++++----- Master/texmf-dist/doc/support/latexmk/CHANGES | 8 ++ Master/texmf-dist/doc/support/latexmk/INSTALL | 2 +- Master/texmf-dist/doc/support/latexmk/README | 7 +- Master/texmf-dist/doc/support/latexmk/latexmk.pdf | Bin 102763 -> 103044 bytes Master/texmf-dist/doc/support/latexmk/latexmk.txt | 74 +++++----- Master/texmf-dist/scripts/latexmk/latexmk.pl | 156 ++++++++++++++++----- Master/texmf/doc/man/man1/latexmk.1 | 4 +- Master/texmf/doc/man/man1/latexmk.man1.pdf | Bin 116037 -> 116395 bytes 9 files changed, 296 insertions(+), 111 deletions(-) diff --git a/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl b/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl index 2bceb1e803d..b77f379993f 100755 --- a/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl +++ b/Build/source/texk/texlive/linked_scripts/latexmk/latexmk.pl @@ -113,8 +113,8 @@ use warnings; $my_name = 'latexmk'; $My_name = 'Latexmk'; -$version_num = '4.27a'; -$version_details = "$My_name, John Collins, 10 October 2011"; +$version_num = '4.28a'; +$version_details = "$My_name, John Collins, 28 November 2011"; use Config; @@ -183,6 +183,23 @@ else { ## ## Modification log from 1 Jan 2011 onwards in detail ## +## 28 Nov 2011, John Collins Correct duplicate making of view file +## (in subroutine do_viewfile) +## 14 Nov 2011, John Collins Extend bibtex treatment of missing files +## to biber +## 13 Nov 2011, John Collins Possibility of moving cleaned up files to +## directory instead of deleting them. +## Change criterion in rdb_makeB1 for no-run when +## dest doesn't exist. If primary source also +## doesn't exist, then run is pointless for all +## non-primary rules, not just cusdep (which was +## previous case). +## Also change parse_bibtex_log to treat missing +## aux file as warning, not error. Did I do that +## correctly? +## Better: combinations of missing aux, missing bbl, +## and changed bib file seem to work now, for bibtex. +## 3 Nov 2011, John Collins Update help text ## 10 Oct 2011, John Collins Corrections to new options: ## Substitutions in commands ## Locate .fls correctly @@ -482,7 +499,8 @@ $new_viewer_always = 0; # If 1, always open a new viewer in pvc mode. $quote_filenames = 1; # Quote filenames in external commands - +$del_dir = ''; # Directory into which cleaned up files are to be put. + # If $del_dir is '', just delete the files ######################################################################### @@ -1876,11 +1894,11 @@ foreach $filename ( @file_list ) split(' ',$clean_ext), keys %generated_exts_all ); - unlink( 'texput.log', "texput.aux", + unlink_or_move( 'texput.log', "texput.aux", keys %index_bibtex_generated, keys %aux_files ); if ($cleanup_includes_generated) { - unlink( keys %other_generated ); + unlink_or_move( keys %other_generated ); } if ( $cleanup_includes_cusdep_generated) { &cleanup_cusdep_generated; @@ -1891,7 +1909,7 @@ foreach $filename ( @file_list ) ); } } - if ($cleanup_fdb) { unlink $fdb_name; } + if ($cleanup_fdb) { unlink_or_move( $fdb_name ); } if ($cleanup_only) { next FILE; } @@ -2355,7 +2373,6 @@ sub do_viewfile { } else { $return = &rdb_ext_cmd; - $return = &rdb_ext_cmd; } return $return; } #END do_viewfile @@ -2776,7 +2793,7 @@ sub cleanup1 { my $dir = shift; foreach (@_) { (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$dir$root_filename/; - unlink("$name"); + unlink_or_move("$name"); } } #END cleanup1 @@ -2799,7 +2816,7 @@ sub cleanup_one_cusdep_generated { return; } if ( (-e $$Pdest) && (-e $$Psource) ) { - unlink $$Pdest; + unlink_or_move( $$Pdest ); } elsif ( (-e $$Pdest) && (!-e $$Psource) ) { warn "$My_name: For custom dependency '$rule',\n", @@ -2964,6 +2981,7 @@ sub print_help " on force mode, so errors do not cause $my_name to stop.)\n", " (Side effect: turn off ordinary preview mode.)\n", " -pvc- - turn off -pvc\n", + " -quiet - silence progress messages from called programs\n", " -r - Read custom RC file\n", " (N.B. This file could override options specified earlier\n", " on the command line.)\n", @@ -3049,6 +3067,7 @@ sub check_biber_log { # 3: could not open .blg file; # 4: failed to find one or more source files, except for bibfile; # 5: failed to find bib file; + # 6: missing file, one of which is control file # 10: only error is missing \citation commands. # Side effect: add source files @biber_source my $base = $_[0]; @@ -3063,10 +3082,11 @@ sub check_biber_log { my $no_citations = 0; my $error_count = 0; # From my counting of error messages my $warning_count = 0; # From my counting of warning messages - # The next two occur only from biber v > + # The next two occur only from biber my $bibers_error_count = 0; # From biber's counting of errors my $bibers_warning_count = 0; # From biber's counting of warnings my $not_found_count = 0; + my $control_file_missing = 0; while (<$log_file>) { if (/> WARN /) { print "Biber warning: $_"; @@ -3079,6 +3099,11 @@ sub check_biber_log { $not_found_count++; push @$Pbiber_source, $1; } + elsif ( /> FATAL - Cannot find control file '([^']+)'/ ) { #' + $not_found_count++; + $control_file_missing = 1; + push @$Pbiber_source, $1; + } else { $have_error = 1; $error_count ++; @@ -3109,7 +3134,7 @@ sub check_biber_log { my @not_found = &find_file_list1( $Pbiber_source, $Pbiber_source, '', \@BIBINPUTS ); @$Pbiber_source = uniqs( @$Pbiber_source ); - if ( $#not_found < 0) { + if ( ($#not_found < 0) && ($#$Pbiber_source >= 0) ) { warn "$My_name: Found biber source file(s) [@$Pbiber_source]\n" unless $silent; } @@ -3126,6 +3151,9 @@ sub check_biber_log { warn "==== Force_mode is on, so I will continue. ", "But there may be problems ===\n"; } + if ($control_file_missing) { + return 6; + } return 4; } # print "$My_name: #Biber errors = $error_count, warning messages = $warning_count,\n ", @@ -3148,7 +3176,9 @@ sub check_bibtex_log { # Usage: check_bibtex_log( base_of_bibtex_run ) # return 0: OK, 1: bibtex warnings, 2: bibtex errors, # 3: could not open .blg file. - # 10: only error is missing \citation commands. + # 10: only error is missing \citation commands or a missing aux file + # (which would normally be corrected after a later run of + # (pdf)latex). my $base = $_[0]; my $log_name = "$base.blg"; @@ -3158,27 +3188,41 @@ sub check_bibtex_log { my $have_warning = 0; my $have_error = 0; my $missing_citations = 0; + my @missing_aux = (); my $error_count = 0; while (<$log_file>) { if (/^Warning--/) { #print "Bibtex warning: $_"; $have_warning = 1; } + elsif ( /^I couldn\'t open auxiliary file (.*\.aux)/ ) { + push @missing_aux, $1; + } elsif ( /^I found no \\citation commands---while reading file/ ) { - $missing_citations++; + $missing_citations++; } - elsif (/There (were|was) (\d+) error message/) { + elsif (/There (were|was) (\d+) error message/) { $error_count = $2; #print "Bibtex error: count=$error_count $_"; $have_error = 1; } } close $log_file; - #print "Bibtex errors = $error_count, missing citations = $missing_citations\n"; - if ($have_error && ($error_count <= $missing_citations ) - && ($missing_citations > 0) ) { - # If the only error is a missing citation line, that should only + my $missing = $missing_citations + $#missing_aux + 1; + + if ( $#missing_aux > -1 ) { + # Need to make the missing files. + warn "$My_name: One or more aux files is missing for bibtex. I'll try\n", + " to get (pdf)latex to remake them.\n"; + rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); + } + #print "Bibtex errors = $error_count, missing aux files and citations = $missing\n"; + if ($have_error && ($error_count <= $missing ) + && ($missing > 0) ) { + # If the only error is a missing citation line, that should only # count as a warning. + # Also a missing aux file should be innocuous; it will be created on + # next run of (pdf)latex. ?? HAVE I HANDLED THAT CORRECTLY? # But have to deal with the problem that bibtex gives a non-zero # exit code. So leave things as they are so that the user gets # a better diagnostic ?????????????????????????? @@ -5274,8 +5318,15 @@ sub rdb_makeB1 { # not run the rule, but not set an error condition. # Any error will arise at the (pdf)latex level due to a # missing source file at that level. - if ( ( $$Pcmd_type eq 'cusdep') && $$Psource && (! -e $$Psource) ) { - # No action + if ( $$Psource && (! -e $$Psource) +# OLD && ( ( $$Pcmd_type eq 'cusdep') ) +# NEW + && ( ( $$Pcmd_type ne 'primary') ) + ) { + # Main source file doesn't exist, and rule is NOT primary. + # No action, since a run is pointless. Primary is different: + # file might be found elsewhere (by kpsearch from (pdf)latex), + # while non-existence of main source file is a clear error. } elsif ( $$Pcmd_type eq 'delegated' ) { # Delegate to destination rule @@ -5373,14 +5424,18 @@ sub rdb_makeB1 { # For a primary rule, i.e., (pdf)latex, not to produce the # expected output file may not be an error condition. # Diagnostics were handled in parsing the log file. - # Special action in main loop inrdb_makeB1 + # Special action in main loop in rdb_makeB $missing_dvi_pdf = $$Pdest; } + elsif ($return == -2) { + # Missing output file was reported to be NOT an error + $$Pout_of_date = 0; + } else { $failure = 1; } } - if ($return != 0) { + if ( ($return != 0) && ($return != -2) ) { $failure = 1; $$Plast_result = 2; if ( !$$Plast_message ) { @@ -5407,7 +5462,6 @@ sub rdb_submakeB { #************************************************************ - sub rdb_classify_rules { # Usage: rdb_classify_rules( \%allowed_primaries, requested targets ) # Assume the following variables are available (global or local): @@ -5520,7 +5574,8 @@ sub rdb_run1 { # Assumes contexts for: rule. # Unconditionally apply the rule # Returns return code from applying the rule. - # Otherwise: 0 on other kind of success, -1 on error. + # Otherwise: 0 on other kind of success, -1 on error, -2 when missing dest_file + # is to be ignored # Source file data, by definition, correspond to the file state just before # the latest run, and the run_time to the time just before the run: @@ -5572,6 +5627,14 @@ sub rdb_run1 { # $$Plast_message = "Could not find bib file for '$$Pbase'"; push @warnings, "Bib file not found for '$$Pbase'"; } + elsif ($retcode == 6) { + # Missing control file. Need to remake it (if possible) + # Don't treat missing bbl file as error. + warn "$My_name: bibtex control file missing. Since that can\n", + " be recreated, I'll try to do so.\n"; + $return = -2; + rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); + } elsif ($retcode == 4) { $$Plast_result = 2; $$Plast_message = "Could not find all biber source files for '$$Pbase'"; @@ -5591,13 +5654,16 @@ sub rdb_run1 { } elsif ($retcode == 10) { push @warnings, "Biber found no citations for '$$Pbase'"; - # Biber doesn't generate a bbl file in this situation. So I cannot - # ignore the error the way I do with bibtex. - #$return = 0; + # Biber doesn't generate a bbl file in this situation. + $return = -2; } } if ( $rule =~ /^bibtex/ ) { my $retcode = check_bibtex_log($$Pbase); + if ( ! -e $$Psource ) { + $retcode = 10; + rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); + } if ($retcode == 3) { $$Plast_result = 2; $$Plast_message = "Could not open bibtex log file for '$$Pbase'"; @@ -5605,15 +5671,23 @@ sub rdb_run1 { } elsif ($retcode == 2) { $$Plast_message = "Bibtex errors: See file '$$Pbase.blg'"; + $failure = 1; push @warnings, $$Plast_message; } elsif ($retcode == 1) { push @warnings, "Bibtex warnings for '$$Pbase'"; } elsif ($retcode == 10) { - push @warnings, "Bibtex found no citations for '$$Pbase'"; - # But this is an innocuous error, so fix return code - $return = 0; + push @warnings, "Bibtex found no citations for '$$Pbase',\n", + " or bibtex found a missing aux file\n"; + if (! -e $$Pdest ) { + warn "$My_name: Bibtex did not produce '$$Pdest'. But that\n", + " was because of missing files, so I will continue.\n"; + $return = -2; + } + else { + $return = 0; + } } } @@ -5625,16 +5699,15 @@ sub rdb_run1 { } $$Pout_of_date = $$Pout_of_date_user = 0; - if ( ($$Plast_result == 0) && ($return != 0) ) { + if ( ($$Plast_result == 0) && ($return != 0) && ($return != -2) ) { $$Plast_result = 2; if ($$Plast_message eq '') { $$Plast_message = "Command for '$rule' gave return code $return"; } } - elsif ( $$Pdest && (! -e $$Pdest) ) { + elsif ( $$Pdest && (! -e $$Pdest) && ($return != -2) ) { $$Plast_result = 1; } - return $return; } # END rdb_run1 @@ -6474,7 +6547,7 @@ sub cus_dep_delete_dest { # primary run. # Remove the destination file, to indicate it needs to be remade: - unlink $$Pdest; + unlink_or_move( $$Pdest ); # Arrange that the non-existent destination file is not treated as # an error. The variable changed here is a bit misnamed. $$Pchanged = 1; @@ -6843,6 +6916,21 @@ sub find_file_list1 { #************************************************************ +sub unlink_or_move { + if ( $del_dir eq '' ) { + unlink @_; + } + else { + foreach (@_) { + if (-e $_ && ! rename $_, "$del_dir/$_" ) { + warn "$My_name:Cannot move '$_' to '$del_dir/$_'\n"; + } + } + } +} + +#************************************************************ + sub kpsewhich { # Usage: kpsewhich( filespec, ...) # Returns array of files with paths as found by kpsewhich diff --git a/Master/texmf-dist/doc/support/latexmk/CHANGES b/Master/texmf-dist/doc/support/latexmk/CHANGES index 8c299b861b2..531a5cd6ab8 100644 --- a/Master/texmf-dist/doc/support/latexmk/CHANGES +++ b/Master/texmf-dist/doc/support/latexmk/CHANGES @@ -277,3 +277,11 @@ From v. 4.26 to v. 4.27a is MiKTeX only). Corresponding configuration variables, and placeholders for command specification. +From v. 4.27a to 4.28 + Correct handling of situations where some file(s) needed by bibtex + (or biber) don't exist. Previously latexmk incorrectly stopped + with an error message instead of continuing. + +From v. 4.28 to 4.28a + Correct duplicate making of view file + diff --git a/Master/texmf-dist/doc/support/latexmk/INSTALL b/Master/texmf-dist/doc/support/latexmk/INSTALL index 79090f85597..e7a48085381 100644 --- a/Master/texmf-dist/doc/support/latexmk/INSTALL +++ b/Master/texmf-dist/doc/support/latexmk/INSTALL @@ -1,6 +1,6 @@ INSTALLING latexmk ================== - (Version 4.27a, 10 October 2011) + (Version 4.28a, 28 November 2011) John Collins Physics Department diff --git a/Master/texmf-dist/doc/support/latexmk/README b/Master/texmf-dist/doc/support/latexmk/README index 5024ca9d37c..f6752ba33f5 100644 --- a/Master/texmf-dist/doc/support/latexmk/README +++ b/Master/texmf-dist/doc/support/latexmk/README @@ -1,5 +1,5 @@ -Latexmk, version 4.27a, 10 October 2011 ---------------------------------------- +Latexmk, version 4.28a, 28 November 2011 +---------------------------------------- Latexmk completely automates the process of generating a LaTeX document. Essentially, it is a highly specialized cousin of the @@ -92,7 +92,7 @@ NOTES:- John Collins ---------------------------- "latexmk -h" ---------------------------- -Latexmk 4.27a: Automatic LaTeX document generation routine +Latexmk 4.28a: Automatic LaTeX document generation routine Usage: latexmk [latexmk_options] [filename ...] @@ -170,6 +170,7 @@ Usage: latexmk [latexmk_options] [filename ...] on force mode, so errors do not cause latexmk to stop.) (Side effect: turn off ordinary preview mode.) -pvc- - turn off -pvc + -quiet - silence progress messages from called programs -r - Read custom RC file (N.B. This file could override options specified earlier on the command line.) diff --git a/Master/texmf-dist/doc/support/latexmk/latexmk.pdf b/Master/texmf-dist/doc/support/latexmk/latexmk.pdf index d8ecbeb19d5..046bb197e9c 100644 Binary files a/Master/texmf-dist/doc/support/latexmk/latexmk.pdf and b/Master/texmf-dist/doc/support/latexmk/latexmk.pdf differ diff --git a/Master/texmf-dist/doc/support/latexmk/latexmk.txt b/Master/texmf-dist/doc/support/latexmk/latexmk.txt index 4a558531332..e44c1b50f05 100644 --- a/Master/texmf-dist/doc/support/latexmk/latexmk.txt +++ b/Master/texmf-dist/doc/support/latexmk/latexmk.txt @@ -127,7 +127,7 @@ LATEXMK OPTIONS AND ARGUMENTS ON COMMAND LINE - 10 October 2011 2 + 28 November 2011 2 @@ -195,7 +195,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 3 + 28 November 2011 3 @@ -263,7 +263,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 4 + 28 November 2011 4 @@ -331,7 +331,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 5 + 28 November 2011 5 @@ -400,7 +400,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 6 + 28 November 2011 6 @@ -469,7 +469,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 7 + 28 November 2011 7 @@ -539,7 +539,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 8 + 28 November 2011 8 @@ -609,7 +609,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 9 + 28 November 2011 9 @@ -679,7 +679,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 10 + 28 November 2011 10 @@ -749,7 +749,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 11 + 28 November 2011 11 @@ -819,7 +819,7 @@ CONFIGURATION/INITIALIZATION (RC) FILES - 10 October 2011 12 + 28 November 2011 12 @@ -889,7 +889,7 @@ HOW TO SET VARIABLES IN INITIALIZATION FILES - 10 October 2011 13 + 28 November 2011 13 @@ -959,7 +959,7 @@ FORMAT OF COMMAND SPECIFICATIONS - 10 October 2011 14 + 28 November 2011 14 @@ -1029,7 +1029,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 15 + 28 November 2011 15 @@ -1099,7 +1099,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 16 + 28 November 2011 16 @@ -1169,7 +1169,7 @@ LIST OF CONFIGURATION VARIABLES USABLE IN INITIALIZATION FILES - 10 October 2011 17 + 28 November 2011 17 @@ -1239,7 +1239,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 18 + 28 November 2011 18 @@ -1309,7 +1309,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 19 + 28 November 2011 19 @@ -1379,7 +1379,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 20 + 28 November 2011 20 @@ -1449,7 +1449,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 21 + 28 November 2011 21 @@ -1519,7 +1519,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 22 + 28 November 2011 22 @@ -1589,7 +1589,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 23 + 28 November 2011 23 @@ -1659,7 +1659,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 24 + 28 November 2011 24 @@ -1729,7 +1729,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 25 + 28 November 2011 25 @@ -1801,7 +1801,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 26 + 28 November 2011 26 @@ -1873,7 +1873,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 27 + 28 November 2011 27 @@ -1945,7 +1945,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 28 + 28 November 2011 28 @@ -2018,7 +2018,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 29 + 28 November 2011 29 @@ -2091,7 +2091,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 30 + 28 November 2011 30 @@ -2164,7 +2164,7 @@ CUSTOM DEPENDENCIES - 10 October 2011 31 + 28 November 2011 31 @@ -2237,7 +2237,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 32 + 28 November 2011 32 @@ -2310,7 +2310,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 33 + 28 November 2011 33 @@ -2383,7 +2383,7 @@ USING latexmk WITH make - 10 October 2011 34 + 28 November 2011 34 @@ -2456,7 +2456,7 @@ LATEXMK(1L) LATEXMK(1L) - 10 October 2011 35 + 28 November 2011 35 @@ -2531,7 +2531,7 @@ BUGS - 10 October 2011 36 + 28 November 2011 36 @@ -2564,7 +2564,7 @@ THANKS TO AUTHOR Current version, by John Collins (username collins at node - phys.psu.edu). (Version 4.27). + phys.psu.edu). (Version 4.28a). Released version can be obtained from CTAN: , and from the author's website @@ -2606,6 +2606,6 @@ AUTHOR - 10 October 2011 37 + 28 November 2011 37 diff --git a/Master/texmf-dist/scripts/latexmk/latexmk.pl b/Master/texmf-dist/scripts/latexmk/latexmk.pl index 2bceb1e803d..b77f379993f 100755 --- a/Master/texmf-dist/scripts/latexmk/latexmk.pl +++ b/Master/texmf-dist/scripts/latexmk/latexmk.pl @@ -113,8 +113,8 @@ use warnings; $my_name = 'latexmk'; $My_name = 'Latexmk'; -$version_num = '4.27a'; -$version_details = "$My_name, John Collins, 10 October 2011"; +$version_num = '4.28a'; +$version_details = "$My_name, John Collins, 28 November 2011"; use Config; @@ -183,6 +183,23 @@ else { ## ## Modification log from 1 Jan 2011 onwards in detail ## +## 28 Nov 2011, John Collins Correct duplicate making of view file +## (in subroutine do_viewfile) +## 14 Nov 2011, John Collins Extend bibtex treatment of missing files +## to biber +## 13 Nov 2011, John Collins Possibility of moving cleaned up files to +## directory instead of deleting them. +## Change criterion in rdb_makeB1 for no-run when +## dest doesn't exist. If primary source also +## doesn't exist, then run is pointless for all +## non-primary rules, not just cusdep (which was +## previous case). +## Also change parse_bibtex_log to treat missing +## aux file as warning, not error. Did I do that +## correctly? +## Better: combinations of missing aux, missing bbl, +## and changed bib file seem to work now, for bibtex. +## 3 Nov 2011, John Collins Update help text ## 10 Oct 2011, John Collins Corrections to new options: ## Substitutions in commands ## Locate .fls correctly @@ -482,7 +499,8 @@ $new_viewer_always = 0; # If 1, always open a new viewer in pvc mode. $quote_filenames = 1; # Quote filenames in external commands - +$del_dir = ''; # Directory into which cleaned up files are to be put. + # If $del_dir is '', just delete the files ######################################################################### @@ -1876,11 +1894,11 @@ foreach $filename ( @file_list ) split(' ',$clean_ext), keys %generated_exts_all ); - unlink( 'texput.log', "texput.aux", + unlink_or_move( 'texput.log', "texput.aux", keys %index_bibtex_generated, keys %aux_files ); if ($cleanup_includes_generated) { - unlink( keys %other_generated ); + unlink_or_move( keys %other_generated ); } if ( $cleanup_includes_cusdep_generated) { &cleanup_cusdep_generated; @@ -1891,7 +1909,7 @@ foreach $filename ( @file_list ) ); } } - if ($cleanup_fdb) { unlink $fdb_name; } + if ($cleanup_fdb) { unlink_or_move( $fdb_name ); } if ($cleanup_only) { next FILE; } @@ -2355,7 +2373,6 @@ sub do_viewfile { } else { $return = &rdb_ext_cmd; - $return = &rdb_ext_cmd; } return $return; } #END do_viewfile @@ -2776,7 +2793,7 @@ sub cleanup1 { my $dir = shift; foreach (@_) { (my $name = /%R/ ? $_ : "%R.$_") =~ s/%R/$dir$root_filename/; - unlink("$name"); + unlink_or_move("$name"); } } #END cleanup1 @@ -2799,7 +2816,7 @@ sub cleanup_one_cusdep_generated { return; } if ( (-e $$Pdest) && (-e $$Psource) ) { - unlink $$Pdest; + unlink_or_move( $$Pdest ); } elsif ( (-e $$Pdest) && (!-e $$Psource) ) { warn "$My_name: For custom dependency '$rule',\n", @@ -2964,6 +2981,7 @@ sub print_help " on force mode, so errors do not cause $my_name to stop.)\n", " (Side effect: turn off ordinary preview mode.)\n", " -pvc- - turn off -pvc\n", + " -quiet - silence progress messages from called programs\n", " -r - Read custom RC file\n", " (N.B. This file could override options specified earlier\n", " on the command line.)\n", @@ -3049,6 +3067,7 @@ sub check_biber_log { # 3: could not open .blg file; # 4: failed to find one or more source files, except for bibfile; # 5: failed to find bib file; + # 6: missing file, one of which is control file # 10: only error is missing \citation commands. # Side effect: add source files @biber_source my $base = $_[0]; @@ -3063,10 +3082,11 @@ sub check_biber_log { my $no_citations = 0; my $error_count = 0; # From my counting of error messages my $warning_count = 0; # From my counting of warning messages - # The next two occur only from biber v > + # The next two occur only from biber my $bibers_error_count = 0; # From biber's counting of errors my $bibers_warning_count = 0; # From biber's counting of warnings my $not_found_count = 0; + my $control_file_missing = 0; while (<$log_file>) { if (/> WARN /) { print "Biber warning: $_"; @@ -3079,6 +3099,11 @@ sub check_biber_log { $not_found_count++; push @$Pbiber_source, $1; } + elsif ( /> FATAL - Cannot find control file '([^']+)'/ ) { #' + $not_found_count++; + $control_file_missing = 1; + push @$Pbiber_source, $1; + } else { $have_error = 1; $error_count ++; @@ -3109,7 +3134,7 @@ sub check_biber_log { my @not_found = &find_file_list1( $Pbiber_source, $Pbiber_source, '', \@BIBINPUTS ); @$Pbiber_source = uniqs( @$Pbiber_source ); - if ( $#not_found < 0) { + if ( ($#not_found < 0) && ($#$Pbiber_source >= 0) ) { warn "$My_name: Found biber source file(s) [@$Pbiber_source]\n" unless $silent; } @@ -3126,6 +3151,9 @@ sub check_biber_log { warn "==== Force_mode is on, so I will continue. ", "But there may be problems ===\n"; } + if ($control_file_missing) { + return 6; + } return 4; } # print "$My_name: #Biber errors = $error_count, warning messages = $warning_count,\n ", @@ -3148,7 +3176,9 @@ sub check_bibtex_log { # Usage: check_bibtex_log( base_of_bibtex_run ) # return 0: OK, 1: bibtex warnings, 2: bibtex errors, # 3: could not open .blg file. - # 10: only error is missing \citation commands. + # 10: only error is missing \citation commands or a missing aux file + # (which would normally be corrected after a later run of + # (pdf)latex). my $base = $_[0]; my $log_name = "$base.blg"; @@ -3158,27 +3188,41 @@ sub check_bibtex_log { my $have_warning = 0; my $have_error = 0; my $missing_citations = 0; + my @missing_aux = (); my $error_count = 0; while (<$log_file>) { if (/^Warning--/) { #print "Bibtex warning: $_"; $have_warning = 1; } + elsif ( /^I couldn\'t open auxiliary file (.*\.aux)/ ) { + push @missing_aux, $1; + } elsif ( /^I found no \\citation commands---while reading file/ ) { - $missing_citations++; + $missing_citations++; } - elsif (/There (were|was) (\d+) error message/) { + elsif (/There (were|was) (\d+) error message/) { $error_count = $2; #print "Bibtex error: count=$error_count $_"; $have_error = 1; } } close $log_file; - #print "Bibtex errors = $error_count, missing citations = $missing_citations\n"; - if ($have_error && ($error_count <= $missing_citations ) - && ($missing_citations > 0) ) { - # If the only error is a missing citation line, that should only + my $missing = $missing_citations + $#missing_aux + 1; + + if ( $#missing_aux > -1 ) { + # Need to make the missing files. + warn "$My_name: One or more aux files is missing for bibtex. I'll try\n", + " to get (pdf)latex to remake them.\n"; + rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); + } + #print "Bibtex errors = $error_count, missing aux files and citations = $missing\n"; + if ($have_error && ($error_count <= $missing ) + && ($missing > 0) ) { + # If the only error is a missing citation line, that should only # count as a warning. + # Also a missing aux file should be innocuous; it will be created on + # next run of (pdf)latex. ?? HAVE I HANDLED THAT CORRECTLY? # But have to deal with the problem that bibtex gives a non-zero # exit code. So leave things as they are so that the user gets # a better diagnostic ?????????????????????????? @@ -5274,8 +5318,15 @@ sub rdb_makeB1 { # not run the rule, but not set an error condition. # Any error will arise at the (pdf)latex level due to a # missing source file at that level. - if ( ( $$Pcmd_type eq 'cusdep') && $$Psource && (! -e $$Psource) ) { - # No action + if ( $$Psource && (! -e $$Psource) +# OLD && ( ( $$Pcmd_type eq 'cusdep') ) +# NEW + && ( ( $$Pcmd_type ne 'primary') ) + ) { + # Main source file doesn't exist, and rule is NOT primary. + # No action, since a run is pointless. Primary is different: + # file might be found elsewhere (by kpsearch from (pdf)latex), + # while non-existence of main source file is a clear error. } elsif ( $$Pcmd_type eq 'delegated' ) { # Delegate to destination rule @@ -5373,14 +5424,18 @@ sub rdb_makeB1 { # For a primary rule, i.e., (pdf)latex, not to produce the # expected output file may not be an error condition. # Diagnostics were handled in parsing the log file. - # Special action in main loop inrdb_makeB1 + # Special action in main loop in rdb_makeB $missing_dvi_pdf = $$Pdest; } + elsif ($return == -2) { + # Missing output file was reported to be NOT an error + $$Pout_of_date = 0; + } else { $failure = 1; } } - if ($return != 0) { + if ( ($return != 0) && ($return != -2) ) { $failure = 1; $$Plast_result = 2; if ( !$$Plast_message ) { @@ -5407,7 +5462,6 @@ sub rdb_submakeB { #************************************************************ - sub rdb_classify_rules { # Usage: rdb_classify_rules( \%allowed_primaries, requested targets ) # Assume the following variables are available (global or local): @@ -5520,7 +5574,8 @@ sub rdb_run1 { # Assumes contexts for: rule. # Unconditionally apply the rule # Returns return code from applying the rule. - # Otherwise: 0 on other kind of success, -1 on error. + # Otherwise: 0 on other kind of success, -1 on error, -2 when missing dest_file + # is to be ignored # Source file data, by definition, correspond to the file state just before # the latest run, and the run_time to the time just before the run: @@ -5572,6 +5627,14 @@ sub rdb_run1 { # $$Plast_message = "Could not find bib file for '$$Pbase'"; push @warnings, "Bib file not found for '$$Pbase'"; } + elsif ($retcode == 6) { + # Missing control file. Need to remake it (if possible) + # Don't treat missing bbl file as error. + warn "$My_name: bibtex control file missing. Since that can\n", + " be recreated, I'll try to do so.\n"; + $return = -2; + rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); + } elsif ($retcode == 4) { $$Plast_result = 2; $$Plast_message = "Could not find all biber source files for '$$Pbase'"; @@ -5591,13 +5654,16 @@ sub rdb_run1 { } elsif ($retcode == 10) { push @warnings, "Biber found no citations for '$$Pbase'"; - # Biber doesn't generate a bbl file in this situation. So I cannot - # ignore the error the way I do with bibtex. - #$return = 0; + # Biber doesn't generate a bbl file in this situation. + $return = -2; } } if ( $rule =~ /^bibtex/ ) { my $retcode = check_bibtex_log($$Pbase); + if ( ! -e $$Psource ) { + $retcode = 10; + rdb_for_some( [keys %current_primaries], sub{ $$Pout_of_date = 1; } ); + } if ($retcode == 3) { $$Plast_result = 2; $$Plast_message = "Could not open bibtex log file for '$$Pbase'"; @@ -5605,15 +5671,23 @@ sub rdb_run1 { } elsif ($retcode == 2) { $$Plast_message = "Bibtex errors: See file '$$Pbase.blg'"; + $failure = 1; push @warnings, $$Plast_message; } elsif ($retcode == 1) { push @warnings, "Bibtex warnings for '$$Pbase'"; } elsif ($retcode == 10) { - push @warnings, "Bibtex found no citations for '$$Pbase'"; - # But this is an innocuous error, so fix return code - $return = 0; + push @warnings, "Bibtex found no citations for '$$Pbase',\n", + " or bibtex found a missing aux file\n"; + if (! -e $$Pdest ) { + warn "$My_name: Bibtex did not produce '$$Pdest'. But that\n", + " was because of missing files, so I will continue.\n"; + $return = -2; + } + else { + $return = 0; + } } } @@ -5625,16 +5699,15 @@ sub rdb_run1 { } $$Pout_of_date = $$Pout_of_date_user = 0; - if ( ($$Plast_result == 0) && ($return != 0) ) { + if ( ($$Plast_result == 0) && ($return != 0) && ($return != -2) ) { $$Plast_result = 2; if ($$Plast_message eq '') { $$Plast_message = "Command for '$rule' gave return code $return"; } } - elsif ( $$Pdest && (! -e $$Pdest) ) { + elsif ( $$Pdest && (! -e $$Pdest) && ($return != -2) ) { $$Plast_result = 1; } - return $return; } # END rdb_run1 @@ -6474,7 +6547,7 @@ sub cus_dep_delete_dest { # primary run. # Remove the destination file, to indicate it needs to be remade: - unlink $$Pdest; + unlink_or_move( $$Pdest ); # Arrange that the non-existent destination file is not treated as # an error. The variable changed here is a bit misnamed. $$Pchanged = 1; @@ -6843,6 +6916,21 @@ sub find_file_list1 { #************************************************************ +sub unlink_or_move { + if ( $del_dir eq '' ) { + unlink @_; + } + else { + foreach (@_) { + if (-e $_ && ! rename $_, "$del_dir/$_" ) { + warn "$My_name:Cannot move '$_' to '$del_dir/$_'\n"; + } + } + } +} + +#************************************************************ + sub kpsewhich { # Usage: kpsewhich( filespec, ...) # Returns array of files with paths as found by kpsewhich diff --git a/Master/texmf/doc/man/man1/latexmk.1 b/Master/texmf/doc/man/man1/latexmk.1 index 034da7cb064..617c5c56042 100644 --- a/Master/texmf/doc/man/man1/latexmk.1 +++ b/Master/texmf/doc/man/man1/latexmk.1 @@ -1,4 +1,4 @@ -.TH LATEXMK 1L "10 October 2011" "" +.TH LATEXMK 1L "28 November 2011" "" .SH NAME latexmk \- generate LaTeX document .SH SYNOPSIS @@ -2169,7 +2169,7 @@ e-mail addresses are not written in their standard form to avoid being harvested by worms and viruses.) .SH AUTHOR Current version, by John Collins (username collins at node phys.psu.edu). -(Version 4.27). +(Version 4.28a). Released version can be obtained from CTAN: , and from the diff --git a/Master/texmf/doc/man/man1/latexmk.man1.pdf b/Master/texmf/doc/man/man1/latexmk.man1.pdf index 2559491adaf..edc5a333362 100644 Binary files a/Master/texmf/doc/man/man1/latexmk.man1.pdf and b/Master/texmf/doc/man/man1/latexmk.man1.pdf differ -- cgit v1.2.3