texlive[54472] Master/tlpkg/tlpostcode/haranoaji-tlpost.pl:
commits+hironobu at tug.org
commits+hironobu at tug.org
Sun Mar 22 10:59:00 CET 2020
Revision: 54472
http://tug.org/svn/texlive?view=revision&revision=54472
Author: hironobu
Date: 2020-03-22 10:58:59 +0100 (Sun, 22 Mar 2020)
Log Message:
-----------
haranoaji-tlpost.pl: less verbosity (update from M. Hosoda)
Modified Paths:
--------------
trunk/Master/tlpkg/tlpostcode/haranoaji-tlpost.pl
Modified: trunk/Master/tlpkg/tlpostcode/haranoaji-tlpost.pl
===================================================================
--- trunk/Master/tlpkg/tlpostcode/haranoaji-tlpost.pl 2020-03-22 08:31:56 UTC (rev 54471)
+++ trunk/Master/tlpkg/tlpostcode/haranoaji-tlpost.pl 2020-03-22 09:58:59 UTC (rev 54472)
@@ -47,7 +47,6 @@
binmode (STDIN, ':encoding(console_in)');
binmode (STDOUT, ':encoding(console_out)');
binmode (STDERR, ':encoding(console_out)');
- print "haranoaji-tlpost\n";
require Win32::API;
Win32::API->import ();
@@ -55,6 +54,7 @@
# for non-Windows, silently do nothing, to avoid tl-update-tlnet failure.
exit 0;
}
+my $verbose = 0;
# Font list: PostScript name => File name in TEXMF
my %font_list = (
@@ -87,6 +87,11 @@
my $mode = lc (decode ('locale', $ARGV[0]));
my $texdir = decode ('locale', $ARGV[1]);
+unshift (@INC, "$texdir/tlpkg");
+require TeXLive::TLUtils;
+
+my_log ("haranoaji-tlpost\n");
+
my $resourcedir = "$texdir/tlpkg/tlgs/Resource";
my $cidfontdir = "$resourcedir/CIDFont";
my $cmapdir = "$resourcedir/CMap";
@@ -100,13 +105,13 @@
die ("unknown mode: $mode\n");
}
-print "\ndone.\n";
+my_log ("\ndone.\n");
exit 0;
# Install
sub do_install {
- print "\ndo_install\n";
+ my_log ("\ndo_install\n");
tlgs_check ();
@@ -117,7 +122,7 @@
# Remove
sub do_remove {
- print "\ndo_remove\n";
+ my_log ("\ndo_remove\n");
tlgs_check ();
@@ -144,14 +149,14 @@
# Link or copy CID font
sub install_cidfont {
- print "\ninstall_cidfont\n";
+ my_log ("\ninstall_cidfont\n");
for my $psname (sort keys %font_list) {
- print "\nFor $psname ...\n";
+ my_log ("\nFor $psname ...\n");
my $fontpath_in_cidfontdir = "$cidfontdir/$psname";
if (wrapper_isfile ($fontpath_in_cidfontdir)) {
- print "Already exists: ${fontpath_in_cidfontdir}\n";
+ my_log ("Already exists: ${fontpath_in_cidfontdir}\n");
next;
}
my $fontpath_in_texmf = search_fontpath ($font_list{$psname}) or next;
@@ -161,14 +166,14 @@
# Link or copy CMap
sub install_cmap {
- print "\ninstall_cmap\n";
+ my_log ("\ninstall_cmap\n");
foreach my $cmapname (@cmap_list) {
- print "\nFor $cmapname ...\n";
+ my_log ("\nFor $cmapname ...\n");
my $cmappath_in_cmapdir = "$cmapdir/$cmapname";
if (wrapper_isfile ($cmappath_in_cmapdir)) {
- print "Already exists: ${cmappath_in_cmapdir}\n";
+ my_log ("Already exists: ${cmappath_in_cmapdir}\n");
next;
}
my $cmappath_in_texmf = search_cmappath ($cmapname) or next;
@@ -178,15 +183,15 @@
# Create snippet
sub install_snippet {
- print "\ninstall_snippet\n";
+ my_log ("\ninstall_snippet\n");
for my $psname (sort keys %font_list) {
- print "\nFor $psname ...\n";
+ my_log ("\nFor $psname ...\n");
foreach my $cmapname (@cmap_list) {
my $snippetpath = "$fontdir/$psname-$cmapname";
if (wrapper_isfile ($snippetpath)) {
- print "Already exists: ${snippetpath}\n";
+ my_log ("Already exists: ${snippetpath}\n");
next;
}
@@ -205,7 +210,7 @@
EOS
create_file_with_contents ($snippetpath,
encode ('UTF-8', $contents));
- print "Created: ${snippetpath}\n";
+ my_log ("Created: ${snippetpath}\n");
}
}
}
@@ -212,17 +217,17 @@
# Remove CID font
sub remove_cidfont {
- print "\nremove_cidfont\n";
+ my_log ("\nremove_cidfont\n");
for my $psname (sort keys %font_list) {
- print "\nFor $psname ...\n";
+ my_log ("\nFor $psname ...\n");
my $fontpath_in_cidfontdir = "$cidfontdir/$psname";
if (wrapper_isfile ($fontpath_in_cidfontdir)) {
wrapper_unlink ($fontpath_in_cidfontdir);
- print "Removed: ${fontpath_in_cidfontdir}\n";
+ my_log ("Removed: ${fontpath_in_cidfontdir}\n");
} else {
- print "Not exist: ${fontpath_in_cidfontdir}\n";
+ my_log ("Not exist: ${fontpath_in_cidfontdir}\n");
}
}
}
@@ -229,18 +234,18 @@
# Remove snippet
sub remove_snippet {
- print "\nremove_snippet\n";
+ my_log ("\nremove_snippet\n");
for my $psname (sort keys %font_list) {
- print "\nFor $psname ...\n";
+ my_log ("\nFor $psname ...\n");
foreach my $cmapname (@cmap_list) {
my $snippetpath = "$fontdir/$psname-$cmapname";
if (wrapper_isfile ($snippetpath)) {
wrapper_unlink ($snippetpath);
- print "Removed: ${snippetpath}\n";
+ my_log ("Removed: ${snippetpath}\n");
} else {
- print "Not exist: ${snippetpath}\n";
+ my_log ("Not exist: ${snippetpath}\n");
}
}
}
@@ -249,6 +254,21 @@
# Check Windows environment
sub win32 { return ($^O=~/^MSWin(32|64)$/i); }
+# Log
+sub my_log {
+ my ($msg) = @_;
+
+ print $msg if ($verbose);
+ TeXLive::TLUtils::log ($msg);
+}
+
+# Warn
+sub my_warn {
+ my ($msg) = @_;
+
+ TeXLive::TLUtils::tlwarn ($msg);
+}
+
# Search TEXMF font path
sub search_fontpath {
my ($filename) = @_;
@@ -256,11 +276,11 @@
my $foo = kpsewhich ($filename);
if ($foo eq "") {
- print "Not found font path: ${filename}\n";
+ my_log ("Not found font path: ${filename}\n");
return;
}
- print "Font path is ${foo}.\n";
+ my_log ("Font path is ${foo}.\n");
return $foo;
}
@@ -271,11 +291,11 @@
my $foo = kpsewhich ("-format=cmap $cmapname");
if ($foo eq "") {
- print "Not found CMap path: ${cmapname}\n";
+ my_log ("Not found CMap path: ${cmapname}\n");
return;
}
- print "CMap path is ${foo}.\n";
+ my_log ("CMap path is ${foo}.\n");
return $foo;
}
@@ -304,21 +324,21 @@
my ($existingfilename, $newfilename) = @_;
if (wrapper_symlink ($existingfilename, $newfilename)) {
- print "Symbolic link succeeded: ${newfilename}\n";
+ my_log ("Symbolic link succeeded: ${newfilename}\n");
return;
}
if (wrapper_hardlink ($existingfilename, $newfilename)) {
- print "Hard link succeeded: ${newfilename}\n";
+ my_log ("Hard link succeeded: ${newfilename}\n");
return;
}
if (wrapper_copy ($existingfilename, $newfilename)) {
- print "Copy succeeded: ${newfilename}\n";
+ my_log ("Copy succeeded: ${newfilename}\n");
return;
}
- print "Link/copy failed: ${newfilename}\n";
+ my_warn ("Link/copy failed: ${newfilename}\n");
}
# Create file with contents
@@ -386,7 +406,7 @@
my $msg = decode ('locale',
Win32::FormatMessage (Win32::GetLastError ()));
$msg =~ s/[\r\n]+\z//;
- print "CreateSymbolicLinkW failed: ${msg}\n";
+ my_warn ("CreateSymbolicLinkW failed: ${msg}\n");
return 0;
}
@@ -413,7 +433,7 @@
my $msg = decode ('locale',
Win32::FormatMessage (Win32::GetLastError ()));
$msg =~ s/[\r\n]+\z//;
- print "CreateHardLinkW failed: ${msg}\n";
+ my_warn ("CreateHardLinkW failed: ${msg}\n");
return 0;
}
@@ -440,7 +460,7 @@
my $msg = decode ('locale',
Win32::FormatMessage (Win32::GetLastError ()));
$msg =~ s/[\r\n]+\z//;
- print "CopyFileW failed: ${msg}\n";
+ my_warn ("CopyFileW failed: ${msg}\n");
return 0;
}
More information about the tex-live-commits
mailing list.