Skip to content

Commit f4b626b

Browse files
committed
add --make-opt, --cdo-opt
Add a new kpatch-build options --make-opt=arg_for_make and --cdo-opt=arg_for_create-diff-object. These accumulate and are passed to the underlying make. This merges with the existing MAKEVARS/CDO_FLAGS processing, and allows site-specific make param overrides to be used, (matching params used to create the kernel to be patched) without hacking kpatch-build, even when turning on debug in create-diff-object. Signed-off-by: Pete Swain <[email protected]>
1 parent 0aff647 commit f4b626b

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

kpatch-build/kpatch-build

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ declare -a PATCH_LIST
5656
APPLIED_PATCHES=0
5757
OOT_MODULE=
5858
KLP_REPLACE=1
59+
declare -a MAKEVARS
60+
declare -a CDO_FLAGS
5961

6062
# default tools may be overridden by env
6163
: "${GCC:="${CROSS_COMPILE:-}gcc"}"
@@ -549,9 +551,11 @@ usage() {
549551
echo " --skip-cleanup Skip post-build cleanup" >&2
550552
echo " --skip-compiler-check Skip compiler version matching check" >&2
551553
echo " (not recommended)" >&2
554+
echo " --make-opt pass an arg to make" >&2
555+
echo " --cdo-opt pass an arg to create-diff-object" >&2
552556
}
553557

554-
options="$(getopt -o ha:r:s:c:v:j:t:n:o:dR -l "help,archversion:,sourcerpm:,sourcedir:,config:,vmlinux:,jobs:,target:,name:,output:,oot-module:,oot-module-src:,debug,skip-gcc-check,skip-compiler-check,skip-cleanup,non-replace" -- "$@")" || die "getopt failed"
558+
options="$(getopt -o ha:r:s:c:v:j:t:n:o:dR -l "help,archversion:,sourcerpm:,sourcedir:,cdo-opt:,config:,vmlinux:,jobs:,target:,make-opt:,name:,output:,oot-module:,oot-module-src:,debug,skip-gcc-check,skip-compiler-check,skip-cleanup,non-replace" -- "$@")" || die "getopt failed"
555559

556560
eval set -- "$options"
557561

@@ -633,6 +637,14 @@ while [[ $# -gt 0 ]]; do
633637
echo "WARNING: Skipping compiler version matching check (not recommended)"
634638
SKIPCOMPILERCHECK=1
635639
;;
640+
--make-opt)
641+
MAKEVARS+=("$2")
642+
shift
643+
;;
644+
--cdo-opt)
645+
CDO_FLAGS+=("$2")
646+
shift
647+
;;
636648
*)
637649
[[ "$1" = "--" ]] && shift && continue
638650
[[ ! -f "$1" ]] && die "patch file '$1' not found"
@@ -902,7 +914,7 @@ if [[ -n "$CONFIG_LIVEPATCH" ]] && (kernel_is_rhel || kernel_version_gte 4.9.0);
902914
if use_klp_arch; then
903915
USE_KLP_ARCH=1
904916
KPATCH_LDFLAGS="--unique=.parainstructions --unique=.altinstructions"
905-
CDO_FLAGS="--klp-arch"
917+
CDO_FLAGS+=(--klp-arch)
906918
fi
907919

908920
if [[ "$KLP_REPLACE" -eq 1 ]] ; then
@@ -989,7 +1001,6 @@ echo "Building original source"
9891001
unset KPATCH_GCC_TEMPDIR
9901002

9911003
KPATCH_CC_PREFIX="$TOOLSDIR/kpatch-cc "
992-
declare -a MAKEVARS
9931004
if [[ -n "$CONFIG_CC_IS_CLANG" ]]; then
9941005
MAKEVARS+=("CC=${KPATCH_CC_PREFIX}${CLANG}")
9951006
MAKEVARS+=("HOSTCC=${HOSTCC:-${CLANG}}")
@@ -1146,7 +1157,7 @@ for i in $FILES; do
11461157

11471158
# create-diff-object orig.o patched.o parent-name parent-symtab
11481159
# Module.symvers patch-mod-name output.o
1149-
"$TOOLSDIR"/create-diff-object $CDO_FLAGS "orig/$i" "patched/$i" "$KOBJFILE_NAME" \
1160+
"$TOOLSDIR"/create-diff-object "${CDO_FLAGS[@]}" "orig/$i" "patched/$i" "$KOBJFILE_NAME" \
11501161
"$SYMTAB" "$SYMVERS_FILE" "${MODNAME//-/_}" \
11511162
"output/$i" 2>&1 | logger 1
11521163
check_pipe_status create-diff-object

0 commit comments

Comments
 (0)