pmb.parse.kconfig: implement UEFI kconfig check (MR 2169)

This commit is contained in:
Bart Ribbers 2022-02-26 16:06:59 +01:00 committed by Oliver Smith
parent 8c429f74ca
commit 1eef7fbdeb
No known key found for this signature in database
GPG Key ID: 0BF4C1B5988C50D8
8 changed files with 152 additions and 2 deletions

View File

@ -158,4 +158,5 @@ def menuconfig(args, pkgname, use_oldconfig):
force_containers_check=False,
force_zram_check=False,
force_netboot_check=False,
force_uefi_check=False,
details=True)

View File

@ -581,6 +581,22 @@ necessary_kconfig_options_netboot = {
},
}
# Necessary UEFI boot config options
necessary_kconfig_options_uefi = {
">=0.0.0": { # all versions
"all": { # all arches
"EFI_STUB": True,
"EFI": True,
"DMI": True,
"EFI_ESRT": True,
"EFI_VARS_PSTORE": True,
"EFI_PARAMS_FROM_FDT": True,
"EFI_RUNTIME_WRAPPERS": True,
"EFI_GENERIC_STUB": True,
}
},
}
#
# PARSE
#

View File

@ -384,6 +384,7 @@ def kconfig(args):
containers=args.containers,
zram=args.zram,
netboot=args.netboot,
uefi=args.uefi,
details=True):
logging.info("kconfig check succeeded!")
return
@ -420,6 +421,7 @@ def kconfig(args):
force_containers_check=args.containers,
force_zram_check=args.zram,
force_netboot_check=args.netboot,
force_uefi_check=args.uefi,
details=True):
error = True

View File

@ -477,7 +477,9 @@ def arguments_kconfig(subparser):
check.add_argument("--zram", action="store_true", help="check"
" options needed for zram support too")
check.add_argument("--netboot", action="store_true", help="check"
" options needed for netboooting too")
" options needed for netbooting too")
check.add_argument("--uefi", action="store_true", help="check"
" options needed for uefi too")
add_kernel_arg(check)
# "pmbootstrap kconfig edit"

View File

