2018-11-02 11:27:01

by Zhenzhong Duan

[permalink] [raw]
Subject: [PATCH] kbuild: rpm-pkg: fix two build breaks when O= is used

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.

Export KBUILD_OUTPUT when O= is used so that it could be used in locating
include/config/auto.conf

Use $srctree to locate source dir when generating image name, no matter
if O= is used.

Signed-off-by: Zhenzhong Duan <[email protected]>
---
Makefile | 5 +++++
scripts/package/mkspec | 4 ++--
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index 9aa352b..df316e5 100644
--- a/Makefile
+++ b/Makefile
@@ -135,6 +135,7 @@ KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
$(if $(KBUILD_OUTPUT),, \
$(error failed to create output directory "$(saved-output)"))

+export KBUILD_OUTPUT
# Look for make include files relative to root of kernel src
#
# This does not become effective immediately because MAKEFLAGS is re-parsed
@@ -597,7 +598,11 @@ virt-y := virt/
endif # KBUILD_EXTMOD

ifeq ($(dot-config),1)
+ifeq ($(KBUILD_OUTPUT),)
include include/config/auto.conf
+else
+include $(KBUILD_OUTPUT)/include/config/auto.conf
+endif
endif

# The all: target is the default when no target is given on the
diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index e05646d..3b4e5e4 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -84,10 +84,10 @@ $S
mkdir -p %{buildroot}/boot
%ifarch ia64
mkdir -p %{buildroot}/boot/efi
- cp \$(make image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
+ cp \$(make -C \$srctree image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/
%else
- cp \$(make image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
+ cp \$(make -C \$srctree image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
%endif
$M make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} KBUILD_SRC= modules_install
make %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr KBUILD_SRC= headers_install
--
1.8.3.1


2018-11-05 07:56:33

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] kbuild: rpm-pkg: fix two build breaks when O= is used

Hi Zhenzhong,

On Fri, Nov 2, 2018 at 8:26 PM Zhenzhong Duan <[email protected]> wrote:
>
> 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.
>
> Export KBUILD_OUTPUT when O= is used so that it could be used in locating
> include/config/auto.conf
>
> Use $srctree to locate source dir when generating image name, no matter
> if O= is used.
>
> Signed-off-by: Zhenzhong Duan <[email protected]>


Sorry for the breakage, and thanks for your report.

I'd like to fix the issue in a cleaner way.

See this:
https://patchwork.kernel.org/patch/10667539/


Thanks.


> ---
> Makefile | 5 +++++
> scripts/package/mkspec | 4 ++--
> 2 files changed, 7 insertions(+), 2 deletions(-)
>
> diff --git a/Makefile b/Makefile
> index 9aa352b..df316e5 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -135,6 +135,7 @@ KBUILD_OUTPUT := $(shell mkdir -p $(KBUILD_OUTPUT) && cd $(KBUILD_OUTPUT) \
> $(if $(KBUILD_OUTPUT),, \
> $(error failed to create output directory "$(saved-output)"))
>
> +export KBUILD_OUTPUT
> # Look for make include files relative to root of kernel src
> #
> # This does not become effective immediately because MAKEFLAGS is re-parsed
> @@ -597,7 +598,11 @@ virt-y := virt/
> endif # KBUILD_EXTMOD
>
> ifeq ($(dot-config),1)
> +ifeq ($(KBUILD_OUTPUT),)
> include include/config/auto.conf
> +else
> +include $(KBUILD_OUTPUT)/include/config/auto.conf
> +endif
> endif
>
> # The all: target is the default when no target is given on the
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index e05646d..3b4e5e4 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -84,10 +84,10 @@ $S
> mkdir -p %{buildroot}/boot
> %ifarch ia64
> mkdir -p %{buildroot}/boot/efi
> - cp \$(make image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
> + cp \$(make -C \$srctree image_name) %{buildroot}/boot/efi/vmlinuz-$KERNELRELEASE
> ln -s efi/vmlinuz-$KERNELRELEASE %{buildroot}/boot/
> %else
> - cp \$(make image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
> + cp \$(make -C \$srctree image_name) %{buildroot}/boot/vmlinuz-$KERNELRELEASE
> %endif
> $M make %{?_smp_mflags} INSTALL_MOD_PATH=%{buildroot} KBUILD_SRC= modules_install
> make %{?_smp_mflags} INSTALL_HDR_PATH=%{buildroot}/usr KBUILD_SRC= headers_install
> --
> 1.8.3.1



--
Best Regards
Masahiro Yamada

2018-11-05 09:28:02

by Zhenzhong Duan

[permalink] [raw]
Subject: Re: [PATCH] kbuild: rpm-pkg: fix two build breaks when O= is used

On 2018/11/5 15:55, Masahiro Yamada wrote:
> Hi Zhenzhong,
>
> On Fri, Nov 2, 2018 at 8:26 PM Zhenzhong Duan<[email protected]> wrote:
>> 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.
>>
>> Export KBUILD_OUTPUT when O= is used so that it could be used in locating
>> include/config/auto.conf
>>
>> Use $srctree to locate source dir when generating image name, no matter
>> if O= is used.
>>
>> Signed-off-by: Zhenzhong Duan<[email protected]>
>
> Sorry for the breakage, and thanks for your report.
>
> I'd like to fix the issue in a cleaner way.
>
> See this:
> https://patchwork.kernel.org/patch/10667539/

Never mind, appreciate you fixed it in a smart way:)

Thanks
Zhenzhong