[Buildroot] [PATCH v3 2/7] boot/grub2: add support to build multiple Grub2 configurations in the same build

Yann E. MORIN yann.morin.1998 at free.fr
Thu Oct 7 09:53:26 UTC 2021


Köry, All,

On 2021-10-07 10:23 +0200, Köry Maincent spake thusly:
> On Wed, 6 Oct 2021 20:11:04 +0200
> "Yann E. MORIN" <yann.morin.1998 at free.fr> wrote:
> > On 2021-09-23 17:57 +0200, Kory Maincent spake thusly:
> > [--SNIP--]
> > > We can no longer use autotools-package as a consequence of this
> > > multi-build, and we have to resort to generic-package and a partial
> > > duplication of the autotools-infra. Grub2 was already using custom option
> > > like --prefix or --exec-prefix so this won't add much more weirdness.  
> > But this had an unfortunate side effect: the grub2 tools, like
> > grub-editenv, enabled with BR2_TARGET_GRUB2_INSTALL_TOOLS, are no
> > longer installed in the target now.
> Doh, didn't thought of that!

Neither did I...

[--SNIP--]
> > Care to look into that, please?
> 
> mmh that's tricky, because in the case we want to use the Grub modules it need
> to be generated for each platforms.
> For example we can face a case where we will have these three Grub modules
> repositories for each platform:
> target/lib/grub/i386-pc/
> target/lib/grub/i386-efi/
> target/lib/grub/x86_64-efi/
> 
> What about just adding the "make install" command in the foreach loop?
> This will overwrite the binaries, the locale and the /etc configurations for
> each "make" loop but we will have all the Grub modules repositories. I don't
> think the overwrites will cause issues because it is just tools.

I was thinking about something along the lines of:

    diff --git a/boot/grub2/grub2.mk b/boot/grub2/grub2.mk
    index e01ebb2edb..bb853cace6 100644
    --- a/boot/grub2/grub2.mk
    +++ b/boot/grub2/grub2.mk
    @@ -127,6 +127,9 @@ GRUB2_TUPLES-$(BR2_TARGET_GRUB2_ARM64_EFI) +=
    arm64-efi
     HOST_GRUB2_CONF_ENV = \
        CPP="$(HOSTCC) -E"
     
    +# Main build: only build tools
    +GRUB2_CONF_OPTS = --with-platform=none --blabla...
    +
     GRUB2_CONF_ENV = \
        CPP="$(TARGET_CC) -E" \
        TARGET_CC="$(TARGET_CC)" \
    @@ -147,7 +150,7 @@ HOST_GRUB2_CONF_OPTS = \
        --enable-libzfs=no \
        --disable-werror
     
    -define GRUB2_CONFIGURE_CMDS
    +define GRUB2_CONFIGURE_CMDS_PTF
        $(foreach tuple, $(GRUB2_TUPLES-y), \
            mkdir -p $(@D)/build-$(tuple) ; \
            cd $(@D)/build-$(tuple) ; \
    @@ -169,14 +172,16 @@ define GRUB2_CONFIGURE_CMDS
                --disable-werror
        )
     endef
    +GRUB2_POST_CONFIGURE_HOOKS += GRUB2_CONFIGURE_CMDS_PTF
     
    -define GRUB2_BUILD_CMDS
    +define GRUB2_BUILD_CMDS_PTF
        $(foreach tuple, $(GRUB2_TUPLES-y), \
            $(TARGET_MAKE_ENV) $(MAKE) -C $(@D)/build-$(tuple)
        )
     endef
    +GRUB2_POST_BUILD_HOOKS += GRUB2_BUILD_CMDS_PTF
     
    -define GRUB2_INSTALL_IMAGES_CMDS
    +define GRUB2_INSTALL_IMAGES_CMDS_PTF
        $(foreach tuple, $(GRUB2_TUPLES-y), \
            mkdir -p $(dir $(GRUB2_IMAGE_$(tuple))) ; \
            $(HOST_DIR)/usr/bin/grub-mkimage \
    @@ -194,6 +199,7 @@ define GRUB2_INSTALL_IMAGES_CMDS
            ) \
        )
     endef
    +GRUB2_POST_INSTALL_IMAGES_HOOKS += GRUB2_INSTALL_IMAGES_CMDS_PTF
     
    -$(eval $(generic-package))
    +$(eval $(autotools-package))
     $(eval $(host-autotools-package))

By using --with-platform=none in the main CONF_OPTS, we should be able
to disable building any of the "images", and just build the tools.

Totally untested, of course...

Alternatively, we could introduce a new package, grub2-tools, not unlike
uboot-tools, which sole responsibility would be to build and install
those tools.

Regards,
Yann E. MORIN.

> Regards,
> 
> Köry

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'


More information about the buildroot mailing list