mirror of
https://github.com/dynup/kpatch
synced 2024-12-11 16:04:40 +00:00
kpatch-build: do not clobber ~/rpmbuild directory
If a source RPM is used to obtain the kernel sources, kpatch-build executes rpmdev-setuptree to prepare ~/rpmbuild directory tree, installs the source RPM there. Then it calls 'rpmbuild -bp' to prepare the kernel source tree. All this, however, may clobber the existing contents of ~/rpmbuild, which is very inconvenient if one uses rpmbuild to build other packages. To avoid that, I could not find a better way than to specify a fake home directory (~/.kpatch/tempsrc) for that portion of kpatch-build. It seems, neither rpmdev-setuptree nor rpm have appropriate options for that. I put the affected commands into a subshell so that the changes in $HOME could not propagate to other parts of kpatch-build.
This commit is contained in:
parent
d444caa907
commit
9df043bc2e
@ -44,6 +44,7 @@ CPUS="$(getconf _NPROCESSORS_ONLN)"
|
|||||||
CACHEDIR="$HOME/.kpatch"
|
CACHEDIR="$HOME/.kpatch"
|
||||||
SRCDIR="$CACHEDIR/src"
|
SRCDIR="$CACHEDIR/src"
|
||||||
OBJDIR="$CACHEDIR/obj"
|
OBJDIR="$CACHEDIR/obj"
|
||||||
|
TMPSRCDIR="$CACHEDIR/tempsrc"
|
||||||
VERSIONFILE="$CACHEDIR/version"
|
VERSIONFILE="$CACHEDIR/version"
|
||||||
TEMPDIR=
|
TEMPDIR=
|
||||||
APPLIEDPATCHFILE="kpatch.patch"
|
APPLIEDPATCHFILE="kpatch.patch"
|
||||||
@ -358,14 +359,24 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Unpacking kernel source"
|
echo "Unpacking kernel source"
|
||||||
|
(
|
||||||
|
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
|
||||||
|
|
||||||
rpmdev-setuptree >> "$LOGFILE" 2>&1 || die
|
rpmdev-setuptree >> "$LOGFILE" 2>&1 || die
|
||||||
rpm -ivh "$SRCRPM" >> "$LOGFILE" 2>&1 || die
|
rpm -ivh "$SRCRPM" >> "$LOGFILE" 2>&1 || die
|
||||||
rpmbuild -bp "--target=$(uname -m)" "$(rpm --eval %{_specdir})"/kernel.spec >> "$LOGFILE" 2>&1 ||
|
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."
|
die "rpmbuild -bp failed. you may need to run 'yum-builddep kernel' first."
|
||||||
|
|
||||||
clean_cache
|
RPM_BUILD_DIR=$(rpm --eval %{_builddir})
|
||||||
|
mv "$RPM_BUILD_DIR"/kernel-*/linux-"${ARCHVERSION%.*}"*"${ARCHVERSION##*.}" "$SRCDIR" >> "$LOGFILE" 2>&1 || die
|
||||||
mv "$(rpm --eval %{_builddir})"/kernel-*/linux-"${ARCHVERSION%.*}"*"${ARCHVERSION##*.}" "$SRCDIR" >> "$LOGFILE" 2>&1 || die
|
)
|
||||||
|
|
||||||
cp "$SRCDIR/.config" "$OBJDIR" || die
|
cp "$SRCDIR/.config" "$OBJDIR" || die
|
||||||
if [[ "$ARCHVERSION" == *-* ]]; then
|
if [[ "$ARCHVERSION" == *-* ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user