API 3.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. In addition to livecd-creator itself, the livecd-creator package
  2. provides a python API for building your own, other types of images.
  3. This API could also be used to build on top of the live image
  4. functionality.
  5. == Image Creation Frontends ==
  6. livecd-creator and image-creator are both frontends for creating
  7. images. But really, it's straight-forward to build your own which
  8. deals with your own specific needs. To do so, you'll want to do
  9. the following:
  10. * Create a pykickstart handler object. All of the image creators are
  11. driven by data stored in pykickstart handlers.
  12. * Then, instantiate a creator
  13. creator = ImageCreator(ks, name)
  14. where ks is your pykickstart object and name is the label/name you
  15. want for the image.
  16. * With the image, you can either do everything in one-shot with
  17. creator.create()
  18. or call the steps of creator.create() itself. The latter lets you add
  19. an interactive shell step if you want as well as a few other
  20. options. The order, though, is
  21. creator.mount()
  22. creator.install()
  23. creator.configure()
  24. creator.unmount()
  25. creator.package()
  26. Other available methods are
  27. * creator.launch_shell(): This launches a root shell within the
  28. install root
  29. * creator.cleanup(): Tear down the image. Note that this also
  30. occurs when the image object is deleted
  31. == Image Creator Backends ==
  32. The basic idea is that there are (presently) 3 main classes used to
  33. implement different types of images. No matter which you use, the
  34. interface should be largely the same. This means that, eg,
  35. livecd-creator _could_ generate other types of outputs just by
  36. switching from the LiveImageCreator to another ImageCreator object.
  37. * ImageCreator: This is the guts of what most image creators will
  38. need to use. It provides all of the bits to handle a kickstart
  39. config, install packages into an install root, etc. It leaves
  40. a number of hook methods which maybe be implemented by more specific
  41. creators:
  42. i) _mount_instroot(self): This method is where your filesystems
  43. should get mounted. The root of your filesystem tree should be
  44. located at self._instroot
  45. ii) _unmount_instroot(self): This method is called to undo
  46. _mount_instroot() basically.
  47. iii) _create_bootconfig(self): Set up anything needed for your
  48. image to boot. This could involve creating an initramfs, writing a
  49. bootloader configuration, etc. The filesystem is still mounted at
  50. self._instroot at this point. Note that this could be a no-op.
  51. iv) _stage_final_image(self): Do whatever is needed to make your
  52. image "consumable" and copy it to self._outdir. eg, for live CDs,
  53. this is where we generate the iso images. Note that this could be
  54. a no-op.
  55. Other hooks are available to subclasses, as well as a number of
  56. helper methods which can be used in implementing the hooks. See
  57. the inline docstrings for more details.
  58. Overriding other methods is not supported or guaranteed to continue
  59. to give consistent results over time.
  60. * LoopImageCreator: This generates ext3 images in a loopback file
  61. which could then later be booted in a virtual machine environment.
  62. NOTE: this does nothing to set up booting
  63. * LiveImageCreator: This builds on top of the LoopImageCreator to
  64. build live images which use dm-snapshot, etc. This is what is used
  65. by livecd-creator.