Add Paravis return entry for legacy Ventoy

This commit is contained in:
paravis committed 2026-11-08 18:50:14 +03:00
1 parent def566d9ba
commit 3ce96d1366
2 files changed
+88

No files matched your search

+11
View File
@@ -24,6 +24,7 @@ paravis/
patch_ventoy_grubcfg.py патч grub.cfg (поиск раздела данных по маркеру)
patch_ventoy_hook.py патч initramfs hook для раздела данных не 1
patch_vtoyjump.py обход проверки MBR в vtoyjump32/64
patch_ventoy_paravis_return.py пункт «Возврат в главное меню Paravis Flash»
patch-ventoy-lang.sh язык меню по умолчанию → ru_RU
build-theme-main.py сборка темы GRUB из PSD-макета
theme/ ресурсы темы GRUB и ventoy.json
@@ -50,8 +51,18 @@ python3 paravis/patch_vtoyjump.py <каталог-с-бинарниками-vtoy
# 5. язык меню по умолчанию
./paravis/patch-ventoy-lang.sh vtoyefi/grub/grub.cfg
# 6. пункт «Возврат в главное меню Paravis Flash» (legacy + UEFI)
python3 paravis/patch_ventoy_paravis_return.py vtoyefi/grub/grub.cfg
```
`patch_ventoy_paravis_return.py` добавляет в `grub.cfg` функцию
`paravis_return` и пункт меню, который возвращает в главное меню Paravis:
в UEFI — через `grubx64.efi`, в BIOS — через MBR диска
(`chainloader (${vtoydev})+1`). Результат копируется в `grbp.cfg` — его
загружает UEFI-сборка `grubx64_parv.efi`, которую запускает меню Paravis;
legacy `core.img` загружает обычный `grub.cfg`.
`patch_vtoyjump.py` патчит скомпилированные бинарники; его можно запускать
повторно — уже пропатченные файлы пропускаются.
+77
View File
@@ -0,0 +1,77 @@
#!/usr/bin/env python3
"""Add the "return to Paravis main menu" item to Ventoy's grub.cfg.
The extra menu entry chainloads the Paravis boot menu:
* UEFI -> /efi/Paravis/Boot/grub2/grubx64.efi
* BIOS -> MBR of the Ventoy disk: chainloader (${vtoydev})+1
Usage:
python3 patch_ventoy_paravis_return.py <path-to-grub/grub.cfg>
The patched file is written back to grub.cfg and copied to grbp.cfg in the
same directory. grbp.cfg is loaded by the UEFI build (grubx64_parv.efi) that
the Paravis menu chainloads; the legacy core.img loads grub.cfg.
"""
import io
import os
import sys
FUNC = '''function paravis_return {
if [ "$grub_platform" = "efi" ]; then
search --no-floppy --file --set=root /efi/Paravis/Boot/grub2/grub.cfg
if [ "$grub_cpu" = "x86_64" ]; then
chainloader /efi/Paravis/Boot/grub2/grubx64.efi
else
chainloader /EFI/Boot/bootia32.efi
fi
else
chainloader (${vtoydev})+1
fi
boot
}
'''
MENU = '''menuentry "Возврат в главное меню Paravis Flash" --id="paravis_return" --class="vtoyret" {
paravis_return
}
set default="paravis_return"
'''
def main():
if len(sys.argv) != 2:
print(__doc__)
return 1
path = sys.argv[1]
text = io.open(path, encoding='utf-8', newline='').read()
if 'function paravis_return' in text:
print('already patched: ' + path)
else:
anchor = 'function ventoy_ext_menu {'
if text.count(anchor) != 1:
print('anchor not found or not unique: ' + anchor)
return 1
text = text.replace(anchor, FUNC + '\n' + anchor, 1)
anchor = '#special VTOY_DEFAULT_IMAGE process'
if text.count(anchor) != 1:
print('anchor not found or not unique: ' + anchor)
return 1
text = text.replace(anchor, MENU + '\n' + anchor, 1)
io.open(path, 'w', encoding='utf-8', newline='').write(text)
print('patched: ' + path)
grbp = os.path.join(os.path.dirname(path), 'grbp.cfg')
io.open(grbp, 'w', encoding='utf-8', newline='').write(text)
print('written: ' + grbp)
return 0
if __name__ == '__main__':
sys.exit(main())