Openembedded Core Discussions
 help / color / mirror / Atom feed
From: Saul Wold <sgw@linux.intel.com>
To: Jason Wessel <jason.wessel@windriver.com>
Cc: Openembedded-core@lists.openembedded.org
Subject: Re: [PATCH] syslinux.bbclass: Add a default serial console option and real boot menu support
Date: Wed, 27 Feb 2013 17:52:33 -0800	[thread overview]
Message-ID: <512EB861.1050504@linux.intel.com> (raw)
In-Reply-To: <1361930646-10689-1-git-send-email-jason.wessel@windriver.com>

On 02/26/2013 06:04 PM, Jason Wessel wrote:
> The previous syslinux menu code did not support using both a serial
> and vga console, but this has worked for years in syslinux so there is
> no reason not to take advantage of it.  The previous menu looked like:
>
> -------------------------------------------------------
> Linux Boot Menu
> The following targets are available on this image:
>
>               boot: None
>               install: None
> -------------------------------------------------------
>
> This commit makes it look something more like a traditional grub menu
> on both the serial console and vga console as well as providing the
> option to continue on using either the serial or vga console with the
> correct kernel arguments.
>
> You can see the screen shots attached to the bugzilla.
>
> https://bugzilla.yoctoproject.org/show_bug.cgi?id=3944
>
> [ YOCTO #3944 ]
>
> Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
> ---
>   meta/classes/syslinux.bbclass |  128 ++++++++++++++++-------------------------
>   1 files changed, 49 insertions(+), 79 deletions(-)
>
> diff --git a/meta/classes/syslinux.bbclass b/meta/classes/syslinux.bbclass
> index c4596bf..c6a5a15 100644
> --- a/meta/classes/syslinux.bbclass
> +++ b/meta/classes/syslinux.bbclass
> @@ -11,15 +11,17 @@
>   # ${LABELS} - a list of targets for the automatic config
>   # ${APPEND} - an override list of append strings for each label
>   # ${SYSLINUX_OPTS} - additional options to add to the syslinux file ';' delimited
> +# ${SYSLINUX_SPLASH} - A background for the vga boot menu if using the boot menu
> +# ${SYSLINUX_SERIAL} - Set an alternate serial port or turn off serial with empty string
>
>   do_bootimg[depends] += "syslinux:do_populate_sysroot \
>                           syslinux-native:do_populate_sysroot"
>
>   SYSLINUXCFG  = "${S}/syslinux.cfg"
> -SYSLINUXMENU = "${S}/menu"
>
>   ISOLINUXDIR = "/isolinux"
>   SYSLINUXDIR = "/"
> +SYSLINUX_SERIAL ?= "0 115200"
>   ISO_BOOTIMG = "isolinux/isolinux.bin"
>   ISO_BOOTCAT = "isolinux/boot.cat"
>   MKISOFS_OPTIONS = "-no-emul-boot -boot-load-size 4 -boot-info-table"
> @@ -34,82 +36,34 @@ syslinux_populate() {
>
>   	# Install the config files
>   	install -m 0644 ${SYSLINUXCFG} ${DEST}${BOOTDIR}/${CFGNAME}
> -	if [ -f ${SYSLINUXMENU} ]; then
> -		install -m 0644 ${SYSLINUXMENU} ${DEST}${BOOTDIR}
> -	fi
>   }
>
>   syslinux_iso_populate() {
>   	syslinux_populate ${ISODIR} ${ISOLINUXDIR} isolinux.cfg
>   	install -m 0644 ${STAGING_LIBDIR}/syslinux/isolinux.bin ${ISODIR}${ISOLINUXDIR}
> +	if [ x${AUTO_SYSLINUXMENU} = x1 ] ; then
I believe that the convention is for these string tests to be quoted, 
here and below.

> +		install -m 0644 ${STAGING_DIR}/${MACHINE}/usr/share/syslinux/vesamenu.c32 ${ISODIR}${ISOLINUXDIR}/vesamenu.c32
> +		if [ x${SYSLINUX_SPLASH} != x ] ; then
> +			install -m 0644 ${SYSLINUX_SPLASH} ${ISODIR}${ISOLINUXDIR}/splash.lss
> +		fi
> +	fi
>   }
>
>   syslinux_hddimg_populate() {
>   	syslinux_populate ${HDDDIR} ${SYSLINUXDIR} syslinux.cfg
>   	install -m 0444 ${STAGING_LIBDIR}/syslinux/ldlinux.sys ${HDDDIR}${SYSLINUXDIR}/ldlinux.sys
> +	if [ x${AUTO_SYSLINUXMENU} = x1 ] ; then
> +		install -m 0644 ${STAGING_DIR}/${MACHINE}/usr/share/syslinux/vesamenu.c32 ${HDDDIR}${SYSLINUXDIR}/vesamenu.c32
> +		if [ x${SYSLINUX_SPLASH} != x ] ; then
> +			install -m 0644 ${SYSLINUX_SPLASH} ${HDDDIR}${SYSLINUXDIR}/splash.lss
> +		fi
> +	fi
>   }
>
>   syslinux_hddimg_install() {
>   	syslinux ${DEPLOY_DIR_IMAGE}/${IMAGE_NAME}.hddimg
>   }
>
> -python build_syslinux_menu () {
> -    import copy
> -    import sys
> -
> -    workdir = d.getVar('WORKDIR', True)
> -    if not workdir:
> -        bb.error("WORKDIR is not defined")
> -        return
> -
> -    labels = d.getVar('LABELS', True)
> -    if not labels:
> -        bb.debug(1, "LABELS not defined, nothing to do")
> -        return
> -
> -    if labels == []:
> -        bb.debug(1, "No labels, nothing to do")
> -        return
> -
> -    cfile = d.getVar('SYSLINUXMENU', True)
> -    if not cfile:
> -        raise bb.build.FuncFailed('Unable to read SYSLINUXMENU')
> -
> -    try:
> -        cfgfile = file(cfile, 'w')
> -    except OSError:
> -        raise bb.build.funcFailed('Unable to open %s' % (cfile))
> -
> -    # Beep the speaker and Clear the screen
> -    cfgfile.write('\x07\x0C')
> -
> -    # The title should be configurable
> -    cfgfile.write('Linux Boot Menu\n')
> -    cfgfile.write('The following targets are available on this image:\n')
> -    cfgfile.write('\n')
> -
> -    for label in labels.split():
> -        from copy import deepcopy
> -        localdata = deepcopy(d)
> -
> -        overrides = localdata.getVar('OVERRIDES')
> -        if not overrides:
> -            raise bb.build.FuncFailed('OVERRIDES not defined')
> -        overrides = localdata.expand(overrides)
> -
> -        localdata.setVar('OVERRIDES', label + ':' + overrides)
> -        bb.data.update_data(localdata)
> -
> -        usage = localdata.getVar('USAGE', True)
> -        cfgfile.write('  \x0F\x30\x3E%16s\x0F\x30\x37: ' % (label))
> -        cfgfile.write('%s\n' % (usage))
> -
> -        del localdata
> -
> -    cfgfile.write('\n')
> -    cfgfile.close()
> -}
> -
>   python build_syslinux_cfg () {
>       import copy
>       import sys
> @@ -146,7 +100,16 @@ python build_syslinux_cfg () {
>               cfgfile.write('%s\n' % opt)
>
>       cfgfile.write('ALLOWOPTIONS 1\n');
> -    cfgfile.write('DEFAULT %s\n' % (labels.split()[0]))
> +    syslinux_serial = d.getVar('SYSLINUX_SERIAL', True)
> +    if syslinux_serial:
> +        cfgfile.write('SERIAL %s\n' % syslinux_serial)
> +
> +    menu = d.getVar('AUTO_SYSLINUXMENU', True)
> +
> +    if menu and syslinux_serial:
> +        cfgfile.write('DEFAULT Graphics console %s\n' % (labels.split()[0]))
> +    else:
> +        cfgfile.write('DEFAULT %s\n' % (labels.split()[0]))
>
>       timeout = d.getVar('SYSLINUX_TIMEOUT', True)
>
> @@ -161,14 +124,13 @@ python build_syslinux_cfg () {
>       else:
>           cfgfile.write('PROMPT 1\n')
>
> -    menu = d.getVar('AUTO_SYSLINUXMENU', True)
> -
> -    # This is ugly.  My bad.
> -
>       if menu:
> -        bb.build.exec_func('build_syslinux_menu', d)
> -        mfile = d.getVar('SYSLINUXMENU', True)
> -        cfgfile.write('DISPLAY %s\n' % (mfile.split('/')[-1]) )
> +        cfgfile.write('ui vesamenu.c32\n')
> +        cfgfile.write('menu title Select kernel options and boot kernel\n')
> +        cfgfile.write('menu tabmsg Press [Tab] to edit, [Return] to select\n')
> +        splash = d.getVar('SYSLINUX_SPLASH', True)
> +        if splash:
> +            cfgfile.write('menu background splash.lss\n')
>
>       for label in labels.split():
>           localdata = bb.data.createCopy(d)
> @@ -176,24 +138,32 @@ python build_syslinux_cfg () {
>           overrides = localdata.getVar('OVERRIDES', True)
>           if not overrides:
>               raise bb.build.FuncFailed('OVERRIDES not defined')
> -
> +
>           localdata.setVar('OVERRIDES', label + ':' + overrides)
>           bb.data.update_data(localdata)
>
> -        cfgfile.write('LABEL %s\nKERNEL /vmlinuz\n' % (label))
> +        btypes = [ [ "", "console=tty0" ] ]
> +        if menu and syslinux_serial:
> +            btypes = [ [ "Graphics console ", " console=tty0" ],
> +                [ "Serial console ",  " console=ttyS0,115200" ] ]
> +
> +        for btype in btypes:
> +            cfgfile.write('LABEL %s%s\nKERNEL /vmlinuz\n' % (btype[0], label))
>
> -        append = localdata.getVar('APPEND', True)
> -        initrd = localdata.getVar('INITRD', True)
> +            append = localdata.getVar('APPEND', True)
> +            initrd = localdata.getVar('INITRD', True)
>
> -        if append:
> -            cfgfile.write('APPEND ')
> +            if append:
> +                cfgfile.write('APPEND ')
>
> -            if initrd:
> -                cfgfile.write('initrd=/initrd ')
> +                if initrd:
> +                    cfgfile.write('initrd=/initrd ')
>
> -            cfgfile.write('LABEL=%s '% (label))
> +                cfgfile.write('LABEL=%s '% (label))
>
> -            cfgfile.write('%s\n' % (append))
> +                cfgfile.write('%s %s\n' % (append, btype[1]))
> +            else:
> +                cfgfile.write('APPEND %s\n' % btype[1])
>
>       cfgfile.close()
>   }
>



  parent reply	other threads:[~2013-02-28  2:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-27  2:04 [PATCH] syslinux.bbclass: Add a default serial console option and real boot menu support Jason Wessel
2013-02-27 11:51 ` Trevor Woerner
2013-02-27 12:08   ` Jason Wessel
2013-02-28  1:52 ` Saul Wold [this message]
2013-03-04 22:01   ` Jason Wessel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=512EB861.1050504@linux.intel.com \
    --to=sgw@linux.intel.com \
    --cc=Openembedded-core@lists.openembedded.org \
    --cc=jason.wessel@windriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox