ALT Linux Distributions development
 help / color / mirror / Atom feed
From: "Антон Мидюков" <midyukov-anton@ya.ru>
To: devel-distro@lists.altlinux.org
Subject: Re: [devel-distro] grub-efi в инсталяторе
Date: Sun, 12 Jan 2020 22:18:46 +0700
Message-ID: <de2000ac-e518-fad0-2a86-d655a7b47b5c@ya.ru> (raw)
In-Reply-To: <3e580857-e644-bc79-f860-2cabaa3badac@ya.ru>

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

09.01.2020 21:39, Антон Мидюков пишет:
> 09.01.2020 2:29, Антон Мидюков пишет:
>>
>> [...]
>>
>> 4. В mki-copy-efiboot для grub-efi ядро копировать в boot, если его 
>> ещё там нет. Аналогично для других EFI_BOOTLOADER проверять, есть ли 
>> уже ядро в EFI/BOOT, и если есть не копировать.
>>
> Копировать ядро в boot, видимо, плохая идея. В qemu грузится, на 
> железе же ядро не находит.
>> [...]
>
В связи с этим переделал задание 243937 (mkimage), всё хорошенько 
перепроверил и исправил очепятки.

Количество правок сократил. Убрал упоминание несуществующего grubx86boot.

Без патча 
0017-sub.in-stage1-call-copy-kernel-instead-of-copy-BOOTL.patch для 
mkimage-profiles будет работать по-старому.

Прошу аппрув для задания 243937 (mkimage).

Во вложении также патчи для mkimage-profiles. 
0000-add-grub-feature.patch -- патч shaba@, от которого я отталкивался.

-- 
С уважением, Антон Мидюков <antohami@altlinux.org>


[-- Attachment #2: 0000-add-grub-feature.patch --]
[-- Type: text/x-patch, Size: 14963 bytes --]

>From 29b94953c301bb59037c0a2c1e851a886fcbb5ab Mon Sep 17 00:00:00 2001
From: Alexey Shabalin <shaba@altlinux.org>
Date: Wed, 30 Oct 2019 20:36:22 +0300
Subject: [PATCH 01/23] add grub feature

---
 features.in/grub/cfg.in/00defaults.cfg        |  17 +++
 features.in/grub/cfg.in/20install2.cfg        |   6 ++
 .../grub/cfg.in/25install-vnc-connect.cfg     |   5 +
 .../grub/cfg.in/25install-vnc-listen.cfg      |   6 ++
 features.in/grub/cfg.in/30live.cfg            |   6 ++
 features.in/grub/cfg.in/32live_rw.cfg         |   4 +
 features.in/grub/cfg.in/80rescue.cfg          |   4 +
 features.in/grub/cfg.in/82rescue_rw.cfg       |   4 +
 features.in/grub/cfg.in/83rescue_fm.cfg       |   4 +
 features.in/grub/cfg.in/85mediacheck.cfg      |   4 +
 features.in/grub/cfg.in/90memtest.cfg         |   3 +
 features.in/grub/cfg.in/95fwsetup.cfg         |   3 +
 features.in/grub/config.mk                    |  39 +++++++
 features.in/grub/generate.mk                  | 100 ++++++++++++++++++
 .../grub/scripts.d/20-propagator-ramdisk      |  20 ++++
 .../grub/scripts.d/20-propagator-rescue-hash  |  14 +++
 features.in/grub/stage1/scripts.d/01-grub     |  41 +++++++
 17 files changed, 280 insertions(+)
 create mode 100644 features.in/grub/cfg.in/00defaults.cfg
 create mode 100644 features.in/grub/cfg.in/20install2.cfg
 create mode 100644 features.in/grub/cfg.in/25install-vnc-connect.cfg
 create mode 100644 features.in/grub/cfg.in/25install-vnc-listen.cfg
 create mode 100644 features.in/grub/cfg.in/30live.cfg
 create mode 100644 features.in/grub/cfg.in/32live_rw.cfg
 create mode 100644 features.in/grub/cfg.in/80rescue.cfg
 create mode 100644 features.in/grub/cfg.in/82rescue_rw.cfg
 create mode 100644 features.in/grub/cfg.in/83rescue_fm.cfg
 create mode 100644 features.in/grub/cfg.in/85mediacheck.cfg
 create mode 100644 features.in/grub/cfg.in/90memtest.cfg
 create mode 100644 features.in/grub/cfg.in/95fwsetup.cfg
 create mode 100644 features.in/grub/config.mk
 create mode 100644 features.in/grub/generate.mk
 create mode 100755 features.in/grub/scripts.d/20-propagator-ramdisk
 create mode 100755 features.in/grub/scripts.d/20-propagator-rescue-hash
 create mode 100755 features.in/grub/stage1/scripts.d/01-grub

diff --git a/features.in/grub/cfg.in/00defaults.cfg b/features.in/grub/cfg.in/00defaults.cfg
new file mode 100644
index 0000000000..4d469d4817
--- /dev/null
+++ b/features.in/grub/cfg.in/00defaults.cfg
@@ -0,0 +1,17 @@
+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
diff --git a/features.in/grub/cfg.in/20install2.cfg b/features.in/grub/cfg.in/20install2.cfg
new file mode 100644
index 0000000000..1da6304eb5
--- /dev/null
+++ b/features.in/grub/cfg.in/20install2.cfg
@@ -0,0 +1,6 @@
+
+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
+}
diff --git a/features.in/grub/cfg.in/25install-vnc-connect.cfg b/features.in/grub/cfg.in/25install-vnc-connect.cfg
new file mode 100644
index 0000000000..178e8fccd5
--- /dev/null
+++ b/features.in/grub/cfg.in/25install-vnc-connect.cfg
@@ -0,0 +1,5 @@
+
+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
+}
diff --git a/features.in/grub/cfg.in/25install-vnc-listen.cfg b/features.in/grub/cfg.in/25install-vnc-listen.cfg
new file mode 100644
index 0000000000..53b2b5119b
--- /dev/null
+++ b/features.in/grub/cfg.in/25install-vnc-listen.cfg
@@ -0,0 +1,6 @@
+
+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
+}
+
diff --git a/features.in/grub/cfg.in/30live.cfg b/features.in/grub/cfg.in/30live.cfg
new file mode 100644
index 0000000000..d53a1e506a
--- /dev/null
+++ b/features.in/grub/cfg.in/30live.cfg
@@ -0,0 +1,6 @@
+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
+}
+
+
diff --git a/features.in/grub/cfg.in/32live_rw.cfg b/features.in/grub/cfg.in/32live_rw.cfg
new file mode 100644
index 0000000000..55c4b977fe
--- /dev/null
+++ b/features.in/grub/cfg.in/32live_rw.cfg
@@ -0,0 +1,4 @@
+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
+}
diff --git a/features.in/grub/cfg.in/80rescue.cfg b/features.in/grub/cfg.in/80rescue.cfg
new file mode 100644
index 0000000000..c6c0ae53c9
--- /dev/null
+++ b/features.in/grub/cfg.in/80rescue.cfg
@@ -0,0 +1,4 @@
+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
+}
diff --git a/features.in/grub/cfg.in/82rescue_rw.cfg b/features.in/grub/cfg.in/82rescue_rw.cfg
new file mode 100644
index 0000000000..ec18be28bb
--- /dev/null
+++ b/features.in/grub/cfg.in/82rescue_rw.cfg
@@ -0,0 +1,4 @@
+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
+}
diff --git a/features.in/grub/cfg.in/83rescue_fm.cfg b/features.in/grub/cfg.in/83rescue_fm.cfg
new file mode 100644
index 0000000000..71bf21d3b7
--- /dev/null
+++ b/features.in/grub/cfg.in/83rescue_fm.cfg
@@ -0,0 +1,4 @@
+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
+}
diff --git a/features.in/grub/cfg.in/85mediacheck.cfg b/features.in/grub/cfg.in/85mediacheck.cfg
new file mode 100644
index 0000000000..6779dd00d3
--- /dev/null
+++ b/features.in/grub/cfg.in/85mediacheck.cfg
@@ -0,0 +1,4 @@
+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
+}
diff --git a/features.in/grub/cfg.in/90memtest.cfg b/features.in/grub/cfg.in/90memtest.cfg
new file mode 100644
index 0000000000..f4c2121687
--- /dev/null
+++ b/features.in/grub/cfg.in/90memtest.cfg
@@ -0,0 +1,3 @@
+menuentry 'Memory Test' --id 'memtest' {
+  linux$linux_suffix /EFI/BOOT/memtest86.efi
+}
diff --git a/features.in/grub/cfg.in/95fwsetup.cfg b/features.in/grub/cfg.in/95fwsetup.cfg
new file mode 100644
index 0000000000..52404efd28
--- /dev/null
+++ b/features.in/grub/cfg.in/95fwsetup.cfg
@@ -0,0 +1,3 @@
+menuentry 'System setup' --id 'uefi-firmware' {
+        fwsetup
+}
diff --git a/features.in/grub/config.mk b/features.in/grub/config.mk
new file mode 100644
index 0000000000..9f80822fa4
--- /dev/null
+++ b/features.in/grub/config.mk
@@ -0,0 +1,39 @@
+# 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,$*)
diff --git a/features.in/grub/generate.mk b/features.in/grub/generate.mk
new file mode 100644
index 0000000000..a0b59221a2
--- /dev/null
+++ b/features.in/grub/generate.mk
@@ -0,0 +1,100 @@
+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
diff --git a/features.in/grub/scripts.d/20-propagator-ramdisk b/features.in/grub/scripts.d/20-propagator-ramdisk
new file mode 100755
index 0000000000..c47302a769
--- /dev/null
+++ b/features.in/grub/scripts.d/20-propagator-ramdisk
@@ -0,0 +1,20 @@
+#!/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
diff --git a/features.in/grub/scripts.d/20-propagator-rescue-hash b/features.in/grub/scripts.d/20-propagator-rescue-hash
new file mode 100755
index 0000000000..fff0be0ce9
--- /dev/null
+++ b/features.in/grub/scripts.d/20-propagator-rescue-hash
@@ -0,0 +1,14 @@
+#!/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
diff --git a/features.in/grub/stage1/scripts.d/01-grub b/features.in/grub/stage1/scripts.d/01-grub
new file mode 100755
index 0000000000..620b8dac4b
--- /dev/null
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -0,0 +1,41 @@
+#!/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
-- 
2.24.1


