--- doc/loncapafiles/picins_check.piml	2009/07/05 21:23:42	1.2
+++ doc/loncapafiles/picins_check.piml	2019/09/20 15:01:54	1.42
@@ -3,7 +3,7 @@
 <!-- picins_check.piml -->
 <!-- Stuart Raeburn -->
 
-<!-- $Id: picins_check.piml,v 1.2 2009/07/05 21:23:42 raeburn Exp $ -->
+<!-- $Id: picins_check.piml,v 1.42 2019/09/20 15:01:54 raeburn Exp $ -->
 
 <!--
 
@@ -32,7 +32,7 @@ http://www.lon-capa.org/
 <piml>
 <files>
 <file>
-<perlscript mode="fg" dist="fedora9 fedora10 fedora11 sles11.1">
+<perlscript mode="fg" dist="fedora9 fedora10 fedora11 fedora12 fedora13 fedora14 fedora15 fedora16 fedora17 fedora18 fedora19 fedora20 fedora21 fedora22 fedora 23 fedora24 fedora25 fedora26 fedora27 fedora28 fedora29 fedora30 rhes6 scientific6 centos6 oracle6 rhes7 scientific7 centos7 oracle7 rhes8 centos8 oracle8 sles11 sles12 sles15 suse11.1 suse11.2 suse11.3 suse11.4 suse12.1 suse12.2 suse12.3 suse13.1 suse13.2 debian5 debian6 ubuntu8 ubuntu10 ubuntu12 ubuntu14 ubuntu16 ubuntu18">
     my $picinspath = '/usr/share/texmf/tex/latex/picins'; 
     my $file = 'picins.sty';
     if (!-e "$picinspath/$file") {
@@ -45,14 +45,25 @@ http://www.lon-capa.org/
                     mkdir($filepath,0755);
                 }
             }
+        } else {
+            chmod(0755,$picinspath);
         }
         if (-d $picinspath) {
-            system("/usr/bin/wget -O $picinspath/$file  http://www.ctan.org/get/macros/latex209/contrib/picins/picins.sty  1>/dev/null 2>/dev/null");
-            die("/usr/bin/wget -O  http://www.ctan.org/get/macros/latex209/contrib/picins/picins.sty failed") if $?;
+            my $srcurl = 'http://install.loncapa.org/ctan/tex-archive/macros/latex209/contrib/picins/picins.sty';
+            system("/usr/bin/wget -O $picinspath/$file $srcurl 1>/dev/null 2>/dev/null");
+            die("/usr/bin/wget -O $srcurl failed") if $?;
+            chmod(0644, "$picinspath/$file");
             if (-e $picinspath.'/'.$file) {
-                system('/usr/bin/texconfig rehash  1>/dev/null 2>/dev/null');
-                die("Can't run /usr/bin/texconfig rehash") if $?;
-                system("/usr/bin/fmtutil-sys --missing  1>/dev/null 2>/dev/null");                print "$picinspath/$file created and /usr/bin/texconfig rehash ran successfully.\n";
+                if ('<DIST />' eq 'ubuntu16' || '<DIST />' eq 'ubuntu18') {
+                    system('/usr/bin/mktexlsr');
+                    die("Can't run /usr/bin/mktexlsr") if $?;
+                    print "$picinspath/$file created and /usr/bin/mktexlsr ran successfully.\n";
+                } else { 
+                    system('/usr/bin/texconfig rehash  1>/dev/null 2>/dev/null');
+                    die("Can't run /usr/bin/texconfig rehash") if $?;
+                    print "$picinspath/$file created and /usr/bin/texconfig rehash ran successfully.\n";
+                }
+                chmod(0644,"$picinspath/$file");
             } else {
                 die("Can't find $picinspath/$file");
             }
@@ -60,6 +71,8 @@ http://www.lon-capa.org/
             die("Can't find $picinspath") if $?;
         }
     } else {
+        chmod(0755,$picinspath);
+        chmod(0644,"$picinspath/$file");
         print "No action required - $picinspath/$file already exists.\n";
     }
 </perlscript>