Commit 21b42eb4 authored by Masahiro Yamada's avatar Masahiro Yamada

kbuild: rpm-pkg: fix binrpm-pkg breakage when O= is used

Zhenzhong Duan reported that running 'make O=/build/kernel binrpm-pkg'
failed with the following errors:

  Running 'make O=/build/kernel binrpm-pkg' failed with below two errors.

  Makefile:600: include/config/auto.conf: No such file or directory

  + cp make -C /mnt/root/kernel O=/build/kernel image_name make -f
  /mnt/root/kernel/Makefile ...
  cp: invalid option -- 'C'
  Try 'cp --help' for more information.

Prior to commit 80463f1b ("kbuild: add --include-dir flag only
for out-of-tree build"), both srctree and objtree were added to
--include-dir redundantly, and the wrong code 'make image_name'
was working by relying on that. Now, the potential issue that had
previously been hidden just showed up.

'make image_name' recurses to the generated $(objtree)/Makefile and
ends up with running in srctree, which is incorrect. It should be
invoked with '-f $srctree/Makefile' (or KBUILD_SRC=) to be executed
in objtree.

Fixes: 80463f1b ("kbuild: add --include-dir flag only for out-of-tree build")
Reported-by: default avatarZhenzhong Duan <zhenzhong.duan@oracle.com>
Signed-off-by: default avatarMasahiro Yamada <yamada.masahiro@socionext.com>
parent 65102238
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
# how we were called determines which rpms we build and how we build them # how we were called determines which rpms we build and how we build them
if [ "$1" = prebuilt ]; then if [ "$1" = prebuilt ]; then
S=DEL S=DEL
MAKE="$MAKE -f $srctree/Makefile"
else else
S= S=
fi fi
...@@ -78,19 +79,19 @@ $S %prep ...@@ -78,19 +79,19 @@ $S %prep
$S %setup -q $S %setup -q
$S $S
$S %build $S %build
$S make %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release} $S $MAKE %{?_smp_mflags} KBUILD_BUILD_VERSION=%{release}
$S $S
%install %install
mkdir -p %{buildroot}/boot mkdir -p %{buildroot}/boot
%ifarch ia64 %ifarch ia64
mkdir -p %{buildroot}/boot/efi mkdir -p %{buildroot}/boot/efi
cp \$(make image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE cp \$($MAKE image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/ ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/
%else %else
cp \$(make image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE cp \$($MAKE image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
%endif %endif
$M make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} KBUILD_SRC= modules_install $M $MAKE %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} modules_install
make %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr KBUILD_SRC= headers_install $MAKE %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr headers_install
cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE cp System.map %{buildroot}/boot/System.map-$KERNELRELEASE
cp .config %{buildroot}/boot/config-$KERNELRELEASE cp .config %{buildroot}/boot/config-$KERNELRELEASE
bzip2 -9 --keep vmlinux bzip2 -9 --keep vmlinux
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment