Openembedded Core Discussions
 help / color / mirror / Atom feed
* [PATCH 1/2] grub_git: extend recipe for proper target deployment
@ 2016-12-13 11:19 Awais Belal
  2016-12-13 11:19 ` [PATCH 2/2] grub-efi/live-vm-common: allow grub as EFI_PROVIDER Awais Belal
  2016-12-13 14:17 ` [PATCH 1/2] grub_git: extend recipe for proper target deployment Burton, Ross
  0 siblings, 2 replies; 4+ messages in thread
From: Awais Belal @ 2016-12-13 11:19 UTC (permalink / raw)
  To: openembedded-core

This extends the grub_git recipe so it can deploy grub
on the target boot disk just like grub-efi. Mainly
this copies stuff from the grub-efi recipe and then
adjusts some bits accordingly. This would allow
using the latest and greatest versions of grub
on the target.

Signed-off-by: Awais Belal <awais_belal@mentor.com>
---
 meta/recipes-bsp/grub/grub_git.bb | 60 +++++++++++++++++++++++++++++++++++----
 1 file changed, 54 insertions(+), 6 deletions(-)

diff --git a/meta/recipes-bsp/grub/grub_git.bb b/meta/recipes-bsp/grub/grub_git.bb
index eb824cc..86fa208 100644
--- a/meta/recipes-bsp/grub/grub_git.bb
+++ b/meta/recipes-bsp/grub/grub_git.bb
@@ -3,11 +3,15 @@ require grub2.inc
 DEFAULT_PREFERENCE = "-1"
 DEFAULT_PREFERENCE_arm = "1"
 
+DEPENDS_class-target += "grub-native"
+RDEPENDS_${PN}_class-target = "diffutils freetype"
+
 FILESEXTRAPATHS =. "${FILE_DIRNAME}/grub-git:"
 
 PV = "2.00+${SRCPV}"
 SRCREV = "7a5b301e3adb8e054288518a325135a1883c1c6c"
 SRC_URI = "git://git.savannah.gnu.org/grub.git \
+           file://cfg \
            file://0001-Disable-mfpmath-sse-as-well-when-SSE-is-disabled.patch \
            file://autogen.sh-exclude-pc.patch \
            file://0001-grub.d-10_linux.in-add-oe-s-kernel-name.patch \
@@ -19,29 +23,73 @@ COMPATIBLE_HOST = '(x86_64.*|i.86.*|arm.*|aarch64.*)-(linux.*|freebsd.*)'
 COMPATIBLE_HOST_armv7a = 'null'
 COMPATIBLE_HOST_armv7ve = 'null'
 
-inherit autotools gettext texinfo
+inherit autotools gettext texinfo deploy
 
 # configure.ac has code to set this automagically from the target tuple
 # but the OE freeform one (core2-foo-bar-linux) don't work with that.
-
 GRUBPLATFORM_arm = "uboot"
 GRUBPLATFORM_aarch64 = "efi"
 GRUBPLATFORM ??= "pc"
 
+CACHED_CONFIGUREVARS += "ac_cv_path_HELP2MAN="
 EXTRA_OECONF = "--with-platform=${GRUBPLATFORM} --disable-grub-mkfont --program-prefix="" \
                 --enable-liblzma=no --enable-device-mapper=no --enable-libzfs=no"
-
+EXTRA_OECONF += "${@bb.utils.contains('GRUBPLATFORM', 'efi', '--enable-efiemu=no', '', d)}"
 EXTRA_OECONF += "${@bb.utils.contains('DISTRO_FEATURES', 'largefile', '--enable-largefile', '--disable-largefile', d)}"
 
-do_install_append () {
+# Determine the target arch for the grub modules
+python __anonymous () {
+    import re
+    target = d.getVar('TARGET_ARCH', True)
+    platform = d.getVar('GRUBPLATFORM', True)
+    if target == "x86_64":
+        grubtarget = 'x86_64'
+        grubimage = "bootx64." + platform
+    elif re.match('i.86', target):
+        grubtarget = 'i386'
+        grubimage = "bootia32." + platform
+    elif re.match('arm', target):
+        grubtarget = 'arm'
+        grubimage = "bootarm." + platform
+    elif re.match('aarch64', target):
+        grubtarget = 'arm64'
+        grubimage = "bootaa64." + platform
+    else:
+        raise bb.parse.SkipPackage("grub is incompatible with target %s" % target)
+    d.setVar("GRUB_TARGET", grubtarget)
+    d.setVar("GRUB_IMAGE", grubimage)
+}
+
+do_install_class-native() {
+    install -d ${D}${bindir}
+    install -m 755 grub-mkimage ${D}${bindir}
+}
+
+do_install_append() {
     install -d ${D}${sysconfdir}/grub.d
     rm -rf ${D}${libdir}/charset.alias
 }
 
+GRUB_BUILDIN ?= "boot linux ext2 fat serial part_msdos part_gpt normal efi_gop iso9660 search"
+do_deploy() {
+    # Search for the grub.cfg on the local boot media by using the
+    # built in cfg file provided via this recipe
+    grub-mkimage -c ../cfg -p /EFI/BOOT -d ./grub-core/ \
+                   -O ${GRUB_TARGET}-${GRUBPLATFORM} -o ./${GRUB_IMAGE} \
+                   ${GRUB_BUILDIN}
+    install -m 644 ${B}/${GRUB_IMAGE} ${DEPLOYDIR}
+}
+
+do_deploy_class-native() {
+    :
+}
+
+addtask deploy after do_install before do_build
+
 # debugedit chokes on bare metal binaries
 INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
 
-RDEPENDS_${PN} = "diffutils freetype"
-
 INSANE_SKIP_${PN} = "arch"
 INSANE_SKIP_${PN}-dbg = "arch"
+
+BBCLASSEXTEND = "native"
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] grub-efi/live-vm-common: allow grub as EFI_PROVIDER
  2016-12-13 11:19 [PATCH 1/2] grub_git: extend recipe for proper target deployment Awais Belal
@ 2016-12-13 11:19 ` Awais Belal
  2016-12-13 14:17 ` [PATCH 1/2] grub_git: extend recipe for proper target deployment Burton, Ross
  1 sibling, 0 replies; 4+ messages in thread
From: Awais Belal @ 2016-12-13 11:19 UTC (permalink / raw)
  To: openembedded-core

This allows grub to be used as EFI_PROVIDER and
extends the grub-efi class so it can be used as is
when EFI_PROVIDER is grub.
Currently this can only be leveraged if you are
using the grub_git recipe and GRUBPLATFORM plus
EFI_PROVIDER are set correctly.

Signed-off-by: Awais Belal <awais_belal@mentor.com>
---
 meta/classes/grub-efi.bbclass       | 23 +++++++++++++++++------
 meta/classes/live-vm-common.bbclass |  2 +-
 2 files changed, 18 insertions(+), 7 deletions(-)

diff --git a/meta/classes/grub-efi.bbclass b/meta/classes/grub-efi.bbclass
index 17417ba..c847645 100644
--- a/meta/classes/grub-efi.bbclass
+++ b/meta/classes/grub-efi.bbclass
@@ -16,8 +16,8 @@
 # ${GRUB_TIMEOUT} - timeout before executing the deault label (optional)
 # ${GRUB_ROOT} - grub's root device.
 
-do_bootimg[depends] += "${MLPREFIX}grub-efi:do_deploy"
-do_bootdirectdisk[depends] += "${MLPREFIX}grub-efi:do_deploy"
+do_bootimg[depends] += "${MLPREFIX}${EFI_PROVIDER}:do_deploy"
+do_bootdirectdisk[depends] += "${MLPREFIX}${EFI_PROVIDER}:do_deploy"
 
 GRUB_SERIAL ?= "console=ttyS0,115200"
 GRUB_CFG_VM = "${S}/grub_vm.cfg"
@@ -40,10 +40,21 @@ efi_populate() {
 
 	install -d ${DEST}${EFIDIR}
 
-	GRUB_IMAGE="bootia32.efi"
-	if [ "${TARGET_ARCH}" = "x86_64" ]; then
-		GRUB_IMAGE="bootx64.efi"
-	fi
+    if [ "${EFI_PROVIDER}" = "grub" ]; then
+	    GRUB_IMAGE="bootia32.${GRUBPLATFORM}"
+	    if [ "${TARGET_ARCH}" = "x86_64" ]; then
+		    GRUB_IMAGE="bootx64.${GRUBPLATFORM}"
+	    elif [ "${TARGET_ARCH}" = "arm" ]; then
+            grubimage = "bootarm.${GRUBPLATFORM}"
+	    elif [ "${TARGET_ARCH}" = "aarch64" ]; then
+            grubimage = "bootaa64.${GRUBPLATFORM}"
+        fi
+    else
+        GRUB_IMAGE="bootia32.efi"
+	    if [ "${TARGET_ARCH}" = "x86_64" ]; then
+		    GRUB_IMAGE="bootx64.efi"
+        fi
+    fi
 	install -m 0644 ${DEPLOY_DIR_IMAGE}/${GRUB_IMAGE} ${DEST}${EFIDIR}
 	EFIPATH=$(echo "${EFIDIR}" | sed 's/\//\\/g')
 	printf 'fs0:%s\%s\n' "$EFIPATH" "$GRUB_IMAGE" >${DEST}/startup.nsh
diff --git a/meta/classes/live-vm-common.bbclass b/meta/classes/live-vm-common.bbclass
index 734697f..0af228b 100644
--- a/meta/classes/live-vm-common.bbclass
+++ b/meta/classes/live-vm-common.bbclass
@@ -13,7 +13,7 @@ def set_live_vm_vars(d, suffix):
 
 EFI = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "1", "0", d)}"
 EFI_PROVIDER ?= "grub-efi"
