Update SHORT_CIRCUIT behavior to better handle patch validation and
argument processing in later klp-build steps.

Perform patch validation for both step 1 (building original kernel)
and step 2 (building patched kernel) to ensure patches are verified
before any compilation occurs.

Additionally, allow the user to omit input patches when skipping past
step 2, while noting that any specified patches will be ignored in that
case if they were provided.

Signed-off-by: Joe Lawrence <[email protected]>
---
 scripts/livepatch/klp-build | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/scripts/livepatch/klp-build b/scripts/livepatch/klp-build
index ee43a9caa107..df3a0fa031a6 100755
--- a/scripts/livepatch/klp-build
+++ b/scripts/livepatch/klp-build
@@ -214,12 +214,18 @@ process_args() {
        done
 
        if [[ $# -eq 0 ]]; then
-               usage
-               exit 1
+               if (( SHORT_CIRCUIT <= 2 )); then
+                       usage
+                       exit 1
+               fi
+       else
+               if (( SHORT_CIRCUIT >= 3 )); then
+                       status "note: patch arguments ignored at step 
$SHORT_CIRCUIT"
+               fi
        fi
+       PATCHES=("$@")
 
        KEEP_TMP="$keep_tmp"
-       PATCHES=("$@")
 }
 
 # temporarily disable xtrace for especially verbose code
@@ -801,9 +807,12 @@ build_patch_module() {
 process_args "$@"
 do_init
 
-if (( SHORT_CIRCUIT <= 1 )); then
+if (( SHORT_CIRCUIT <= 2 )); then
        status "Validating patch(es)"
        validate_patches
+fi
+
+if (( SHORT_CIRCUIT <= 1 )); then
        status "Building original kernel"
        clean_kernel
        build_kernel
-- 
2.52.0


Reply via email to