kpatch-build: don't do "make mrproper" on every build

As discussed in #848, there is no known reason to do "make mrproper" on
every build.  It seems to be an artifact from previous iterations (we
used to use 'O=' to build the kernel in a separate object tree.

It has many downsides:

- massive performance degradation
- breaks the '-t' option
- prevents the user from manually saving/restoring ~/.kpatch

Only do it where it's really needed, which is after first extracting the
source from an RPM.

Signed-off-by: Josh Poimboeuf <jpoimboe@redhat.com>
This commit is contained in:
Josh Poimboeuf 2018-06-02 13:58:50 -05:00
parent a310e9e82e
commit f32363e634

View File

@ -115,8 +115,7 @@ cleanup() {
remove_patches
# restore original .config and vmlinux if they were removed with mrproper
[[ -e "$TEMPDIR/.config" ]] && mv -f "$TEMPDIR/.config" "$SRCDIR/"
# restore original vmlinux if it was overwritten by sourcedir build
[[ -e "$TEMPDIR/vmlinux" ]] && mv -f "$TEMPDIR/vmlinux" "$SRCDIR/"
[[ "$DEBUG" -eq 0 ]] && rm -rf "$TEMPDIR"
@ -555,7 +554,7 @@ fi
if [[ -n "$USERSRCDIR" ]]; then
echo "Using source directory at $USERSRCDIR"
# save vmlinux before it gets removed with mrproper
# save original vmlinux before it gets overwritten by sourcedir build
[[ "$VMLINUX" -ef "$SRCDIR"/vmlinux ]] && cp -f "$VMLINUX" "$TEMPDIR/vmlinux" && VMLINUX="$TEMPDIR/vmlinux"
elif [[ -e "$SRCDIR"/.config ]] && [[ -e "$VERSIONFILE" ]] && [[ "$(cat "$VERSIONFILE")" = "$ARCHVERSION" ]]; then
@ -597,6 +596,8 @@ else
[[ -z "$CONFIGFILE" ]] && CONFIGFILE="$SRCDIR/configs/kernel$ALT-$KVER-$ARCH.config"
(cd "$SRCDIR" && make mrproper 2>&1 | logger) || die
elif [[ "$DISTRO" = ubuntu ]] || [[ "$DISTRO" = debian ]]; then
echo "Debian/Ubuntu distribution detected"
@ -639,10 +640,9 @@ else
fi
fi
# save .config before it gets removed with mrproper
[[ -z "$CONFIGFILE" ]] && CONFIGFILE="$SRCDIR"/.config
[[ ! -e "$CONFIGFILE" ]] && die "can't find config file"
[[ "$CONFIGFILE" -ef "$SRCDIR"/.config ]] && cp -f "$CONFIGFILE" "$TEMPDIR" && CONFIGFILE="$TEMPDIR"/.config
[[ ! "$CONFIGFILE" -ef "$SRCDIR"/.config ]] && cp -f "$CONFIGFILE" "$SRCDIR/.config"
# Build variables - Set some defaults, then adjust features
# according to .config and kernel version
@ -699,8 +699,6 @@ fi
echo "Building original kernel"
./scripts/setlocalversion --save-scmversion || die
make mrproper 2>&1 | logger || die
cp -f "$CONFIGFILE" "$SRCDIR/.config"
unset KPATCH_GCC_TEMPDIR
# $TARGETS used as list, no quotes.
# shellcheck disable=SC2086