[LON-CAPA-cvs] cvs: doc /loncapafiles latex_fixup.piml

raeburn raeburn@source.lon-capa.org
Sat, 10 Jan 2009 04:43:15 -0000


raeburn		Sat Jan 10 04:43:15 2009 EDT

  Modified files:              
    /doc/loncapafiles	latex_fixup.piml 
  Log:
  - RHEL4 and SLES9 both use tetex-2.0 which lacks the lmodern package.
    - For these distros, if lmodern.sty is missing - get the tarball containg fonts tc from install.loncapa.org, unpack in /tmp and copy to appropriate locations in /usr/share/texmf/.      
  
  
Index: doc/loncapafiles/latex_fixup.piml
diff -u doc/loncapafiles/latex_fixup.piml:1.2 doc/loncapafiles/latex_fixup.piml:1.3
--- doc/loncapafiles/latex_fixup.piml:1.2	Sat Apr  5 11:57:01 2008
+++ doc/loncapafiles/latex_fixup.piml	Sat Jan 10 04:43:15 2009
@@ -3,7 +3,7 @@
 <!-- latex_fixup.piml -->
 <!-- Stuart Raeburn -->
 
-<!-- $Id: latex_fixup.piml,v 1.2 2008/04/05 11:57:01 raeburn Exp $ -->
+<!-- $Id: latex_fixup.piml,v 1.3 2009/01/10 04:43:15 raeburn Exp $ -->
 
 <!--
 
@@ -32,6 +32,127 @@
 <piml>
 <files>
 <file>
+<perlscript mode="fg" dist="rhes4 sles9">
+    my $lmodernafmpath = '/usr/share/texmf/fonts/afm/public';
+    my $lmoderntfmpath = '/usr/share/texmf/fonts/tfm/public';
+    my $lmoderntype1path = '/usr/share/texmf/fonts/type1/public';
+    my $lmoderndvipspath = '/usr/share/texmf/dvips';
+    my $lmoderntexpath = '/usr/share/texmf/tex/latex';
+    my $file = 'lmodern.sty';
+    if (!-e "$lmoderntexpath/lm/$file") {
+        if (!-d $lmoderntexpath) {
+            if (!&create_dir("$lmoderntexpath")) {
+                die("Failed to create directory: $lmoderntexpath");
+            }
+        }
+        if (!-d $lmodernafmpath) {
+            if (!&create_dir($lmodernafmpath)) {
+                die("Failed to create directory: $lmodernafmpath");
+            }
+
+        }
+        if (!-d $lmoderntfmpath) {
+            if (!&create_dir($lmoderntfmpath)) {
+                die("Failed to create directory: $lmoderntfmpath");
+            }
+        }
+        if (!-d $lmoderntype1path) {
+            if (!&create_dir($lmoderntype1path)) {
+                die("Failed to create directory: $lmoderntype1path");
+            }
+        }
+        if (!-d $lmoderndvipspath) {
+            if (!&create_dir($lmoderndvipspath)) {
+                die("Failed to create directory: $lmoderndvipspath");
+            }
+        }
+        if (-d $lmoderntexpath) {
+            if (!-d "/tmp/LONCAPA") {
+                mkdir("/tmp/LONCAPA",0755);
+                die("mkdir('/tmp/LONCAPA',0755) failed") if $?;
+            }
+            system("/usr/bin/wget -O /tmp/LONCAPA/LC_lmodern.tar.gz  http://install.loncapa.org/versions/tex/LC_lmodern.tar.gz  1>/dev/null 2>/dev/null");
+            die("/usr/bin/wget -O /tmp/LONCAPA/LC_lmodern.tar.gz  http://install.loncapa.org/versions/tex/LC_lmodern.tar.gz failed") if $?;
+            system("/bin/tar zxf /tmp/LONCAPA/LC_lmodern.tar.gz --directory /tmp/LONCAPA");
+            die("/bin/tar zxf /tmp/LONCAPA/LC_lmodern.tar.gz --directory /tmp/LONCAPA failed") if $?;
+            unlink('/tmp/LONCAPA/LC_lmodern.tar.gz');
+            if (-d "/tmp/LONCAPA/lmodern/fonts/afm/public/lm") {
+                if (-d $lmodernafmpath && !-e "$lmodernafmpath/lm/") {
+                    system("mv /tmp/LONCAPA/lmodern/fonts/afm/public/lm $lmodernafmpath");
+                    die("mv /tmp/LONCAPA/lmodern/fonts/afm/public/lm $lmodernafmpath failed") if $?;
+                }
+            } else {
+                die("Fonts directory: /tmp/LONCAPA/lmodern/fonts/afm/public/lm missing");
+            }
+            if (-d "/tmp/LONCAPA/lmodern/fonts/tfm/public/lm") {
+                if (-d $lmoderntfmpath && !-e "$lmoderntfmpath/lm/") {
+                    system("mv /tmp/LONCAPA/lmodern/fonts/tfm/public/lm $lmoderntfmpath");
+                    die("mv /tmp/LONCAPA/lmodern/fonts/tfm/public/lm $lmoderntfmpath failed") if $?;
+                }
+            } else {
+               die("Fonts directory: /tmp/LONCAPA/lmodern/fonts/tfm/public/lm missing");
+            }
+            if (-d "/tmp/LONCAPA/lmodern/fonts/type1/public/lm") {
+                if (-d $lmoderntype1path && !-e "$lmoderntype1path/lm/") {
+                    system("mv /tmp/LONCAPA/lmodern/fonts/type1/public/lm $lmoderntype1path");
+                    die("mv /tmp/LONCAPA/lmodern/fonts/type1/public/lm $lmoderntype1path failed") if $?;
+                }
+            } else {
+               die("Fonts directory: /tmp/LONCAPA/lmodern/fonts/type1/public/lm missing");
+            }
+            if (-d "/tmp/LONCAPA/lmodern/fonts/dvips/lm") {
+                if (-d $lmoderndvipspath && !-e "$lmoderndvipspath/lm/") {
+                    system("mv /tmp/LONCAPA/lmodern/fonts/dvips/lm $lmoderndvipspath");
+                    die("mv /tmp/LONCAPA/lmodern/fonts/dvips/lm $lmoderndvipspath failed") if $?;
+                }
+            } else {
+               die("Fonts directory: /tmp/LONCAPA/lmodern/fonts/dvips/lm missing");
+            }
+            if (-d "/tmp/LONCAPA/lmodern/tex/latex/lm") {
+                if (-d $lmoderntexpath && !-e "$lmoderntexpath/lm/") {
+                    system("mv /tmp/LONCAPA/lmodern/tex/latex/lm $lmoderntexpath");
+                    die("mv /tmp/LONCAPA/lmodern/tex/latex/lm $lmoderntexpath failed") if $?;
+                }
+            } else {
+               die("TeX directory: /tmp/LONCAPA/lmodern/tex/latex/lm missing");
+            }
+            if (-e $lmoderntexpath.'/lm/'.$file) {
+                system('/usr/bin/updmap --enable Map lm.map 1>/dev/null 2>/dev/null');
+                die("Can't run /usr/bin/updmap --enable Map lm.map") if $?;
+                system('/usr/bin/texconfig rehash  1>/dev/null 2>/dev/null');
+                die("Can't run /usr/bin/texconfig rehash") if $?;
+                system('/usr/bin/updmap 1>/dev/null 2>/dev/null');
+                die("Can't run /usr/bin/updmap") if $?;
+                print "$lmoderntexpath/lm/$file created and lmodern fonts copied.\n".
+                      "/usr/bin/texconfig rehash ran successfully.\n";
+            } else {
+                die("Can't find $lmoderntexpath/lm/$file");
+            }
+        } else {
+            die("Can't find $lmoderntexpath") if $?;
+        }
+    } else {
+        print "No action required - $lmoderntexpath/lm/$file already exists.\n";
+    }
+
+sub create_dir {
+    my ($dir) = @_;
+    my @parts=split('/',$dir);
+    my $filepath;
+    foreach my $part (@parts) {
+        $filepath.= '/'.$part;
+        if (!-d $filepath) {
+            mkdir($filepath,0755);
+        }
+    }
+    if (-d $dir) {
+        return 1;
+    } else {
+        return 0;
+    }
+}
+
+</perlscript>
 <perlscript mode="fg" dist="rhes4">
     system('/usr/bin/mktexlsr');
     die("Can't run /usr/bin/mktexlsr") if $?;