From 06b931d396298c9d8c967fe5aa0140c5159cbabd Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Fri, 14 Nov 2025 11:14:11 +0530 Subject: [PATCH 1/2] kernel_patch_verify: Improve missing apps error message formatting Add visual emphasis with colored error message (red background) and provide clearer guidance to users when required applications are missing. Also fix the application check to use recommend_missing_application directly to simplify the error handling flow. This way, unnecessary printing of usage guide is avoided when there's a more fundamental issue at hand like missing packages. Signed-off-by: Dhruva Gole --- kernel_patch_verify | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/kernel_patch_verify b/kernel_patch_verify index 27f8074..5ec1d24 100755 --- a/kernel_patch_verify +++ b/kernel_patch_verify @@ -784,7 +784,9 @@ check_missing_application() { recommend_missing_application() { check_missing_application if [ -n "$APPS_MISSING" ]; then - echo "Missing Applications in system: $APPS_MISSING" >&2 + # Red background, white foreground + echo -e "\e[1m\e[97m\e[101mError: Missing Applications in system: $APPS_MISSING\e[0m" >&2 + echo "" >&2 # Lets see if we can recommend an application if [ -x /usr/lib/command-not-found ]; then for i in $APPS_MISSING @@ -792,6 +794,8 @@ recommend_missing_application() { /usr/lib/command-not-found --no-failure-msg "$i" done fi + echo "" >&2 + echo "Please install the missing applications and try again." >&2 return 2 fi return 0 @@ -1038,8 +1042,7 @@ if [ -n "${CROSS_COMPILE}" ]; then APPS_NEEDED="$APPS_NEEDED ${CROSS_COMPILE}gcc" fi -if ! check_missing_application; then - usage "Missing apps" +if ! recommend_missing_application; then exit 2 fi From 3656f6ba3b5857902c27fe3f4251097201fd6d61 Mon Sep 17 00:00:00 2001 From: Dhruva Gole Date: Fri, 14 Nov 2025 11:17:20 +0530 Subject: [PATCH 2/2] kernel_patch_verify: Add support for separate build output directory Add -O option to specify a build output directory for out-of-tree kernel builds. This allows using O= make parameter for builds in a separate directory from the kernel source tree. Update all .config and make operations to respect BUILD_OUTPUT_DIR when specified. Signed-off-by: Dhruva Gole --- kernel_patch_verify | 46 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/kernel_patch_verify b/kernel_patch_verify index 5ec1d24..9b8a41a 100755 --- a/kernel_patch_verify +++ b/kernel_patch_verify @@ -73,13 +73,13 @@ fi kmake_single() { # XXX: kmake operations depend on variable expansion- do not quote variables here. # Except for compiler option since ccache will be involved - make $KM_A $KP_PARAMS "$KM_C" $KM_L -j1 $@ + make $KM_A $KP_PARAMS "$KM_C" $KM_L $KM_O -j1 $@ } kmake() { # XXX: kmake operations depend on variable expansion- do not quote variables here. # Except for compiler option since ccache will be involved - make $KM_A $KP_PARAMS "$KM_C" $KM_L -j$KM_CPUS $@ + make $KM_A $KP_PARAMS "$KM_C" $KM_L $KM_O -j$KM_CPUS $@ } to_time() { @@ -380,7 +380,11 @@ defconfig() { if [ -n "$DEFCONFIG" ]; then kmake "$DEFCONFIG" >/dev/null else - cp "$TEST_DIR"/.config .config + if [ -n "$BUILD_OUTPUT_DIR" ]; then + cp "$TEST_DIR"/.config "$BUILD_OUTPUT_DIR"/.config + else + cp "$TEST_DIR"/.config .config + fi kmake olddefconfig >/dev/null fi } @@ -597,7 +601,11 @@ on_exit() { fi if [ -f "$TEST_DIR/.config" ]; then echo "restoring .config" - cp "$TEST_DIR"/.config .config + if [ -n "$BUILD_OUTPUT_DIR" ]; then + cp "$TEST_DIR"/.config "$BUILD_OUTPUT_DIR"/.config + else + cp "$TEST_DIR"/.config .config + fi fi if [ -n "$TEST_DIR" ] && [ -d "$TEST_DIR" ]; then echo "Removing temp dir" @@ -810,7 +818,7 @@ usage() { printf '%s\n' \ '' \ - "Usage: $APP_NAME [-d | -V] [-j CPUs] [-B build_target] [-T tmp_dir_base] [-l logfile] [-C] [-P] [-c defconfig_name] [-n N][-1..9]|[-p patch_dir]|[-b base_branch [-t head_branch]] [-S smatch_script] -U -Z" \ + "Usage: $APP_NAME [-d | -V] [-j CPUs] [-B build_target] [-O build_output_dir] [-T tmp_dir_base] [-l logfile] [-C] [-P] [-c defconfig_name] [-n N][-1..9]|[-p patch_dir]|[-b base_branch [-t head_branch]] [-S smatch_script] -U -Z" \ '' printf '\t%s\n' \ @@ -818,6 +826,7 @@ usage() { "-V: (default armV8 targets) if not already defined, use CROSS_COMPILE=$DEF_V8_CROSS_COMPILE, ARCH=$DEF_V8_ARCH, and builds for '$KP_TARGETS $DEF_V8_BUILDTARGETS' build targets" \ "-j CPUs: override default CPUs count with build (default is $KM_CPUS)" \ "-B build_target: override default build target and use provided build_target" \ + "-O build_output_dir: kernel build output directory (for separate build directory with O=)" \ "-T temp_dir_base: temporary directory base (default is $TEST_B_DIR)" \ "-l logfile: report file (defaults to $LOG_FILE)" \ "-L Use llvm to build 'LLVM=1 CC='$ccache clang''" \ @@ -858,7 +867,9 @@ usage() { "Example usage 7: on a cross_compiled ARM build using defaults, 1 patch" \ "$APP_NAME -d -1" \ "Example usage 8: on a cross_compiled ARM build using defaults,15 patches" \ - "$APP_NAME -d -n 15" + "$APP_NAME -d -n 15" \ + "Example usage 9: verify last patch using separate build output directory" \ + "$APP_NAME -O /path/to/build/output -1" printf '%s\n' '' @@ -869,7 +880,8 @@ usage() { ORIDE=0 DTB_NOSKIP=0 -while getopts "S:n:j:c:T:B:l:p:b:t:m:123456789CdDUVZLP" opt; do +BUILD_OUTPUT_DIR="" +while getopts "S:n:j:c:T:B:l:p:b:t:m:O:123456789CdDUVZLP" opt; do case $opt in j) KM_CPUS=$OPTARG @@ -942,6 +954,13 @@ while getopts "S:n:j:c:T:B:l:p:b:t:m:123456789CdDUVZLP" opt; do exit 1 fi ;; + O) + BUILD_OUTPUT_DIR=$OPTARG + if [ ! -d "$BUILD_OUTPUT_DIR" ]; then + usage "Build output directory $BUILD_OUTPUT_DIR does not exist" + exit 1 + fi + ;; C) COMPLETE_TESTS=1 KP_PARAMS="$KP_PARAMS W=12 EXTRA_CFLAGS=-W" @@ -1080,6 +1099,10 @@ if [ -n "$ARCH" ]; then KM_A="ARCH=$ARCH" fi +if [ -n "$BUILD_OUTPUT_DIR" ]; then + KM_O="O=$BUILD_OUTPUT_DIR" +fi + KDIR=$(pwd) CURRENT_BRANCH=$(git branch | grep '^\*' | cut -d " " -f 2) @@ -1096,7 +1119,12 @@ if [ -n "$TEST_BRANCH" ] && [ "$TEST_BRANCH" = "$BASE_BRANCH" ]; then exit 3 fi -if [ ! -e ".config" ] && [ -z "$DEFCONFIG" ]; then +CONFIG_FILE=".config" +if [ -n "$BUILD_OUTPUT_DIR" ]; then + CONFIG_FILE="$BUILD_OUTPUT_DIR/.config" +fi + +if [ ! -e "$CONFIG_FILE" ] && [ -z "$DEFCONFIG" ]; then usage "No default .config exists nor is a defconfig specified with -c" exit 3 fi @@ -1120,7 +1148,7 @@ if [ -e "$GIT_RM_DIR" ] || [ -e "$GIT_RA_DIR" ]; then exit 3 fi -cp .config "$TEST_DIR"/.config 2>/dev/null +cp "$CONFIG_FILE" "$TEST_DIR"/.config 2>/dev/null if [ -z "$SMATCH" ]; then SMATCH=$TEST_DIR/smatch echo -e '#!/bin/bash\nsmatch -p=kernel $@'> "$SMATCH"