pakhandler.py 784 B

12345678910111213141516171819202122232425262728
  1. # -*- coding: utf-8 -*-
  2. import os
  3. import piksemel
  4. import subprocess
  5. def doinfo(filepath, remove=False):
  6. # install-info is broken with i18n :(
  7. os.environ["LC_ALL"] = "C"
  8. doc = piksemel.parse(filepath)
  9. for item in doc.tags("File"):
  10. path = item.getTagData("Path")
  11. if path.startswith("usr/share/info") and path.endswith((".info", ".info.gz")):
  12. if remove:
  13. subprocess.call(["install-info", "--delete", "/%s" % path, "/usr/share/info/dir"])
  14. else:
  15. subprocess.call(["install-info", "/%s" % path, "/usr/share/info/dir"])
  16. def setupPackage(metapath, filepath):
  17. doinfo(filepath)
  18. def cleanupPackage(metapath, filepath):
  19. doinfo(filepath, True)
  20. def postCleanupPackage(metapath, filepath):
  21. pass