pakhandler.py 1.1 KB

1234567891011121314151617181920212223242526272829303132
  1. # -*- coding: utf-8 -*-
  2. import os
  3. import piksemel
  4. import subprocess
  5. import os
  6. def updateInitrd(filepath):
  7. patterns = ("/lib/modules", "/usr/lib/initcpio", "/boot/kernel", "/bin/busybox")
  8. parse = piksemel.parse(filepath)
  9. for xmlfile in parse.tags("File"):
  10. path = xmlfile.getTagData("Path")
  11. if not path.startswith("/"):
  12. path = "/%s" % path
  13. if path.startswith(patterns):
  14. version = path.split("/")[3]
  15. os.environ['PATH'] = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin'
  16. subprocess.call(["mkinitcpio","-k","%s"% version ,"-g","/boot/initramfs-%s-fallback.img"% version,"-S","autodetect"])
  17. subprocess.call(["mkinitcpio","-k","%s"% version ,"-c","/etc/mkinitcpio.conf","-g","/boot/initramfs-%s.img"% version])
  18. if os.path.exists("/proc/cmdline"):
  19. os.system("/usr/bin/update-grub")
  20. break
  21. def setupPackage(metapath, filepath):
  22. updateInitrd(filepath)
  23. def cleanupPackage(metapath, filepath):
  24. pass
  25. def postCleanupPackage(metapath, filepath):
  26. pass