Skip to content

Commit cbfc0b8

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 7dcd7c9 commit cbfc0b8

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

kpatch-build/kpatch-build

+15-4
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}
@@ -546,9 +548,11 @@ usage() {
546548
echo " --skip-cleanup Skip post-build cleanup" >&2
547549
echo " --skip-compiler-check Skip compiler version matching check" >&2
548550
echo " (not recommended)" >&2
551+
echo " --make-opt pass an arg to make" >&2
552+
echo " --cdo-opt pass an arg to create-diff-object" >&2
549553
}
550554
551-
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"
555+
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"
552556
553557
eval set -- "$options"
554558
@@ -630,6 +634,14 @@ while [[ $# -gt 0 ]]; do
630634
echo "WARNING: Skipping compiler version matching check (not recommended)"
631635
SKIPCOMPILERCHECK=1
632636
;;
637+
--make-opt)
638+
MAKEVARS+=("$2")
639+
shift
640+
;;
641+
--cdo-opt)
642+
CDO_FLAGS+=("$2")
643+
shift
644+
;;
633645
*)
634646
[[ "$1" = "--" ]] && shift && continue
635647
[[ ! -f "$1" ]] && die "patch file '$1' not found"
@@ -899,7 +911,7 @@ if [[ -n "$CONFIG_LIVEPATCH" ]] && (kernel_is_rhel || kernel_version_gte 4.9.0);
899911
if use_klp_arch; then
900912
USE_KLP_ARCH=1
901913
KPATCH_LDFLAGS="--unique=.parainstructions --unique=.altinstructions"
902-
CDO_FLAGS="--klp-arch"
914+
CDO_FLAGS+=(--klp-arch)
903915
fi
904916
905917
if [[ "$KLP_REPLACE" -eq 1 ]] ; then
@@ -986,7 +998,6 @@ echo "Building original source"
986998
unset KPATCH_GCC_TEMPDIR
987999
9881000
KPATCH_CC_PREFIX="$TOOLSDIR/kpatch-cc "
989-
declare -a MAKEVARS
9901001
if [[ -n "$CONFIG_CC_IS_CLANG" ]]; then
9911002
MAKEVARS+=("CC=${KPATCH_CC_PREFIX}${CLANG}")
9921003
MAKEVARS+=("HOSTCC=${HOSTCC:-${CLANG}}")
@@ -1143,7 +1154,7 @@ for i in $FILES; do
11431154
11441155
# create-diff-object orig.o patched.o parent-name parent-symtab
11451156
# Module.symvers patch-mod-name output.o
1146-
"$TOOLSDIR"/create-diff-object $CDO_FLAGS "orig/$i" "patched/$i" "$KOBJFILE_NAME" \
1157+
"$TOOLSDIR"/create-diff-object "${CDO_FLAGS[@]}" "orig/$i" "patched/$i" "$KOBJFILE_NAME" \
11471158
"$SYMTAB" "$SYMVERS_FILE" "${MODNAME//-/_}" \
11481159
"output/$i" 2>&1 | logger 1
11491160
check_pipe_status create-diff-object

0 commit comments

Comments
 (0)