summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2017-11-14 08:45:15 +0000
committerNorbert Preining <preining@logic.at>2017-11-14 08:45:15 +0000
commit06e737558e409a7cf2daacd88b2e6bbe3f4fdd76 (patch)
tree218043947afae52dafba1215859447e0a64c7bad
parent471d3a9f2891620433afd016d281adb38a84ae64 (diff)
tlmgr paper: use tlmgr in msgs, report file, break when --json is unsupported
git-svn-id: svn://tug.org/texlive/trunk@45794 c570f23f-e606-0410-a88d-b1316a301751
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl10
-rw-r--r--Master/tlpkg/TeXLive/TLPaper.pm44
2 files changed, 33 insertions, 21 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index b9ebe94dd6b..61f8ff5aec8 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -110,6 +110,8 @@ use TeXLive::TLPaper;
#
# set up $prg for warning messages
$prg = TeXLive::TLUtils::basename($0);
+# for usage in various Perl modules
+$::prg = $prg;
binmode(STDOUT, ":utf8");
binmode(STDERR, ":utf8");
@@ -1242,6 +1244,10 @@ sub action_paper {
} else { # tlmgr paper {a4|letter} => do it.
return ($F_ERROR) if !check_on_writable();
+ if ($opts{'json'}) {
+ tlwarn("$prg: option --json not supported with other arguments\n");
+ return ($F_ERROR);
+ }
my $ret = $F_OK;
for my $prog (sort keys %TeXLive::TLPaper::paper) {
my $pkg = $TeXLive::TLPaper::paper{$prog}{'pkg'};
@@ -1254,6 +1260,10 @@ sub action_paper {
}
} else { # program-specific paper
+ if ($opts{'json'}) {
+ tlwarn("$prg: option --json not supported with other arguments\n");
+ return ($F_ERROR);
+ }
my $prog = $action; # first argument is the program to change
my $pkg = $TeXLive::TLPaper::paper{$prog}{'pkg'};
if (!$pkg) {
diff --git a/Master/tlpkg/TeXLive/TLPaper.pm b/Master/tlpkg/TeXLive/TLPaper.pm
index 70bd55ef501..ffb3b1d2fc6 100644
--- a/Master/tlpkg/TeXLive/TLPaper.pm
+++ b/Master/tlpkg/TeXLive/TLPaper.pm
@@ -28,6 +28,8 @@ BEGIN {
@EXPORT = @EXPORT_OK;
}
+my $prg = ($::prg ? $::prg : TeXLive::TLUtils::basename($0));
+
=pod
=head1 NAME
@@ -232,7 +234,7 @@ sub do_paper {
my $sub = $paper{$prog}{'sub'};
return(&$sub($texmfsysconfig, @args));
} else {
- tlwarn("$0: unknown paper program $prog ($texmfsysconfig,@args)\n");
+ tlwarn("$prg: unknown paper program $prog ($texmfsysconfig,@args)\n");
return($F_ERROR);
}
return ($F_OK); # not reached
@@ -274,7 +276,7 @@ sub find_paper_file {
}
}
- debug("$0: found no paper file for $progname (from $cmd)\n") if ! $ret;
+ debug("$prg: found no paper file for $progname (from $cmd)\n") if ! $ret;
return $ret;
}
@@ -341,7 +343,7 @@ sub paper_pdftex {
return($F_ERROR) unless $inp;
- open(FOO, "<$inp") || die "$0: open($inp) failed: $!";
+ open(FOO, "<$inp") || die "$prg: open($inp) failed: $!";
my @lines = <FOO>;
close(FOO);
@@ -455,23 +457,23 @@ sub paper_pdftex {
$lines[$#lines] = $addlines;
}
}
- info("$0: setting paper size for pdftex to $newpaper.\n");
+ info("$prg: setting paper size for pdftex to $newpaper: $outfile\n");
mkdirhier(dirname($outfile));
# if we create the outfile we have to call mktexlsr
TeXLive::TLUtils::announce_execute_actions("files-changed")
unless (-r $outfile);
if (!open(TMP, ">$outfile")) {
- tlwarn("$0: Cannot write to $outfile: $!\n");
+ tlwarn("$prg: Cannot write to $outfile: $!\n");
tlwarn("Not setting paper size for pdftex.\n");
return($F_ERROR);
}
for (@lines) { print TMP; }
- close(TMP) || warn "$0: close(>$outfile) failed: $!";
+ close(TMP) || warn "$prg: close(>$outfile) failed: $!";
TeXLive::TLUtils::announce_execute_actions("regenerate-formats");
# TODO should we return the value of announce_execute action?
return($F_OK);
} else {
- tlwarn("$0: Not a valid paper size for pdftex: $newpaper\n");
+ tlwarn("$prg: Not a valid paper size for pdftex: $newpaper\n");
return($F_WARNING);
}
}
@@ -520,7 +522,7 @@ sub paper_dvips {
return($F_ERROR) unless $inp;
- open(FOO, "<$inp") || die "$0: open($inp) failed: $!";
+ open(FOO, "<$inp") || die "$prg: open($inp) failed: $!";
my @lines = <FOO>;
close(FOO);
@@ -587,20 +589,20 @@ sub paper_dvips {
}
push @newlines, $lines[$idx];
}
- info("$0: setting paper size for dvips to $newpaper.\n");
+ info("$prg: setting paper size for dvips to $newpaper: $outfile\n");
mkdirhier(dirname($outfile));
# if we create the outfile we have to call mktexlsr
TeXLive::TLUtils::announce_execute_actions("files-changed")
unless (-r $outfile);
if (!open(TMP, ">$outfile")) {
- tlwarn("$0: Cannot write to $outfile: $!\n");
+ tlwarn("$prg: Cannot write to $outfile: $!\n");
tlwarn("Not setting paper size for dvips.\n");
return ($F_ERROR);
}
for (@newlines) { print TMP; }
- close(TMP) || warn "$0: close(>$outfile) failed: $!";
+ close(TMP) || warn "$prg: close(>$outfile) failed: $!";
} else {
- tlwarn("$0: Not a valid paper size for dvips: $newpaper\n");
+ tlwarn("$prg: Not a valid paper size for dvips: $newpaper\n");
return($F_WARNING);
}
}
@@ -684,7 +686,7 @@ sub paper_context {
return($F_ERROR) unless $inp;
- open(FOO, "<$inp") || die "$0: open($inp) failed: $!";
+ open(FOO, "<$inp") || die "$prg: open($inp) failed: $!";
my @lines = <FOO>;
close(FOO);
@@ -762,23 +764,23 @@ sub paper_context {
$lines[$#lines] = $addlines;
}
}
- info("$0: setting paper size for context to $newpaper.\n");
+ info("$prg: setting paper size for context to $newpaper: $outfile\n");
mkdirhier(dirname($outfile));
# if we create the outfile we have to call mktexlsr
TeXLive::TLUtils::announce_execute_actions("files-changed")
unless (-r $outfile);
if (!open(TMP, ">$outfile")) {
- tlwarn("$0: Cannot write to $outfile: $!\n");
+ tlwarn("$prg: Cannot write to $outfile: $!\n");
tlwarn("Not setting paper size for context.\n");
return($F_ERROR);
}
for (@lines) { print TMP; }
- close(TMP) || warn "$0: close(>$outfile) failed: $!";
+ close(TMP) || warn "$prg: close(>$outfile) failed: $!";
TeXLive::TLUtils::announce_execute_actions("regenerate-formats");
# TODO should we return the value of announce_execute action?
return($F_OK);
} else {
- tlwarn("$0: Not a valid paper size for context: $newpaper\n");
+ tlwarn("$prg: Not a valid paper size for context: $newpaper\n");
return($F_WARNING);
}
}
@@ -931,23 +933,23 @@ sub paper_do_simple {
if (!$foundcfg) {
push @newlines, &$bl($defaultline, $newpaper);
}
- info("$0: setting paper size for $prog to $newpaper.\n");
+ info("$prg: setting paper size for $prog to $newpaper: $outfile\n");
mkdirhier(dirname($outp));
# if we create the outfile we have to call mktexlsr
TeXLive::TLUtils::announce_execute_actions("files-changed")
unless (-r $outp);
if (!open(TMP, ">$outp")) {
- tlwarn("$0: Cannot write to $outp: $!\n");
+ tlwarn("$prg: Cannot write to $outp: $!\n");
tlwarn("Not setting paper size for $prog.\n");
return ($F_ERROR);
}
for (@newlines) { print TMP; }
- close(TMP) || warn "$0: close(>$outp) failed: $!";
+ close(TMP) || warn "$prg: close(>$outp) failed: $!";
TeXLive::TLUtils::announce_execute_actions("regenerate-formats")
if ($prog eq "context");
return($F_OK);
} else {
- tlwarn("$0: Not a valid paper size for $prog: $newpaper\n");
+ tlwarn("$prg: Not a valid paper size for $prog: $newpaper\n");
return($F_WARNING);
}
}