BUNDLEDOC(1)

๐Ÿ“ฆ
version 74306 ยท 3 versions
, in arch rolling, debian trixie, fedora 44, opensuse-leap 16.0, ubuntu questing, ubuntu resolute

okay so bestie, welcome to the bundledoc(1) manual page ๐Ÿ’– this one lives in the User Commands corner of the manual, and honestly? it's giving "I will literally zip up your entire LaTeX life for you." no cap. let's get into it.


โœจ NAME โœจ

bundledoc โ€” bundle all the files needed by a LaTeX document ๐ŸŽ€


๐ŸŒธ SYNOPSIS ๐ŸŒธ

bundledoc [--version] [--help] [--[no]verbose] [--texfile=file.tex]
[--directory=directory] [--[no]localonly] [--exclude=string]
[--include=filespec] [--manifest=file] [--listdeps=[yes|no|only|rel]...]
[--[no]keepdirs] [--config=file.cfg] file.dep

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

bundledoc is a post-processor for the snapshot package, and what it does is gather up all the classes, packages, and files you need to actually build a given LaTeX document, and shove them all into one place. ๐Ÿ’…

Here's the flow, bestie: it reads the .dep file that snapshot produces, hunts down every single file mentioned in there, and packages them into one single archive file (like a .tar.gz, you know the vibe). Perfect for moving stuff between systems, sending to a colleague, etc. etc. iconic.

As the simplest example possible โ€” and I mean simplest, don't come for me โ€” consider a LaTeX file called, say, hello.tex:

\RequirePackage{snapshot}       % Needed by bundledoc
\documentclass[11pt]{article}

\begin{document}
Hello, world!
\end{document}

The \RequirePackage{snapshot} line is what makes a hello.dep file get produced. Then when bundledoc is handed "hello.dep" as an argument, it goes and locates the dependent files โ€” snapshot.sty, article.cls, and size11.clo โ€” and bundles them all into a single archive file, along with hello.tex and a MANIFEST file (we get into that in "OPTIONS", below). ๐Ÿซถ


๐Ÿ’… OPTIONS ๐Ÿ’…

In the following descriptions, somefile refers to the name of your main LaTeX document (no extension).

bundledoc requires the name of the dependency file produced by snapshot, normally somefile.dep. (For convenience, the file can be specified without its .dep extension.) The following options may also be given:

  • --version โ€” outputs the bundledoc script's version number. This one overrides all of the remaining options, so it's the main character and everything else is background noise, fr fr.
  • --help โ€” gives you a brief usage message. This also overrides all of the remaining options. it's the "okay let me just explain myself real quick" of flags.
  • --[no]verbose โ€” (default: "noverbose") โ€” normally bundledoc doesn't output anything except error messages (silent queen ๐Ÿ‘‘). With --verbose, it outputs copious status messages. copious. like, so many.
  • --texfile=main .tex file โ€” (default: somefile.tex) โ€” here's the tea: snapshot's dependency file does not list the main LaTeX file (the one that gets passed to latex). so for bundledoc to find and bundle that file, it just assumes the file has the same name as the snapshot dependency file but with a .tex extension. if that's not the case for you, use --texfile to specify the correct filename. ๐Ÿ’–
  • --directory=archive directory โ€” (default: somefile) โ€” when bundledoc creates an archive (e.g., a .tar or .zip file) holding the document's files, it drops them all into a directory so it doesn't clutter up your current directory like a messy room ๐Ÿ™ˆ. If the given dependency file is called somefile.dep, then by default the resulting archive stores all the dependent files in a somefile directory. Wanna change the directory name? that's what --directory is for, babe.
  • --[no]localonly โ€” (default: "nolocalonly") โ€” bundledoc normally archives all the files named in the .dep file, but --localonly tells it to exclude every file sitting in a directory other than the .tex file's directory or one of its subdirectories. local files only, we're keeping it close-knit. ๐Ÿ 
  • --exclude=string โ€” (default: none) โ€” --localonly is the big blunt "files outside the .tex tree are OUT" move, and --exclude is the finer-grained version. This option can be specified repeatedly on the command line, and it makes bundledoc omit from the archive every file whose name contains string. bye bestie โœ‚๏ธ
  • --include=filespec โ€” (default: none) โ€” this one, which can also be specified repeatedly on the command line, tells bundledoc to include in the archive all the files matching filespec โ€” even if they're not referenced in the .dep file at all. "you're coming with us, whether the .dep file knows you or not." โœจ
  • --manifest=manifest file โ€” (default: MANIFEST) โ€” besides the dependent files, bundledoc also throws one extra file into the archive, called by default MANIFEST. MANIFEST is a text file listing the original filenames of all the dependencies. Wanna rename it from MANIFEST to something else? use --manifest. And as a special case: --manifest="" tells bundledoc to not include a manifest file at all. no manifest, no problem. ๐ŸŽ€
  • --listdeps=[yes|no|only|rel]...] โ€” (default: "no") โ€” --listdeps accepts one or more of yes, no, only, or rel as a comma-separated list. As long as no does not appear in this list, bundledoc outputs all of the main LaTeX file's dependencies. If the list contains rel, then bundledoc outputs the list of dependencies with relative pathnames. And if the list contains only, then bundledoc exits after displaying the list โ€” without producing an archive. just the receipts, no bundle. ๐Ÿ“‹
  • --[no]keepdirs โ€” (default: "nokeepdirs") โ€” normally the archive file that bundledoc produces contains a single directory โ€” plus subdirectories, if the document refers explicitly to them โ€” and all the dependent files lie in there. If --keepdirs is specified, all the dependent files are stored with their original pathnames. For example, if somefile.tex depends on figures/somefigure.eps, article.cls, and snapshot.sty, then the somefile archive will normally contain the following files:
    • somefile/somefile.tex
    • somefile/figures/somefigure.eps
    • somefile/article.cls
    • somefile/snapshot.sty
    • somefile/MANIFEST

However, --keepdirs will cause the somefile archive to contain the following sorts of filenames instead:

  • home/me/mydocs/somefile.tex
  • home/me/mydocs/figures/somefigure.eps
  • usr/share/texmf/tex/latex/base/article.cls
  • usr/share/texmf/tex/latex/snapshot/snapshot.sty
heads up bestie: --directory is not used when --keepdirs is in effect. In addition, no manifest file is written to the archive file, since it would contain redundant information. ๐Ÿšซ
  • --config=configuration file โ€” (default: <none>) โ€” --config points bundledoc at the appropriate configuration (.cfg) file for your TeX distribution and operating system. bundledoc comes with a few configuration files and it's easy to write more (go off โœ๏ธ). See "CONFIGURATION FILES" (below) for a description of the configuration file format. And for convenience? the file can be specified without its .cfg extension. slay.

๐ŸŒˆ CONFIGURATION FILES ๐ŸŒˆ

๐Ÿ“ Format

Configuration files follow a fairly simple format. Lines beginning with # are comments. Blank lines are ignored. All other lines are of the form:

variable: value

The current version of bundledoc recognizes the following variables:

  • bundle โ€” the command to use to bundle a set of files into a single archive file
  • sink โ€” the affix to a command to discard its output
  • find โ€” the command to find a file within the TeX tree(s).

Values that are too long for one line can be split across multiple lines by using \ as the line-continuation symbol. ๐Ÿงต

There are two environment variables that bundledoc makes available for use by configuration-file commands:

  • BDBASE, which is set to somefile (as in "OPTIONS"), and
  • BDINPUTS, which is set to a space-separated list of files that a command is to operate upon.

That is: when the command associated with bundle is running, BDINPUTS contains the list of all the files that are to be archived. In contrast, when the command associated with find is running, BDINPUTS contains the name of the file to search for. two very different jobs, one very versatile variable. ๐Ÿ’œ

๐Ÿ“ Examples

The following configuration file parallels bundledoc's default values of the various configuration-file variables, which represents a kpathsea-based TeX distribution running on a generic Unix system, which doesn't necessarily have any of the GNU tools, such as gzip or GNU tar:

# "Default" configuration file
# By Scott Pakin <scott+bdoc@pakin.org>

bundle: (tar -cvf - $BDINPUTS | compress > $BDBASE.tar.Z)
sink:   > /dev/null 2>&1
find:   kpsewhich -progname=latex $BDINPUTS

The parentheses in the bundle: line tell the Unix shell to run the command in a subshell. This is to make the sink: affix work properly (i.e., so there aren't two >'s in the same command). we love a technicality that saves us. ๐Ÿ’…

Notice how the commands treat BDBASE and BDINPUTS like any other environment variables in a Unix shell, using $ to take their value. Other operating systems use different conventions for referring to environment variables. For instance, a configuration file for a Windows-based TeX distribution would use %BDBASE% and %BDINPUTS% instead. ๐ŸชŸ

The value for sink: is specific to an operating system. The value for find: is specific to a TeX distribution. bundle: is where the most opportunity for customization lies โ€” this is your moment, main character energy โœจ. You can use bundle: to specify your favorite archive format. For example, you can produce a shar file on Unix with something like:

bundle: (shar --archive-name="$BDBASE" $BDINPUTS > $BDBASE.sh)

or a CAB file on Microsoft Windows with something like:

bundle: cabarc -r -p N %BDBASE%.cab %BDINPUTS%

๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

Assume that myfile.dep was produced from myfile.tex by following the instructions in the Description section. The following command produces a .zip file with the MikTeX TeX distribution running on Microsoft Windows:

bundledoc --config=miktex.cfg myfile.dep

This can be abbreviated to

bundledoc --config=miktex myfile

The following builds a .tar.gz archive with the TeX Live distribution running on a Unix-like operating system. bundledoc will produce verbose output describing its operations. All files not in the same directory tree as myfile.tex and all files containing .fd or .sty in their names are omitted. However, all .bib files in the current directory will be included in the archive even though none of them are referenced by myfile.dep. Finally, no MANIFEST file will be produced.

bundledoc --config=texlive-unix.cfg --verbose --localonly \
  --exclude=.fd --exclude=.cfg --include="*.bib" --manifest="" \
  myfile.dep

๐Ÿ“ FILES ๐Ÿ“

Okay so before any of this even works, bestie, the user must have previously installed snapshot.sty and used it to produce a dependency file for their document. No snapshot.sty, no dependency file, no bundling, periodt. ๐Ÿ’…

Besides that, the set of external files needed by bundledoc is system-specific and depends on the configuration file used. (Peep "CONFIGURATION FILES", above, for the tea.)

bundledoc currently comes with two configuration files:

  • texlive-unix.cfg โ€” configuration file for TeX Live installations on Unix or Linux. TeX Live is a kpathsea-based TeX distribution that runs on various flavors of Unix and Microsoft Windows. texlive-unix.cfg assumes you have gzip and uses it to produce a .tar.gz archive file. The configuration file has bundledoc use kpsewhich to find LaTeX files. โœจ
  • miktex.cfg โ€” configuration file for MikTeX installations. MikTeX is a popular TeX distribution for Microsoft Windows. miktex.cfg assumes you have zip and uses it to produce a .zip archive file. The configuration file now has bundledoc use kpsewhich to find LaTeX files; older version of MikTeX required the rather nonstandard initexmf for this purpose. ๐Ÿฆ‹
  • texlive-unix-arlatex.cfg โ€” this is a variant of texlive-unix.cfg that uses arlatex instead of gzip to archive files. arlatex is a script included in the bundledoc distribution that generates a self-extracting .tex file based on LaTeX's "filecontents" environment. ๐Ÿ’–

And yes, bestie, the manpage says two and then lists three. We're just going to accept that as canon. ๐Ÿ’€


๐Ÿ“ NOTES ๐Ÿ“

๐Ÿซถ Including and excluding files ๐Ÿซถ

The --localonly, --exclude, and --include options provide control over the archive's contents. --exclude and --include can be specified repeatedly on the command line. The order in which these options are specified is immaterial; bundledoc processes file inclusions and exclusions in the following order:

  1. All files referenced by the .dep file are added to the list of files to archive.
  2. If --localonly is specified, all files not found in the .tex file's directory are removed from the list.
  3. For each --exclude string specified, all files containing that string are removed from the list.
  4. For each --include file specification, the set of files designated by its expansion are added to the list.

๐Ÿ˜ญ Issues When Running Under Microsoft Windows ๐Ÿ˜ญ

First, because bundledoc is a Perl script, you should do one of the following to run it under Windows:

  • perl bundledoc
  • Rename bundledoc to bundledoc.pl and run bundledoc.pl. (This is assuming you have a file association set up for .pl.)
  • Run the pl2bat script (if you have it) to convert bundledoc to bundledoc.bat, then run bundledoc.

Second, Windows uses a multi-rooted filesystem (i.e., multiple drive letters). I wouldn't be surprised if bad things were to happen if the files to be bundled are scattered across drives. In addition, Windows supports UNC filenames, which have no drive letter at all, just a machine and share name. UNC filenames are also untested waters for bundledoc. Be careful! โš ๏ธ

๐Ÿงช Testing Status ๐Ÿงช

I have tested bundledoc only with Perl v5.6.0 and later and only on the following platforms:

  • Linux + TeX Live
  • Linux + teTeX
  • Windows NT + MiKTeX
  • Solaris + ??? (something kpathsea-based)

It is my hope that bundledoc works on many more platforms than those. I tried to make the program itself fairly independent of the operating system; only the configuration files should have to change to run bundledoc on a different system.

๐Ÿ”ฎ Future Work ๐Ÿ”ฎ

I'd like bundledoc to work on as wide a variety of TeX distributions as possible. If your platform is significantly different from the ones listed in "Testing Status" (e.g., if you're running OS X) and you need to create a substantially different configuration file from texlive-unix.cfg and miktex.cfg, please send it to me at the address listed in "AUTHOR" so I can include it in a future version of bundledoc. (I make no promises, though).

Once bundledoc works on all the major operating systems and TeX distributions it would be really convenient if I could get bundledoc to detect the platform it's running on and automatically select an appropriate configuration file.

Finally, it would be handy for bundledoc to include fonts in the archive file. At a minimum, it should include .tfm files, but it would be even better if it included .mf, .pfb, .ttf, and other common font formats, as well. ๐ŸŒˆ

๐Ÿ’– Acknowledgments ๐Ÿ’–

Thanks to Fabien Vignes-Tourneret for suggesting what became the --localonly option and for a discussion that led to the --exclude and --include options; to Marius Kleiner for updating bundledoc to properly handle document subdirectories; and to Frank Mittelbach for suggesting using Kpathsea to help find .cfg files and to automatically append .cfg and .dep extensions if necessary. ๐Ÿซถ


๐Ÿ‘€ SEE ALSO ๐Ÿ‘€


โœ๏ธ AUTHOR โœ๏ธ

Scott Pakin, scott+bdoc@pakin.org


That's the whole vibe, bestie: bundledoc v3.5, dated 2025-02-26. Now go archive something iconic. ๐Ÿ’–โœจ๐ŸŽ€