[-- Attachment #3: 0001-grub-fix-typo.patch --]
[-- Type: text/x-patch, Size: 1001 bytes --]

>From d59e532386690265ce4bd1ed5af33562e4e02d7f Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 22:50:57 +0700
Subject: [PATCH 01/22] grub: fix typo

---
 features.in/grub/stage1/scripts.d/01-grub | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/features.in/grub/stage1/scripts.d/01-grub b/features.in/grub/stage1/scripts.d/01-grub
index 620b8dac4b..d331c0b016 100755
--- a/features.in/grub/stage1/scripts.d/01-grub
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -1,5 +1,5 @@
 #!/bin/sh
-# gather syslinux configuration from snippets;
+# gather grub configuration from snippets;
 # copy modules; see also this feature's generate.mk
 
 CFG="grub.cfg"
@@ -38,4 +38,4 @@ fi
 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
+#     done by features.in/grub/scripts.d/20-propagator-ramdisk
-- 
2.24.1


[-- Attachment #4: 0002-grub-fixed-search-default-in-stage1-scripts.d-01-gru.patch --]
[-- Type: text/x-patch, Size: 1293 bytes --]

>From 63c0b2e2da50c7e16cd7b70ed8a8268939ef4e50 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 20:34:52 +0700
Subject: [PATCH 02/22] grub: fixed search default in stage1/scripts.d/01-grub

The definition of the default menu item has been fixed.
Grub.cfg does not use label, uses --id.
It is assumed that --id is given last.
---
 features.in/grub/stage1/scripts.d/01-grub | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/features.in/grub/stage1/scripts.d/01-grub b/features.in/grub/stage1/scripts.d/01-grub
index d331c0b016..9f87292925 100755
--- a/features.in/grub/stage1/scripts.d/01-grub
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -24,10 +24,10 @@ fi
 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 ! grep -i '^default' .in/[0-9][0-9]*.cfg; then
+	DEFAULT="$(grep -i '\-\-id ' .in/[0-9][0-9]*.cfg | head -1 | rev| cut -f2 -d' ' |rev)"
 	if [ -n "$DEFAULT" ]; then
-		echo "default $DEFAULT" >> "$CFG"
+		echo "default=$DEFAULT" >> "$CFG"
 	else
 		echo "error: no DEFAULT or UI directive and cannot guess" >&2
 		exit 1
-- 
2.24.1


[-- Attachment #5: 0003-grub-generate-grub.cfg-for-grub-efi-ieee1275boot-and.patch --]
[-- Type: text/x-patch, Size: 12481 bytes --]

>From 675ebfb1fc1e7e1368980e160e05f98cbb8e152e Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Thu, 2 Jan 2020 22:28:16 +0700
Subject: [PATCH 03/22] grub: generate grub.cfg for grub-efi, ieee1275boot and
 grub-pc

---
 features.in/grub/cfg.in/20install2.cfg        |  6 +-
 .../grub/cfg.in/25install-vnc-connect.cfg     |  4 +-
 .../grub/cfg.in/25install-vnc-listen.cfg      |  4 +-
 features.in/grub/cfg.in/30live.cfg            |  4 +-
 features.in/grub/cfg.in/32live_rw.cfg         |  4 +-
 features.in/grub/cfg.in/80rescue.cfg          |  4 +-
 features.in/grub/cfg.in/82rescue_rw.cfg       |  4 +-
 features.in/grub/cfg.in/83rescue_fm.cfg       |  4 +-
 features.in/grub/cfg.in/85mediacheck.cfg      |  4 +-
 features.in/grub/generate.mk                  |  2 +-
 .../grub/scripts.d/20-propagator-ramdisk      | 10 ++--
 .../grub/scripts.d/20-propagator-rescue-hash  |  8 ++-
 features.in/grub/stage1/scripts.d/01-grub     | 60 ++++++++++++++-----
 13 files changed, 77 insertions(+), 41 deletions(-)

diff --git a/features.in/grub/cfg.in/20install2.cfg b/features.in/grub/cfg.in/20install2.cfg
index 1da6304eb5..373cd892fc 100644
--- a/features.in/grub/cfg.in/20install2.cfg
+++ b/features.in/grub/cfg.in/20install2.cfg
@@ -1,6 +1,6 @@
 
 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 @relname@' --hotkey 'i' --id 'linux' {
+  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@
+  initrd$linux_suffix @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/25install-vnc-connect.cfg b/features.in/grub/cfg.in/25install-vnc-connect.cfg
index 178e8fccd5..77cbee0e5c 100644
--- a/features.in/grub/cfg.in/25install-vnc-connect.cfg
+++ b/features.in/grub/cfg.in/25install-vnc-connect.cfg
@@ -1,5 +1,5 @@
 
 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
+  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncconnect=IP
+  initrd$linux_suffix @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/25install-vnc-listen.cfg b/features.in/grub/cfg.in/25install-vnc-listen.cfg
index 53b2b5119b..39606a400a 100644
--- a/features.in/grub/cfg.in/25install-vnc-listen.cfg
+++ b/features.in/grub/cfg.in/25install-vnc-listen.cfg
@@ -1,6 +1,6 @@
 
 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
+  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD
+  initrd$linux_suffix @boot_path@/full.cz
 }
 
diff --git a/features.in/grub/cfg.in/30live.cfg b/features.in/grub/cfg.in/30live.cfg
index d53a1e506a..b03b5ade9e 100644
--- a/features.in/grub/cfg.in/30live.cfg
+++ b/features.in/grub/cfg.in/30live.cfg
@@ -1,6 +1,6 @@
 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
+  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
+  initrd$linux_suffix @boot_path@/full.cz
 }
 
 
diff --git a/features.in/grub/cfg.in/32live_rw.cfg b/features.in/grub/cfg.in/32live_rw.cfg
index 55c4b977fe..5aec351804 100644
--- a/features.in/grub/cfg.in/32live_rw.cfg
+++ b/features.in/grub/cfg.in/32live_rw.cfg
@@ -1,4 +1,4 @@
 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
+  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
+  initrd$linux_suffix @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/80rescue.cfg b/features.in/grub/cfg.in/80rescue.cfg
index c6c0ae53c9..230f8c6cb3 100644
--- a/features.in/grub/cfg.in/80rescue.cfg
+++ b/features.in/grub/cfg.in/80rescue.cfg
@@ -1,4 +1,4 @@
 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
+  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@
+  initrd$linux_suffix @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/82rescue_rw.cfg b/features.in/grub/cfg.in/82rescue_rw.cfg
index ec18be28bb..6266962645 100644
--- a/features.in/grub/cfg.in/82rescue_rw.cfg
+++ b/features.in/grub/cfg.in/82rescue_rw.cfg
@@ -1,4 +1,4 @@
 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
+  linux$linux_suffix @boot_path@/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 @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/83rescue_fm.cfg b/features.in/grub/cfg.in/83rescue_fm.cfg
index 71bf21d3b7..e2214b6cc5 100644
--- a/features.in/grub/cfg.in/83rescue_fm.cfg
+++ b/features.in/grub/cfg.in/83rescue_fm.cfg
@@ -1,4 +1,4 @@
 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
+  linux$linux_suffix @boot_path@/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 @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/85mediacheck.cfg b/features.in/grub/cfg.in/85mediacheck.cfg
index 6779dd00d3..490df685f2 100644
--- a/features.in/grub/cfg.in/85mediacheck.cfg
+++ b/features.in/grub/cfg.in/85mediacheck.cfg
@@ -1,4 +1,4 @@
 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
+  linux$linux_suffix @boot_path@/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@
+  initrd$linux_suffix @boot_path@/full.cz
 }
diff --git a/features.in/grub/generate.mk b/features.in/grub/generate.mk
index a0b59221a2..f321ce798e 100644
--- a/features.in/grub/generate.mk
+++ b/features.in/grub/generate.mk
@@ -19,7 +19,7 @@ ifndef GRUB_DIRECT
 GRUB_CFG := $(GRUB_CFG) $(SUBPROFILE_DIRS) defaults
 endif
 
-DSTDIR  := $(BUILDDIR)/stage1/files/EFI/BOOT/.in
+DSTDIR  := $(BUILDDIR)/stage1/files/boot/grub/.in
 DSTCFGS := $(DSTDIR)/*.cfg
 
 # we can do GRUB_{CFG,MODULES,FILES}
diff --git a/features.in/grub/scripts.d/20-propagator-ramdisk b/features.in/grub/scripts.d/20-propagator-ramdisk
index c47302a769..04470b6c85 100755
--- a/features.in/grub/scripts.d/20-propagator-ramdisk
+++ b/features.in/grub/scripts.d/20-propagator-ramdisk
@@ -5,11 +5,11 @@
 
 cd "$WORKDIR"
 
-cfgs="$(find EFI/BOOT -name '*.cfg')"
-[ -n "$cfgs" ] || {
-	echo "${0##*/}: did not find any config under EFI/BOOT " >&2
-	exit 1
-}
+[ -f boot/grub/grub.cfg -o -f EFI/BOOT/grub.cfg ] || exit 0
+
+cfgs=
+[ ! -f boot/grub/grub.cfg ] || cfgs+='boot/grub/grub.cfg '
+[ ! -f EFI/BOOT/grub.cfg ] || cfgs+='EFI/BOOT/grub.cfg'
 
 # apply size census while looking for potential squashfs images
 find -maxdepth 1 -type f -size +1M \
diff --git a/features.in/grub/scripts.d/20-propagator-rescue-hash b/features.in/grub/scripts.d/20-propagator-rescue-hash
index fff0be0ce9..3ca61591bc 100755
--- a/features.in/grub/scripts.d/20-propagator-rescue-hash
+++ b/features.in/grub/scripts.d/20-propagator-rescue-hash
@@ -5,10 +5,14 @@
 
 cd "$WORKDIR"
 
