[Fedora-livecd-list] 2 commits - docs/livecd-creator.pod imgcreate/creator.py imgcreate/live.py imgcreate/yuminst.py Makefile tools/livecd-creator

Brian C. Lane bcl at fedoraproject.org
Thu Jan 6 22:50:54 UTC 2011


 Makefile                |    2 +-
 docs/livecd-creator.pod |   10 +++++++++-
 imgcreate/creator.py    |   11 +++++++----
 imgcreate/live.py       |    6 +++---
 imgcreate/yuminst.py    |   17 +++++++++++++++--
 tools/livecd-creator    |   25 ++++++++++++++-----------
 6 files changed, 49 insertions(+), 22 deletions(-)

New commits:
commit bc27dbd5b98f8e690b84dc85a40868ae74665915
Author: Brian C. Lane <bcl at redhat.com>
Date:   Wed Jan 5 10:38:59 2011 -0800

    Version 15.3

diff --git a/Makefile b/Makefile
index 5a8a9ea..0340df1 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,5 @@
 
-VERSION = 15.2
+VERSION = 15.3
 
 INSTALL = /usr/bin/install -c
 INSTALL_PROGRAM = ${INSTALL}


commit 86653488f170be16b9b9dcb7a11310422b0e80e7
Author: Brian C. Lane <bcl at redhat.com>
Date:   Wed Jan 5 10:18:47 2011 -0800

    Change releasever to a command line option (#667474)
    
    The release version of the running system may not be the release you
    want to build the livecd for, or the rpmdb may not be accessable from
    the build environment (koji and chroot) so set the value to use for
    $releasever in kickstart repo url's by passing --releasever=VER
    
    If $releasever is used and no --releasever is passed it will try to
    use the system's version. Under some circumstances (chroot environments
    like koji) this isn't possible so an error will be raised.

diff --git a/docs/livecd-creator.pod b/docs/livecd-creator.pod
index 553f865..dd70fb9 100644
--- a/docs/livecd-creator.pod
+++ b/docs/livecd-creator.pod
@@ -47,6 +47,10 @@ currently requires a custom kernel to produce a functional image. lzo works with
 is used, the -comp option is not passed to mksquashfs to allow the use of
 older versions of mksquashfs.
 
+=item --releasever=VER
+
+Set the value to substitute for $releasever in kickstart repo urls
+
 =back
 
 =head1 SYSTEM DIRECTORY OPTIONS
@@ -81,12 +85,16 @@ livecd-creator \
 =head1 REPO EXTENSIONS
 
 livecd-creator provides for some extensions to the repo commands similar
-to what yum supports. The strings $arch, $basearch and $releveasever
+to what yum supports. The strings $arch, $basearch and $releasever
 are replaced with the system arch, basearch and release version respectively.
+When no --releasever is passed it defaults to the current system's version.
 The allows the use of repo commands such as the following:
 
 repo --name=fedora --mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch
 
+Note that in a chroot environment (like koji) the rpmdb is not available,
+so either don't use $releasever in that case, or pass --releasever=VER
+
 =head1 CONTRIBUTORS
 
 David Zeuthen, Jeremy Katz, Douglas McClendon and a team of many other contributors. See the AUTHORS file in the source distribution for the complete list of credits. 
diff --git a/imgcreate/creator.py b/imgcreate/creator.py
index 1f1e5b8..4d0e59d 100644
--- a/imgcreate/creator.py
+++ b/imgcreate/creator.py
@@ -51,7 +51,7 @@ class ImageCreator(object):
 
     """
 
-    def __init__(self, ks, name):
+    def __init__(self, ks, name, releasever=None):
         """Initialize an ImageCreator instance.
 
         ks -- a pykickstart.KickstartParser instance; this instance will be
@@ -61,6 +61,7 @@ class ImageCreator(object):
         name -- a name for the image; used for e.g. image filenames or
                 filesystem labels
 
+        releasever -- Value to substitute for $releasever in repo urls
         """
         self.ks = ks
         """A pykickstart.KickstartParser instance."""
@@ -68,6 +69,8 @@ class ImageCreator(object):
         self.name = name
         """A name for the image."""
 
+        self.releasever = releasever
+
         self.tmpdir = "/var/tmp"
         """The directory in which all temporary files will be created."""
 
@@ -634,7 +637,7 @@ class ImageCreator(object):
         """
         yum_conf = self._mktemp(prefix = "yum.conf-")
 
-        ayum = LiveCDYum()
+        ayum = LiveCDYum(releasever=self.releasever)
         ayum.setup(yum_conf, self._instroot)
 
         for repo in kickstart.get_repos(self.ks, repo_urls):
@@ -793,7 +796,7 @@ class LoopImageCreator(ImageCreator):
 
     """
 
-    def __init__(self, ks, name, fslabel = None):
+    def __init__(self, ks, name, fslabel=None, releasever=None):
         """Initialize a LoopImageCreator instance.
 
         This method takes the same arguments as ImageCreator.__init__() with
@@ -802,7 +805,7 @@ class LoopImageCreator(ImageCreator):
         fslabel -- A string used as a label for any filesystems created.
 
         """
-        ImageCreator.__init__(self, ks, name)
+        ImageCreator.__init__(self, ks, name, releasever=releasever)
 
         self.__fslabel = None
         self.fslabel = fslabel
diff --git a/imgcreate/live.py b/imgcreate/live.py
index 5e47159..93a4b4e 100644
--- a/imgcreate/live.py
+++ b/imgcreate/live.py
@@ -38,13 +38,13 @@ class LiveImageCreatorBase(LoopImageCreator):
 
     """
 
-    def __init__(self, *args):
+    def __init__(self, ks, name, fslabel=None, releasever=None):
         """Initialise a LiveImageCreator instance.
 
-        This method takes the same arguments as ImageCreator.__init__().
+        This method takes the same arguments as LoopImageCreator.__init__().
 
         """
-        LoopImageCreator.__init__(self, *args)
+        LoopImageCreator.__init__(self, ks, name, fslabel=fslabel, releasever=releasever)
 
         self.compress_type = "gzip"
         """mksquashfs compressor to use."""
diff --git a/imgcreate/yuminst.py b/imgcreate/yuminst.py
index 92b8f45..82a5788 100644
--- a/imgcreate/yuminst.py
+++ b/imgcreate/yuminst.py
@@ -45,8 +45,12 @@ class TextProgress(object):
         self.emit(logging.INFO, "...OK\n")
 
 class LiveCDYum(yum.YumBase):
-    def __init__(self):
+    def __init__(self, releasever=None):
+        """
+        releasever = optional value to use in replacing $releasever in repos
+        """
         yum.YumBase.__init__(self)
+        self.releasever = releasever
 
     def doFileLogSetup(self, uid, logfile):
         # don't do the file log for the livecd as it can lead to open fds
@@ -138,7 +142,16 @@ class LiveCDYum(yum.YumBase):
             # takes a variable and substitutes like yum configs do
             option = option.replace("$basearch", rpmUtils.arch.getBaseArch())
             option = option.replace("$arch", rpmUtils.arch.getCanonArch())
-            option = option.replace("$releasever", yum.config._getsysver("/", "redhat-release"))
+            # If the url includes $releasever substitute user's value or
+            # current system's version.
+            if option.find("$releasever") > -1:
+                if self.releasever:
+                    option = option.replace("$releasever", self.releasever)
+                else:
+                    try:
+                        option = option.replace("$releasever", yum.config._getsysver("/", "redhat-release"))
+                    except yum.Errors.YumBaseError:
+                        raise CreatorError("$releasever in repo url, but no releasever set")
             return option
 
         repo = yum.yumRepo.YumRepository(name)
diff --git a/tools/livecd-creator b/tools/livecd-creator
index afe592f..18c50cd 100755
--- a/tools/livecd-creator
+++ b/tools/livecd-creator
@@ -40,16 +40,19 @@ def parse_options(args):
                       help="Path or url to kickstart config file")
     imgopt.add_option("-b", "--base-on", type="string", dest="base_on",
                       help="Add packages to an existing live CD iso9660 image.")
-    imgopt.add_option("-f", "--fslabel", type="string", dest="fs_label",
+    imgopt.add_option("-f", "--fslabel", type="string", dest="fslabel",
                       help="File system label (default based on config name)")
     # Provided for img-create compatibility
-    imgopt.add_option("-n", "--name", type="string", dest="fs_label",
+    imgopt.add_option("-n", "--name", type="string", dest="fslabel",
                       help=optparse.SUPPRESS_HELP)
     imgopt.add_option("", "--image-type", type="string", dest="image_type",
                       help=optparse.SUPPRESS_HELP)
     imgopt.add_option("", "--compression-type", type="string", dest="compress_type",
                       help="Compression type recognized by mksquashfs (default gzip, lzma needs custom kernel, lzo needs a 2.6.36+ kernel)",
                       default="gzip")
+    imgopt.add_option("", "--releasever", type="string", dest="releasever",
+                      default=None,
+                      help="Value to substitute for $releasever in kickstart repo urls")
     parser.add_option_group(imgopt)
 
     # options related to the config of your system
@@ -97,9 +100,9 @@ def parse_options(args):
     if options.base_on and not os.path.isfile(options.base_on):
         raise Usage("Image file '%s' does not exist" %(options.base_on,))
     if options.image_type == 'livecd':
-        if options.fs_label and len(options.fs_label) > imgcreate.FSLABEL_MAXLEN:
+        if options.fslabel and len(options.fslabel) > imgcreate.FSLABEL_MAXLEN:
             raise Usage("CD labels are limited to 32 characters")
-        if options.fs_label and options.fs_label.find(" ") != -1:
+        if options.fslabel and options.fslabel.find(" ") != -1:
             raise Usage("CD labels cannot contain spaces.")
 
     return options
@@ -122,25 +125,25 @@ def main():
         print >> sys.stderr, "You must run %s as root" % sys.argv[0]
         return 1
 
-    if options.fs_label:
-        fs_label = options.fs_label
-        name = fs_label
+    if options.fslabel:
+        fslabel = options.fslabel
+        name = fslabel
     else:
         name = imgcreate.build_name(options.kscfg, options.image_type + "-")
 
-        fs_label = imgcreate.build_name(options.kscfg,
+        fslabel = imgcreate.build_name(options.kscfg,
                                         options.image_type + "-",
                                         maxlen = imgcreate.FSLABEL_MAXLEN,
                                         suffix = "%s-%s" %(os.uname()[4], time.strftime("%Y%m%d%H%M")))
 
-        logging.info("Using label '%s' and name '%s'" % (fs_label, name))
+        logging.info("Using label '%s' and name '%s'" % (fslabel, name))
 
     ks = imgcreate.read_kickstart(options.kscfg)
 
     if options.image_type == 'livecd':
-        creator = imgcreate.LiveImageCreator(ks, name, fs_label)
+        creator = imgcreate.LiveImageCreator(ks, name, fslabel=fslabel, releasever=options.releasever)
     elif options.image_type == 'image':
-        creator = imgcreate.LoopImageCreator(ks, name, fs_label)
+        creator = imgcreate.LoopImageCreator(ks, name, fslabel=fslabel, releasever=options.releasever)
     else:
         # Cannot happen, we validate this when parsing options.
         logging.error(u"'%s' is not a valid image type" % options.image_type)




More information about the livecd mailing list