diff mbox series

[2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec

Message ID 20240611211123.959459-3-aquini@redhat.com (mailing list archive)
State New
Headers show
Series kbuild: rpm-pkg: fix rpmbuild warnings for kernel.spec | expand

Commit Message

Rafael Aquini June 11, 2024, 9:11 p.m. UTC
Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      source_date_epoch_from_changelog set but %changelog is missing

Signed-off-by: Rafael Aquini <aquini@redhat.com>
---
 scripts/package/kernel.spec | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Rafael Aquini July 4, 2024, 3:28 p.m. UTC | #1
On Tue, Jun 11, 2024 at 05:11:22PM -0400, Rafael Aquini wrote:
> Fix the following rpmbuild warning:
> 
>   $ make srcrpm-pkg
>   ...
>   RPM build warnings:
>       source_date_epoch_from_changelog set but %changelog is missing
> 
> Signed-off-by: Rafael Aquini <aquini@redhat.com>
> ---
>  scripts/package/kernel.spec | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index 19e458341f45..126b23c1f6c2 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -132,3 +132,8 @@ fi
>  /usr/src/kernels/%{KERNELRELEASE}
>  /lib/modules/%{KERNELRELEASE}/build
>  %endif
> +
> +%changelog
> +* %(echo "$(LC_ALL=C; date +'%a %b %d %Y') $(git config --get user.name) \
> +<$(git config --get user.email)>") - %{version}-%{release}
> +- Custom built Linux kernel.
> -- 
> 2.45.1
> 

Please, don't forget this one.

Thank you!
Masahiro Yamada July 4, 2024, 3:52 p.m. UTC | #2
On Wed, Jun 12, 2024 at 6:11 AM Rafael Aquini <aquini@redhat.com> wrote:
>
> Fix the following rpmbuild warning:
>
>   $ make srcrpm-pkg
>   ...
>   RPM build warnings:
>       source_date_epoch_from_changelog set but %changelog is missing
>
> Signed-off-by: Rafael Aquini <aquini@redhat.com>
> ---
>  scripts/package/kernel.spec | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index 19e458341f45..126b23c1f6c2 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -132,3 +132,8 @@ fi
>  /usr/src/kernels/%{KERNELRELEASE}
>  /lib/modules/%{KERNELRELEASE}/build
>  %endif
> +
> +%changelog
> +* %(echo "$(LC_ALL=C; date +'%a %b %d %Y') $(git config --get user.name) \
> +<$(git config --get user.email)>") - %{version}-%{release}
> +- Custom built Linux kernel.
> --
> 2.45.1
>


This approach is wrong because %(...) is not expanded when generating
the source package.


Expand the generated SRPM to see what has happened.


[vagrant@fedora39 ~]$ rpm2cpio
kernel-6.10.0_rc3_00002_gdb908e378f93-6.src.rpm | cpio -idvm

[vagrant@fedora39 ~]$ tail -n 4 kernel.spec
%changelog
* %(echo "$(LC_ALL=C; date +'%a %b %d %Y') $(git config --get user.name) \
<$(git config --get user.email)>") - %{version}-%{release}
- Custom built Linux kern



This %changelog section is meaningless, as it does not contain
any useful information about the person who packaged it.



Just like mkdebian, this log information must be generated
when you create the package.


Using 'git config' is OK, but git is optional for 'make binrpm-pkg'.

So, you need to add fallback defaults in case git is not available.
(this code is available in scripts/package/mkdebian)





How about adding this to scripts/package/mkspec?


if [ "$(command -v git)" ]; then
        name=$(git config user.name) || true
        email=$(git config user.email) || true
fi

if [ ! "${name:+set}" ]; then
        name=${KBUILD_BUILD_USER:-$(id -nu)}
fi

if [ ! "${email:+set}" ]; then
        email="${KBUILD_BUILD_USER:-$(id
-nu)}@${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}"
fi

cat<<EOF

%changelog
* $(LC_ALL=C date +'%a %b %d %Y') ${name} <${email}>
- Custom built Linux kernel.
EOF




--
Best Regards

Masahiro Yamada
Rafael Aquini July 4, 2024, 6:16 p.m. UTC | #3
On Fri, Jul 05, 2024 at 12:52:41AM +0900, Masahiro Yamada wrote:
[...]
> Using 'git config' is OK, but git is optional for 'make binrpm-pkg'.
>
> So, you need to add fallback defaults in case git is not available.
> (this code is available in scripts/package/mkdebian)
>
Alright, that's a fair point. I was originally under the impression 
that check-git would always run on Makefile.package target calls, 
but I see where/why I was mistaken, now. 
I'll get it done in scripts/package/mkspec, as suggested. 

Thank you!
-- Rafael
diff mbox series

Patch

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index 19e458341f45..126b23c1f6c2 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -132,3 +132,8 @@  fi
 /usr/src/kernels/%{KERNELRELEASE}
 /lib/modules/%{KERNELRELEASE}/build
 %endif
+
+%changelog
+* %(echo "$(LC_ALL=C; date +'%a %b %d %Y') $(git config --get user.name) \
+<$(git config --get user.email)>") - %{version}-%{release}
+- Custom built Linux kernel.