This file is indexed.

/usr/bin/tl-paper is in texlive-base 2015.20160320-1ubuntu0.1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/perl
#
# tl-paper
#
# query and change paper settings using TLPaper
# this is independent from tlmgr
#
# Copyright 2011-2015 Norbert Preining
# This file is licensed under the GNU General Public License version 3
# or any later version.
#

BEGIN {
  $^W = 1;
  chomp ($mydir = `dirname $0`);
  unshift (@INC, "/usr/share/texlive/tlpkg");
}

$^W = 1;
use strict;
use Cwd qw/abs_path/;
use Pod::Usage;
use Getopt::Long qw(:config no_autoabbrev permute);
use TeXLive::TLPaper;

# overwrite the default paper config settings
our %paper_config_name = (
  "xdvi"     => "XDvi-paper",
  "pdftex"   => "pdftexconfig-paper.tex",
  "dvips"    => "config-paper.ps",
  "dvipdfmx" => "dvipdfmx-paper.cfg",
  "context"  => "cont-sys-paper.tex",
);

binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");

&main();

sub main {
  # the script always runs in sys mode
  chomp(my $texmfsysconfig = `kpsewhich -var-value=TEXMFSYSCONFIG`);
  chomp(my $texmfsysvar = `kpsewhich -var-value=TEXMFSYSVAR`);
  $ENV{"TEXMFCONFIG"} = $texmfsysconfig;
  $ENV{"TEXMFVAR"} = $texmfsysvar;

  my $action = shift @ARGV;
  $action = "status" if !defined($action);
  if ($action =~ m/^status$/i) {  # "tl-paper status" shows the current settings
    TeXLive::TLPaper::paper_all($texmfsysvar,undef);
    
  } elsif ($action =~ m/^list$/i) { # "tl-paper list prg" lists options for prg
    my $prg = shift @ARGV;
    if (!$prg) {
      # currently, pdftex has the most restricted set of paper sizes
      $prg = "pdftex";
    }
    # the following actually also *reads* the configuration and returns
    # a list where the first item is the one selected.
    my $paperref = TeXLive::TLPaper::get_paper_list($prg);
    my ($current_paper, @other_options) = @{$paperref};
    for my $i ($current_paper, sort @other_options) {
      print "$i\n";
    }
    # for simply getting the list of supported paper sizes without reading
    # anything, one can use:
    # my @paper_options = keys(%{${prg}_papersize});

  } elsif ($action =~ m/^set$/i) { # "tl-paper set <prg|all> <paper>" sets paper
    my $prg = shift @ARGV;
    my $newpaper = shift @ARGV;

    if ($prg !~ m/^(xdvi|pdftex|dvips|dvipdfmx|context|all)$/i) {
      usage();
      exit 1;
    }
    # set TEXMFVAR and TEXMFSYSVAR to TEXMFDIST (which is == TEXMFMAIN)
    # so that we always find either the system provided config file
    # as distributed in /usr/share/texlive/texmf-dist, or, if the
    # admin decided to override that, a copy in TEXMFSYSCONFIG
    # but *not* the one we have created at some point in history
    # in TEXMF(SYS)VAR
    chomp(my $texmfdist = `kpsewhich -var-value=TEXMFDIST`);
    $ENV{"TEXMFVAR"} = $ENV{"TEXMFSYSVAR"} = $texmfdist;
    if ($prg =~ m/^all$/i) {
      if ($newpaper !~ /^(a4|letter)$/) {
        # we cannot deal with that for now, only a4|letter supported for
        # all programs
        print "tl-paper: cannot change setting for all programs to $newpaper\n\n";
        exit 1;
      }
      TeXLive::TLPaper::paper_all($texmfsysvar,$newpaper);
    
    } else {
      TeXLive::TLPaper::do_paper($prg,$texmfsysvar,$newpaper);
    }
  
    # we probably have changed the paper, so run the execute actions
    # as announced by TLPaper, that is $::files_changed and 
    # $::regenerate_all_formats.
    #
    # but we do not do this here, but rely on the libpaper shell
    # script to do the rest

  } elsif ($action =~ m/^get$/i) { # "tl-paper get prg" gets paper setting for prg
    my $prg = shift @ARGV;
    if ($prg !~ m/^(xdvi|pdftex|dvips|dvipdfmx|context)$/i) {
      usage();
      exit 1;
    }
    my $paperref = TeXLive::TLPaper::get_paper_list($prg);
    my ($current_paper, @other_options) = @{$paperref};
    print "$current_paper\n" if defined($current_paper);
    
  } else {
    usage();
    exit 1;
  }
  exit 0;
}

sub usage {
  print STDERR "
tl-paper: inquire and set paper settings for various programs in the TeX World.


usage:
  tl-paper list <program>     lists available papers, current paper first
  tl-paper status             lists all current settings
  tl-paper get <program>      prints the current paper for <program>
  tl-paper set <program> <newpaper>    sets new paper for <program>
  tl-paper set all <a4|letter>         sets new paper for all programs

";
}



### Local Variables:
### perl-indent-level: 2
### tab-width: 2
### indent-tabs-mode: nil
### End:
# vim:set tabstop=2 expandtab: #