texlive[52059] trunk: bundledoc (8sep19)

commits+karl at tug.org commits+karl at tug.org
Sun Sep 8 23:54:05 CEST 2019


Revision: 52059
          http://tug.org/svn/texlive?view=revision&revision=52059
Author:   karl
Date:     2019-09-08 23:54:05 +0200 (Sun, 08 Sep 2019)
Log Message:
-----------
bundledoc (8sep19)

Modified Paths:
--------------
    trunk/Build/source/texk/texlive/linked_scripts/bundledoc/bundledoc
    trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl
    trunk/Master/texmf-dist/doc/man/man1/arlatex.1
    trunk/Master/texmf-dist/doc/man/man1/arlatex.man1.pdf
    trunk/Master/texmf-dist/doc/man/man1/bundledoc.1
    trunk/Master/texmf-dist/doc/man/man1/bundledoc.man1.pdf
    trunk/Master/texmf-dist/doc/support/bundledoc/README
    trunk/Master/texmf-dist/scripts/bundledoc/bundledoc

Modified: trunk/Build/source/texk/texlive/linked_scripts/bundledoc/bundledoc
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/bundledoc/bundledoc	2019-09-08 21:45:40 UTC (rev 52058)
+++ trunk/Build/source/texk/texlive/linked_scripts/bundledoc/bundledoc	2019-09-08 21:54:05 UTC (rev 52059)
@@ -7,7 +7,7 @@
 
 ########################################################################
 # bundledoc                                                            #
-# Copyright (C) 2018 Scott Pakin                                       #
+# Copyright (C) 2018-2019 Scott Pakin                                  #
 #                                                                      #
 # This program may be distributed and/or modified under the conditions #
 # of the LaTeX Project Public License, either version 1.3c of this     #
@@ -24,8 +24,8 @@
 # in the Files section of the associated README file.                  #
 ########################################################################
 
-use 5.006;             # Fail gracefully if we're not using Perl v5.6.0.
-our $VERSION = "3.3";  # Specify the version of bundledoc.
+use 5.006;             # Fail gracefully if we're not using Perl v5.6.0+.
+our $VERSION = "3.4";  # Specify the version of bundledoc.
 use File::Basename;
 use File::Copy;
 use File::Spec::Functions qw(abs2rel catfile devnull rel2abs rootdir updir);
@@ -87,8 +87,7 @@
     my $retval;
 
     if ($verbose) {
-        print "EXECUTING: $command\n";
-        print "           (BDINPUTS = $ENV{BDINPUTS})\n";
+        print "EXECUTING $command WITH BDINPUTS = $ENV{BDINPUTS}\n";
     }
     if ($pathsep eq "\\") {
         # Dirty trick to work around idiotic "\" --> "/" conversion
@@ -100,12 +99,65 @@
     die "${progname}: $!.  Failing command was:\n\t$command\n" if $retval;
 }
 
