Skip to content

Commit db9038c

Browse files
Frans Popsravnborg
authored andcommitted
kbuild: fix the binrpm-pkg target to work with KBUILD_OUTPUT set
The binrpm-pkg target (binary RPM only) fails when called with KBUILD_OUTPUT set. This patch makes it work. For the rpm-pkg target (source + binary RPM), building with KBUILD_OUTPUT set is not possible and also not needed as the actual build is done in a temporary directory anyway, so check that KBUILD_OUTPUT is not set in that case to avoid later errors. Signed-off-by: Frans Pop <elendil@planet.nl> Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
1 parent f144c78 commit db9038c

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

scripts/package/Makefile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@
1818
# e) generate the rpm files, based on kernel.spec
1919
# - Use /. to avoid tar packing just the symlink
2020

21+
# Note that the rpm-pkg target cannot be used with KBUILD_OUTPUT,
22+
# but the binrpm-pkg target can; for some reason O= gets ignored.
23+
2124
# Do we have rpmbuild, otherwise fall back to the older rpm
2225
RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
2326
else echo rpm; fi)
@@ -33,6 +36,12 @@ $(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
3336
$(CONFIG_SHELL) $(MKSPEC) > $@
3437

3538
rpm-pkg rpm: $(objtree)/kernel.spec FORCE
39+
@if test -n "$(KBUILD_OUTPUT)"; then \
40+
echo "Building source + binary RPM is not possible outside the"; \
41+
echo "kernel source tree. Don't set KBUILD_OUTPUT, or use the"; \
42+
echo "binrpm-pkg target instead."; \
43+
false; \
44+
fi
3645
$(MAKE) clean
3746
$(PREV) ln -sf $(srctree) $(KERNELPATH)
3847
$(CONFIG_SHELL) $(srctree)/scripts/setlocalversion > $(objtree)/.scmversion
@@ -61,7 +70,7 @@ binrpm-pkg: $(objtree)/binkernel.spec FORCE
6170
set -e; \
6271
mv -f $(objtree)/.tmp_version $(objtree)/.version
6372

64-
$(RPM) $(RPMOPTS) --define "_builddir $(srctree)" --target \
73+
$(RPM) $(RPMOPTS) --define "_builddir $(objtree)" --target \
6574
$(UTS_MACHINE) -bb $<
6675

6776
clean-files += $(objtree)/binkernel.spec

scripts/package/mkspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ echo 'mkdir -p $RPM_BUILD_ROOT/boot $RPM_BUILD_ROOT/lib/modules'
7070
echo 'mkdir -p $RPM_BUILD_ROOT/lib/firmware'
7171
echo "%endif"
7272

73-
echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} modules_install'
73+
echo 'INSTALL_MOD_PATH=$RPM_BUILD_ROOT make %{_smp_mflags} KBUILD_SRC= modules_install'
7474
echo "%ifarch ia64"
7575
echo 'cp $KBUILD_IMAGE $RPM_BUILD_ROOT'"/boot/efi/vmlinuz-$KERNELRELEASE"
7676
echo 'ln -s '"efi/vmlinuz-$KERNELRELEASE" '$RPM_BUILD_ROOT'"/boot/"

0 commit comments

Comments
 (0)