mirror of
https://github.com/dynup/kpatch
synced 2024-12-15 01:44:32 +00:00
cleanup the cleanup handling
- always remove TEMPDIR, otherwise /tmp can fill up if you get multiple build errors - always remove KSRCDIR - only remove the log file on success
This commit is contained in:
parent
06ed1bdcc0
commit
aed73433a7
@ -32,10 +32,6 @@ KSRCDIR_CACHE="$KSRCDIR.tgz"
|
||||
TEMPDIR=
|
||||
STRIPCMD="strip -d --keep-file-symbols"
|
||||
|
||||
cleanup() {
|
||||
rm -Rf "$KSRCDIR" "$LOGFILE" "$TEMPDIR" > /dev/null 2>/dev/null
|
||||
}
|
||||
|
||||
die() {
|
||||
if [[ -z $1 ]]; then
|
||||
echo "ERROR: kpatch build failed. Check $LOGFILE for more details." >&2
|
||||
@ -73,10 +69,10 @@ if [[ "$PATCHNAME" =~ \.patch ]] || [[ "$PATCHNAME" =~ \.diff ]]; then
|
||||
PATCHNAME="${PATCHNAME%.*}"
|
||||
fi
|
||||
|
||||
cleanup
|
||||
|
||||
TEMPDIR="$(mktemp -d)" || die "mktemp failed"
|
||||
|
||||
trap "rm -rf $TEMPDIR $KSRCDIR" EXIT INT TERM
|
||||
|
||||
if [[ -f "$KSRCDIR_CACHE" ]]; then
|
||||
echo "Using cache at $KSRCDIR_CACHE"
|
||||
rm -rf "$KSRCDIR"
|
||||
@ -164,5 +160,6 @@ $STRIPCMD "kpatch-$PATCHNAME.ko" >> "$LOGFILE" 2>&1 || die
|
||||
|
||||
cp -f "$TEMPDIR/patch/kpatch-$PATCHNAME.ko" "$BASE" || die
|
||||
|
||||
cleanup
|
||||
rm -f "$LOGFILE"
|
||||
|
||||
echo "SUCCESS"
|
||||
|
Loading…
Reference in New Issue
Block a user