Merge pull request #513 from euspectre/do-not-clobber-rpmbuild-dir

kpatch-build: do not clobber ~/rpmbuild directory
This commit is contained in:
Seth Jennings 2015-10-20 09:09:14 -05:00
commit f6aba601ed
1 changed files with 17 additions and 6 deletions

View File

@ -44,6 +44,7 @@ CPUS="$(getconf _NPROCESSORS_ONLN)"
CACHEDIR="$HOME/.kpatch"
SRCDIR="$CACHEDIR/src"
OBJDIR="$CACHEDIR/obj"
TMPSRCDIR="$CACHEDIR/tempsrc"
VERSIONFILE="$CACHEDIR/version"
TEMPDIR=
APPLIEDPATCHFILE="kpatch.patch"
@ -358,14 +359,24 @@ else
fi
echo "Unpacking kernel source"
rpmdev-setuptree >> "$LOGFILE" 2>&1 || die
rpm -ivh "$SRCRPM" >> "$LOGFILE" 2>&1 || die
rpmbuild -bp "--target=$(uname -m)" "$(rpm --eval %{_specdir})"/kernel.spec >> "$LOGFILE" 2>&1 ||
die "rpmbuild -bp failed. you may need to run 'yum-builddep kernel' first."
(
clean_cache
clean_cache
# By default, rpmdev-setuptree and rpmbuild use
# ~/rpmbuild/ tree. However, this could clobber its
# existing contents, so let us use a fake home directory
# here to avoid that.
mkdir -p $TMPSRCDIR
HOME=$TMPSRCDIR
mv "$(rpm --eval %{_builddir})"/kernel-*/linux-"${ARCHVERSION%.*}"*"${ARCHVERSION##*.}" "$SRCDIR" >> "$LOGFILE" 2>&1 || die
rpmdev-setuptree >> "$LOGFILE" 2>&1 || die
rpm -ivh "$SRCRPM" >> "$LOGFILE" 2>&1 || die
rpmbuild -bp "--target=$(uname -m)" "$(rpm --eval %{_specdir})"/kernel.spec >> "$LOGFILE" 2>&1 ||
die "rpmbuild -bp failed. you may need to run 'yum-builddep kernel' first."
RPM_BUILD_DIR=$(rpm --eval %{_builddir})
mv "$RPM_BUILD_DIR"/kernel-*/linux-"${ARCHVERSION%.*}"*"${ARCHVERSION##*.}" "$SRCDIR" >> "$LOGFILE" 2>&1 || die
)
cp "$SRCDIR/.config" "$OBJDIR" || die
if [[ "$ARCHVERSION" == *-* ]]; then