[LEDE-DEV] [PATCH] x86: image: avoid duplicating some ops by using Image/Prepare/grub2
Felix Fietkau
nbd at nbd.name
Tue Mar 14 08:29:57 PDT 2017
On 2017-03-13 00:00, Rafał Miłecki wrote:
> From: Rafał Miłecki <rafal at milecki.pl>
>
> These commands aren't root filesystem image specific so it's OK to
> execute them just once. It saves some time when building images.
>
> Signed-off-by: Rafał Miłecki <rafal at milecki.pl>
> ---
> target/linux/x86/image/Makefile | 50 +++++++++++++++++++++--------------------
> 1 file changed, 26 insertions(+), 24 deletions(-)
>
> diff --git a/target/linux/x86/image/Makefile b/target/linux/x86/image/Makefile
> index f34788d67b..8a153e6392 100644
> --- a/target/linux/x86/image/Makefile
> +++ b/target/linux/x86/image/Makefile
> @@ -51,6 +51,32 @@ ifneq ($(CONFIG_TARGET_x86_xen_domu),)
> GRUB_ROOT = xen/xvda,msdos1
> endif
>
> +define Image/Prepare/grub2
> + $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2
> + $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz
> +
> + grub-mkimage \
> + -p /boot/grub \
> + -d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
> + -o $(KDIR)/grub2/core.img \
> + -O i386-pc \
> + -c ./grub-early.cfg \
> + $(GRUB2_MODULES)
> + $(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/grub2/
> +
> + grub-mkimage \
> + -p /boot/grub \
> + -d $(STAGING_DIR_HOST)/lib/grub/i386-pc \
> + -o $(KDIR)/grub2/eltorito.img \
> + -O i386-pc \
> + -c ./grub-early.cfg \
> + $(GRUB2_MODULES_ISO)
> + cat \
> + $(STAGING_DIR_HOST)/lib/grub/i386-pc/cdboot.img \
> + $(KDIR)/grub2/eltorito.img \
> + > $(KDIR)/root.grub/boot/grub/eltorito.img
> +endef
But now you're executing the iso commands even if ISO images aren't
being used. Also, since you're making the code duplication painfully
obvious by moving the duplicated lines next to each other, maybe it's
time to address that as well ;)
- Felix
More information about the Lede-dev
mailing list