From f8a401f068a83f71ac266f91dc07c4228f5efff7 Mon Sep 17 00:00:00 2001 From: Lyndon Brown Date: Sat, 28 Mar 2020 06:11:15 +0000 Subject: [PATCH] config: add --validate option running `lb config --validate` causes the script to stop after running the validation check on the config compiled at that point, prior to writing the config to disk. this gives users the ability to check the validity of a config without modifying or rewriting the saved config. note that if users provide new config options alongside --validate, these are taken into account in the check performed. the 'check complete' message will not be seen if an error is reported by the check function, while it will be seen if only warnings are given, but it would require a redesign of the validation check function to make any improvement in that area, and it's perhaps not worth it. Gbp-Dch: Short --- manpages/en/lb_config.1 | 4 ++++ scripts/build/config | 13 ++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/manpages/en/lb_config.1 b/manpages/en/lb_config.1 index 897a0db6c..4b258f8a0 100644 --- a/manpages/en/lb_config.1 +++ b/manpages/en/lb_config.1 @@ -231,6 +231,8 @@ [\fB\-\-uefi\-secure\-boot\fR \fIauto|enable|disable\fR] .br [\fB\-\-updates\fR true|false] +.br + [\fB\-\-validate\fR] .br [\fB\-\-verbose\fR] .br @@ -479,6 +481,8 @@ selects which program is used to install tasks. By default, this is set to tasks enables or disables Secure Boot support when using grub-efi, by installing signed shim and grub-efi packages. By default, this is set to auto, which means if the packages are available they will be installed, but if not only a warning will be printed and the normal non-signed grub-efi will be used. .IP "\fB\-\-updates\fR true|false" 4 defines if debian updates package archives should be included in the image or not. +.IP "\fB\-\-validate\fR" 4 +requests that the config be validated only, not changed, thus after the validation check the script ends rather than writing an updated config. Please note that at the time of writing, many options do not have corresponding validation checks. .IP "\fB\-\-verbose\fR" 4 increases the verbosity of messages output by \fBlb build\fR. .IP "\fB\-\-win32\-loader\fR true|false" 4 diff --git a/scripts/build/config b/scripts/build/config index d9ada6f84..9c375b4b9 100755 --- a/scripts/build/config +++ b/scripts/build/config @@ -129,6 +129,7 @@ USAGE="${PROGRAM} [--apt apt|aptitude]\n\ \t [--tasksel apt|aptitude|tasksel]\n\ \t [--uefi-secure-boot auto|enable|disable]\n\ \t [--updates true|false]\n\ +\t [--validate]\n\ \t [--verbose]\n\ \t [--win32-loader true|false]\n\ \t [--zsync true|false]" @@ -159,7 +160,7 @@ Local_arguments () net-root-path:,net-root-server:,net-cow-filesystem:,net-cow-mountoptions:,net-cow-path:, net-cow-server:,net-tarball:,onie:,onie-kernel-cmdline:,firmware-binary:,firmware-chroot:,swap-file-path:,swap-file-size:, loadlin:,win32-loader:,source:,source-images:,breakpoints,conffile:,color,no-color,debug,force, - help,ignore-system-defaults,quiet,usage,verbose,version,bootstrap-qemu-static:,bootstrap-qemu-arch:, + help,ignore-system-defaults,quiet,usage,validate,verbose,version,bootstrap-qemu-static:,bootstrap-qemu-arch:, uefi-secure-boot:, bootstrap-qemu-exclude:" # Remove spaces added by indentation @@ -220,6 +221,11 @@ Local_arguments () exit 0 ;; + --validate) + _VALIDATE_MODE="true" + shift + ;; + --clean) _CLEAN="true" shift @@ -940,6 +946,11 @@ fi Prepare_config Validate_config +if [ "${_VALIDATE_MODE}" = "true" ]; then + Echo_message "Validation check complete! Please address any problem notices given above." + exit 0 +fi + # Creating or updating saved config if [ ! -e config ]