2019-10-30 20:36:22 +03:00
i f d e f B U I L D D I R
2020-08-26 10:45:04 +03:00
# in seconds
DEFAULT_TIMEOUT = 60
2019-10-30 20:36:22 +03:00
# prepare data for grub installation;
# see also stage1/scripts.d/01-grub
i n c l u d e $( BUILDDIR ) / d i s t c f g . m k
i f n d e f B O O T L O A D E R
$( error grub feature enabled but BOOTLOADER undefined )
e n d i f
i f n d e f G R U B _ D I R E C T
# SUBPROFILES are considered GRUB_CFG too
# (note these can appear like stage2@live);
# 01defaults.cfg is included indefinitely
2020-01-10 21:56:52 +03:00
GRUB_CFG := $( GRUB_CFG) $( SUBPROFILE_DIRS) defaults fwsetup_efi
2019-10-30 20:36:22 +03:00
e n d i f
2020-03-11 19:37:32 +03:00
i f d e f G R U B _ U I
GRUB_CFG := $( GRUB_CFG) gfxterm
e n d i f
2020-03-03 16:50:43 +03:00
i f d e f L O C A L E
GRUB_CFG := $( GRUB_CFG) lang
e n d i f
2021-03-21 05:30:39 +03:00
i f n e q ( $( words $ ( KFLAVOURS ) ) , 1 )
GRUB_CFG := $( GRUB_CFG) kernel
e n d i f
2020-01-02 18:28:16 +03:00
DSTDIR := $( BUILDDIR) /stage1/files/boot/grub/.in
2019-10-30 20:36:22 +03:00
DSTCFGS := $( DSTDIR) /*.cfg
# we can do GRUB_{CFG,MODULES,FILES}
# CFG have only cfg snippet
cfg = $( wildcard cfg.in/??$( 1) .cfg)
# NB: list position determined by file numbering (*.cfg sorting)
#
# config snippets are copied into generated profile where they can
# be also tested against grub modules (some can be unavailable);
# we can't do tests right now since that implies host grub being
# identical to build system one which might be not the case...
#
# have to piggyback parameters as we're running in host system yet,
# and files involved will appear inside instrumental chroot
#
# arguments get evaluated before recipe body execution thus prep
all : debug timeout
@### proper text branding should be implemented
@echo $( GRUB_FILES) > $( DSTDIR) /grub.list
@sed -i \
-e 's,@mkimage-profiles@,$(IMAGE_NAME),' \
$( DSTCFGS)
# integerity check
timeout : distro
@if [ " $( GRUB_TIMEOUT) " -ge 0 ] 2>/dev/null; then \
TIMEOUT = " $( GRUB_TIMEOUT) " ; \
else \
TIMEOUT = " $( DEFAULT_TIMEOUT) " ; \
fi ; \
sed -i " s,@timeout@, $$ TIMEOUT, " $( DSTCFGS)
distro : bootargs
2021-01-27 15:06:07 +03:00
@if [ -n " $( META_VOL_ID) " ] ; then \
DISTRO = " $( META_VOL_ID) " ; \
2019-10-30 20:36:22 +03:00
else \
2021-01-27 15:06:07 +03:00
DISTRO = " $( RELNAME) " ; \
2019-10-30 20:36:22 +03:00
fi ; \
sed -i " s,@distro@, $$ DISTRO, " $( DSTCFGS)
# pass over additional parameters, if any
bootargs : clean
2020-12-03 20:52:11 +03:00
@if [ -n " $( EFI_BOOTARGS) " ] ; then \
2021-02-12 20:46:18 +03:00
sed -i " s,@efi_bootargs@, $( EFI_BOOTARGS) , " $( DSTCFGS) ; \
fi ; \
sed -i "s,@efi_bootargs@,," $( DSTCFGS)
2019-10-30 20:36:22 +03:00
@if [ -n " $( STAGE2_BOOTARGS) " ] ; then \
2021-02-12 20:46:18 +03:00
sed -i " s, $( STAGE2_BOOTARGS) ,, " $( DSTCFGS) ; \
2019-10-30 20:36:22 +03:00
sed -i " s,@bootargs@, $( STAGE2_BOOTARGS) , " $( DSTCFGS) ; \
fi ; \
sed -i "s,@bootargs@,," $( DSTCFGS)
@if [ -n " $( RESCUE_BOOTARGS) " ] ; then \
sed -i " s,@rescue_bootargs@, $( RESCUE_BOOTARGS) , " $( DSTCFGS) ; \
fi ; \
sed -i "s,@rescue_bootargs@,," $( DSTCFGS)
@if [ -n " $( BOOTVGA) " ] ; then \
sed -i " s,@bootvga@, $( BOOTVGA) , " $( DSTCFGS) ; \
fi ; \
sed -i "s,@bootvga@,,;s,vga= ,," $( DSTCFGS)
2020-03-03 16:50:43 +03:00
@if [ -n " $( LOCALE) " ] ; then \
sed -i " s,@LOCALE@, $( LOCALE) ,g " $( DSTCFGS) ; \
else \
sed -i "s, lang=.lang,,g" $( DSTCFGS) ; \
fi ; \
sed -i "/lang=@LOCALE@/d" $( DSTCFGS)
2020-03-20 09:34:50 +03:00
GRUBTHEME = $( GRUBTHEME) ; \
[ -n " $$ GRUBTHEME " ] || GRUBTHEME = $$ ( cut -d "-" -f2 <<< $( BRANDING) ) ; \
2021-01-21 21:41:08 +03:00
sed -i " s,@grubtheme@, $$ GRUBTHEME,g " $( DSTCFGS)
2021-03-29 09:28:43 +03:00
@if [ " $( STAGE1_INITRD) " = initrd-propagator ] ; then \
2021-03-22 20:28:29 +03:00
sed -i "s,@initrd@,full," $( DSTCFGS) ; \
sed -i "s,@initrd_ext@,cz," $( DSTCFGS) ; \
else \
sed -i "s,@initrd@,initrd," $( DSTCFGS) ; \
sed -i "s,@initrd_ext@,img," $( DSTCFGS) ; \
fi
2019-10-30 20:36:22 +03:00
clean : copy
@if [ " $( GRUB_UI) " = gfxboot ] ; then \
sed -i "s/\^//;/menu label /d" $( DSTCFGS) ; \
fi
copy : prep
@cp -pLt $( DSTDIR) -- $( sort \
$( foreach C,$( GRUB_CFG) ,$( call cfg,$( C) ) ) )
prep :
@mkdir -p $( DSTDIR)
debug :
@if [ -n " $( DEBUG) " ] ; then \
echo " ** BOOTLOADER: $( BOOTLOADER) " ; \
echo " ** GRUB_CFG: $( GRUB_CFG) " ; \
echo " ** GRUB_FILES: $( GRUB_FILES) " ; \
fi
e n d i f