2023-04-19 06:30:08

by Jiwei Sun

[permalink] [raw]
Subject: [PATCH] kbuild: rpm-pkg: fix rpm-pkg build error

From: Jiwei Sun <[email protected]>

The following error will trigger when building rpm-pkg
$ make rpm-pkg
SYNC include/config/auto.conf.cmd
HOSTLD scripts/kconfig/conf
UPD include/config/kernel.release
UPD .tmp_HEAD
ARCHIVE linux.tar.gz
sh ./scripts/package/mkspec >./kernel.spec
rpmbuild --target x86_64-linux -bs kernel.spec \
--define='_smp_mflags %{nil}' --define='_sourcedir rpmbuild/SOURCES' --define='_srcrpmdir .'
Building target platforms: x86_64-linux
Building for target x86_64-linux
Wrote: ./kernel-6.3.0_rc7-47.src.rpm
rpmbuild --target x86_64-linux -rb kernel-6.3.0_rc7-47.src.rpm \
--define='_smp_mflags %{nil}'
Installing kernel-6.3.0_rc7-47.src.rpm
Building target platforms: x86_64-linux
Building for target x86_64-linux
Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.QtGSXP
+ umask 022
+ cd /mnt/datapart/rpmbuild/BUILD
+ cd /mnt/datapart/rpmbuild/BUILD
+ rm -rf linux
+ /usr/bin/gzip -dc /mnt/datapart/rpmbuild/SOURCES/linux.tar.gz
+ /usr/bin/tar -xof -
+ STATUS=0
+ '[' 0 -ne 0 ']'
+ cd linux
/var/tmp/rpm-tmp.QtGSXP: line 40: cd: linux: No such file or directory
error: Bad exit status from /var/tmp/rpm-tmp.QtGSXP (%prep)

There is linux.tar, not linux, and the linux.tar.gz is create by the following
quiet_cmd_archive = ARCHIVE $@
cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \
--output=$$(realpath $@) --prefix=$(basename $@)/ $(archive-args)
Here the $@ is linux.tar.gz, and $(basename $@) will be linux.tar,
The above fact is the cause, so use $(basename $(basename $@)) to get the right directory name.

Signed-off-by: Jiwei Sun <[email protected]>
---
scripts/Makefile.package | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/Makefile.package b/scripts/Makefile.package
index 4d90691505b1..3718ecdf9edf 100644
--- a/scripts/Makefile.package
+++ b/scripts/Makefile.package
@@ -49,7 +49,7 @@ git-config-tar.zst = -c tar.tar.zst.command="$(ZSTD)"

quiet_cmd_archive = ARCHIVE $@
cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \
- --output=$$(realpath $@) --prefix=$(basename $@)/ $(archive-args)
+ --output=$$(realpath $@) --prefix=$(basename $(basename $@))/ $(archive-args)

# Linux source tarball
# ---------------------------------------------------------------------------
--
2.27.0


2023-04-19 15:48:53

by Masahiro Yamada

[permalink] [raw]
Subject: Re: [PATCH] kbuild: rpm-pkg: fix rpm-pkg build error

On Wed, Apr 19, 2023 at 12:18 PM <[email protected]> wrote:
>
> From: Jiwei Sun <[email protected]>
>
> The following error will trigger when building rpm-pkg
> $ make rpm-pkg
> SYNC include/config/auto.conf.cmd
> HOSTLD scripts/kconfig/conf
> UPD include/config/kernel.release
> UPD .tmp_HEAD
> ARCHIVE linux.tar.gz
> sh ./scripts/package/mkspec >./kernel.spec
> rpmbuild --target x86_64-linux -bs kernel.spec \
> --define='_smp_mflags %{nil}' --define='_sourcedir rpmbuild/SOURCES' --define='_srcrpmdir .'
> Building target platforms: x86_64-linux
> Building for target x86_64-linux
> Wrote: ./kernel-6.3.0_rc7-47.src.rpm
> rpmbuild --target x86_64-linux -rb kernel-6.3.0_rc7-47.src.rpm \
> --define='_smp_mflags %{nil}'
> Installing kernel-6.3.0_rc7-47.src.rpm
> Building target platforms: x86_64-linux
> Building for target x86_64-linux
> Executing(%prep): /bin/sh -e /var/tmp/rpm-tmp.QtGSXP
> + umask 022
> + cd /mnt/datapart/rpmbuild/BUILD
> + cd /mnt/datapart/rpmbuild/BUILD
> + rm -rf linux
> + /usr/bin/gzip -dc /mnt/datapart/rpmbuild/SOURCES/linux.tar.gz
> + /usr/bin/tar -xof -
> + STATUS=0
> + '[' 0 -ne 0 ']'
> + cd linux
> /var/tmp/rpm-tmp.QtGSXP: line 40: cd: linux: No such file or directory
> error: Bad exit status from /var/tmp/rpm-tmp.QtGSXP (%prep)
>
> There is linux.tar, not linux, and the linux.tar.gz is create by the following
> quiet_cmd_archive = ARCHIVE $@
> cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \
> --output=$$(realpath $@) --prefix=$(basename $@)/ $(archive-args)
> Here the $@ is linux.tar.gz, and $(basename $@) will be linux.tar,
> The above fact is the cause, so use $(basename $(basename $@)) to get the right directory name.
>
> Signed-off-by: Jiwei Sun <[email protected]>
> ---
> scripts/Makefile.package | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/Makefile.package b/scripts/Makefile.package
> index 4d90691505b1..3718ecdf9edf 100644
> --- a/scripts/Makefile.package
> +++ b/scripts/Makefile.package
> @@ -49,7 +49,7 @@ git-config-tar.zst = -c tar.tar.zst.command="$(ZSTD)"
>
> quiet_cmd_archive = ARCHIVE $@
> cmd_archive = git -C $(srctree) $(git-config-tar$(suffix $@)) archive \
> - --output=$$(realpath $@) --prefix=$(basename $@)/ $(archive-args)
> + --output=$$(realpath $@) --prefix=$(basename $(basename $@))/ $(archive-args)


Thanks for the report and patch, but
this would introduce another regression for
'make perf-tar-src-pkg'.

If you run it on the mainline
the file name will be "perf-6.3.0-rc7.tar"

The inner $(basename ...) will strip ".tar",
then the outer $(basename ...) will strip ".0-rc7".

The resulting prefix will become "perf-6.3/"
while the expected prefix is "pref-6.3.0-rc7/".




>
> # Linux source tarball
> # ---------------------------------------------------------------------------
> --
> 2.27.0
>


--
Best Regards
Masahiro Yamada