@ -92,6 +92,7 @@ def check_config(config_path, config_path_pretty, config_arch, pkgver,
containers=False,
zram=False,
netboot=False,
uefi=False,
details=False):
logging.debug(f"Check kconfig: {config_path}")
with open(config_path) as handle:
@ -113,6 +114,8 @@ def check_config(config_path, config_path_pretty, config_arch, pkgver,
components["zram"] = pmb.config.necessary_kconfig_options_zram
if netboot:
components["netboot"] = pmb.config.necessary_kconfig_options_netboot
if uefi:
components["uefi"] = pmb.config.necessary_kconfig_options_uefi
results = [check_config_options_set(config, config_path_pretty,
config_arch, options, component,
@ -163,6 +166,7 @@ def check(args, pkgname,
force_containers_check=False,
force_zram_check=False,
force_netboot_check=False,
force_uefi_check=False,
details=False):
"""
Check for necessary kernel config options in a package.
@ -194,6 +198,8 @@ def check(args, pkgname,
"pmb:kconfigcheck-zram" in apkbuild["options"])
check_netboot = force_netboot_check or (
"pmb:kconfigcheck-netboot" in apkbuild["options"])
check_uefi = force_uefi_check or (
"pmb:kconfigcheck-uefi" in apkbuild["options"])
for config_path in glob.glob(aport + "/config-*"):
# The architecture of the config is in the name, so it just needs to be
# extracted
@ -208,6 +214,7 @@ def check(args, pkgname,
containers=check_containers,
zram=check_zram,
netboot=check_netboot,
uefi=check_uefi,
details=details)
return ret
@ -245,7 +252,8 @@ def extract_version(config_file):
def check_file(config_file, anbox=False, nftables=False,
containers=False, zram=False, netboot=False, details=False):
containers=False, zram=False, netboot=False, uefi=False,
details=False):
"""
Check for necessary kernel config options in a kconfig file.
@ -261,4 +269,5 @@ def check_file(config_file, anbox=False, nftables=False,
containers=containers,
zram=zram,
netboot=netboot,
uefi=uefi,
details=details)

View File

@ -38,6 +38,10 @@ def test_kconfig_check(args):
nftables=True)
assert pmb.parse.kconfig.check_file(dir + "good-zram",
zram=True)
assert pmb.parse.kconfig.check_file(dir + "good-uefi",
uefi=True)
assert not pmb.parse.kconfig.check_file(dir + "bad-uefi",
uefi=True)
# tests on real devices
# *** do not add more of these! ***

58
test/testdata/kconfig_check/bad-uefi vendored Normal file
View File

@ -0,0 +1,58 @@
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 5.12.2 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="aarch64-alpine-linux-musl-gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=100301
CONFIG_CLANG_VERSION=0
CONFIG_LD_IS_BFD=y
CONFIG_LD_VERSION=23502
CONFIG_LLD_VERSION=0
CONFIG_CC_HAS_ASM_GOTO=y
CONFIG_CC_HAS_ASM_INLINE=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_TABLE_SORT=y
CONFIG_THREAD_INFO_IN_TASK=y
#
# General setup
#
CONFIG_LOCALVERSION="-zram-good"
CONFIG_BUILD_SALT=""
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_KERNEL_GZIP=y
# CONFIG_KERNEL_LZMA is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
# needed for bubblewrap
CONFIG_USER_NS=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_CGROUPS=y
CONFIG_DEVTMPFS=y
CONFIG_DM_CRYPT=y
CONFIG_INPUT_EVDEV=y
CONFIG_SYSVIPC=y
CONFIG_VT=y
CONFIG_UEVENT_HELPER=y
CONFIG_LBDAF=y
CONFIG_CRYPTO_AES=y
CONFIG_CRYPTO_XTS=y
CONFIG_TMPFS_POSIX_ACL=y
### here's one explicitely disabled:
# ANDROID_PARANOID_NETWORK is not set
### here's one set to module:
CONFIG_EXT4_FS=m
### here's a line set to no:
CONFIG_KINETO_GAN=n
# the required options
#
CONFIG_EFI=n
CONFIG_EFI_STUB=n
CONFIG_DMI=n
CONFIG_EFI_ESRT=n
CONFIG_EFI_VARS_PSTORE=n
CONFIG_EFI_PARAMS_FROM_FDT=n
CONFIG_EFI_RUNTIME_WRAPPERS=n
CONFIG_EFI_GENERIC_STUB=n

58
test/testdata/kconfig_check/good-uefi vendored Normal file
View File

@ -0,0 +1,58 @@
#
# Automatically generated file; DO NOT EDIT.
# Linux/arm64 5.12.2 Kernel Configuration
#
CONFIG_CC_VERSION_TEXT="aarch64-alpine-linux-musl-gcc (Alpine 10.3.1_git20210424) 10.3.1 20210424"
CONFIG_CC_IS_GCC=y
CONFIG_GCC_VERSION=100301
CONFIG_CLANG_VERSION=0
CONFIG_LD_IS_BFD=y
CONFIG_LD_VERSION=23502
CONFIG_LLD_VERSION=0
CONFIG_CC_HAS_ASM_GOTO=y
CONFIG_CC_HAS_ASM_INLINE=y
CONFIG_IRQ_WORK=y
CONFIG_BUILDTIME_TABLE_SORT=y
CONFIG_THREAD_INFO_IN_TASK=y
#
# General setup
#
CONFIG_LOCALVERSION="-zram-good"
CONFIG_BUILD_SALT=""
CONFIG_HAVE_KERNEL_GZIP=y
CONFIG_HAVE_KERNEL_LZO=y
CONFIG_KERNEL_GZIP=y
# CONFIG_KERNEL_LZMA is not set
CONFIG_DEFAULT_HOSTNAME="(none)"
# needed for bubblewrap
CONFIG_USER_NS=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_CGROUPS=y
CONFIG_DEVTMPFS=y
CONFIG_DM_CRYPT=y
CONFIG_INPUT_EVDEV=y
CONFIG_SYSVIPC=y
CONFIG_VT=y
CONFIG_UEVENT_HELPER=y
CONFIG_LBDAF=y
CONFIG_CRYPTO_AES=y
CONFIG_CRYPTO_XTS=y
CONFIG_TMPFS_POSIX_ACL=y
### here's one explicitely disabled:
# ANDROID_PARANOID_NETWORK is not set
### here's one set to module:
CONFIG_EXT4_FS=m
### here's a line set to no:
CONFIG_KINETO_GAN=n
# the required options
#
CONFIG_EFI=y
CONFIG_EFI_STUB=y
CONFIG_DMI=y
CONFIG_EFI_ESRT=y
CONFIG_EFI_VARS_PSTORE=y
CONFIG_EFI_PARAMS_FROM_FDT=y
CONFIG_EFI_RUNTIME_WRAPPERS=y
CONFIG_EFI_GENERIC_STUB=y