-EFI_CLASS = "${@bb.utils.contains("MACHINE_FEATURES", "efi", "${EFI_PROVIDER}", "", d)}"
+EFI_CLASS = "${@bb.utils.contains("EFI_PROVIDER", "grub", "grub-efi", "${EFI_PROVIDER}", d)}"
 
 # Include legacy boot if MACHINE_FEATURES includes "pcbios" or if it does not
 # contain "efi". This way legacy is supported by default if neither is
-- 
1.9.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] grub_git: extend recipe for proper target deployment
  2016-12-13 11:19 [PATCH 1/2] grub_git: extend recipe for proper target deployment Awais Belal
  2016-12-13 11:19 ` [PATCH 2/2] grub-efi/live-vm-common: allow grub as EFI_PROVIDER Awais Belal
@ 2016-12-13 14:17 ` Burton, Ross
  2016-12-14 13:29   ` Belal, Awais
  1 sibling, 1 reply; 4+ messages in thread
From: Burton, Ross @ 2016-12-13 14:17 UTC (permalink / raw)
  To: Awais Belal; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 335 bytes --]

On 13 December 2016 at 11:19, Awais Belal <awais_belal@mentor.com> wrote:

> +DEPENDS_class-target += "grub-native"
>

The native magic won't generate dependencies on itself, so this can just be
DEPENDS.


> +RDEPENDS_${PN}_class-target = "diffutils freetype"
>

Does this really need to be class-target-specific?

Ross

[-- Attachment #2: Type: text/html, Size: 1164 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] grub_git: extend recipe for proper target deployment
  2016-12-13 14:17 ` [PATCH 1/2] grub_git: extend recipe for proper target deployment Burton, Ross
@ 2016-12-14 13:29   ` Belal, Awais
  0 siblings, 0 replies; 4+ messages in thread
From: Belal, Awais @ 2016-12-14 13:29 UTC (permalink / raw)
  To: Burton, Ross; +Cc: OE-core

[-- Attachment #1: Type: text/plain, Size: 1112 bytes --]

Hi Ross,


>> +RDEPENDS_${PN}_class-target = "diffutils freetype"
> Does this really need to be class-target-specific?


Without the class-target override I get


ERROR: Nothing RPROVIDES 'diffutils-native' (but virtual:native:/data/amd_yocto/poky/meta/recipes-bsp/grub/grub_git.bb RDEPENDS on or otherwise requires it)


so I believe this is necessary in this case. Are you through your review? If so, just let me know and I'll send a v2 fixing the other DEPENDS issue you pointed out.


BR,
Awais
________________________________
From: Burton, Ross <ross.burton@intel.com>
Sent: Tuesday, December 13, 2016 7:17 PM
To: Belal, Awais
Cc: OE-core
Subject: Re: [OE-core] [PATCH 1/2] grub_git: extend recipe for proper target deployment


On 13 December 2016 at 11:19, Awais Belal <awais_belal@mentor.com<mailto:awais_belal@mentor.com>> wrote:
+DEPENDS_class-target += "grub-native"

The native magic won't generate dependencies on itself, so this can just be DEPENDS.

+RDEPENDS_${PN}_class-target = "diffutils freetype"

Does this really need to be class-target-specific?

Ross

[-- Attachment #2: Type: text/html, Size: 3042 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-14 13:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-12-13 11:19 [PATCH 1/2] grub_git: extend recipe for proper target deployment Awais Belal
2016-12-13 11:19 ` [PATCH 2/2] grub-efi/live-vm-common: allow grub as EFI_PROVIDER Awais Belal
2016-12-13 14:17 ` [PATCH 1/2] grub_git: extend recipe for proper target deployment Burton, Ross
2016-12-14 13:29   ` Belal, Awais

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox