imgcreate/creator.py | 5 + imgcreate/live.py | 151 +++++++++++++++++++++++++++++++++------------------ tools/livecd-creator | 25 ++++++++ 3 files changed, 127 insertions(+), 54 deletions(-)
New commits: commit 807bff3450212a6ecc5802252752ef37febfe115 Author: Brian C. Lane <[email protected]> Date: Wed Aug 31 17:37:20 2011 -0700 Add title and product args (#669120) Pass --title to set the syslinux.cfg title string Pass --product to set the syslinux.cfg string used as part of each kernel boot stanza. If they are not passed it will try to split the fslabel on - and use the first 2 elements (eg. Livecd Fedora). If that fails it will use Linux for both. diff --git a/imgcreate/live.py b/imgcreate/live.py index f7d3be8..721b609 100755 --- a/imgcreate/live.py +++ b/imgcreate/live.py @@ -39,7 +39,8 @@ class LiveImageCreatorBase(LoopImageCreator): """ - def __init__(self, ks, name, fslabel=None, releasever=None, tmpdir="/tmp"): + def __init__(self, ks, name, fslabel=None, releasever=None, tmpdir="/tmp", + title="Linux", product="Linux"): """Initialise a LiveImageCreator instance. This method takes the same arguments as LoopImageCreator.__init__(). @@ -82,6 +83,9 @@ class LiveImageCreatorBase(LoopImageCreator): self._isofstype = "iso9660" self.base_on = False + self.title = title + self.product = product + # # Hooks for subclasses # @@ -456,10 +460,10 @@ class x86LiveImageCreator(LiveImageCreatorBase): default %(menu)s timeout %(timeout)d menu background %(background)s -menu autoboot Starting %(name)s in # second{,s}. Press any key to interrupt. +menu autoboot Starting %(title)s in # second{,s}. Press any key to interrupt. menu clear -menu title @PRODUCT@ @VERSION@ +menu title %(title)s menu vshift 8 menu rows 18 menu margin 8 @@ -535,11 +539,11 @@ menu separator default = self.__is_default_kernel(kernel, kernels) if default: - long = "" + long = self.product elif kernel.startswith("kernel-"): - long = "%s(%s)" % (self.name, kernel[7:]) + long = "%s (%s)" % (self.product, kernel[7:]) else: - long = "%s(%s)" % (self.name, kernel) + long = "%s (%s)" % (self.product, kernel) # tell dracut not to ask for LUKS passwords or activate mdraid sets if isDracut: @@ -625,7 +629,7 @@ menu separator cfg = self.__get_basic_syslinux_config(menu = menu, background = background, - name = self.name, + title = self.title, timeout = self._timeout * 10) cfg += "menu separator\n" diff --git a/tools/livecd-creator b/tools/livecd-creator index d997095..6b2c799 100755 --- a/tools/livecd-creator +++ b/tools/livecd-creator @@ -42,6 +42,10 @@ def parse_options(args): help="Add packages to an existing live CD iso9660 image.") imgopt.add_option("-f", "--fslabel", type="string", dest="fslabel", help="File system label (default based on config name)") + imgopt.add_option("", "--title", type="string", dest="title", + help="Title used by syslinux.cfg file"), + imgopt.add_option("", "--product", type="string", dest="product", + help="Product name used in syslinux.cfg boot stanzas and countdown"), # Provided for img-create compatibility imgopt.add_option("-n", "--name", type="string", dest="fslabel", help=optparse.SUPPRESS_HELP) @@ -142,13 +146,32 @@ def main(): logging.info("Using label '%s' and name '%s'" % (fslabel, name)) + if options.title: + title = options.title + else: + try: + title = " ".join(name.split("-")[:2]) + title = title.title() + except: + title = "Linux" + if options.product: + product = options.product + else: + try: + product = " ".join(name.split("-")[:2]) + product = product.title() + except: + product = "Linux" + logging.info("Using title '%s' and product '%s'" % (title, product)) + ks = imgcreate.read_kickstart(options.kscfg) if options.image_type == 'livecd': creator = imgcreate.LiveImageCreator(ks, name, fslabel=fslabel, releasever=options.releasever, - tmpdir=os.path.abspath(options.tmpdir)) + tmpdir=os.path.abspath(options.tmpdir), + title=title, product=product) elif options.image_type == 'image': creator = imgcreate.LoopImageCreator(ks, name, fslabel=fslabel, commit 7a90b7e306b96e1fa1a4091c61f734d7d921d6ef Author: Brian C. Lane <[email protected]> Date: Wed Aug 31 14:45:02 2011 -0700 Skip bind mounts when source isn't there When running on a system w/o SELinux enabled the selinux bind mount fails. Instead just skip them if the source of the mount isn't present in the host system. diff --git a/imgcreate/creator.py b/imgcreate/creator.py index 0492c81..deb9d95 100644 --- a/imgcreate/creator.py +++ b/imgcreate/creator.py @@ -500,7 +500,10 @@ class ImageCreator(object): ("/dev/pts", None), ("/dev/shm", None), (self.__selinux_mountpoint, self.__selinux_mountpoint), (cachesrc, "/var/cache/yum")]: - self.__bindmounts.append(BindChrootMount(f, self._instroot, dest)) + if os.path.exists(f): + self.__bindmounts.append(BindChrootMount(f, self._instroot, dest)) + else: + logging.warn("Skipping (%s,%s) because source doesn't exist." % (f, dest)) self._do_bindmounts() commit ab889bf22a2dad7e1afc8be352292b9c352f92ea Author: Brian C. Lane <[email protected]> Date: Wed Aug 31 10:43:13 2011 -0700 Add new syslinux.cfg template (#734173) Move basicvideo and xdriver into extra argument Add help section to kernel stanzas Move basic and check into troubleshooting menu diff --git a/imgcreate/live.py b/imgcreate/live.py index 6ad9c5b..f7d3be8 100755 --- a/imgcreate/live.py +++ b/imgcreate/live.py @@ -455,21 +455,34 @@ class x86LiveImageCreator(LiveImageCreatorBase): return """ default %(menu)s timeout %(timeout)d - -%(background)s -menu title Welcome to %(name)s! -menu color border 0 #ffffffff #00000000 -menu color sel 7 #ffffffff #ff000000 -menu color title 0 #ffffffff #00000000 -menu color tabmsg 0 #ffffffff #00000000 -menu color unsel 0 #ffffffff #00000000 -menu color hotsel 0 #ff000000 #ffffffff -menu color hotkey 7 #ffffffff #ff000000 -menu color timeout_msg 0 #ffffffff #00000000 -menu color timeout 0 #ffffffff #00000000 -menu color cmdline 0 #ffffffff #00000000 -menu hidden -menu hiddenrow 5 +menu background %(background)s +menu autoboot Starting %(name)s in # second{,s}. Press any key to interrupt. + +menu clear +menu title @PRODUCT@ @VERSION@ +menu vshift 8 +menu rows 18 +menu margin 8 +#menu hidden +menu helpmsgrow 15 +menu tabmsgrow 13 + +menu color border * #00000000 #00000000 none +menu color sel 0 #ffffffff #00000000 none +menu color title 0 #ff7ba3d0 #00000000 none +menu color tabmsg 0 #ff3a6496 #00000000 none +menu color unsel 0 #84b8ffff #00000000 none +menu color hotsel 0 #84b8ffff #00000000 none +menu color hotkey 0 #ffffffff #00000000 none +menu color help 0 #ffffffff #00000000 none +menu color scrollbar 0 #ffffffff #ff355594 none +menu color timeout 0 #ffffffff #00000000 none +menu color timeout_msg 0 #ffffffff #00000000 none +menu color cmdmark 0 #84b8ffff #00000000 none +menu color cmdline 0 #ffffffff #00000000 none + +menu tabmsg Press Tab for full configuration options on menu items. +menu separator """ % args def __get_image_stanza(self, is_xen, isDracut, **args): @@ -482,13 +495,18 @@ menu hiddenrow 5 template = """label %(short)s menu label %(long)s kernel vmlinuz%(index)s - append initrd=initrd%(index)s.img root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(xdriver)s %(extra)s + append initrd=initrd%(index)s.img root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s """ else: template = """label %(short)s menu label %(long)s kernel mboot.c32 - append xen%(index)s.gz --- vmlinuz%(index)s root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(xdriver)s %(extra)s --- initrd%(index)s.img + append xen%(index)s.gz --- vmlinuz%(index)s root=%(rootlabel)s rootfstype=%(isofstype)s %(liveargs)s %(extra)s --- initrd%(index)s.img +""" + if args.get("help"): + template += """ text help + %(help)s + endtext """ return template % args @@ -503,7 +521,10 @@ menu hiddenrow 5 checkisomd5 = self._has_checkisomd5() - cfg = "" + # Stanzas for insertion into the config template + linux = [] + basic = [] + check = [] index = "0" for version in versions: @@ -514,16 +535,11 @@ menu hiddenrow 5 default = self.__is_default_kernel(kernel, kernels) if default: - long = "Boot" + long = "" elif kernel.startswith("kernel-"): - long = "Boot %s(%s)" % (self.name, kernel[7:]) + long = "%s(%s)" % (self.name, kernel[7:]) else: - long = "Boot %s(%s)" % (self.name, kernel) - - # Basic video driver - basic = "system with basic video driver" - xdriver = "xdriver=vesa nomodeset" - + long = "%s(%s)" % (self.name, kernel) # tell dracut not to ask for LUKS passwords or activate mdraid sets if isDracut: @@ -531,46 +547,45 @@ menu hiddenrow 5 else: kern_opts = kernel_options - cfg += self.__get_image_stanza(is_xen, isDracut, + linux.append(self.__get_image_stanza(is_xen, isDracut, fslabel = self.fslabel, isofstype = "auto", liveargs = kern_opts, - long = long, + long = "^Start " + long, short = "linux" + index, - basicvideo = "", - xdriver = "", extra = "", - index = index) + help = "", + index = index)) if default: - cfg += "menu default\n" + linux[-1] += " menu default\n" - cfg += self.__get_image_stanza(is_xen, isDracut, + basic.append(self.__get_image_stanza(is_xen, isDracut, fslabel = self.fslabel, isofstype = "auto", liveargs = kern_opts, - long = long + " (Basic Video)", - short = "linux" + index, - basicvideo = basic, - xdriver = xdriver, - extra = "", - index = index) + long = "Start " + long + " in ^basic graphics mode.", + short = "basic" + index, + extra = "xdriver=vesa nomodeset", + help = "Try this option out if you're having trouble starting.", + index = index)) if checkisomd5: - cfg += self.__get_image_stanza(is_xen, isDracut, + check.append(self.__get_image_stanza(is_xen, isDracut, fslabel = self.fslabel, isofstype = "auto", liveargs = kern_opts, - long = "Verify and " + long, - short = "rd.live.check" + index, - basicvideo = "", - xdriver = "", + long = "^Test this media & start " + long, + short = "check" + index, extra = "rd.live.check", - index = index) + help = "", + index = index)) + else: + check.append(None) index = str(int(index) + 1) - return cfg + return (linux, basic, check) def __get_memtest_stanza(self, isodir): memtest = glob.glob(self._instroot + "/boot/memtest86*") @@ -580,13 +595,18 @@ menu hiddenrow 5 shutil.copyfile(memtest[0], isodir + "/isolinux/memtest") return """label memtest - menu label Memory Test + menu label Run a ^memory test. + text help + If your system is having issues, an problem with your + system's memory may be the cause. Use this utility to + see if the memory is working correctly. + endtext kernel memtest """ def __get_local_stanza(self, isodir): return """label local - menu label Boot from local drive + menu label Boot from ^local drive localboot 0xffff """ @@ -601,18 +621,41 @@ menu hiddenrow 5 background = "" if self.__copy_syslinux_background(isodir + "/isolinux/splash.jpg"): - background = "menu background splash.jpg" + background = "splash.jpg" cfg = self.__get_basic_syslinux_config(menu = menu, background = background, name = self.name, timeout = self._timeout * 10) + cfg += "menu separator\n" + + linux, basic, check = self.__get_image_stanzas(isodir) + # Add linux stanzas to main menu + for s in linux: + cfg += s + cfg += "menu separator\n" + + cfg += """menu begin ^Troubleshooting + menu title Troubleshooting +""" + # Add basic video and check to submenu + for b, c in zip(basic, check): + cfg += b + if c: + cfg += c - cfg += self.__get_image_stanzas(isodir) cfg += self.__get_memtest_stanza(isodir) + cfg += "menu separator\n" + cfg += self.__get_local_stanza(isodir) cfg += self._get_isolinux_stanzas(isodir) + cfg += """menu separator +label returntomain + menu label Return to ^main menu. + menu exit +menu end +""" cfgf = open(isodir + "/isolinux/isolinux.cfg", "w") cfgf.write(cfg) cfgf.close() -- livecd mailing list [email protected] https://admin.fedoraproject.org/mailman/listinfo/livecd
