texlive[54782] Master/tlpkg/tlpostcode/haranoaji-tlpost.pl:

commits+hironobu at tug.org commits+hironobu at tug.org
Sat Apr 18 13:41:04 CEST 2020


Revision: 54782
          http://tug.org/svn/texlive?view=revision&revision=54782
Author:   hironobu
Date:     2020-04-18 13:41:04 +0200 (Sat, 18 Apr 2020)
Log Message:
-----------
haranoaji-tlpost.pl: prepare for haranoaji update (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-04-18 01:26:28 UTC (rev 54781)
+++ trunk/Master/tlpkg/tlpostcode/haranoaji-tlpost.pl	2020-04-18 11:41:04 UTC (rev 54782)
@@ -37,6 +37,8 @@
 use feature 'state';
 use Encode;
 
+my $verbose = 0;
+
 if (win32 ()) {
     # These packages are not necessarily available on non-Windows, so
     # read them at runtime instead of compile time.
@@ -50,11 +52,12 @@
 
     require Win32::API;
     Win32::API->import ();
+    require File::Compare;
+    File::Compare->import ();
 } else {
     # 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 = (
@@ -75,8 +78,11 @@
     'HaranoAjiGothic-Heavy'      => 'HaranoAjiGothic-Heavy.otf'
     );
 
-# CMap list
-my @cmap_list = (
+# CMap list for install
+my @cmap_list_install = ('2004-H', '2004-V');
+
+# CMap list for snippet
+my @cmap_list_snippet = (
     'H', 'V',
     '2004-H', '2004-V',
     'UniJIS-UTF16-H', 'UniJIS-UTF16-V',
@@ -154,12 +160,24 @@
     for my $psname (sort keys %font_list) {
         my_log ("\nFor $psname ...\n");
 
+        my $fontpath_in_texmf = search_fontpath ($font_list{$psname});
+        if (! $fontpath_in_texmf) {
+            my_log ("Not found: Font in TEXMF: $font_list{$psname}\n");
+            next;
+        }
+
         my $fontpath_in_cidfontdir = "$cidfontdir/$psname";
         if (wrapper_isfile ($fontpath_in_cidfontdir)) {
             my_log ("Already exists: ${fontpath_in_cidfontdir}\n");
-            next;
+            if (file_compare ($fontpath_in_texmf, $fontpath_in_cidfontdir)) {
+                my_log ("Different from the file in TEXMF. Deleting.\n");
+                wrapper_unlink ($fontpath_in_cidfontdir);
+            } else {
+                my_log ("Same as the file in TEXMF. Skipping.\n");
+                next;
+            }
         }
-        my $fontpath_in_texmf = search_fontpath ($font_list{$psname}) or next;
+
         link_or_copy ($fontpath_in_texmf, $fontpath_in_cidfontdir);
     }
 }
@@ -168,15 +186,27 @@
 sub install_cmap {
     my_log ("\ninstall_cmap\n");
 
-    foreach my $cmapname (@cmap_list) {
+    foreach my $cmapname (@cmap_list_install) {
         my_log ("\nFor $cmapname ...\n");
 
+        my $cmappath_in_texmf = search_cmappath ($cmapname);
+        if (! $cmappath_in_texmf) {
+            my_log ("Not found: CMap in TEXMF: $cmapname\n");
+            next;
+        }
+
         my $cmappath_in_cmapdir = "$cmapdir/$cmapname";
         if (wrapper_isfile ($cmappath_in_cmapdir)) {
             my_log ("Already exists: ${cmappath_in_cmapdir}\n");
-            next;
+            if (file_compare ($cmappath_in_texmf, $cmappath_in_cmapdir)) {
+                my_log ("Different from the file in TEXMF. Deleting.\n");
+                wrapper_unlink ($cmappath_in_cmapdir);
+            } else {
+                my_log ("Same as the file in TEXMF. Skipping.\n");
+                next;
+            }
         }
-        my $cmappath_in_texmf = search_cmappath ($cmapname) or next;
+
         link_or_copy ($cmappath_in_texmf, $cmappath_in_cmapdir);
     }
 }
@@ -188,11 +218,11 @@
     for my $psname (sort keys %font_list) {
         my_log ("\nFor $psname ...\n");
 
-        foreach my $cmapname (@cmap_list) {
+        foreach my $cmapname (@cmap_list_snippet) {
             my $snippetpath = "$fontdir/$psname-$cmapname";
             if (wrapper_isfile ($snippetpath)) {
-                my_log ("Already exists: ${snippetpath}\n");
-                next;
+                my_log ("Already exists: ${snippetpath}\nDeleting.\n");
+                wrapper_unlink ($snippetpath);
             }
 
             my $contents = <<"EOS";
@@ -239,7 +269,7 @@
     for my $psname (sort keys %font_list) {
         my_log ("\nFor $psname ...\n");
 
-        foreach my $cmapname (@cmap_list) {
+        foreach my $cmapname (@cmap_list_snippet) {
             my $snippetpath = "$fontdir/$psname-$cmapname";
             if (wrapper_isfile ($snippetpath)) {
                 wrapper_unlink ($snippetpath);
@@ -352,6 +382,20 @@
     close $fh;
 }
 
+# File compare
+sub file_compare {
+    my ($filename1, $filename2) = @_;
+
+    # TODO: Compare file by -W API on Windows
+    my $result = compare (encode ('locale_fs', $filename1),
+                          encode ('locale_fs', $filename2));
+    if ($result == -1) {
+        die ("File compare failed: ${filename1}, ${filename2}\n");
+    }
+
+    return $result;
+}
+
 # Directory existence check
 sub wrapper_isdir {
     my ($dirname) = @_;



More information about the tex-live-commits mailing list.