kpatch-build: put build artifacts into cachedir

Build artifacts are stored in $CACHEDIR/tmp instead of /tmp. This includes
files such as the build log and the temp directories used to build the patch.

In addition, allow $CACHEDIR to be set as an environment variable.

Signed-off-by: Chris J Arges <chris.j.arges@canonical.com>
This commit is contained in:
Chris J Arges 2015-10-27 17:13:09 -05:00
parent a1db97bd7c
commit d0c8f43656

View File

@ -37,16 +37,16 @@
# - Runs kpatch tools to create and link the patch kernel module
BASE="$PWD"
LOGFILE="/tmp/kpatch-build-$(date +%s).log"
SCRIPTDIR="$(readlink -f $(dirname $(type -p $0)))"
ARCHVERSION="$(uname -r)"
CPUS="$(getconf _NPROCESSORS_ONLN)"
CACHEDIR="$HOME/.kpatch"
CACHEDIR="${CACHEDIR:-$HOME/.kpatch}"
SRCDIR="$CACHEDIR/src"
OBJDIR="$CACHEDIR/obj"
TMPSRCDIR="$CACHEDIR/tempsrc"
VERSIONFILE="$CACHEDIR/version"
TEMPDIR=
TEMPDIR="$CACHEDIR/tmp"
LOGFILE="$TEMPDIR/build.log"
APPLIEDPATCHFILE="kpatch.patch"
DEBUG=0
SKIPGCCCHECK=0
@ -274,7 +274,10 @@ while [[ $# -gt 0 ]]; do
shift
done
TEMPDIR="$(mktemp -d /tmp/kpatch-build-XXXXXX)" || die "mktemp failed"
# ensure cachedir and tempdir are setup properly and cleaned
mkdir -p "$TEMPDIR" || die "Couldn't create $TEMPDIR"
rm -rf "$TEMPDIR"/*
trap cleanup EXIT INT TERM
KVER=${ARCHVERSION%%-*}