Commit 300ee8a8 authored by Alexey Shabalin's avatar Alexey Shabalin Committed by Anton Midyukov

add grub feature

parent adecafb3
insmod echo
insmod gzio
insmod minicmd
insmod normal
insmod test
set timeout=@timeout@
if [ $grub_cpu = x86_64 -o $grub_cpu = i386 ]; then
if [ $grub_platform = efi ]; then
linux_suffix=efi
elif [ $grub_platform = pc ]; then
linux_suffix=16
else
linux_suffix=
else
linux_suffix=
fi
default='linux'
menuentry 'Install ALT @relname@' --hotkey 'i' --id 'linux' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
}
menuentry 'Install ALT @relname@ (headless with DHCP+VNC client) (edit to set server IP address)' --id 'vncconnect' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncconnect=IP
initrd$linux_suffix /EFI/BOOT/full.cz
}
menuentry 'Install ALT @relname@ (headless with DHCP+VNC) (password VNCPWD)' --id 'vncpasswd' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD
initrd$linux_suffix /EFI/BOOT/full.cz
}
menuentry 'LiveCD (no hard disk needed)' --id 'live' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
}
menuentry 'LiveCD with sessions support' --id 'session' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
}
menuentry 'Rescue LiveCD' --id 'rescue' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
}
menuentry 'Rescue with sessions support' --id 'rescue_session' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom,label:ALT* ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@ live_rw
initrd$linux_suffix /EFI/BOOT/full.cz
}
menuentry 'Forensic mode (leave disks alone)' --id 'rescue_forensic' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ max_loop=16 forensic hash=@rescue_hash@
initrd$linux_suffix /EFI/BOOT/full.cz
}
menuentry 'Check this media for defects' --id 'mediachk' {
linux$linux_suffix /EFI/BOOT/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@
initrd$linux_suffix /EFI/BOOT/full.cz
}
menuentry 'Memory Test' --id 'memtest' {
linux$linux_suffix /EFI/BOOT/memtest86.efi
}
menuentry 'System setup' --id 'uefi-firmware' {
fwsetup
}
# default is plain text prompt
# NB: might be usbflash-ready hybrid iso
# on ppc64le syslinux feature is used only to generate config
#ifeq (,$(filter-out i586 x86_64 ppc64le aarch64,$(ARCH)))
ifeq (,$(filter-out i586 x86_64,$(ARCH)))
use/grub: sub/stage1 $(ISOHYBRID:%=use/isohybrid)
@$(call add_feature)
ifeq (,$(filter-out i586 x86_64,$(ARCH)))
@$(call add,STAGE1_PACKAGES,grub-efi shim-signed)
@$(call try,BOOTVGA,normal)
endif
@$(call set,RELNAME,ALT ($(IMAGE_NAME)))
@$(call set,IMAGE_PACKTYPE,boot)
else
use/grub: ; @:
endif
ifeq (,$(filter-out i586 x86_64,$(ARCH)))
# UI is overwritten
use/grub/ui/%: use/grub
@$(call set,GRUB_UI,$*)
@if [ "$*" == gfxboot ]; then \
$(call add,STAGE1_PACKAGES,gfxboot); \
$(call add,STAGE1_BRANDING,bootloader); \
fi
else
use/grub/ui/%: use/grub; @:
endif
use/grub/%.cfg: use/grub
@$(call add,GRUB_CFG,$*)
use/grub/timeout/%: use/grub
@$(call set,GRUB_TIMEOUT,$*)
ifdef BUILDDIR
# in deciseconds
DEFAULT_TIMEOUT = 90
# prepare data for grub installation;
# see also stage1/scripts.d/01-grub
include $(BUILDDIR)/distcfg.mk
ifndef BOOTLOADER
$(error grub feature enabled but BOOTLOADER undefined)
endif
ifndef GRUB_DIRECT
# SUBPROFILES are considered GRUB_CFG too
# (note these can appear like stage2@live);
# 01defaults.cfg is included indefinitely
GRUB_CFG := $(GRUB_CFG) $(SUBPROFILE_DIRS) defaults
endif
DSTDIR := $(BUILDDIR)/stage1/files/EFI/BOOT/.in
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),' \
-e 's,@relname@,$(RELNAME),' \
$(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
@if [ -n "$(META_VOL_SET)" ]; then \
DISTRO="$(META_VOL_SET)"; \
else \
DISTRO="ALT"; \
fi; \
sed -i "s,@distro@,$$DISTRO," $(DSTCFGS)
# pass over additional parameters, if any
bootargs: clean
@if [ -n "$(STAGE2_BOOTARGS)" ]; then \
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)
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
endif
#!/bin/sh
# postprocess isolinux configuration
# when the image sizes are finally known
# NB: install2_size, live_size, rescue_size get defined here
cd "$WORKDIR"
cfgs="$(find EFI/BOOT -name '*.cfg')"
[ -n "$cfgs" ] || {
echo "${0##*/}: did not find any config under EFI/BOOT " >&2
exit 1
}
# apply size census while looking for potential squashfs images
find -maxdepth 1 -type f -size +1M \
| sed 's,^\./,,' \
| while read image; do
size="$[ $(stat -c%s "$image") / 1024 + 1 ]"
sed -i "s,@${image}_size@,$size," $cfgs
done
#!/bin/sh
# postprocess isolinux configuration
# to add rescue image hash, if any
# (for propagator in forensic mode)
cd "$WORKDIR"
grep -qs "@rescue_hash@" EFI/BOOT/*.cfg || exit 0
find -maxdepth 1 -type f -name rescue \
| while read image; do
rescue_hash="$(sha256sum -b "$image" | cut -f1 -d' ')"
sed -i "s,@rescue_hash@,$rescue_hash," EFI/BOOT/*.cfg
done
#!/bin/sh
# gather syslinux configuration from snippets;
# copy modules; see also this feature's generate.mk
CFG="grub.cfg"
mkdir -p "$WORKDIR/EFI/BOOT"
cd "$WORKDIR/EFI/BOOT"
# validate just in case (see also stage1 Makefile)
case "$GLOBAL_BOOTLOADER" in
isolinux|syslinux|ieee1275boot|grubaa64boot|grubx86boot) ;;
*) echo "error: weird GLOBAL_BOOTLOADER: \`$GLOBAL_BOOTLOADER'" >&2;
exit 1;;
esac
# copy extra files, if any
GRUB_FILES="$(cat .in/grub.list)"
if [ -n "${GRUB_FILES% }" ]; then
cp -a $GRUB_FILES .
fi
# number ordering sponsored by shell's pathname expansion
grep -hv '^#' .in/[0-9][0-9]*.cfg > "$CFG"
# there should be DEFAULT directive there (at least for alterator-netinst)
if ! grep -i '^default' "$CFG"; then
DEFAULT="$(grep -i '^label ' "$CFG" | head -1 | cut -f2 -d' ')"
if [ -n "$DEFAULT" ]; then
echo "default $DEFAULT" >> "$CFG"
else
echo "error: no DEFAULT or UI directive and cannot guess" >&2
exit 1
fi
fi
# snippets are not going into the actual image
if [ "$DEBUG" != 2 ]; then rm -r .in/; fi
# NB: there will be final macro expansion based on actual image sizes
# done by features.in/syslinux/scripts.d/20-propagator-ramdisk
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment