live
  7   ˆl–ßi~” ”Ð?Je@‚ãn\ªbÑ¿�þ]ƒY¹G$}¢·)üÿÈ„d,²÷ÇËÊ ?÷     #!/usr/bin/perl
# Debian required shebang above
# Original shebang below
# #! /usr/bin/env perl

##########################################################
# Bundle all the files needed to build a LaTeX document. #
# By Scott Pakin <scott+bdoc@pakin.org>                  #
##########################################################

########################################################################
# bundledoc                                                            #
# 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     #
# license or (at your option) any later version.                       #
#                                                                      #
# The latest version of this license is in:                            #
#                                                                      #
#    http://www.latex-project.org/lppl.txt                             #
#                                                                      #
# and version 1.3c or later is part of all distributions of LaTeX      #
# version 2008/05/04 or later.                                         #
#                                                                      #
# This program consists of the file bundledoc and all the files listed #
# 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.4";  # Specify the version of bundledoc.
use File::Basename;
use File::Copy;
use File::Spec::Functions qw(abs2rel catfile devnull rel2abs rootdir updir);
use File::Path;
use File::Temp qw(tempdir);
use Getopt::Long;
use Pod::Usage;
use warnings;
use strict;

######################################################################

# Variables the user can override with a configuration file
# DEFAULTS: Linux + kpathsea
my %uservariable;
$uservariable{"bundle"} = '(tar -cvf - $BDINPUTS | gzip --best > $BDBASE.tar.gz)';
$uservariable{"find"}   = 'kpsewhich -progname=latex $BDINPUTS';
$uservariable{"sink"}   = '> ' . devnull() . ' 2>&1';

# OS path separator (Is there a better way to get this?)
my $pathsep = catfile ("", "");

# File that lists original directory names
my $manifest = "MANIFEST";

# Cleaned-up name of this Perl script
my $progname = basename($0);

# Other global variables
my ($verbose, $keepdirs, $depfile, $localonly);  # Taken from the command line
my (@exclude_files, @include_files, @listdeps);  # Taken from the command line
my ($texfile, $docdirname);               # Derived from $depfile
my %subdirs;                              # Map from a qualified name to its subdirectory

######################################################################

# Find a file in the LaTeX hierarchy and fully qualify it,
# or abort if we can't.
sub qualifyname ($)
{
    my $filename = $_[0];
    $filename = "\"$filename\"" if $filename =~ /\s/ && substr($filename, 0, 1) ne '"';
    my $command = $uservariable{find};
    $command =~ s/[\$\%]BDINPUTS\%?/$filename/g;
    $command =~ s/[\$\%]BDBASE\%?/$ENV{"BDBASE"}/g;
    my $qualified = `$command` ||
        die "${progname}: \"$uservariable{find}\" (BDINPUTS=\"$_[0]\") failed to find $_[0]\n";
    chomp $qualified;
    $qualified = rel2abs $qualified;
    return $qualified;
}

# Execute a command, and return an error message if it fails.
sub executecmd ($)
{
    my $command = ($verbose ? $_[0] : "$_[0] $uservariable{sink}");
    $command =~ s/[\$\%]BDINPUTS\%?/$ENV{"BDINPUTS"}/g;
    $command =~ s/[\$\%]BDBASE\%?/$ENV{"BDBASE"}/g;
    my $retval;

    if ($verbose) {
        print "EXECUTING $command WITH BDINPUTS = $ENV{BDINPUTS}\n";
    }
    if ($pathsep eq "\\") {
        # Dirty trick 