+# Append ".dep" to the dependency file if necessary.
+sub find_dependency_file ($)
+{
+    my $depfile = $_[0];
+
+    # Return the file as is if it exists.
+    return $depfile if -e $depfile || $depfile =~ /\.dep$/;
+
+    # Return the file with ".dep" appended if that exists.
+    return "${depfile}.dep" if -e "${depfile}.dep";
+
+    # Give up and return the file as specified.
+    return $depfile;
+}
+
+# Try hard to find a configuration file.  Return the name of the actual file we
+# located.
+sub find_config_file ($)
+{
+    my $configfile = $_[0];
+    no warnings;   # Don't complain if kpsewhich isn't found.
+
+    # Attempt 1: See if the file exists as named.
+    return $configfile if -e $configfile;
+
+    # Attempt 2: Append ".cfg" if it's not already there.
+    my $config_cfg = $configfile;
+    if ($config_cfg !~ /\.cfg$/) {
+        $config_cfg = "${configfile}.cfg";
+        return $config_cfg if -e $config_cfg;
+    }
+
+    # Attempt 3: Use kpsewhich to find the file with ".cfg" appended.  (We
+    # don't search for it without ".cfg" because kpsewhich may find a version
+    # with ".tex" appended.)
+    my $kpfound = `kpsewhich $config_cfg`;
+    if (defined $kpfound) {
+        chomp $kpfound;
+        return $kpfound if -e $kpfound;
+    }
+
+    # Give up.  Return the file name as specified.
+    return $configfile;
+}
+
 # Read a configuration file, and set %uservariable accordingly.
 sub process_config_file ($)
 {
-    my $configfile = $_[0];
+    my $configfile = find_config_file $_[0];
+    printf("CONFIGURATION FILE: %s\n", rel2abs($configfile)) if $verbose;
     my $prevline = "";
-    open (CONFIGFILE, "<$configfile") || die "${progname}: $! ($configfile)\n";
+    open (CONFIGFILE, "<", $configfile) || do {
+	my $configlist = $configfile;
+	if (! -e $configfile) {
+	    # Error is "file not found".  List the files we considered.
+	    $configlist .= "; also considered ${configfile}.cfg" if $configfile !~ /\.cfg$/;
+	}
+	die "${progname}: $! ($configlist)\n";
+    };
     while (my $oneline=<CONFIGFILE>) {
         # Read a line and trim it.
         chomp $oneline;
@@ -222,7 +274,7 @@
     my $numextras = 0;
     foreach my $include_glob (@include_files) {
         foreach my $include_file (glob $include_glob) {
-            push @dependencies, $include_file;
+            push @dependencies, qualifyname $include_file;
             $numextras++;
         }
     }
@@ -255,6 +307,7 @@
 $keepdirs = 0;
 $verbose = 0;
 $localonly = 0;
+my $configfile;
 Getopt::Long::Configure("bundling");
 GetOptions ('texfile=s' => \$texfile,
             'directory=s' => \$docdirname,
@@ -263,7 +316,7 @@
             'localonly!' => \$localonly,
             'exclude=s' => \@exclude_files,
             'include=s' => \@include_files,
-            'config=s' => sub { process_config_file($_[1]) },
+            'config=s' => \$configfile,
             'v|verbose!' => \$verbose,
             'listdeps=s' => \@listdeps,
             'V|version' => sub { print "bundledoc $VERSION\n"; exit -1 },
@@ -276,7 +329,8 @@
 pod2usage (-message => "${progname}: Too few arguments",
            -exitval => 1,
            -verbose => 0) if $#ARGV==-1;
-$depfile = shift;                # Dependencies from snapshot.sty
+$depfile = find_dependency_file shift;      # Dependencies from snapshot.sty
+process_config_file $configfile if defined $configfile;
 ($texfile = $depfile) =~ s/\.[^.]*$/.tex/ if !$texfile;   # Main LaTeX source file
 ($docdirname = basename($depfile)) =~ s/\.[^.]*$// if !$docdirname;     # Name to use for the document directory
 ($ENV{"BDBASE"} = rel2abs($depfile)) =~ s/\.[^.]*$//;   # May be needed by user-defined variables
@@ -370,7 +424,7 @@
 [B<--version>]
 [B<--help>]
 [B<-->[B<no>]B<verbose>]
-[B<--texfile>=I<file>]
+[B<--texfile>=I<file.tex>]
 [B<--directory>=I<directory>]
 [B<-->[B<no>]B<localonly>]
 [B<--exclude>=I<string>]
@@ -378,8 +432,8 @@
 [B<--manifest>=I<file>]
 [B<-->B<listdeps>=[yes|no|only|rel]...]
 [B<-->[B<no>]B<keepdirs>]
-[B<--config>=I<file>]
-I<.dep file>
+[B<--config>=I<file.cfg>]
+I<file.dep>
 
 
 =head1 DESCRIPTION
@@ -414,8 +468,9 @@
 main LaTeX document (no extension).
 
 B<bundledoc> requires the name of the dependency file produced by
-B<snapshot> (normally I<somefile>F<.dep>).  The following options may
-also be given:
+B<snapshot>, normally I<somefile>F<.dep>).  (For convenience, the file
+can be specified without its F<.dep> extension.)  The following
+options may also be given:
 
 =over 4
 
@@ -561,7 +616,8 @@
 appropriate configuration (F<.cfg>) file for your TeX distribution and
 operating system.  B<bundledoc> comes with a few configuration files
 and it's easy to write more.  See L<"CONFIGURATION FILES"> (below) for
-a description of the configuration file format.
+a description of the configuration file format.  For convenience, the
+file can be specified without its F<.cfg> extension.
 
 =back
 
@@ -654,9 +710,10 @@
 
     bundledoc --config=miktex.cfg myfile.dep
 
-(In practice, it's probably necessary to specify to C<--config> the
-complete path to B<bundledoc>'s F<miktex.cfg> configuration file.)
+This can be abbreviated to
 
+    bundledoc --config=miktex myfile
+
 The following builds a F<.tar.gz> archive with the TeX Live
 distribution running on a Unix-like operating system.  B<bundledoc>
 will produce verbose output describing its operations.  All files not
@@ -830,8 +887,11 @@
 
 Thanks to Fabien Vignes-Tourneret for suggesting what became the
 C<--localonly> option and for a discussion that led to the
-C<--exclude> and C<--include> options; and to Marius Kleiner for
-updating B<bundledoc> to properly handle document subdirectories.
+C<--exclude> and C<--include> options; to Marius Kleiner for updating
+B<bundledoc> to properly handle document subdirectories; and to Frank
+Mittelbach for suggesting using Kpathsea to help find F<.cfg> files
+and to automatically append F<.cfg> and F<.dep> extensions if
+necessary.
 
 
 =head1 SEE ALSO

Modified: trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl
===================================================================
--- trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl	2019-09-08 21:45:40 UTC (rev 52058)
+++ trunk/Build/source/texk/texlive/linked_scripts/texlive/tlmgr.pl	2019-09-08 21:54:05 UTC (rev 52059)
@@ -1,12 +1,12 @@
 #!/usr/bin/env perl
-# $Id: tlmgr.pl 51800 2019-08-01 22:51:44Z karl $
+# $Id: tlmgr.pl 52045 2019-09-07 05:32:39Z preining $
 #
 # Copyright 2008-2019 Norbert Preining
 # This file is licensed under the GNU General Public License version 2
 # or any later version.
 
-my $svnrev = '$Revision: 51800 $';
-my $datrev = '$Date: 2019-08-02 00:51:44 +0200 (Fri, 02 Aug 2019) $';
+my $svnrev = '$Revision: 52045 $';
+my $datrev = '$Date: 2019-09-07 07:32:39 +0200 (Sat, 07 Sep 2019) $';
 my $tlmgrrevision;
 my $tlmgrversion;
 my $prg;
@@ -5340,6 +5340,8 @@
     $ret |= check_executes();
     print "Running check runfiles:\n";
     $ret |= check_runfiles();
+    print "Running check texmfdb paths\n";
+    $ret |= check_texmfdbs();
   } elsif ($what =~ m/^files/i) {
     my $tltree = init_tltree($svn);
     $ret |= check_files($tltree);
@@ -5352,6 +5354,8 @@
     $ret |= check_runfiles();
   } elsif ($what =~ m/^executes/i) {
     $ret |= check_executes();
+  } elsif ($what =~ m/^texmfdbs/i) {
+    $ret |= check_texmfdbs();
   } else {
     print "No idea how to check that: $what\n";
   }
@@ -5842,7 +5846,50 @@
   return $ret;
 }
 
+sub check_texmfdbs {
 
+#!/usr/bin/perl
+  my $texmfdbs = `kpsewhich -var-value TEXMFDBS`;
+  my @tfmdbs = glob $texmfdbs;
+  my $tfms = `kpsewhich -var-value TEXMF`;
+  my @tfms = glob $tfms;
+  my %tfmdbs;
+  my $ret = 0;
+
+  print "Checking TEXMFDBS\n";
+  for my $p (@tfmdbs) {
+    print "-> $p\n";
+    if ($p !~ m/^!!/) {
+      printf "Warn: entry $p in TEXMFDBS does not have leading !!\n";
+      $ret++;
+    }
+    $p =~ s/^!!//;
+    $tfmdbs{$p} = 1;
+    if (! -r "$p/ls-R") {
+      printf "Warn: entry $p does not have an associated ls-R\n";
+      $ret++;
+    }
+  }
+
+  print "Checking TEXMF\n";
+  for my $p (@tfms) {
+    print "-> $p\n";
+    my $pnobang = $p;
+    $pnobang =~ s/^!!//;
+    if (! $tfmdbs{$pnobang}) {
+      if ($p =~ m/^!!/) {
+        printf "Warn: tree $p in TEXMF is not in TEXMFDBS but has !!\n";
+        $ret++;
+      }
+      if (-r "$pnobang/ls-R") {
+        printf "Warn: tree $p in TEXMF is not in TEXMFDBS but has ls-R file\n";
+        $ret++;
+      }
+    }
+  }
+  return($ret);
+}
+
 # 
 POSTACTION
 # 
 # explictly run the various post actions, e.g.,
@@ -9861,7 +9908,7 @@
 distribution (L<https://tug.org/texlive>) and both are licensed under the
 GNU General Public License Version 2 or later.
 
-$Id: tlmgr.pl 51800 2019-08-01 22:51:44Z karl $
+$Id: tlmgr.pl 52045 2019-09-07 05:32:39Z preining $
 =cut
 
 # test HTML version: pod2html --cachedir=/tmp tlmgr.pl >/tmp/tlmgr.html

Modified: trunk/Master/texmf-dist/doc/man/man1/arlatex.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/arlatex.1	2019-09-08 21:45:40 UTC (rev 52058)
+++ trunk/Master/texmf-dist/doc/man/man1/arlatex.1	2019-09-08 21:54:05 UTC (rev 52059)
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
+.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
@@ -54,16 +54,20 @@
 .\" Avoid warning from groff about undefined register 'F'.
 .de IX
 ..
-.if !\nF .nr F 0
-.if \nF>0 \{\
-.    de IX
-.    tm Index:\\$1\t\\n%\t"\\$2"
+.nr rF 0
+.if \n(.g .if rF .nr rF 1
+.if (\n(rF:(\n(.g==0)) \{\
+.    if \nF \{\
+.        de IX
+.        tm Index:\\$1\t\\n%\t"\\$2"
 ..
-.    if !\nF==2 \{\
-.        nr % 0
-.        nr F 2
+.        if !\nF==2 \{\
+.            nr % 0
+.            nr F 2
+.        \}
 .    \}
 .\}
+.rr rF
 .\"
 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
@@ -278,7 +282,7 @@
 a different directory.
 .SH "SEE ALSO"
 .IX Header "SEE ALSO"
-\&\fIbundledoc\fR\|(1), \fIlatex\fR\|(1), \fIshar\fR\|(1), \fItar\fR\|(1), \fIzip\fR\|(1)
+\&\fBbundledoc\fR\|(1), \fBlatex\fR\|(1), \fBshar\fR\|(1), \fBtar\fR\|(1), \fBzip\fR\|(1)
 .SH "AUTHOR"
 .IX Header "AUTHOR"
 Scott Pakin, \fIscott+bdoc at pakin.org\fR

Modified: trunk/Master/texmf-dist/doc/man/man1/arlatex.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/man/man1/bundledoc.1
===================================================================
--- trunk/Master/texmf-dist/doc/man/man1/bundledoc.1	2019-09-08 21:45:40 UTC (rev 52058)
+++ trunk/Master/texmf-dist/doc/man/man1/bundledoc.1	2019-09-08 21:54:05 UTC (rev 52059)
@@ -1,4 +1,4 @@
-.\" Automatically generated by Pod::Man 4.09 (Pod::Simple 3.35)
+.\" Automatically generated by Pod::Man 4.10 (Pod::Simple 3.35)
 .\"
 .\" Standard preamble:
 .\" ========================================================================
@@ -54,16 +54,20 @@
 .\" Avoid warning from groff about undefined register 'F'.
 .de IX
 ..
-.if !\nF .nr F 0
-.if \nF>0 \{\
-.    de IX
-.    tm Index:\\$1\t\\n%\t"\\$2"
+.nr rF 0
+.if \n(.g .if rF .nr rF 1
+.if (\n(rF:(\n(.g==0)) \{\
+.    if \nF \{\
+.        de IX
+.        tm Index:\\$1\t\\n%\t"\\$2"
 ..
-.    if !\nF==2 \{\
-.        nr % 0
-.        nr F 2
+.        if !\nF==2 \{\
+.            nr % 0
+.            nr F 2
+.        \}
 .    \}
 .\}
+.rr rF
 .\"
 .\" Accent mark definitions (@(#)ms.acc 1.5 88/02/08 SMI; from UCB 4.2).
 .\" Fear.  Run.  Save yourself.  No user-serviceable parts.
@@ -129,7 +133,7 @@
 .\" ========================================================================
 .\"
 .IX Title "BUNDLEDOC 1"
-.TH BUNDLEDOC 1 "2018-05-23" "v3.3" "User Commands"
+.TH BUNDLEDOC 1 "2019-09-08" "v3.4" "User Commands"
 .\" For nroff, turn off justification.  Always turn off hyphenation; it makes
 .\" way too many mistakes in technical documents.
 .if n .ad l
@@ -142,7 +146,7 @@
 [\fB\-\-version\fR]
 [\fB\-\-help\fR]
 [\fB\-\-\fR[\fBno\fR]\fBverbose\fR]
-[\fB\-\-texfile\fR=\fIfile\fR]
+[\fB\-\-texfile\fR=\fIfile.tex\fR]
 [\fB\-\-directory\fR=\fIdirectory\fR]
 [\fB\-\-\fR[\fBno\fR]\fBlocalonly\fR]
 [\fB\-\-exclude\fR=\fIstring\fR]
@@ -150,8 +154,8 @@
 [\fB\-\-manifest\fR=\fIfile\fR]
 [\fB\-\-\fR\fBlistdeps\fR=[yes|no|only|rel]...]
 [\fB\-\-\fR[\fBno\fR]\fBkeepdirs\fR]
-[\fB\-\-config\fR=\fIfile\fR]
-\&\fI.dep file\fR
+[\fB\-\-config\fR=\fIfile.cfg\fR]
+\&\fIfile.dep\fR
 .SH "DESCRIPTION"
 .IX Header "DESCRIPTION"
 \&\fBbundledoc\fR is a post-processor for the \fBsnapshot\fR package that
@@ -184,8 +188,9 @@
 main LaTeX document (no extension).
 .PP
 \&\fBbundledoc\fR requires the name of the dependency file produced by
-\&\fBsnapshot\fR (normally \fIsomefile\fR\fI.dep\fR).  The following options may
-also be given:
+\&\fBsnapshot\fR, normally \fIsomefile\fR\fI.dep\fR).  (For convenience, the file
+can be specified without its \fI.dep\fR extension.)  The following
+options may also be given:
 .IP "\fB\-\-version\fR" 4
 .IX Item "--version"
 Output the \fBbundledoc\fR script's version number.  This overrides all
@@ -301,7 +306,8 @@
 appropriate configuration (\fI.cfg\fR) file for your TeX distribution and
 operating system.  \fBbundledoc\fR comes with a few configuration files
 and it's easy to write more.  See \*(L"\s-1CONFIGURATION FILES\*(R"\s0 (below) for
-a description of the configuration file format.
+a description of the configuration file format.  For convenience, the
+file can be specified without its \fI.cfg\fR extension.
 .SH "CONFIGURATION FILES"
 .IX Header "CONFIGURATION FILES"
 .SS "Format"
@@ -390,9 +396,12 @@
 \&    bundledoc \-\-config=miktex.cfg myfile.dep
 .Ve
 .PP
-(In practice, it's probably necessary to specify to \f(CW\*(C`\-\-config\*(C'\fR the
-complete path to \fBbundledoc\fR's \fImiktex.cfg\fR configuration file.)
+This can be abbreviated to
 .PP
+.Vb 1
+\&    bundledoc \-\-config=miktex myfile
+.Ve
+.PP
 The following builds a \fI.tar.gz\fR archive with the TeX Live
 distribution running on a Unix-like operating system.  \fBbundledoc\fR
 will produce verbose output describing its operations.  All files not
@@ -517,11 +526,14 @@
 .IX Subsection "Acknowledgments"
 Thanks to Fabien Vignes-Tourneret for suggesting what became the
 \&\f(CW\*(C`\-\-localonly\*(C'\fR option and for a discussion that led to the
-\&\f(CW\*(C`\-\-exclude\*(C'\fR and \f(CW\*(C`\-\-include\*(C'\fR options; and to Marius Kleiner for
-updating \fBbundledoc\fR to properly handle document subdirectories.
+\&\f(CW\*(C`\-\-exclude\*(C'\fR and \f(CW\*(C`\-\-include\*(C'\fR options; to Marius Kleiner for updating
+\&\fBbundledoc\fR to properly handle document subdirectories; and to Frank
+Mittelbach for suggesting using Kpathsea to help find \fI.cfg\fR files
+and to automatically append \fI.cfg\fR and \fI.dep\fR extensions if
+necessary.
 .SH "SEE ALSO"
 .IX Header "SEE ALSO"
-\&\fIarlatex\fR\|(1), \fIgzip\fR\|(1), \fIkpsewhich\fR\|(1), \fIlatex\fR\|(1), \fIperl\fR\|(1), \fIzip\fR\|(1),
+\&\fBarlatex\fR\|(1), \fBgzip\fR\|(1), \fBkpsewhich\fR\|(1), \fBlatex\fR\|(1), \fBperl\fR\|(1), \fBzip\fR\|(1),
 the \fBsnapshot\fR documentation
 .SH "AUTHOR"
 .IX Header "AUTHOR"

Modified: trunk/Master/texmf-dist/doc/man/man1/bundledoc.man1.pdf
===================================================================
(Binary files differ)

Modified: trunk/Master/texmf-dist/doc/support/bundledoc/README
===================================================================
--- trunk/Master/texmf-dist/doc/support/bundledoc/README	2019-09-08 21:45:40 UTC (rev 52058)
+++ trunk/Master/texmf-dist/doc/support/bundledoc/README	2019-09-08 21:54:05 UTC (rev 52059)
@@ -25,14 +25,14 @@
 Files
 -----
 
--rwxrwxr-x 1 pakin users  9978 May 22 22:39 arlatex
--rw-r--r-- 1 pakin users 10176 May 22 22:40 arlatex.1
--rw-r--r-- 1 pakin users 16731 May 22 22:40 arlatex.pdf
--rwxrwxr-x 1 pakin users 29338 May 22 22:37 bundledoc
--rw-r--r-- 1 pakin users 23015 May 22 22:37 bundledoc.1
--rw-r--r-- 1 pakin users 29217 May 22 22:37 bundledoc.pdf
+-rwxrwxr-x 1 pakin users  9978 May 22  2018 arlatex
+-rw-r--r-- 1 pakin users 10262 Sep  6 22:21 arlatex.1
+-rw-r--r-- 1 pakin users 33296 Sep  6 22:26 arlatex.pdf
+-rwxrwxr-x 1 pakin users 31263 Sep  7 23:17 bundledoc
+-rw-r--r-- 1 pakin users 23351 Sep  7 23:18 bundledoc.1
+-rw-r--r-- 1 pakin users 49713 Sep  7 23:18 bundledoc.pdf
 -rw-rw-r-- 1 pakin users   342 Jan 22  2014 miktex.cfg
--rw-r--r-- 1 pakin users  4430 May 22 22:40 README
+-rw-r--r-- 1 pakin users  4435 Sep  7 23:18 README
 -rw-r--r-- 1 pakin users   248 Aug 24  2014 texlive-unix-arlatex.cfg
 -rw-rw-r-- 1 pakin users   230 Apr  9  2010 texlive-unix.cfg
 
@@ -84,7 +84,7 @@
 ---------------------
 
     bundledoc
-    Copyright (C) 2018 Scott Pakin
+    Copyright (C) 2018-2019 Scott Pakin
 
     This program may be distributed and/or modified under the conditions
     of the LaTeX Project Public License, either version 1.3c of this

Modified: trunk/Master/texmf-dist/scripts/bundledoc/bundledoc
===================================================================
--- trunk/Master/texmf-dist/scripts/bundledoc/bundledoc	2019-09-08 21:45:40 UTC (rev 52058)
+++ trunk/Master/texmf-dist/scripts/bundledoc/bundledoc	2019-09-08 21:54:05 UTC (rev 52059)
@@ -7,7 +7,7 @@
 
 ########################################################################
 # bundledoc                                                            #
-# Copyright (C) 2018 Scott Pakin                                       #
+# Copyright (C) 2018-2019 Scott Pakin                                  #
 #                                                                      #
 # This program may be distributed and/or modified under the conditions #
 # of the LaTeX Project Public License, either version 1.3c of this     #
@@ -24,8 +24,8 @@
 # in the Files section of the associated README file.                  #
 ########################################################################
 
-use 5.006;             # Fail gracefully if we're not using Perl v5.6.0.
-our $VERSION = "3.3";  # Specify the version of bundledoc.
+use 5.006;             # Fail gracefully if we're not using Perl v5.6.0+.
+our $VERSION = "3.4";  # Specify the version of bundledoc.
 use File::Basename;
 use File::Copy;
 use File::Spec::Functions qw(abs2rel catfile devnull rel2abs rootdir updir);
@@ -87,8 +87,7 @@
     my $retval;
 
     if ($verbose) {
-        print "EXECUTING: $command\n";
-        print "           (BDINPUTS = $ENV{BDINPUTS})\n";
+        print "EXECUTING $command WITH BDINPUTS = $ENV{BDINPUTS}\n";
     }
     if ($pathsep eq "\\") {
         # Dirty trick to work around idiotic "\" --> "/" conversion
@@ -100,12 +99,65 @@
     die "${progname}: $!.  Failing command was:\n\t$command\n" if $retval;
 }
 
+# Append ".dep" to the dependency file if necessary.
+sub find_dependency_file ($)
+{
+    my $depfile = $_[0];
+
+    # Return the file as is if it exists.
+    return $depfile if -e $depfile || $depfile =~ /\.dep$/;
+
+    # Return the file with ".dep" appended if that exists.
+    return "${depfile}.dep" if -e "${depfile}.dep";
+
+    # Give up and return the file as specified.
+    return $depfile;
+}
+
+# Try hard to find a configuration file.  Return the name of the actual file we
+# located.
+sub find_config_file ($)
+{
+    my $configfile = $_[0];
+    no warnings;   # Don't complain if kpsewhich isn't found.
+
+    # Attempt 1: See if the file exists as named.
+    return $configfile if -e $configfile;
+
+    # Attempt 2: Append ".cfg" if it's not already there.
+    my $config_cfg = $configfile;
+    if ($config_cfg !~ /\.cfg$/) {
+        $config_cfg = "${configfile}.cfg";
+        return $config_cfg if -e $config_cfg;
+    }
+
+    # Attempt 3: Use kpsewhich to find the file with ".cfg" appended.  (We
+    # don't search for it without ".cfg" because kpsewhich may find a version
+    # with ".tex" appended.)
+    my $kpfound = `kpsewhich $config_cfg`;
+    if (defined $kpfound) {
+        chomp $kpfound;
+        return $kpfound if -e $kpfound;
+    }
+
+    # Give up.  Return the file name as specified.
+    return $configfile;
+}
+
 # Read a configuration file, and set %uservariable accordingly.
 sub process_config_file ($)
 {
-    my $configfile = $_[0];
+    my $configfile = find_config_file $_[0];
+    printf("CONFIGURATION FILE: %s\n", rel2abs($configfile)) if $verbose;
     my $prevline = "";
-    open (CONFIGFILE, "<$configfile") || die "${progname}: $! ($configfile)\n";
+    open (CONFIGFILE, "<", $configfile) || do {
+	my $configlist = $configfile;
+	if (! -e $configfile) {
+	    # Error is "file not found".  List the files we considered.
+	    $configlist .= "; also considered ${configfile}.cfg" if $configfile !~ /\.cfg$/;
+	}
+	die "${progname}: $! ($configlist)\n";
+    };
     while (my $oneline=<CONFIGFILE>) {
         # Read a line and trim it.
         chomp $oneline;
@@ -222,7 +274,7 @@
     my $numextras = 0;
     foreach my $include_glob (@include_files) {
         foreach my $include_file (glob $include_glob) {
-            push @dependencies, $include_file;
+            push @dependencies, qualifyname $include_file;
             $numextras++;
         }
     }
@@ -255,6 +307,7 @@
 $keepdirs = 0;
 $verbose = 0;
 $localonly = 0;
+my $configfile;
 Getopt::Long::Configure("bundling");
 GetOptions ('texfile=s' => \$texfile,
             'directory=s' => \$docdirname,
@@ -263,7 +316,7 @@
             'localonly!' => \$localonly,
             'exclude=s' => \@exclude_files,
             'include=s' => \@include_files,
-            'config=s' => sub { process_config_file($_[1]) },
+            'config=s' => \$configfile,
             'v|verbose!' => \$verbose,
             'listdeps=s' => \@listdeps,
             'V|version' => sub { print "bundledoc $VERSION\n"; exit -1 },
@@ -276,7 +329,8 @@
 pod2usage (-message => "${progname}: Too few arguments",
            -exitval => 1,
            -verbose => 0) if $#ARGV==-1;
-$depfile = shift;                # Dependencies from snapshot.sty
+$depfile = find_dependency_file shift;      # Dependencies from snapshot.sty
+process_config_file $configfile if defined $configfile;
 ($texfile = $depfile) =~ s/\.[^.]*$/.tex/ if !$texfile;   # Main LaTeX source file
 ($docdirname = basename($depfile)) =~ s/\.[^.]*$// if !$docdirname;     # Name to use for the document directory
 ($ENV{"BDBASE"} = rel2abs($depfile)) =~ s/\.[^.]*$//;   # May be needed by user-defined variables
@@ -370,7 +424,7 @@
 [B<--version>]
 [B<--help>]
 [B<-->[B<no>]B<verbose>]
-[B<--texfile>=I<file>]
+[B<--texfile>=I<file.tex>]
 [B<--directory>=I<directory>]
 [B<-->[B<no>]B<localonly>]
 [B<--exclude>=I<string>]
@@ -378,8 +432,8 @@
 [B<--manifest>=I<file>]
 [B<-->B<listdeps>=[yes|no|only|rel]...]
 [B<-->[B<no>]B<keepdirs>]
-[B<--config>=I<file>]
-I<.dep file>
+[B<--config>=I<file.cfg>]
+I<file.dep>
 
 
 =head1 DESCRIPTION
@@ -414,8 +468,9 @@
 main LaTeX document (no extension).
 
 B<bundledoc> requires the name of the dependency file produced by
-B<snapshot> (normally I<somefile>F<.dep>).  The following options may
-also be given:
+B<snapshot>, normally I<somefile>F<.dep>).  (For convenience, the file
+can be specified without its F<.dep> extension.)  The following
+options may also be given:
 
 =over 4
 
@@ -561,7 +616,8 @@
 appropriate configuration (F<.cfg>) file for your TeX distribution and
 operating system.  B<bundledoc> comes with a few configuration files
 and it's easy to write more.  See L<"CONFIGURATION FILES"> (below) for
-a description of the configuration file format.
+a description of the configuration file format.  For convenience, the
+file can be specified without its F<.cfg> extension.
 
 =back
 
@@ -654,9 +710,10 @@
 
     bundledoc --config=miktex.cfg myfile.dep
 
-(In practice, it's probably necessary to specify to C<--config> the
-complete path to B<bundledoc>'s F<miktex.cfg> configuration file.)
+This can be abbreviated to
 
+    bundledoc --config=miktex myfile
+
 The following builds a F<.tar.gz> archive with the TeX Live
 distribution running on a Unix-like operating system.  B<bundledoc>
 will produce verbose output describing its operations.  All files not
@@ -830,8 +887,11 @@
 
 Thanks to Fabien Vignes-Tourneret for suggesting what became the
 C<--localonly> option and for a discussion that led to the
-C<--exclude> and C<--include> options; and to Marius Kleiner for
-updating B<bundledoc> to properly handle document subdirectories.
+C<--exclude> and C<--include> options; to Marius Kleiner for updating
+B<bundledoc> to properly handle document subdirectories; and to Frank
+Mittelbach for suggesting using Kpathsea to help find F<.cfg> files
+and to automatically append F<.cfg> and F<.dep> extensions if
+necessary.
 
 
 =head1 SEE ALSO



More information about the tex-live-commits mailing list