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; } } system('/usr/bin/mktexlsr'); die("Can't run /usr/bin/mktexlsr") if $?;