package.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import glob
  5. import shutil
  6. import subprocess
  7. def postInstall(fromVersion, fromRelease, toVersion, toRelease):
  8. updmap_file = "/etc/texmf/web2c/updmap.cfg"
  9. updmap_local_file = "/etc/texmf/web2c/updmap-local.cfg"
  10. updmap_share_file = "/usr/share/texmf-dist/web2c/updmap-hdr.cfg"
  11. temp_file = "/tmp/updmap.cfg.temp"
  12. texmf_file="/etc/texmf/web2c/texmf.cnf"
  13. texmf_symfile="/usr/share/texmf-dist/web2c/texmf.cnf"
  14. print "texlive: saving updmap.cfg as %s" % temp_file
  15. shutil.copy2(updmap_file, temp_file)
  16. print "texlive: regenerating updmap.cfg (custom additions should go"
  17. print " into /etc/texmf/web2c/updmap-local.cfg"
  18. shutil.copy2(updmap_share_file, updmap_file)
  19. shutil.copy2(texmf_file, texmf_symfile)
  20. # In bash: cat *.maps >> updmap.cfg
  21. # In python:ugly lines below ...
  22. for map_file in glob.glob("/var/lib/texmf/pisilinux/*.maps"):
  23. print "texlive: adding %s to updmap.cfg" % map_file
  24. fin = open(map_file, "r")
  25. updmap_hdr = fin.read()
  26. fin.close()
  27. fout = open(updmap_file, "a")
  28. fout.write(updmap_hdr)
  29. fout.close()
  30. # Look for custom additions, if available add them too
  31. if os.path.exists(updmap_local_file):
  32. fin = open(updmap_local_file, "r")
  33. updmap_local = fin.read()
  34. fin.close()
  35. fout = open(updmap_file, "a")
  36. fout.write(updmap_local)
  37. fout.close()
  38. print "texlive: updating the filename database..."
  39. subprocess.call(["/usr/bin/mktexlsr"])
  40. print "texlive: updating the fontmap files with updmap..."
  41. subprocess.call(["/usr/bin/updmap-sys", "--quiet" ,"--nohash"])
  42. print "texlive: creating all formats..."
  43. fnull = open(os.devnull, 'w')
  44. subprocess.call(["/usr/bin/fmtutil-sys", "--all"], stdout=fnull, stderr=fnull)
  45. print "done ..."
  46. print "texlive: logs are under /var/lib/texmf/web2c/<engine>/<formatname>.log)"