-grep -qs "@rescue_hash@" EFI/BOOT/*.cfg || exit 0
+[ -f boot/grub/grub.cfg -o -f EFI/BOOT/grub.cfg ] || exit 0
+
+cfgs=
+[ ! -f boot/grub/grub.cfg ] || cfgs+='boot/grub/grub.cfg '
+[ ! -f EFI/BOOT/grub.cfg ] || cfgs+='EFI/BOOT/grub.cfg'
 
 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
+	sed -i "s,@rescue_hash@,$rescue_hash," $cfgs
 done
diff --git a/features.in/grub/stage1/scripts.d/01-grub b/features.in/grub/stage1/scripts.d/01-grub
index 9f87292925..4ea9a02acd 100755
--- a/features.in/grub/stage1/scripts.d/01-grub
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -2,17 +2,23 @@
 # gather grub configuration from snippets;
 # copy modules; see also this feature's generate.mk
 
-CFG="grub.cfg"
+CFG="$WORKDIR/boot/grub/grub.cfg"
+CFG_EFI="$WORKDIR/EFI/BOOT/grub.cfg"
 
-mkdir -p "$WORKDIR/EFI/BOOT"
-cd "$WORKDIR/EFI/BOOT"
+if [ -n "$GLOBAL_EFI_BOOTLOADER" -a ! "$GLOBAL_EFI_BOOTLOADER" = "grub-efi" ]; then
+	rm -fr "$WORKDIR/boot"
+	exit 0
+fi
 
-# 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
+if [ -z "$GLOBAL_EFI_BOOTLOADER" ]; then
+	case "$GLOBAL_BOOTLOADER" in
+		ieee1275boot) ;;
+		*) rm -fr "$WORKDIR/boot"
+		   exit 0;;
+	esac
+fi
+
+cd "$WORKDIR/boot/grub"
 
 # copy extra files, if any
 GRUB_FILES="$(cat .in/grub.list)"
@@ -21,21 +27,47 @@ if [ -n "${GRUB_FILES% }" ]; then
 fi
 
 # number ordering sponsored by shell's pathname expansion
-grep -hv '^#' .in/[0-9][0-9]*.cfg > "$CFG"
+case "$GLOBAL_BOOTLOADER" in
+	ieee1275boot)
+		grep -hv '^#' $(find .in/*.cfg -not -name *_efi.cfg) > "$CFG" ;;
+esac
+
+if [ "$GLOBAL_EFI_BOOTLOADER" = "grub-efi" ]; then
+	mkdir -p "$WORKDIR/EFI/BOOT"
+	grep -hv '^#' $(find .in/*.cfg) > "$CFG_EFI"
+fi
 
 # there should be DEFAULT directive there (at least for alterator-netinst)
-if ! grep -i '^default' .in/[0-9][0-9]*.cfg; then
-	DEFAULT="$(grep -i '\-\-id ' .in/[0-9][0-9]*.cfg | head -1 | rev| cut -f2 -d' ' |rev)"
+default_change() {
+local CFG=$1
+if ! grep -i '^default' "$CFG"; then
+	DEFAULT="$(grep -i '\-\-id ' "$CFG" | head -1 | rev| cut -f2 -d' ' |rev)"
 	if [ -n "$DEFAULT" ]; then
 		echo "default=$DEFAULT" >> "$CFG"
 	else
-		echo "error: no DEFAULT or UI directive and cannot guess" >&2
+		echo "error: no DEFAULT or UI directive and cannot guess for $CFG" >&2
 		exit 1
 	fi
 fi
+}
+
+if [ -f "$CFG" ]; then
+	default_change "$CFG"
+	sed -i 's,@boot_path@,/boot,g' "$CFG"
+fi
+
+if [ -f "$CFG_EFI" ]; then
+	default_change "$CFG_EFI"
+	sed -i 's,@boot_path@,/EFI/BOOT,g' "$CFG_EFI"
+fi
 
 # snippets are not going into the actual image
-if [ "$DEBUG" != 2 ]; then rm -r .in/; fi
+if [ "$DEBUG" != 2 ]; then
+	rm -r .in/
+	cd $WORKDIR
+	[ -f "$CFG" ] || rm -r boot/grub
+	[ ! $(ls -A boot/ | wc -l) -eq 0 ] || rm -r boot/
+fi
 
 # NB: there will be final macro expansion based on actual image sizes
 #     done by features.in/grub/scripts.d/20-propagator-ramdisk
-- 
2.24.1


[-- Attachment #6: 0004-grub-add-suffix-_efi-for-EFI-configs.patch --]
[-- Type: text/x-patch, Size: 1005 bytes --]

>From a9a046c71c5045c770ccfec1ba4f1f8ea93b12db Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Wed, 8 Jan 2020 15:29:17 +0700
Subject: [PATCH 04/22] grub: add suffix _efi for EFI configs

---
 features.in/grub/cfg.in/{90memtest.cfg => 90memtest_efi.cfg} | 0
 features.in/grub/cfg.in/{95fwsetup.cfg => 95fwsetup_efi.cfg} | 0
 2 files changed, 0 insertions(+), 0 deletions(-)
 rename features.in/grub/cfg.in/{90memtest.cfg => 90memtest_efi.cfg} (100%)
 rename features.in/grub/cfg.in/{95fwsetup.cfg => 95fwsetup_efi.cfg} (100%)

diff --git a/features.in/grub/cfg.in/90memtest.cfg b/features.in/grub/cfg.in/90memtest_efi.cfg
similarity index 100%
rename from features.in/grub/cfg.in/90memtest.cfg
rename to features.in/grub/cfg.in/90memtest_efi.cfg
diff --git a/features.in/grub/cfg.in/95fwsetup.cfg b/features.in/grub/cfg.in/95fwsetup_efi.cfg
similarity index 100%
rename from features.in/grub/cfg.in/95fwsetup.cfg
rename to features.in/grub/cfg.in/95fwsetup_efi.cfg
-- 
2.24.1


[-- Attachment #7: 0005-grub-fixed-PATH-to-memtest86.efi-in-90memtest-efi.cf.patch --]
[-- Type: text/x-patch, Size: 732 bytes --]

>From b3e3f2c78c52144a301469da12bb7dac35a55cb5 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 20:46:48 +0700
Subject: [PATCH 05/22] grub: fixed PATH to memtest86.efi in 90memtest-efi.cfg

---
 features.in/grub/cfg.in/90memtest_efi.cfg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/features.in/grub/cfg.in/90memtest_efi.cfg b/features.in/grub/cfg.in/90memtest_efi.cfg
index f4c2121687..d0d27372d9 100644
--- a/features.in/grub/cfg.in/90memtest_efi.cfg
+++ b/features.in/grub/cfg.in/90memtest_efi.cfg
@@ -1,3 +1,3 @@
 menuentry 'Memory Test' --id 'memtest' {
-  linux$linux_suffix /EFI/BOOT/memtest86.efi
+  linux$linux_suffix /EFI/tools/memtest86.efi
 }
-- 
2.24.1


[-- Attachment #8: 0006-grub-change-linux_suffix.patch --]
[-- Type: text/x-patch, Size: 9497 bytes --]

>From 16c9382d60f5a0448b5c698a4235d6283edb5603 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Fri, 3 Jan 2020 16:58:15 +0700
Subject: [PATCH 06/22] grub: change @linux_suffix@

---
 features.in/grub/cfg.in/00defaults.cfg            | 11 -----------
 features.in/grub/cfg.in/20install2.cfg            |  4 ++--
 features.in/grub/cfg.in/25install-vnc-connect.cfg |  4 ++--
 features.in/grub/cfg.in/25install-vnc-listen.cfg  |  4 ++--
 features.in/grub/cfg.in/30live.cfg                |  4 ++--
 features.in/grub/cfg.in/32live_rw.cfg             |  4 ++--
 features.in/grub/cfg.in/80rescue.cfg              |  4 ++--
 features.in/grub/cfg.in/82rescue_rw.cfg           |  4 ++--
 features.in/grub/cfg.in/83rescue_fm.cfg           |  4 ++--
 features.in/grub/cfg.in/85mediacheck.cfg          |  4 ++--
 features.in/grub/cfg.in/90memtest_efi.cfg         |  2 +-
 features.in/grub/stage1/scripts.d/01-grub         | 12 ++++++++++++
 12 files changed, 31 insertions(+), 30 deletions(-)

diff --git a/features.in/grub/cfg.in/00defaults.cfg b/features.in/grub/cfg.in/00defaults.cfg
index 4d469d4817..88b56d9873 100644
--- a/features.in/grub/cfg.in/00defaults.cfg
+++ b/features.in/grub/cfg.in/00defaults.cfg
@@ -4,14 +4,3 @@ 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
diff --git a/features.in/grub/cfg.in/20install2.cfg b/features.in/grub/cfg.in/20install2.cfg
index 373cd892fc..9cf86bbed0 100644
--- a/features.in/grub/cfg.in/20install2.cfg
+++ b/features.in/grub/cfg.in/20install2.cfg
@@ -1,6 +1,6 @@
 
 default='linux'
 menuentry 'Install @relname@' --hotkey 'i' --id 'linux' {
-  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@
-  initrd$linux_suffix @boot_path@/full.cz
+  linux@linux_suffix@ @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@
+  initrd@linux_suffix@ @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/25install-vnc-connect.cfg b/features.in/grub/cfg.in/25install-vnc-connect.cfg
index 77cbee0e5c..8277bd4b03 100644
--- a/features.in/grub/cfg.in/25install-vnc-connect.cfg
+++ b/features.in/grub/cfg.in/25install-vnc-connect.cfg
@@ -1,5 +1,5 @@
 
 menuentry 'Install ALT @relname@ (headless with DHCP+VNC client) (edit to set server IP address)' --id 'vncconnect' {
-  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncconnect=IP
-  initrd$linux_suffix @boot_path@/full.cz
+  linux@linux_suffix@ @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncconnect=IP
+  initrd@linux_suffix@ @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/25install-vnc-listen.cfg b/features.in/grub/cfg.in/25install-vnc-listen.cfg
index 39606a400a..a056a64fca 100644
--- a/features.in/grub/cfg.in/25install-vnc-listen.cfg
+++ b/features.in/grub/cfg.in/25install-vnc-listen.cfg
@@ -1,6 +1,6 @@
 
 menuentry 'Install ALT @relname@ (headless with DHCP+VNC) (password VNCPWD)' --id 'vncpasswd' {
-  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD
-  initrd$linux_suffix @boot_path@/full.cz
+  linux@linux_suffix@ @boot_path@/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD
+  initrd@linux_suffix@ @boot_path@/full.cz
 }
 
diff --git a/features.in/grub/cfg.in/30live.cfg b/features.in/grub/cfg.in/30live.cfg
index b03b5ade9e..5e4b85ada6 100644
--- a/features.in/grub/cfg.in/30live.cfg
+++ b/features.in/grub/cfg.in/30live.cfg
@@ -1,6 +1,6 @@
 menuentry 'LiveCD (no hard disk needed)' --id 'live' {
-  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
-  initrd$linux_suffix @boot_path@/full.cz
+  linux@linux_suffix@ @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
+  initrd@linux_suffix@ @boot_path@/full.cz
 }
 
 
diff --git a/features.in/grub/cfg.in/32live_rw.cfg b/features.in/grub/cfg.in/32live_rw.cfg
index 5aec351804..4bac28aa65 100644
--- a/features.in/grub/cfg.in/32live_rw.cfg
+++ b/features.in/grub/cfg.in/32live_rw.cfg
@@ -1,4 +1,4 @@
 menuentry 'LiveCD with sessions support' --id 'session' {
-  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
-  initrd$linux_suffix @boot_path@/full.cz
+  linux@linux_suffix@ @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
+  initrd@linux_suffix@ @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/80rescue.cfg b/features.in/grub/cfg.in/80rescue.cfg
index 230f8c6cb3..a9d2575cfb 100644
--- a/features.in/grub/cfg.in/80rescue.cfg
+++ b/features.in/grub/cfg.in/80rescue.cfg
@@ -1,4 +1,4 @@
 menuentry 'Rescue LiveCD' --id 'rescue' {
-  linux$linux_suffix @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@
-  initrd$linux_suffix @boot_path@/full.cz
+  linux@linux_suffix@ @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@
+  initrd@linux_suffix@ @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/82rescue_rw.cfg b/features.in/grub/cfg.in/82rescue_rw.cfg
index 6266962645..753c642bc3 100644
--- a/features.in/grub/cfg.in/82rescue_rw.cfg
+++ b/features.in/grub/cfg.in/82rescue_rw.cfg
@@ -1,4 +1,4 @@
 menuentry 'Rescue with sessions support' --id 'rescue_session' {
-  linux$linux_suffix @boot_path@/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 @boot_path@/full.cz
+  linux@linux_suffix@ @boot_path@/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@ @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/83rescue_fm.cfg b/features.in/grub/cfg.in/83rescue_fm.cfg
index e2214b6cc5..2374452dee 100644
--- a/features.in/grub/cfg.in/83rescue_fm.cfg
+++ b/features.in/grub/cfg.in/83rescue_fm.cfg
@@ -1,4 +1,4 @@
 menuentry 'Forensic mode (leave disks alone)' --id 'rescue_forensic' {
-  linux$linux_suffix @boot_path@/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 @boot_path@/full.cz
+  linux@linux_suffix@ @boot_path@/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@ @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/85mediacheck.cfg b/features.in/grub/cfg.in/85mediacheck.cfg
index 490df685f2..918f074dbe 100644
--- a/features.in/grub/cfg.in/85mediacheck.cfg
+++ b/features.in/grub/cfg.in/85mediacheck.cfg
@@ -1,4 +1,4 @@
 menuentry 'Check this media for defects' --id 'mediachk' {
-  linux$linux_suffix @boot_path@/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@
-  initrd$linux_suffix @boot_path@/full.cz
+  linux@linux_suffix@ @boot_path@/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@
+  initrd@linux_suffix@ @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/90memtest_efi.cfg b/features.in/grub/cfg.in/90memtest_efi.cfg
index d0d27372d9..c52d1a6ffc 100644
--- a/features.in/grub/cfg.in/90memtest_efi.cfg
+++ b/features.in/grub/cfg.in/90memtest_efi.cfg
@@ -1,3 +1,3 @@
 menuentry 'Memory Test' --id 'memtest' {
-  linux$linux_suffix /EFI/tools/memtest86.efi
+  linux@linux_suffix@ /EFI/tools/memtest86.efi
 }
diff --git a/features.in/grub/stage1/scripts.d/01-grub b/features.in/grub/stage1/scripts.d/01-grub
index 4ea9a02acd..e7e82a9bfd 100755
--- a/features.in/grub/stage1/scripts.d/01-grub
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -61,6 +61,18 @@ if [ -f "$CFG_EFI" ]; then
 	sed -i 's,@boot_path@,/EFI/BOOT,g' "$CFG_EFI"
 fi
 
+# change @linux_suffix@
+case "$GLOBAL_ARCH" in
+	i586|x86_64)
+		[ ! -f "$CFG" ] || sed -i 's/@linux_suffix@/16/g' "$CFG"
+		[ ! -f "$CFG_EFI" ] || sed -i 's/@linux_suffix@/efi/g' "$CFG_EFI"
+	;;
+	*)
+		[ ! -f "$CFG" ] || sed -i 's/@linux_suffix@//g' "$CFG"
+		[ ! -f "$CFG_EFI" ] || sed -i 's/@linux_suffix@//g' "$CFG_EFI"
+	;;
+esac
+
 # snippets are not going into the actual image
 if [ "$DEBUG" != 2 ]; then
 	rm -r .in/
-- 
2.24.1


[-- Attachment #9: 0007-grub-available-for-i586-x86_64-aarch64-ppc64le.patch --]
[-- Type: text/x-patch, Size: 895 bytes --]

>From b92e30b3a8c79255b92e4c52b5b13bdbf5773d35 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 21:51:30 +0700
Subject: [PATCH 07/22] grub: available for i586, x86_64, aarch64, ppc64le

---
 features.in/grub/config.mk | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/features.in/grub/config.mk b/features.in/grub/config.mk
index 9f80822fa4..373001f884 100644
--- a/features.in/grub/config.mk
+++ b/features.in/grub/config.mk
@@ -1,9 +1,7 @@
 # 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)))
+ifeq (,$(filter-out i586 x86_64 ppc64le aarch64,$(ARCH)))
 
 use/grub: sub/stage1 $(ISOHYBRID:%=use/isohybrid)
 	@$(call add_feature)
-- 
2.24.1


[-- Attachment #10: 0008-grub-add-84rescue_remote.cfg.patch --]
[-- Type: text/x-patch, Size: 959 bytes --]

>From 274aa0982b6995215263127aa6ba6b06aff13e8f Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 20:29:45 +0700
Subject: [PATCH 08/22] grub: add 84rescue_remote.cfg

---
 features.in/grub/cfg.in/84rescue_remote.cfg | 4 ++++
 1 file changed, 4 insertions(+)
 create mode 100644 features.in/grub/cfg.in/84rescue_remote.cfg

diff --git a/features.in/grub/cfg.in/84rescue_remote.cfg b/features.in/grub/cfg.in/84rescue_remote.cfg
new file mode 100644
index 0000000000..738abd79ad
--- /dev/null
+++ b/features.in/grub/cfg.in/84rescue_remote.cfg
@@ -0,0 +1,4 @@
+menuentry 'Rescue with remote SSH access (DHCP)' --id 'rescue_remote' {
+  linux@linux_suffix@ @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ splash=0 showopts stagename=rescue @rescue_bootargs@ max_loop=16 ip=dhcp port=22 rootpw=AUTO hash=@rescue_hash@
+  initrd@linux_suffix@ @boot_path@/full.cz
+}
-- 
2.24.1


[-- Attachment #11: 0009-grub-Added-release-name-to-LiveCD-menu-items.patch --]
[-- Type: text/x-patch, Size: 1592 bytes --]

>From 3d28f1797cdbe8029f8da939eea91b859bc61998 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 20:41:23 +0700
Subject: [PATCH 09/22] grub: Added release name to LiveCD menu items

In grub, you cannot set a header with a release name, as in syslinux.
---
 features.in/grub/cfg.in/30live.cfg    | 2 +-
 features.in/grub/cfg.in/32live_rw.cfg | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/features.in/grub/cfg.in/30live.cfg b/features.in/grub/cfg.in/30live.cfg
index 5e4b85ada6..7986432113 100644
--- a/features.in/grub/cfg.in/30live.cfg
+++ b/features.in/grub/cfg.in/30live.cfg
@@ -1,4 +1,4 @@
-menuentry 'LiveCD (no hard disk needed)' --id 'live' {
+menuentry 'LiveCD @relname@ (no hard disk needed)' --id 'live' {
   linux@linux_suffix@ @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
   initrd@linux_suffix@ @boot_path@/full.cz
 }
diff --git a/features.in/grub/cfg.in/32live_rw.cfg b/features.in/grub/cfg.in/32live_rw.cfg
index 4bac28aa65..4c00dd3d4f 100644
--- a/features.in/grub/cfg.in/32live_rw.cfg
+++ b/features.in/grub/cfg.in/32live_rw.cfg
@@ -1,4 +1,4 @@
-menuentry 'LiveCD with sessions support' --id 'session' {
+menuentry 'LiveCD @relname@ with sessions support' --id 'session' {
   linux@linux_suffix@ @boot_path@/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
   initrd@linux_suffix@ @boot_path@/full.cz
 }
-- 
2.24.1


[-- Attachment #12: 0010-install2-live-add-grub.cfg-support.patch --]
[-- Type: text/x-patch, Size: 2831 bytes --]

>From c4aeff917b22f29e3a8397c652fd2b3f3c72d79a Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Fri, 3 Jan 2020 21:11:15 +0700
Subject: [PATCH 10/22] install2, live: add grub.cfg support

---
 features.in/install2/config.mk | 10 +++++-----
 features.in/live/config.mk     |  8 ++++----
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/features.in/install2/config.mk b/features.in/install2/config.mk
index 4c744dac80..71e6c4171b 100644
--- a/features.in/install2/config.mk
+++ b/features.in/install2/config.mk
@@ -3,7 +3,7 @@
 +installer: use/install2/full; @:
 
 use/install2: use/stage2 sub/stage2@install2 use/metadata \
-	use/cleanup/installer use/install2/autoinstall
+	use/cleanup/installer use/install2/autoinstall use/grub/install2.cfg
 	@$(call add_feature)
 	@$(call try,INSTALLER,altlinux-generic)	# might be replaced later
 	@$(call add,INSTALL2_PACKAGES,installer-distro-$$(INSTALLER)-stage2)
@@ -84,12 +84,12 @@ use/install2/vnc:
 	@$(call add,INSTALL2_PACKAGES,x11vnc xterm net-tools)
 
 # this one expects external vncviewer to come
-use/install2/vnc/listen: \
-	use/install2/vnc use/syslinux/install-vnc-listen.cfg; @:
+use/install2/vnc/listen: use/install2/vnc \
+	use/syslinux/install-vnc-listen.cfg use/grub/install-vnc-listen.cfg; @:
 
 # this one connects to a specified vncviewer --listen
-use/install2/vnc/connect: \
-	use/install2/vnc use/syslinux/install-vnc-connect.cfg; @:
+use/install2/vnc/connect: use/install2/vnc \
+	use/syslinux/install-vnc-connect.cfg use/grub/install-vnc-connect.cfg; @:
 
 # add both bootloader items to be *that* explicit ;-)
 use/install2/vnc/full: use/install2/vnc/listen use/install2/vnc/connect; @:
diff --git a/features.in/live/config.mk b/features.in/live/config.mk
index 7644e8591e..1278922ddd 100644
--- a/features.in/live/config.mk
+++ b/features.in/live/config.mk
@@ -12,7 +12,8 @@ _OFF = anacron blk-availability bridge clamd crond dhcpd dmeventd dnsmasq \
 
 # copy stage2 as live
 # NB: starts to preconfigure but doesn't use/cleanup yet
-use/live: use/stage2 sub/rootfs@live sub/stage2@live use/services/lvm2-disable
+use/live: use/stage2 sub/rootfs@live sub/stage2@live \
+	use/services/lvm2-disable use/grub/live.cfg
 	@$(call add_feature)
 	@$(call add,CLEANUP_BASE_PACKAGES,'installer*')
 	@$(call add,DEFAULT_SERVICES_ENABLE,$(_ON))
@@ -28,10 +29,9 @@ use/live/base: use/live/.base use/net use/deflogin/live
 
 # rw slice, see http://www.altlinux.org/make-initrd-propagator and #28289
 ifeq (,$(EFI_BOOTLOADER))
-use/live/rw: use/live use/syslinux
-	@$(call add,SYSLINUX_CFG,live_rw)
+use/live/rw: use/live use/syslinux/live_rw.cfg use/grub/live_rw.cfg; @:
 else
-use/live/rw: use/live; @:
+use/live/rw: use/live use/grub/live_rw.cfg; @:
 endif
 
 # graphical target (not enforcing xorg drivers or blobs)
-- 
2.24.1


[-- Attachment #13: 0011-efi-do-not-call-use-efi-refind-from-use-efi-memtest8.patch --]
[-- Type: text/x-patch, Size: 907 bytes --]

>From 22827511fb488cafa71e86f0074aa714b566295b Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 21:04:02 +0700
Subject: [PATCH 11/22] efi: do not call use/efi/refind from use/efi/memtest86

This is necessary to prevent unintentional assignment of rEFInd
as EFI_BOOTLOADER.
I also want to hope that memtest86.efi can be made to work from
grub-efi in the future.
---
 features.in/efi/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/features.in/efi/config.mk b/features.in/efi/config.mk
index c6fbff4f34..3726cb5162 100644
--- a/features.in/efi/config.mk
+++ b/features.in/efi/config.mk
@@ -48,7 +48,7 @@ use/efi/lilo: use/efi use/bootloader/lilo
 use/efi/refind: use/efi
 	@$(call set,EFI_BOOTLOADER,refind)
 
-use/efi/memtest86: use/efi/refind
+use/efi/memtest86: use/efi
 	@$(call set,EFI_MEMTEST86,efi-memtest86)
 
 else
-- 
2.24.1


[-- Attachment #14: 0012-efi-use-efi-grub-by-default-for-all-arches.patch --]
[-- Type: text/x-patch, Size: 897 bytes --]

>From 4558187d4e2c464e0d15e9a7855d6ba2e77208d8 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Mon, 30 Dec 2019 18:55:32 +0700
Subject: [PATCH 12/22] efi: use/efi/grub by default for all arches

---
 features.in/efi/config.mk | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/features.in/efi/config.mk b/features.in/efi/config.mk
index 3726cb5162..db37b282e4 100644
--- a/features.in/efi/config.mk
+++ b/features.in/efi/config.mk
@@ -10,11 +10,7 @@ use/efi:
 	@$(call add_feature)
 	@$(call set,MKI_VER_MINIMAL,0.2.12)	# it's official now
 	@$(call set,MKI_VER_OPTIMAL,0.2.17)	# for EFI_BOOTARGS
-ifeq (x86_64,$(ARCH))
-	@$(call try,EFI_BOOTLOADER,elilo)	# default one
-else
 	@$(call try,EFI_BOOTLOADER,grub-efi)	# default one
-endif
 	@$(call add,THE_PACKAGES,$$(EFI_BOOTLOADER))
 	@$(call xport,EFI_BOOTLOADER)
 	@$(call add,THE_LISTS,$(EFI_LISTS))
-- 
2.24.1


[-- Attachment #15: 0013-syslinux-do-not-use-syslinux-to-generate-config-on-u.patch --]
[-- Type: text/x-patch, Size: 3849 bytes --]

>From 4b361b25d45fd1688223b3e12f95a227051d3174 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 22:10:07 +0700
Subject: [PATCH 13/22] syslinux: do not use syslinux to generate config on
 unsupported arches

These are partial commits reverts:
01ee4075438e9ecfcf1b7bb71b37025f3232c3bf
e42bcdcb3095346a4c653938f7e90fa3c80b292f
5cfc7ede81024fa62039013a09160b8a7da1457d
---
 features.in/syslinux/config.mk                | 20 ++-----------------
 .../syslinux/scripts.d/20-propagator-ramdisk  |  8 +-------
 .../syslinux/stage1/scripts.d/01-syslinux     |  2 +-
 3 files changed, 4 insertions(+), 26 deletions(-)

diff --git a/features.in/syslinux/config.mk b/features.in/syslinux/config.mk
index c355d8a875..7fa8e2198b 100644
--- a/features.in/syslinux/config.mk
+++ b/features.in/syslinux/config.mk
@@ -1,36 +1,26 @@
 # default is plain text prompt
 # NB: might be usbflash-ready hybrid iso
-
-# on ppc64le, aarch64 syslinux feature is used only to generate config
-# (it's converted into grub.cfg later)
-ifeq (,$(filter-out i586 x86_64 ppc64le aarch64,$(ARCH)))
-
+ifeq (,$(filter-out i586 x86_64,$(ARCH)))
 use/syslinux: sub/stage1 $(ISOHYBRID:%=use/isohybrid)
 	@$(call add_feature)
-ifeq (,$(filter-out i586 x86_64,$(ARCH)))
 	@$(call add,STAGE1_PACKAGES,syslinux)
 	@$(call try,BOOTVGA,normal)
 	@$(call add,SYSLINUX_FILES,/usr/lib/syslinux/pxelinux.0)
-endif
 	@$(call try,META_SYSTEM_ID,SYSLINUX)
 	@$(call set,RELNAME,ALT ($(IMAGE_NAME)))
 	@$(call set,IMAGE_PACKTYPE,boot)
 else
-
 use/syslinux: ; @:
-
 endif
 
-ifeq (,$(filter-out i586 x86_64,$(ARCH)))
 # UI is overwritten
 use/syslinux/ui/%: use/syslinux
 	@$(call set,SYSLINUX_UI,$*)
+ifeq (,$(filter-out i586 x86_64,$(ARCH)))
 	@if [ "$*" == gfxboot ]; then \
 		$(call add,STAGE1_PACKAGES,gfxboot); \
 		$(call add,STAGE1_BRANDING,bootloader); \
 	fi
-else
-use/syslinux/ui/%: use/syslinux; @:
 endif
 
 # modules and config snippets just add up
@@ -40,11 +30,5 @@ use/syslinux/%.com use/syslinux/%.c32: use/syslinux
 use/syslinux/%.cfg: use/syslinux
 	@$(call add,SYSLINUX_CFG,$*)
 
-ifeq (,$(filter-out ppc64le aarch64,$(ARCH)))
-use/syslinux/localboot.cfg use/syslinux/removable.cfg use/syslinux/lateboot.cfg use/syslinux/sdab.cfg: use/syslinux; @:
-use/syslinux/install-vnc-connect.cfg: use/syslinux/grub-install-vnc-connect.cfg; @:
-use/syslinux/install-vnc-listen.cfg: use/syslinux/grub-install-vnc-listen.cfg; @:
-endif
-
 use/syslinux/timeout/%: use/syslinux
 	@$(call set,SYSLINUX_TIMEOUT,$*)
diff --git a/features.in/syslinux/scripts.d/20-propagator-ramdisk b/features.in/syslinux/scripts.d/20-propagator-ramdisk
index b9d9c6266d..525512a0e5 100755
--- a/features.in/syslinux/scripts.d/20-propagator-ramdisk
+++ b/features.in/syslinux/scripts.d/20-propagator-ramdisk
@@ -5,16 +5,10 @@
 
 cd "$WORKDIR"
 
-cfgs="$(find syslinux boot/grub EFI/BOOT -name '*.cfg')"
-[ -n "$cfgs" ] || {
-	echo "${0##*/}: did not find any config under /syslinux or /boot/grub" >&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
+	sed -i "s,@${image}_size@,$size," syslinux/*.cfg
 done
diff --git a/features.in/syslinux/stage1/scripts.d/01-syslinux b/features.in/syslinux/stage1/scripts.d/01-syslinux
index 693a1f58ca..e9390715aa 100755
--- a/features.in/syslinux/stage1/scripts.d/01-syslinux
+++ b/features.in/syslinux/stage1/scripts.d/01-syslinux
@@ -10,7 +10,7 @@ cd "$WORKDIR/syslinux"
 
 # validate just in case (see also stage1 Makefile)
 case "$GLOBAL_BOOTLOADER" in
-	isolinux|syslinux|ieee1275boot|grubaa64boot) ;;
+	isolinux|syslinux) ;;
 	*) echo "error: weird GLOBAL_BOOTLOADER: \`$GLOBAL_BOOTLOADER'" >&2;
 	   exit 1;;
 esac
-- 
2.24.1


[-- Attachment #16: 0014-syslinux-fixed-for-using-BOOTLOADER-not-equal-syslin.patch --]
[-- Type: text/x-patch, Size: 3088 bytes --]

>From c7bbde5adb73bfa018191e8b70ac61dac32081b2 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Mon, 6 Jan 2020 23:26:52 +0700
Subject: [PATCH 14/22] syslinux: fixed for using BOOTLOADER not equal syslinux

Do not create syslinux.cfg if EFI_BOOTLOADER is set to not equal grub-efi.
---
 features.in/syslinux/scripts.d/20-propagator-ramdisk   |  2 ++
 .../syslinux/scripts.d/20-propagator-rescue-hash       |  2 ++
 features.in/syslinux/stage1/scripts.d/01-syslinux      | 10 +++++-----
 features.in/syslinux/stage1/scripts.d/02-gfxboot       |  6 +++---
 4 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/features.in/syslinux/scripts.d/20-propagator-ramdisk b/features.in/syslinux/scripts.d/20-propagator-ramdisk
index 525512a0e5..f4139321df 100755
--- a/features.in/syslinux/scripts.d/20-propagator-ramdisk
+++ b/features.in/syslinux/scripts.d/20-propagator-ramdisk
@@ -3,6 +3,8 @@
 # when the image sizes are finally known
 # NB: install2_size, live_size, rescue_size get defined here
 
+[ -d "$WORKDIR/syslinux" ] || exit 0
+
 cd "$WORKDIR"
 
 # apply size census while looking for potential squashfs images
diff --git a/features.in/syslinux/scripts.d/20-propagator-rescue-hash b/features.in/syslinux/scripts.d/20-propagator-rescue-hash
index c785b35442..72279a8a73 100755
--- a/features.in/syslinux/scripts.d/20-propagator-rescue-hash
+++ b/features.in/syslinux/scripts.d/20-propagator-rescue-hash
@@ -3,6 +3,8 @@
 # to add rescue image hash, if any
 # (for propagator in forensic mode)
 
+[ -d "$WORKDIR/syslinux" ] || exit 0
+
 cd "$WORKDIR"
 
 grep -qs "@rescue_hash@" syslinux/*.cfg || exit 0
diff --git a/features.in/syslinux/stage1/scripts.d/01-syslinux b/features.in/syslinux/stage1/scripts.d/01-syslinux
index e9390715aa..baec719f02 100755
--- a/features.in/syslinux/stage1/scripts.d/01-syslinux
+++ b/features.in/syslinux/stage1/scripts.d/01-syslinux
@@ -5,16 +5,16 @@
 MODDIR="/usr/lib/syslinux"
 CFG="$GLOBAL_BOOTLOADER.cfg"
 
-mkdir -p "$WORKDIR/syslinux"
-cd "$WORKDIR/syslinux"
-
 # validate just in case (see also stage1 Makefile)
 case "$GLOBAL_BOOTLOADER" in
 	isolinux|syslinux) ;;
-	*) echo "error: weird GLOBAL_BOOTLOADER: \`$GLOBAL_BOOTLOADER'" >&2;
-	   exit 1;;
+	*) echo "Warning: GLOBAL_BOOTLOADER not supported: \`$GLOBAL_BOOTLOADER'" >&2;
+	   rm -fr "$WORKDIR/syslinux"
+	   exit 0;;
 esac
 
+cd "$WORKDIR/syslinux"
+
 # copy extra files, if any
 SYSLINUX_FILES="$(cat .in/syslinux.list)"
 if [ -n "${SYSLINUX_FILES% }" ]; then
diff --git a/features.in/syslinux/stage1/scripts.d/02-gfxboot b/features.in/syslinux/stage1/scripts.d/02-gfxboot
index 221deb9aa8..9deb6cddd0 100755
--- a/features.in/syslinux/stage1/scripts.d/02-gfxboot
+++ b/features.in/syslinux/stage1/scripts.d/02-gfxboot
@@ -1,5 +1,7 @@
 #!/bin/sh
 
+[ -d "$WORKDIR/syslinux" ] || exit 0
+
 gfxboot_datadir=/usr/share/gfxboot
 
 if [ ! -d "$gfxboot_datadir" ]; then
@@ -15,9 +17,7 @@ if [ ! -f "$bootlogo" ]; then
 	exit 0
 fi
 
-cd "$WORKDIR"
-mkdir -p syslinux
-cd syslinux
+cd "$WORKDIR/syslinux"
 
 # unpack
 cpio -iduV <"$bootlogo"
-- 
2.24.1


[-- Attachment #17: 0017-sub.in-stage1-call-copy-kernel-instead-of-copy-BOOTL.patch --]
[-- Type: text/x-patch, Size: 1035 bytes --]

>From 27f1f5e8435f9f9c96798a481141280c3ef66268 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Tue, 7 Jan 2020 21:48:53 +0700
Subject: [PATCH 17/22] sub.in/stage1: call copy-kernel instead of
 copy-$BOOTLOADER

copy-$BOOTLOADER was called to copy the kernel and propagator image.
---
 sub.in/stage1/Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sub.in/stage1/Makefile b/sub.in/stage1/Makefile
index 112c953365..6578bdc25c 100644
--- a/sub.in/stage1/Makefile
+++ b/sub.in/stage1/Makefile
@@ -52,7 +52,7 @@ prepare-modules:
 # scripts prepare bootloader configuration, too
 # NB: we pass tested squashfs options for sub.in/stage2/Makefile to include
 all: | debug prepare-workdir copy-tree run-scripts $(BUILD_PROPAGATOR) \
-	copy-$(BOOTLOADER) $(COPY_SQUASHCFG) pack-image $(GLOBAL_CLEAN_WORKDIR)
+	copy-kernel $(COPY_SQUASHCFG) pack-image $(GLOBAL_CLEAN_WORKDIR)
 	@if [ -s $(OUTDIR)/squashcfg.mk ]; then \
 		cp $(OUTDIR)/squashcfg.mk $(GLOBAL_BUILDDIR)/; \
 	fi
-- 
2.24.1


[-- Attachment #18: 0018-grub-added-fwsetup_efi.cfg.patch --]
[-- Type: text/x-patch, Size: 884 bytes --]

>From dadd7b9ea737566165c4dd44fd73881b6175fd82 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sat, 11 Jan 2020 01:56:52 +0700
Subject: [PATCH 18/22] grub: added fwsetup_efi.cfg

Added for EFI only (see stage1/scripts.d/01-grub).
---
 features.in/grub/generate.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/features.in/grub/generate.mk b/features.in/grub/generate.mk
index f321ce798e..8d3870fe90 100644
--- a/features.in/grub/generate.mk
+++ b/features.in/grub/generate.mk
@@ -16,7 +16,7 @@ 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
+GRUB_CFG := $(GRUB_CFG) $(SUBPROFILE_DIRS) defaults fwsetup_efi
 endif
 
 DSTDIR  := $(BUILDDIR)/stage1/files/boot/grub/.in
-- 
2.24.1


[-- Attachment #19: 0019-efi-use-efi-grub-for-EFI_ARHES-only.patch --]
[-- Type: text/x-patch, Size: 752 bytes --]

>From 8184fec1adaa190d4480bc3a8ad45588059a5ea4 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 12 Jan 2020 00:15:55 +0700
Subject: [PATCH 19/22] efi: use/efi/grub for EFI_ARHES only

---
 features.in/efi/config.mk | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/features.in/efi/config.mk b/features.in/efi/config.mk
index db37b282e4..271f9b0cbd 100644
--- a/features.in/efi/config.mk
+++ b/features.in/efi/config.mk
@@ -64,7 +64,7 @@ endif
 else
 
 # ignore on an unsupported target arch but make it hybrid at least
-use/efi use/efi/signed use/efi/debug \
+use/efi use/efi/signed use/efi/debug use/efi/grub \
   use/efi/refind use/efi/shell use/efi/memtest86: use/isohybrid; @:
 
 endif
-- 
2.24.1


[-- Attachment #20: 0020-hdt-for-i586-and-x86_64-only.patch --]
[-- Type: text/x-patch, Size: 717 bytes --]

>From 2fae2778c480ed624af3aeb270c222a4e5a01f1a Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 12 Jan 2020 00:22:06 +0700
Subject: [PATCH 20/22] hdt: for i586 and x86_64 only

---
 features.in/hdt/config.mk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/features.in/hdt/config.mk b/features.in/hdt/config.mk
index c8ec7baa30..1969eb02d5 100644
--- a/features.in/hdt/config.mk
+++ b/features.in/hdt/config.mk
@@ -1,5 +1,9 @@
 # optimized out use/syslinux due to use/memtest
+ifeq (,$(filter-out i586 x86_64,$(ARCH)))
 use/hdt: use/memtest
 	@$(call add_feature)
 	@$(call add,STAGE1_PACKAGES,pciids)
 	@$(call add,SYSLINUX_MODULES,hdt)
+else
+use/hdt: ; @:
+endif
-- 
2.24.1


  reply	other threads:[~2020-01-12 15:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-01 14:18 Alexey Shabalin
2019-11-14 19:10 ` Alexey Shabalin
2019-11-15  9:49   ` Alexey Gladkov
2019-11-15 14:59 ` Alexey Shabalin
2019-11-18 15:57   ` Michael Shigorin
2020-01-08 19:29 ` Антон Мидюков
2020-01-09 14:39   ` Антон Мидюков
2020-01-12 15:18     ` Антон Мидюков [this message]
2020-02-10  2:58       ` Антон Мидюков
2020-02-10  9:51         ` Alexey Gladkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=de2000ac-e518-fad0-2a86-d655a7b47b5c@ya.ru \
    --to=midyukov-anton@ya.ru \
    --cc=devel-distro@lists.altlinux.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

ALT Linux Distributions development

This inbox may be cloned and mirrored by anyone:

	git clone --mirror http://lore.altlinux.org/devel-distro/0 devel-distro/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 devel-distro devel-distro/ http://lore.altlinux.org/devel-distro \
		devel-distro@lists.altlinux.org devel-distro@lists.altlinux.ru devel-distro@lists.altlinux.com
	public-inbox-index devel-distro

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://lore.altlinux.org/org.altlinux.lists.devel-distro


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git