https://bugzilla.redhat.com/show_bug.cgi?id=813429

This adds an option ("-p", or "--plugins") to livecd-creator to allow for
the use of yum plugins during image creation. The initial usage case is
for localized live images that want to use yum-langpacks when creating their
live image so that they include the proper language packs for their locale.

Aside from the noise of propagating the commandline options down to the yum
instance, there is a bugfix where we re-call repository setup after we've
actually added the repositories; this is required so that plugins operate
properly.

Bill
diff -up livecd-tools-18.3/imgcreate/creator.py.foo 
livecd-tools-18.3/imgcreate/creator.py
--- livecd-tools-18.3/imgcreate/creator.py.foo  2012-04-16 20:22:31.000000000 
-0400
+++ livecd-tools-18.3/imgcreate/creator.py      2012-04-23 18:26:15.440702732 
-0400
@@ -51,7 +51,7 @@ class ImageCreator(object):
 
     """
 
-    def __init__(self, ks, name, releasever=None, tmpdir="/tmp"):
+    def __init__(self, ks, name, releasever=None, tmpdir="/tmp", 
useplugins=False):
         """Initialize an ImageCreator instance.
 
         ks -- a pykickstart.KickstartParser instance; this instance will be
@@ -72,6 +72,7 @@ class ImageCreator(object):
         """A name for the image."""
 
         self.releasever = releasever
+        self.useplugins = useplugins
 
         self.tmpdir = tmpdir
         """The directory in which all temporary files will be created."""
@@ -617,7 +618,7 @@ class ImageCreator(object):
         """
         yum_conf = self._mktemp(prefix = "yum.conf-")
 
-        ayum = LiveCDYum(releasever=self.releasever)
+        ayum = LiveCDYum(releasever=self.releasever, 
useplugins=self.useplugins)
         ayum.setup(yum_conf, self._instroot)
 
         for repo in kickstart.get_repos(self.ks, repo_urls):
@@ -632,6 +633,7 @@ class ImageCreator(object):
                 yr.proxy = proxy
             if cost is not None:
                 yr.cost = cost
+        ayum.setup(yum_conf, self._instroot)
 
         if kickstart.exclude_docs(self.ks):
             rpm.addMacro("_excludedocs", "1")
@@ -778,7 +780,7 @@ class LoopImageCreator(ImageCreator):
 
     """
 
-    def __init__(self, ks, name, fslabel=None, releasever=None, tmpdir="/tmp"):
+    def __init__(self, ks, name, fslabel=None, releasever=None, tmpdir="/tmp", 
useplugins=False):
         """Initialize a LoopImageCreator instance.
 
         This method takes the same arguments as ImageCreator.__init__() with
@@ -787,7 +789,7 @@ class LoopImageCreator(ImageCreator):
         fslabel -- A string used as a label for any filesystems created.
 
         """
-        ImageCreator.__init__(self, ks, name, releasever=releasever, 
tmpdir=tmpdir)
+        ImageCreator.__init__(self, ks, name, releasever=releasever, 
tmpdir=tmpdir, useplugins=useplugins)
 
         self.__fslabel = None
         self.fslabel = fslabel
diff -up livecd-tools-18.3/imgcreate/live.py.foo 
livecd-tools-18.3/imgcreate/live.py
--- livecd-tools-18.3/imgcreate/live.py.foo     2012-04-16 20:22:31.000000000 
-0400
+++ livecd-tools-18.3/imgcreate/live.py 2012-04-23 18:24:33.092699876 -0400
@@ -40,7 +40,7 @@ class LiveImageCreatorBase(LoopImageCrea
     """
 
     def __init__(self, ks, name, fslabel=None, releasever=None, tmpdir="/tmp",
-                 title="Linux", product="Linux"):
+                 title="Linux", product="Linux", useplugins=False):
         """Initialise a LiveImageCreator instance.
 
         This method takes the same arguments as LoopImageCreator.__init__().
@@ -49,7 +49,8 @@ class LiveImageCreatorBase(LoopImageCrea
         LoopImageCreator.__init__(self, ks, name,
                                   fslabel=fslabel,
                                   releasever=releasever,
-                                  tmpdir=tmpdir)
+                                  tmpdir=tmpdir,
+                                  useplugins=useplugins)
 
         self.compress_type = "xz"
         """mksquashfs compressor to use."""
diff -up livecd-tools-18.3/imgcreate/yuminst.py.foo 
livecd-tools-18.3/imgcreate/yuminst.py
--- livecd-tools-18.3/imgcreate/yuminst.py.foo  2012-04-16 20:22:31.000000000 
-0400
+++ livecd-tools-18.3/imgcreate/yuminst.py      2012-04-23 18:24:33.093699876 
-0400
@@ -45,12 +45,13 @@ class TextProgress(object):
         self.emit(logging.INFO, "...OK\n")
 
 class LiveCDYum(yum.YumBase):
-    def __init__(self, releasever=None):
+    def __init__(self, releasever=None, useplugins=False):
         """
         releasever = optional value to use in replacing $releasever in repos
         """
         yum.YumBase.__init__(self)
         self.releasever = releasever
+        self.useplugins = useplugins
 
     def doFileLogSetup(self, uid, logfile):
         # don't do the file log for the livecd as it can lead to open fds
@@ -71,7 +72,7 @@ class LiveCDYum(yum.YumBase):
         conf  = "[main]\n"
         conf += "installroot=%s\n" % installroot
         conf += "cachedir=/var/cache/yum\n"
-        conf += "plugins=0\n"
+        conf += "plugins=%s\n" % self.useplugins
         conf += "reposdir=\n"
         conf += "failovermethod=priority\n"
         conf += "keepcache=1\n"
diff -up livecd-tools-18.3/tools/livecd-creator.foo 
livecd-tools-18.3/tools/livecd-creator
--- livecd-tools-18.3/tools/livecd-creator.foo  2012-04-16 20:22:31.000000000 
-0400
+++ livecd-tools-18.3/tools/livecd-creator      2012-04-23 18:24:33.093699876 
-0400
@@ -49,6 +49,9 @@ def parse_options(args):
     # Provided for img-create compatibility
     imgopt.add_option("-n", "--name", type="string", dest="fslabel",
                       help=optparse.SUPPRESS_HELP)
+    imgopt.add_option("-p", "--plugins", action="store_true", dest="plugins",
+                      help="Use yum plugins during image creation",
+                      default=False)
     imgopt.add_option("", "--image-type", type="string", dest="image_type",
                       help=optparse.SUPPRESS_HELP)
     imgopt.add_option("", "--compression-type", type="string", 
dest="compress_type",
@@ -171,11 +174,13 @@ def main():
                                         fslabel=fslabel,
                                         releasever=options.releasever,
                                         tmpdir=os.path.abspath(options.tmpdir),
+                                        useplugins=options.plugins,
                                         title=title, product=product)
     elif options.image_type == 'image':
         creator = imgcreate.LoopImageCreator(ks, name,
                                         fslabel=fslabel,
                                         releasever=options.releasever,
+                                        useplugins=options.plugins,
                                         tmpdir=os.path.abspath(options.tmpdir))
     else:
         # Cannot happen, we validate this when parsing options.
--
livecd mailing list
[email protected]
https://admin.fedoraproject.org/mailman/listinfo/livecd

Reply via email to