pakhandler.py 1.0 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/usr/bin/python
  2. import piksemel
  3. import os
  4. def updateInitrd(filepath):
  5. patterns = ("/lib/modules", "/lib/initrd", "/boot/kernel", "/bin/busybox")
  6. parse = piksemel.parse(filepath)
  7. for xmlfile in parse.tags("File"):
  8. path = xmlfile.getTagData("Path")
  9. if not path.startswith("/"):
  10. path = "/%s" % path # Just in case
  11. if path.startswith(patterns):
  12. # Handle the proper case of modules
  13. version = path.split("/")[3]
  14. os.environ['PATH'] = '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin'
  15. cmd = "update-initrd KERNELVER=%s MODDIR=/lib/modules/%s OUTPUT=/boot/initramfs-%s" % (version, version, version)
  16. os.system(cmd)
  17. if os.path.exists("/proc/cmdline"):
  18. os.system("/usr/bin/update-grub")
  19. break
  20. def setupPackage(metapath, filepath):
  21. updateInitrd(filepath)
  22. def cleanupPackage(metapath, filepath):
  23. pass
  24. def postCleanupPackage(metapath, filepath):
  25. # TODO: Remove old initramfs!
  26. pass