sys-boot/grub: Sync with Gentoo

It's from Gentoo commit c87d524aeca7813214da2451a9e4ab357bb32e2f.

Signed-off-by: Flatcar Buildbot <buildbot@flatcar-linux.org>
This commit is contained in:
Flatcar Buildbot 2026-01-12 07:17:08 +00:00 committed by Krzesimir Nowak
parent d8d5154d87
commit 9a3a104223
4 changed files with 226 additions and 19 deletions

View File

@ -0,0 +1,191 @@
From 0876fdf215292a06ad087f862ae7677c85ae444f Mon Sep 17 00:00:00 2001
From: Gary Lin <glin@suse.com>
Date: Mon, 25 Mar 2024 10:11:34 +0800
Subject: util/bash-completion: Fix for bash-completion 2.12
_split_longopt() was the bash-completion private API and removed since
bash-completion 2.12. This commit initializes the bash-completion
general variables with _init_completion() to avoid the potential
"command not found" error.
Although bash-completion 2.12 introduces _comp_initialize() to deprecate
_init_completion(), _init_completion() is still chosen for the better
backward compatibility.
Signed-off-by: Gary Lin <glin@suse.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
---
util/bash-completion.d/grub-completion.bash.in | 61 ++++++++++----------------
1 file changed, 22 insertions(+), 39 deletions(-)
(limited to 'util/bash-completion.d/grub-completion.bash.in')
diff --git a/util/bash-completion.d/grub-completion.bash.in b/util/bash-completion.d/grub-completion.bash.in
index 4c88ee901..749a5d3cf 100644
--- a/util/bash-completion.d/grub-completion.bash.in
+++ b/util/bash-completion.d/grub-completion.bash.in
@@ -151,13 +151,10 @@ __grub_list_modules () {
# grub-set-default & grub-reboot
#
__grub_set_entry () {
- local cur prev split=false
+ local cur prev words cword split
+ _init_completion -s || return
COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
-
- _split_longopt && split=true
case "$prev" in
--boot-directory)
@@ -180,11 +177,10 @@ __grub_set_entry () {
# grub-editenv
#
__grub_editenv () {
- local cur prev
+ local cur prev words cword
+ _init_completion || return
COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
case "$prev" in
create|list|set|unset)
@@ -201,10 +197,10 @@ __grub_editenv () {
# grub-mkconfig
#
__grub_mkconfig () {
- local cur prev
+ local cur prev words cword
+ _init_completion || return
COMPREPLY=()
- cur=`_get_cword`
if [[ "$cur" == -* ]]; then
__grubcomp "$(__grub_get_options_from_help)"
@@ -217,13 +213,10 @@ __grub_mkconfig () {
# grub-setup
#
__grub_setup () {
- local cur prev split=false
+ local cur prev words cword split
+ _init_completion -s || return
COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
-
- _split_longopt && split=true
case "$prev" in
-d|--directory)
@@ -246,15 +239,12 @@ __grub_setup () {
# grub-install
#
__grub_install () {
- local cur prev last split=false
+ local cur prev words cword split last
+ _init_completion -s || return
COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
last=$(__grub_get_last_option)
- _split_longopt && split=true
-
case "$prev" in
--boot-directory)
_filedir -d
@@ -287,10 +277,10 @@ __grub_install () {
# grub-mkfont
#
__grub_mkfont () {
- local cur
+ local cur prev words cword
+ _init_completion || return
COMPREPLY=()
- cur=`_get_cword`
if [[ "$cur" == -* ]]; then
__grubcomp "$(__grub_get_options_from_help)"
@@ -304,11 +294,10 @@ __grub_mkfont () {
# grub-mkrescue
#
__grub_mkrescue () {
- local cur prev last
+ local cur prev words cword last
+ _init_completion || return
COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
last=$(__grub_get_last_option)
if [[ "$cur" == -* ]]; then
@@ -330,13 +319,10 @@ __grub_mkrescue () {
# grub-mkimage
#
__grub_mkimage () {
- local cur prev split=false
+ local cur prev words cword split
+ _init_completion -s || return
COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
-
- _split_longopt && split=true
case "$prev" in
-d|--directory|-p|--prefix)
@@ -367,10 +353,10 @@ __grub_mkimage () {
# grub-mkpasswd-pbkdf2
#
__grub_mkpasswd_pbkdf2 () {
- local cur
+ local cur prev words cword
+ _init_completion || return
COMPREPLY=()
- cur=`_get_cword`
if [[ "$cur" == -* ]]; then
__grubcomp "$(__grub_get_options_from_help)"
@@ -384,13 +370,10 @@ __grub_mkpasswd_pbkdf2 () {
# grub-probe
#
__grub_probe () {
- local cur prev split=false
+ local cur prev words cword split
+ _init_completion -s || return
COMPREPLY=()
- cur=`_get_cword`
- prev=${COMP_WORDS[COMP_CWORD-1]}
-
- _split_longopt && split=true
case "$prev" in
-t|--target)
@@ -417,10 +400,10 @@ __grub_probe () {
# grub-script-check
#
__grub_script_check () {
- local cur
+ local cur prev words cword
+ _init_completion || return
COMPREPLY=()
- cur=`_get_cword`
if [[ "$cur" == -* ]]; then
__grubcomp "$(__grub_get_options_from_help)"
--
cgit v1.2.3

View File

@ -1,4 +1,4 @@
# Copyright 1999-2025 Gentoo Authors
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=7
@ -66,6 +66,7 @@ PATCHES=(
"${FILESDIR}"/grub-2.12-fwsetup.patch
"${WORKDIR}"/grub-2.12-bash-completion.patch
"${FILESDIR}"/grub-2.12-zfs-zstd-compression-support.patch
"${FILESDIR}"/grub-2.12-fix-for-bash-completion-_split_longopt.patch
)
DEJAVU=dejavu-sans-ttf-2.37
@ -76,7 +77,7 @@ SRC_URI+=" fonts? ( mirror://gnu/unifont/${UNIFONT}/${UNIFONT}.pcf.gz )
# Includes licenses for dejavu and unifont
LICENSE="GPL-3+ BSD MIT fonts? ( GPL-2-with-font-exception ) themes? ( CC-BY-SA-3.0 BitstreamVera )"
SLOT="2/${PVR}"
IUSE="+device-mapper doc efiemu +fonts mount nls sdl test +themes truetype libzfs"
IUSE="+branding +device-mapper doc efiemu +fonts mount nls sdl test +themes truetype libzfs"
GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot
qemu qemu-mips pc uboot xen xen-32 xen-pvh )
@ -130,6 +131,7 @@ DEPEND="
ppc64? ( >=sys-apps/ibm-powerpc-utils-1.3.5 )
"
RDEPEND="${DEPEND}
branding? ( >=sys-boot/grub-themes-gentoo-1.0-r1 )
kernel_linux? (
grub_platforms_efi-32? ( sys-boot/efibootmgr )
grub_platforms_efi-64? ( sys-boot/efibootmgr )
@ -370,6 +372,11 @@ src_install() {
insinto /etc/default
newins "${FILESDIR}"/grub.default-4 grub
if use branding && use themes ; then
sed -i -e 's:^#GRUB_THEME=.*$:GRUB_THEME="/boot/grub/themes/gentoo_glass/theme.txt":g' \
"${ED}/etc/default/grub" || die
fi
# https://bugs.gentoo.org/231935
dostrip -x /usr/lib/grub

View File

@ -1,4 +1,4 @@
# Copyright 1999-2025 Gentoo Authors
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
@ -84,7 +84,7 @@ SRC_URI+="
# Includes licenses for dejavu and unifont
LICENSE="GPL-3+ BSD MIT fonts? ( GPL-2-with-font-exception ) themes? ( CC-BY-SA-3.0 BitstreamVera )"
SLOT="2/${PVR}"
IUSE="+device-mapper doc efiemu +fonts mount nls protect sdl test +themes truetype libzfs"
IUSE="+branding +device-mapper doc efiemu +fonts mount nls protect sdl test +themes truetype libzfs"
GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot
qemu qemu-mips pc uboot xen xen-32 xen-pvh )
@ -138,6 +138,7 @@ DEPEND="
protect? ( dev-libs/libtasn1:= )
"
RDEPEND="${DEPEND}
branding? ( themes? ( >=sys-boot/grub-themes-gentoo-1.0-r1 ) )
kernel_linux? (
grub_platforms_efi-32? ( sys-boot/efibootmgr )
grub_platforms_efi-64? ( sys-boot/efibootmgr )
@ -380,6 +381,11 @@ src_install() {
insinto /etc/default
newins "${FILESDIR}"/grub.default-4 grub
if use branding && use themes ; then
sed -i -e 's:^#GRUB_THEME=.*$:GRUB_THEME="/boot/grub/themes/gentoo_glass/theme.txt":g' \
"${ED}/etc/default/grub" || die
fi
# https://bugs.gentoo.org/231935
dostrip -x /usr/lib/grub

View File

@ -1,4 +1,4 @@
# Copyright 1999-2025 Gentoo Authors
# Copyright 1999-2026 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
EAPI=8
@ -63,12 +63,6 @@ else
EGIT_REPO_URI="https://git.savannah.gnu.org/git/grub.git"
fi
PATCHES=(
"${FILESDIR}"/gfxpayload.patch
"${FILESDIR}"/grub-2.02_beta2-KERNEL_GLOBS.patch
"${FILESDIR}"/grub-2.06-test-words.patch
)
DEJAVU_VER=2.37
DEJAVU=dejavu-fonts-ttf-${DEJAVU_VER}
UNIFONT=unifont-17.0.02
@ -83,7 +77,7 @@ SRC_URI+="
# Includes licenses for dejavu and unifont
LICENSE="GPL-3+ BSD MIT fonts? ( GPL-2-with-font-exception ) themes? ( CC-BY-SA-3.0 BitstreamVera )"
SLOT="2/${PVR}"
IUSE="+device-mapper doc efiemu +fonts mount nls protect sdl test +themes truetype libzfs"
IUSE="+branding +device-mapper doc efiemu +fonts mount nls protect sdl test +themes truetype libzfs"
GRUB_ALL_PLATFORMS=( coreboot efi-32 efi-64 emu ieee1275 loongson multiboot
qemu qemu-mips pc uboot xen xen-32 xen-pvh )
@ -137,6 +131,7 @@ DEPEND="
protect? ( dev-libs/libtasn1:= )
"
RDEPEND="${DEPEND}
branding? ( themes? ( >=sys-boot/grub-themes-gentoo-1.0-r1 ) )
kernel_linux? (
grub_platforms_efi-32? ( sys-boot/efibootmgr )
grub_platforms_efi-64? ( sys-boot/efibootmgr )
@ -164,7 +159,9 @@ src_unpack() {
local GNULIB_REVISION=$(source bootstrap.conf >/dev/null; echo "${GNULIB_REVISION}")
git-r3_fetch "${GNULIB_URI}" "${GNULIB_REVISION}"
git-r3_checkout "${GNULIB_URI}" gnulib
sh linguas.sh || die
if use nls; then
sh linguas.sh || die
fi
popd >/dev/null || die
elif use verify-sig; then
verify-sig_verify_detached "${DISTDIR}"/${MY_P}.tar.xz{,.sig} \
@ -184,7 +181,7 @@ src_prepare() {
if [[ -n ${GRUB_BOOTSTRAP} ]]; then
eautopoint --force
AUTOPOINT=: AUTORECONF=: ./bootstrap || die
AUTOPOINT=: AUTORECONF=: ./bootstrap --skip-po || die
elif [[ -n ${GRUB_AUTOGEN} ]]; then
FROM_BOOTSTRAP=1 ./autogen.sh || die
fi
@ -380,6 +377,11 @@ src_install() {
insinto /etc/default
newins "${FILESDIR}"/grub.default-4 grub
if use branding && use themes ; then
sed -i -e 's:^#GRUB_THEME=.*$:GRUB_THEME="/boot/grub/themes/gentoo_glass/theme.txt":g' \
"${ED}/etc/default/grub" || die
fi
# https://bugs.gentoo.org/231935
dostrip -x /usr/lib/grub
@ -412,16 +414,17 @@ pkg_postinst() {
ewarn
fi
if has_version 'sys-boot/grub:0'; then
elog "A migration guide for GRUB Legacy users is available:"
elog " https://wiki.gentoo.org/wiki/GRUB2_Migration"
fi
if has_version sys-boot/os-prober; then
ewarn "Due to security concerns, os-prober is disabled by default."
ewarn "Set GRUB_DISABLE_OS_PROBER=false in /etc/default/grub to enable it."
fi
if grep -q GRUB_LINUX_KERNEL_GLOBS "${EROOT}"/etc/default/grub; then
ewarn "Support for GRUB_LINUX_KERNEL_GLOBS has been dropped."
ewarn "Ensure that your kernels are named appropriately or edit"
ewarn "/etc/grub.d/10_linux to compensate."
fi
if use secureboot; then
elog
elog "The signed standalone grub EFI executable(s) are available in:"