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: Thu, 9 Jan 2020 02:29:15 +0700
Message-ID: <c0d65896-2cc3-32b2-b61c-46ae46ae816d@ya.ru> (raw)
In-Reply-To: <CAEdvWkQaSZD+z4PMwsxEV4Qr+W7DjbqXXou3vYoWyOb-g3sx0g@mail.gmail.com>

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

01.11.2019 21:18, Alexey Shabalin пишет:
> Всем привет.
> Я для Server-V добавил поддержку grub-efi в инстляторе.
> Прошу посмотреть/проверить. Делал только самое необходимое для себя. В
> дальнейшем можно наращивать функционал. Например, сейчас нет поддержки
> тем для grub, потому что мне не надо было :), мне достаточно
> текстового grub.
>
> 1) поддержка grub-efi в efiboot mkimage
> http://git.altlinux.org/people/shaba/packages/mkimage.git?p=mkimage.git;a=commitdiff;h=932c2e80d41c8ace7bbb5da52a48bab49fde575f
>
> 2) добавил фичу grub для генерации кофигов grub из кусочков, по
> аналогии с syslinux.
> Пока жесткая завязка на местоположение vmlinuz и full.cz в EFI/BOOT
> для grub-efi.
> Не уверен, что можно использовать для aarch64, это буду смотреть дальше.
> http://git.altlinux.org/people/shaba/packages/mkimage-profiles.git?p=mkimage-profiles.git;a=commitdiff;h=7b9d60d6661cad6e6f02b93e646a42bd07645c51
>
> 3) использование конфигов для grub наравне с syslinux
> http://git.altlinux.org/people/shaba/packages/mkimage-profiles.git?p=mkimage-profiles.git;a=commitdiff;h=23a460dd3de2147cc9a0db5de52234ececb0b5ef
>
> 4) переключил server-v с refind на grub-efi
> Вместо (+efi use/efi/refind) использую use/efi/grub use/efi/signed
> http://git.altlinux.org/people/shaba/packages/mkimage-profiles.git?p=mkimage-profiles.git;a=commitdiff;h=5577800554b2e240146b7cfb039c7a97d13e74d7
>
> 5) собираю командой (потому что искать, где это переопределяется, кто
> мне помогает и потом определяет эти переменные подругому, тяжело и
> муторно)
> make ARCH=x86_64 BUILDDIR=~/build-mkimage
> APTCONF=~/etc/p9.x86_64-apt.conf DEBUG=1 REPORT=1 IMAGE_PACKTYPE=boot
> BOOT_TYPE="isolinux efiboot" EFI_BOOTLOADER=grub-efi server-v.iso
>
> Спасибо за внимание. Буду рад исправлениям.

Доброго времени суток

За каникулы серьёзно поработал над mkimage и mkimage-profiles.

В задании [#243937] [test-only] EPERM mkimage.git=0.2.30-alt1 сделал 
следующее:

1. в grubaa64boot сделал структуру файлов как в образе собираемом с 
efiboot. Так что прошу обратить пристальное внимание на это.

2. в grubaa64boot убрал генерацию grub.cfg из syslinux.cfg, так как она 
больше не нужна (да и работала некорректно)

3. Добавил новую цель mki-copy-kernel, которую предлагаю вызывать из 
mkimage-profiles вместо mki-copy-$BOOTLOADER.

Мне не нравится, что у нас сейчас mki-copy-$BOOTLOADER вызывается 
дважды: из mkimage-profiles, чтобы скопировать ядро с образом 
пропагатора, и второй раз уже в mkimage-profiles, чтобы установить 
загрузчик. При первом вызове есть ядро, но не готов syslinux.cfg, при 
втором готов syslinux.cfg, но уже нет ядра. Кроме того, это изменение 
упростит процесс перехода на использование в образе нескольких ядер.

4. В mki-copy-efiboot для grub-efi ядро копировать в boot, если его ещё 
там нет. Аналогично для других EFI_BOOTLOADER проверять, есть ли уже 
ядро в EFI/BOOT, и если есть не копировать.

Но основные изменения в mkimage-profiles:

1. Исправил определение default-ного пункта, если не задан (см 0001).

2. Сделал фильтр конфигов по названиям. Например, пункты меню 
специфичные для EFI должны оканчиваться на _efi.cfg (см 0005)

3. Может генерироваться два конфига grub.cfg, для EFI и всех остальных. 
Два сразу могут быть только при использовании grub для legacy (не 
реализован) и grub-efi (см 0005)

4. Исправил $linux_suffix. То условие не работает и генерит при загрузке 
grub ошибки про не найденные команды (см 0008)

5. Интегрировал по аналогии с syslinux генерацию конфигов grub для 
install2 и live (см 0012). Для того, чтобы это никому не помешало, в 
зависимости от выбранных загрузчиков следы grub подчищаются (см 0004 и 0005)

6. Для syslinux тоже сделал такую проверку (см 0015, 0016) Это позволит 
задать загрузчик grub legacy, не убирая отовсюду syslinux.

7 Вызываю copy-kernel вместо copy-$BOOTLOADER (см 0020)

8 Остальное мелочи.

Также я отправил в Сизиф livecd-install, который может восстанавливать 
ядро не только из syslinux/alt0, но и boot:

[#243884] DONE (try 2) livecd-install.git=0.9.12-alt1

Итого, для полного счастья не хватает только выбора языка и графической 
темы.

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


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

>From 844a75faf4943665aafb81402fdf224b06e1f02f Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 20:34:52 +0700
Subject: [PATCH 01/20] 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 620b8dac4b..11890e5381 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 #3: 0002-grub-replace-PATH-to-kernel-and-grub.cfg-to-boot.patch --]
[-- Type: text/x-patch, Size: 9928 bytes --]

>From e5ef8d26042f88e38a09a94fe9bc0e3756940c1b Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Thu, 2 Jan 2020 22:28:16 +0700
Subject: [PATCH 02/20] grub: replace PATH to kernel and grub.cfg to boot/

grub not only for EFI.
---
 features.in/grub/cfg.in/20install2.cfg               | 6 +++---
 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/generate.mk                         | 2 +-
 features.in/grub/scripts.d/20-propagator-ramdisk     | 4 ++--
 features.in/grub/scripts.d/20-propagator-rescue-hash | 4 ++--
 features.in/grub/stage1/scripts.d/01-grub            | 4 ++--
 13 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/features.in/grub/cfg.in/20install2.cfg b/features.in/grub/cfg.in/20install2.cfg
index 1da6304eb5..fb6d0407b6 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/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@
+  initrd$linux_suffix /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
index 178e8fccd5..5041350e6f 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/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncconnect=IP
+  initrd$linux_suffix /boot/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
index 53b2b5119b..f6252ba262 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/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD
+  initrd$linux_suffix /boot/full.cz
 }
 
diff --git a/features.in/grub/cfg.in/30live.cfg b/features.in/grub/cfg.in/30live.cfg
index d53a1e506a..079eaae8f5 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/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
+  initrd$linux_suffix /boot/full.cz
 }
 
 
diff --git a/features.in/grub/cfg.in/32live_rw.cfg b/features.in/grub/cfg.in/32live_rw.cfg
index 55c4b977fe..406ff19486 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/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
+  initrd$linux_suffix /boot/full.cz
 }
diff --git a/features.in/grub/cfg.in/80rescue.cfg b/features.in/grub/cfg.in/80rescue.cfg
index c6c0ae53c9..d863ef0c1e 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/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@
+  initrd$linux_suffix /boot/full.cz
 }
diff --git a/features.in/grub/cfg.in/82rescue_rw.cfg b/features.in/grub/cfg.in/82rescue_rw.cfg
index ec18be28bb..c6365be080 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/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/full.cz
 }
diff --git a/features.in/grub/cfg.in/83rescue_fm.cfg b/features.in/grub/cfg.in/83rescue_fm.cfg
index 71bf21d3b7..fa8bf7adfb 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/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/full.cz
 }
diff --git a/features.in/grub/cfg.in/85mediacheck.cfg b/features.in/grub/cfg.in/85mediacheck.cfg
index 6779dd00d3..3a2fbe4105 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/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@
+  initrd$linux_suffix /boot/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..a01b8f3127 100755
--- a/features.in/grub/scripts.d/20-propagator-ramdisk
+++ b/features.in/grub/scripts.d/20-propagator-ramdisk
@@ -5,9 +5,9 @@
 
 cd "$WORKDIR"
 
-cfgs="$(find EFI/BOOT -name '*.cfg')"
+cfgs="$(find boot/grub -name '*.cfg')"
 [ -n "$cfgs" ] || {
-	echo "${0##*/}: did not find any config under EFI/BOOT " >&2
+	echo "${0##*/}: did not find any config under boot/grub " >&2
 	exit 1
 }
 
diff --git a/features.in/grub/scripts.d/20-propagator-rescue-hash b/features.in/grub/scripts.d/20-propagator-rescue-hash
index fff0be0ce9..7a13499693 100755
--- a/features.in/grub/scripts.d/20-propagator-rescue-hash
+++ b/features.in/grub/scripts.d/20-propagator-rescue-hash
@@ -5,10 +5,10 @@
 
 cd "$WORKDIR"
 
-grep -qs "@rescue_hash@" EFI/BOOT/*.cfg || exit 0
+grep -qs "@rescue_hash@" boot/grub/*.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
+	sed -i "s,@rescue_hash@,$rescue_hash," boot/grub/*.cfg
 done
diff --git a/features.in/grub/stage1/scripts.d/01-grub b/features.in/grub/stage1/scripts.d/01-grub
index 11890e5381..2c13a4b893 100755
--- a/features.in/grub/stage1/scripts.d/01-grub
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -4,8 +4,8 @@
 
 CFG="grub.cfg"
 
-mkdir -p "$WORKDIR/EFI/BOOT"
-cd "$WORKDIR/EFI/BOOT"
+mkdir -p "$WORKDIR/boot/grub"
+cd "$WORKDIR/boot/grub"
 
 # validate just in case (see also stage1 Makefile)
 case "$GLOBAL_BOOTLOADER" in
-- 
2.24.1


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

>From 77fbdc8d9f2e368c2d5ca95e15971cdd3f544732 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 22:50:57 +0700
Subject: [PATCH 03/20] 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 2c13a4b893..4d2a7ac007 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 #5: 0004-grub-do-not-create-grub.cfg-if-EFI_BOOTLOADER-is-set.patch --]
[-- Type: text/x-patch, Size: 2351 bytes --]

>From 487a864b4275644c5f8a32a2978ffe8264ae9a71 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 20:00:50 +0700
Subject: [PATCH 04/20] grub: do not create grub.cfg if EFI_BOOTLOADER is set
 to not equal grub-efi

---
 .../grub/scripts.d/20-propagator-ramdisk      |  2 ++
 .../grub/scripts.d/20-propagator-rescue-hash  |  2 ++
 features.in/grub/stage1/scripts.d/01-grub     | 20 ++++++++++++-------
 3 files changed, 17 insertions(+), 7 deletions(-)

diff --git a/features.in/grub/scripts.d/20-propagator-ramdisk b/features.in/grub/scripts.d/20-propagator-ramdisk
index a01b8f3127..059c60ef76 100755
--- a/features.in/grub/scripts.d/20-propagator-ramdisk
+++ b/features.in/grub/scripts.d/20-propagator-ramdisk
@@ -5,6 +5,8 @@
 
 cd "$WORKDIR"
 
+[ -d boot/grub ] || exit 0
+
 cfgs="$(find boot/grub -name '*.cfg')"
 [ -n "$cfgs" ] || {
 	echo "${0##*/}: did not find any config under boot/grub " >&2
diff --git a/features.in/grub/scripts.d/20-propagator-rescue-hash b/features.in/grub/scripts.d/20-propagator-rescue-hash
index 7a13499693..92c5972a65 100755
--- a/features.in/grub/scripts.d/20-propagator-rescue-hash
+++ b/features.in/grub/scripts.d/20-propagator-rescue-hash
@@ -5,6 +5,8 @@
 
 cd "$WORKDIR"
 
+[ -d boot/grub ] || exit 0
+
 grep -qs "@rescue_hash@" boot/grub/*.cfg || exit 0
 
 find -maxdepth 1 -type f -name rescue \
diff --git a/features.in/grub/stage1/scripts.d/01-grub b/features.in/grub/stage1/scripts.d/01-grub
index 4d2a7ac007..4c7d5e23ee 100755
--- a/features.in/grub/stage1/scripts.d/01-grub
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -4,16 +4,22 @@
 
 CFG="grub.cfg"
 
+if [ -n "$GLOBAL_EFI_BOOTLOADER" -a ! "$GLOBAL_EFI_BOOTLOADER" = "grub-efi" ]; then
+	rm -fr "$WORKDIR/boot"
+	exit 0
+fi
+
+if [ -z "$GLOBAL_EFI_BOOTLOADER" ]; then
+	case "$GLOBAL_BOOTLOADER" in
+		ieee1275boot|grubaa64boot|grubx86boot) ;;
+		*) rm -fr "$WORKDIR/boot"
+		   exit 0;;
+	esac
+fi
+
 mkdir -p "$WORKDIR/boot/grub"
 cd "$WORKDIR/boot/grub"
 
-# 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
-- 
2.24.1


[-- Attachment #6: 0005-grub-generate-configs-boot-grub-grub.cfg-and-EFI-BOO.patch --]
[-- Type: text/x-patch, Size: 4179 bytes --]

>From 1ee8d93445a8ed6468d2b00645a268bb4532013c Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Wed, 8 Jan 2020 11:24:17 +0700
Subject: [PATCH 05/20] grub: generate configs boot/grub/grub.cfg and
 EFI/BOOT/grub.cfg if necessary

---
 .../grub/scripts.d/20-propagator-ramdisk      | 10 +++---
 .../grub/scripts.d/20-propagator-rescue-hash  |  8 +++--
 features.in/grub/stage1/scripts.d/01-grub     | 33 +++++++++++++++----
 3 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/features.in/grub/scripts.d/20-propagator-ramdisk b/features.in/grub/scripts.d/20-propagator-ramdisk
index 059c60ef76..04470b6c85 100755
--- a/features.in/grub/scripts.d/20-propagator-ramdisk
+++ b/features.in/grub/scripts.d/20-propagator-ramdisk
@@ -5,13 +5,11 @@
 
 cd "$WORKDIR"
 
-[ -d boot/grub ] || exit 0
+[ -f boot/grub/grub.cfg -o -f EFI/BOOT/grub.cfg ] || exit 0
 
-cfgs="$(find boot/grub -name '*.cfg')"
-[ -n "$cfgs" ] || {
-	echo "${0##*/}: did not find any config under boot/grub " >&2
-	exit 1
-}
+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 92c5972a65..3ca61591bc 100755
--- a/features.in/grub/scripts.d/20-propagator-rescue-hash
+++ b/features.in/grub/scripts.d/20-propagator-rescue-hash
@@ -5,12 +5,14 @@
 
 cd "$WORKDIR"
 
-[ -d boot/grub ] || exit 0
+[ -f boot/grub/grub.cfg -o -f EFI/BOOT/grub.cfg ] || exit 0
 
-grep -qs "@rescue_hash@" 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," boot/grub/*.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 4c7d5e23ee..eeb3c49760 100755
--- a/features.in/grub/stage1/scripts.d/01-grub
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -2,7 +2,8 @@
 # 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"
 
 if [ -n "$GLOBAL_EFI_BOOTLOADER" -a ! "$GLOBAL_EFI_BOOTLOADER" = "grub-efi" ]; then
 	rm -fr "$WORKDIR/boot"
@@ -27,21 +28,41 @@ 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
+	grubx86boot)
+		grep -hv '^#' $(find .in/*.cfg -not -name *_efi.cfg) > "$CFG" ;;
+	ieee1275boot)
+		grep -hv '^#' $(find .in/*.cfg -not -name *_efi.cfg -not -name *_x86.cfg) > "$CFG" ;;
+esac
+
+if [ "$GLOBAL_EFI_BOOTLOADER" = "grub-efi" ]; then
+	mkdir -p "$WORKDIR/EFI/BOOT"
+	grep -hv '^#' $(find .in/*.cfg -not -name *_x86.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
+}
+
+[ ! -f "$CFG" ] || default_change "$CFG"
+[ ! -f "$CFG_EFI" ] || default_change "$CFG_EFI"
 
 # snippets are not going into the actual image
-if [ "$DEBUG" != 2 ]; then rm -r .in/; fi
+if [ "$DEBUG" != 2 ]; then
+	rm -r .in/
+	cd ..
+	[ -f "$CFG" ] || rm -r grub/
+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 #7: 0006-grub-add-suffix-_efi-for-EFI-configs.patch --]
[-- Type: text/x-patch, Size: 1005 bytes --]

>From 30d4235d95ea359ecd1c8caa5feb18678015ab88 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Wed, 8 Jan 2020 15:29:17 +0700
Subject: [PATCH 06/20] 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 #8: 0007-grub-fixed-PATH-to-memtest86.efi-in-90memtest-efi.cf.patch --]
[-- Type: text/x-patch, Size: 732 bytes --]

>From 9daadf582c8fec5b1bfbc48fac24a1bfa6c712f5 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 20:46:48 +0700
Subject: [PATCH 07/20] 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 #9: 0008-grub-change-linux_suffix.patch --]
[-- Type: text/x-patch, Size: 9307 bytes --]

>From 5a899a2e925793226a6ba1474eb1390c6a04e22c Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Fri, 3 Jan 2020 16:58:15 +0700
Subject: [PATCH 08/20] 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 fb6d0407b6..0031499e4c 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/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@
-  initrd$linux_suffix /boot/full.cz
+  linux@linux_suffix@ /boot/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ vga=@bootvga@ @bootargs@
+  initrd@linux_suffix@ /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
index 5041350e6f..2c41df10d3 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/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncconnect=IP
-  initrd$linux_suffix /boot/BOOT/full.cz
+  linux@linux_suffix@ /boot/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncconnect=IP
+  initrd@linux_suffix@ /boot/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
index f6252ba262..1b847bd14a 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/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD
-  initrd$linux_suffix /boot/full.cz
+  linux@linux_suffix@ /boot/vmlinuz changedisk fastboot automatic=method:cdrom ramdisk_size=@altinst_size@ showopts @bootargs@ headless no_alt_virt_keyboard vncpassword=VNCPWD
+  initrd@linux_suffix@ /boot/full.cz
 }
 
diff --git a/features.in/grub/cfg.in/30live.cfg b/features.in/grub/cfg.in/30live.cfg
index 079eaae8f5..d4fd6a8303 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/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
-  initrd$linux_suffix /boot/full.cz
+  linux@linux_suffix@ /boot/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
+  initrd@linux_suffix@ /boot/full.cz
 }
 
 
diff --git a/features.in/grub/cfg.in/32live_rw.cfg b/features.in/grub/cfg.in/32live_rw.cfg
index 406ff19486..11df0b62ed 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/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
-  initrd$linux_suffix /boot/full.cz
+  linux@linux_suffix@ /boot/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
+  initrd@linux_suffix@ /boot/full.cz
 }
diff --git a/features.in/grub/cfg.in/80rescue.cfg b/features.in/grub/cfg.in/80rescue.cfg
index d863ef0c1e..59a266c231 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/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@
-  initrd$linux_suffix /boot/full.cz
+  linux@linux_suffix@ /boot/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@rescue_size@ stagename=rescue splash=0 showopts @rescue_bootargs@
+  initrd@linux_suffix@ /boot/full.cz
 }
diff --git a/features.in/grub/cfg.in/82rescue_rw.cfg b/features.in/grub/cfg.in/82rescue_rw.cfg
index c6365be080..2bf7dd628e 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/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/full.cz
+  linux@linux_suffix@ /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@ /boot/full.cz
 }
diff --git a/features.in/grub/cfg.in/83rescue_fm.cfg b/features.in/grub/cfg.in/83rescue_fm.cfg
index fa8bf7adfb..a374a76311 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/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/full.cz
+  linux@linux_suffix@ /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@ /boot/full.cz
 }
diff --git a/features.in/grub/cfg.in/85mediacheck.cfg b/features.in/grub/cfg.in/85mediacheck.cfg
index 3a2fbe4105..02c0dfe286 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/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@
-  initrd$linux_suffix /boot/full.cz
+  linux@linux_suffix@ /boot/vmlinuz changedisk live quiet lowmem automatic=method:cdrom mediacheck=1 stagename=mediacheck showopts @bootargs@
+  initrd@linux_suffix@ /boot/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 eeb3c49760..4cd1825ef9 100755
--- a/features.in/grub/stage1/scripts.d/01-grub
+++ b/features.in/grub/stage1/scripts.d/01-grub
@@ -57,6 +57,18 @@ fi
 [ ! -f "$CFG" ] || default_change "$CFG"
 [ ! -f "$CFG_EFI" ] || default_change "$CFG_EFI"
 
+# 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 #10: 0009-grub-available-for-i586-x86_64-aarch64-ppc64le.patch --]
[-- Type: text/x-patch, Size: 895 bytes --]

>From 28d65b333f31af531c4c9777eed9d9b53adce8cf Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 21:51:30 +0700
Subject: [PATCH 09/20] 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 #11: 0010-grub-add-84rescue_remote.cfg.patch --]
[-- Type: text/x-patch, Size: 947 bytes --]

>From 703cc8cd1cd6289f5569ec0c9909ed5b939b5854 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 20:29:45 +0700
Subject: [PATCH 10/20] 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..c9e3304619
--- /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/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/full.cz
+}
-- 
2.24.1


[-- Attachment #12: 0011-grub-Added-release-name-to-LiveCD-menu-items.patch --]
[-- Type: text/x-patch, Size: 1568 bytes --]

>From 39af0ff9b87ad51acece91e885bcc7d96a5c8e4b Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 20:41:23 +0700
Subject: [PATCH 11/20] 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 d4fd6a8303..a9e9ab7451 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/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts lowmem vga=@bootvga@ @bootargs@
   initrd@linux_suffix@ /boot/full.cz
 }
diff --git a/features.in/grub/cfg.in/32live_rw.cfg b/features.in/grub/cfg.in/32live_rw.cfg
index 11df0b62ed..cec2da186d 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/vmlinuz changedisk fastboot live automatic=method:cdrom ramdisk_size=@live_size@ stagename=live showopts live_rw vga=@bootvga@ @bootargs@
   initrd@linux_suffix@ /boot/full.cz
 }
-- 
2.24.1


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

>From b348e69a85d8777842a1ca9156d8fae006fd1225 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Fri, 3 Jan 2020 21:11:15 +0700
Subject: [PATCH 12/20] 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 #14: 0013-efi-do-not-call-use-efi-refind-from-use-efi-memtest8.patch --]
[-- Type: text/x-patch, Size: 907 bytes --]

>From c172fccaa68797be25bef53f3034e5f18a0a9afa Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 21:04:02 +0700
Subject: [PATCH 13/20] 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 #15: 0014-efi-use-efi-grub-by-default-for-all-arches.patch --]
[-- Type: text/x-patch, Size: 897 bytes --]

>From ae1a96f6530b50882372cda42e31dc09c92eaf28 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Mon, 30 Dec 2019 18:55:32 +0700
Subject: [PATCH 14/20] 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 #16: 0015-syslinux-do-not-use-syslinux-to-generate-config-on-u.patch --]
[-- Type: text/x-patch, Size: 3849 bytes --]

>From 0d66510f857a745a1ac0ffd4dde372c8b7f4e0de Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Sun, 5 Jan 2020 22:10:07 +0700
Subject: [PATCH 15/20] 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 #17: 0016-syslinux-fixed-for-using-BOOTLOADER-not-equal-syslin.patch --]
[-- Type: text/x-patch, Size: 3088 bytes --]

>From 994759b4d916f3b29c4b869ba09e07338b4283a8 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Mon, 6 Jan 2020 23:26:52 +0700
Subject: [PATCH 16/20] 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 #18: 0020-sub.in-stage1-call-copy-kernel-instead-of-copy-BOOTL.patch --]
[-- Type: text/x-patch, Size: 1035 bytes --]

>From 76d5d98c0e730f8af30670a054843a188a068516 Mon Sep 17 00:00:00 2001
From: Anton Midyukov <antohami@altlinux.org>
Date: Tue, 7 Jan 2020 21:48:53 +0700
Subject: [PATCH 20/20] 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


  parent reply	other threads:[~2020-01-08 19:29 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 ` Антон Мидюков [this message]
2020-01-09 14:39   ` Антон Мидюков
2020-01-12 15:18     ` Антон Мидюков
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=c0d65896-2cc3-32b2-b61c-46ae46ae816d@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