Skip to contentSkip to conversation

kbuild: rpm-pkg: fix rpmbuild warnings for kernel.spec

PATCH In review Rafael Aquini 3 participants 21 messages Jun 10, 2024 – Jul 17, 2024 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kbuild: rpm-pkg: fix rpmbuild warnings for kernel.spec

Newer revisions of rpmbuild are throwing warnings about the current kernel.spec template having an unversioned kernel-headers in the 'Obsoletes:' field and not being able to source the epoch's date from the spec's missing '%changelog' section:

  $ make srcrpm-pkg
    UPD     include/config/kernel.release
    GEN     rpmbuild/SPECS/kernel.spec
    UPD     .tmp_HEAD
    ARCHIVE linux.tar.gz
  rpmbuild -bs rpmbuild/SPECS/kernel.spec --define='_topdir /mnt/nfs/work/kernel/linux/rpmbuild'
  warning: line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
  warning: source_date_epoch_from_changelog set but %changelog is missing
  Wrote: /mnt/nfs/work/kernel/linux/rpmbuild/SRPMS/kernel-6.10.0_rc3-1.src.rpm

RPM build warnings:
line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers source_date_epoch_from_changelog set but %changelog is missing

This patch addresses both RPM build warnings.

---
 scripts/package/kernel.spec | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/package/kernel.spec +3 -1
index e095eb1e290e..4d58b29c03ad 100644
@@ -1,3 +1,5 @@
+%global source_date_epoch_from_changelog 0
+
 # _arch is undefined if /usr/lib/rpm/platform/*/macros was not included.
 %{!?_arch: %define _arch dummy}
 %{!?make: %define make make}
@@ -27,7 +29,7 @@ The Linux Kernel, the operating system core itself
 %package headers
 Summary: Header files for the Linux kernel for use by glibc
 Group: Development/System
-Obsoletes: kernel-headers
+Obsoletes: kernel-headers < %{version}
 Provides: kernel-headers = %{version}
 %description headers
 Kernel-headers includes the C header files that specify the interface
Signature · 1 line
2.45.1
#1 lore raw
Quoted 32 lines · Rafael Aquini

Newer revisions of rpmbuild are throwing warnings about the current kernel.spec template having an unversioned kernel-headers in the 'Obsoletes:' field and not being able to source the epoch's date from the spec's missing '%changelog' section:

  $ make srcrpm-pkg
    UPD     include/config/kernel.release
    GEN     rpmbuild/SPECS/kernel.spec
    UPD     .tmp_HEAD
    ARCHIVE linux.tar.gz
  rpmbuild -bs rpmbuild/SPECS/kernel.spec --define='_topdir /mnt/nfs/work/kernel/linux/rpmbuild'
  warning: line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
  warning: source_date_epoch_from_changelog set but %changelog is missing
  Wrote: /mnt/nfs/work/kernel/linux/rpmbuild/SRPMS/kernel-6.10.0_rc3-1.src.rpm

RPM build warnings:
line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers source_date_epoch_from_changelog set but %changelog is missing

This patch addresses both RPM build warnings.

---
 scripts/package/kernel.spec | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/package/kernel.spec +0 -0
index e095eb1e290e..4d58b29c03ad 100644

scripts/package/kernel.spec line 2

Quoted 2 lines
scripts/package/kernel.spec +1 -0
@@ -1,3 +1,5 @@
+%global source_date_epoch_from_changelog 0
 

Another possibility might be to add %changelog section.

In Debian packaging, debian/changelog is a requirement.

scripts/package/mkdebian generates a very small
debian/changelog with a single log entry.

scripts/package/kernel.spec The Linux Kernel, the operating system core itself · line 32

Quoted 9 lines
scripts/package/kernel.spec +1 -1
 # _arch is undefined if /usr/lib/rpm/platform/*/macros was not included.
 %{!?_arch: %define _arch dummy}
 %{!?make: %define make make}
@@ -27,7 +29,7 @@ The Linux Kernel, the operating system core itself
 %package headers
 Summary: Header files for the Linux kernel for use by glibc
 Group: Development/System
-Obsoletes: kernel-headers
+Obsoletes: kernel-headers < %{version}

No objection to this fix.

Quoted 6 lines
scripts/package/kernel.spec +0 -1
 Provides: kernel-headers = %{version}
 %description headers
 Kernel-headers includes the C header files that specify the interface
--

2.45.1

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 39 lines · Masahiro Yamada
Quoted 32 lines · Rafael Aquini

Newer revisions of rpmbuild are throwing warnings about the current kernel.spec template having an unversioned kernel-headers in the 'Obsoletes:' field and not being able to source the epoch's date from the spec's missing '%changelog' section:

  $ make srcrpm-pkg
    UPD     include/config/kernel.release
    GEN     rpmbuild/SPECS/kernel.spec
    UPD     .tmp_HEAD
    ARCHIVE linux.tar.gz
  rpmbuild -bs rpmbuild/SPECS/kernel.spec --define='_topdir /mnt/nfs/work/kernel/linux/rpmbuild'
  warning: line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
  warning: source_date_epoch_from_changelog set but %changelog is missing
  Wrote: /mnt/nfs/work/kernel/linux/rpmbuild/SRPMS/kernel-6.10.0_rc3-1.src.rpm

RPM build warnings:
line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers source_date_epoch_from_changelog set but %changelog is missing

This patch addresses both RPM build warnings.

---
 scripts/package/kernel.spec | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/package/kernel.spec +0 -0
index e095eb1e290e..4d58b29c03ad 100644

scripts/package/kernel.spec line 2

Quoted 2 lines
scripts/package/kernel.spec +1 -0
@@ -1,3 +1,5 @@
+%global source_date_epoch_from_changelog 0
 

Another possibility might be to add %changelog section.

Quoted 5 lines

In Debian packaging, debian/changelog is a requirement.

scripts/package/mkdebian generates a very small
debian/changelog with a single log entry.

I'll take a stab at it, then. Thanks for the pointer!

Cheers,
-- Rafael

#3 lore raw
Quoted 41 lines · Rafael Aquini
Quoted 39 lines · Masahiro Yamada
Quoted 32 lines · Rafael Aquini

Newer revisions of rpmbuild are throwing warnings about the current kernel.spec template having an unversioned kernel-headers in the 'Obsoletes:' field and not being able to source the epoch's date from the spec's missing '%changelog' section:

  $ make srcrpm-pkg
    UPD     include/config/kernel.release
    GEN     rpmbuild/SPECS/kernel.spec
    UPD     .tmp_HEAD
    ARCHIVE linux.tar.gz
  rpmbuild -bs rpmbuild/SPECS/kernel.spec --define='_topdir /mnt/nfs/work/kernel/linux/rpmbuild'
  warning: line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
  warning: source_date_epoch_from_changelog set but %changelog is missing
  Wrote: /mnt/nfs/work/kernel/linux/rpmbuild/SRPMS/kernel-6.10.0_rc3-1.src.rpm

RPM build warnings:
line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers source_date_epoch_from_changelog set but %changelog is missing

This patch addresses both RPM build warnings.

---
 scripts/package/kernel.spec | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/package/kernel.spec +0 -0
index e095eb1e290e..4d58b29c03ad 100644

scripts/package/kernel.spec line 2

Quoted 2 lines
scripts/package/kernel.spec +1 -0
@@ -1,3 +1,5 @@
+%global source_date_epoch_from_changelog 0
 

Another possibility might be to add %changelog section.

Quoted 7 lines
Quoted 5 lines

In Debian packaging, debian/changelog is a requirement.

scripts/package/mkdebian generates a very small
debian/changelog with a single log entry.

I'll take a stab at it, then. Thanks for the pointer!

When you send v2, please split it into two patches.

You are addressing two warnings.
These are separate issues.

Signature · 2 lines
Best Regards
Masahiro Yamada
#4 lore raw

cover kbuild: rpm-pkg: fix rpmbuild warnings for kernel.spec

Newer revisions of rpmbuild are throwing warnings about the current kernel.spec template having an unversioned kernel-headers in the 'Obsoletes:' field and not being able to source the epoch's date from the spec's missing '%changelog' section:

  $ make srcrpm-pkg
    UPD     include/config/kernel.release
    GEN     rpmbuild/SPECS/kernel.spec
    UPD     .tmp_HEAD
    ARCHIVE linux.tar.gz
  rpmbuild -bs rpmbuild/SPECS/kernel.spec --define='_topdir /mnt/nfs/work/kernel/linux/rpmbuild'
  warning: line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
  warning: source_date_epoch_from_changelog set but %changelog is missing
  Wrote: /mnt/nfs/work/kernel/linux/rpmbuild/SRPMS/kernel-6.10.0_rc3-1.src.rpm

RPM build warnings:
line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers source_date_epoch_from_changelog set but %changelog is missing

This patchset addresses both RPM build warnings.

Rafael Aquini (2):
kbuild: rpm-pkg: make sure to have versioned 'Obsoletes' for kernel.spec
kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec

 scripts/package/kernel.spec | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
Signature · 1 line
2.45.1
#5 lore raw

PATCH 1/2 kbuild: rpm-pkg: make sure to have versioned 'Obsoletes' for kernel.spec

In reply to Masahiro Yamada

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
---
 scripts/package/kernel.spec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/kernel.spec +1 -1
index e095eb1e290e..19e458341f45 100644
@@ -27,7 +27,7 @@ The Linux Kernel, the operating system core itself
 %package headers
 Summary: Header files for the Linux kernel for use by glibc
 Group: Development/System
-Obsoletes: kernel-headers
+Obsoletes: kernel-headers < %{version}
 Provides: kernel-headers = %{version}
 %description headers
 Kernel-headers includes the C header files that specify the interface
Signature · 1 line
2.45.1
maintainer Tested-by on v1 1/2
#6 lore raw

Re: [PATCH 1/2] kbuild: rpm-pkg: make sure to have versioned 'Obsoletes' for kernel.spec

Quoted 8 lines · Rafael Aquini

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
Quoted 20 lines
---
 scripts/package/kernel.spec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/kernel.spec +1 -1
index e095eb1e290e..19e458341f45 100644
@@ -27,7 +27,7 @@ The Linux Kernel, the operating system core itself
 %package headers
 Summary: Header files for the Linux kernel for use by glibc
 Group: Development/System
-Obsoletes: kernel-headers
+Obsoletes: kernel-headers < %{version}
 Provides: kernel-headers = %{version}
 %description headers
 Kernel-headers includes the C header files that specify the interface
Signature · 1 line
2.45.1
#7 lore raw

Re: [PATCH 1/2] kbuild: rpm-pkg: make sure to have versioned 'Obsoletes' for kernel.spec

In reply to Rafael Aquini
Quoted 27 lines · Rafael Aquini

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
---
 scripts/package/kernel.spec | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/package/kernel.spec +1 -2
index e095eb1e290e..19e458341f45 100644
@@ -27,7 +27,7 @@ The Linux Kernel, the operating system core itself
 %package headers
 Summary: Header files for the Linux kernel for use by glibc
 Group: Development/System
-Obsoletes: kernel-headers
+Obsoletes: kernel-headers < %{version}
 Provides: kernel-headers = %{version}
 %description headers
 Kernel-headers includes the C header files that specify the interface
--
Quoted 3 lines

2.45.1

Applied to linux-kbuild.
Thanks!

Signature · 2 lines
Best Regards
Masahiro Yamada
#8 lore raw

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

In reply to Masahiro Yamada

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      source_date_epoch_from_changelog set but %changelog is missing
---
 scripts/package/kernel.spec | 5 +++++
 1 file changed, 5 insertions(+)
scripts/package/kernel.spec +5 -0
index 19e458341f45..126b23c1f6c2 100644
@@ -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.
Signature · 1 line
2.45.1
#9 lore raw

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

Quoted 28 lines · Rafael Aquini

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      source_date_epoch_from_changelog set but %changelog is missing
---
 scripts/package/kernel.spec | 5 +++++
 1 file changed, 5 insertions(+)
scripts/package/kernel.spec +5 -0
index 19e458341f45..126b23c1f6c2 100644
@@ -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.
Signature · 1 line
2.45.1

Please, don't forget this one.

Thank you!

#10 lore raw

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

In reply to Rafael Aquini
Quoted 27 lines · Rafael Aquini

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      source_date_epoch_from_changelog set but %changelog is missing
---
 scripts/package/kernel.spec | 5 +++++
 1 file changed, 5 insertions(+)
scripts/package/kernel.spec +5 -1
index 19e458341f45..126b23c1f6c2 100644
@@ -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.
--
Quoted 2 lines

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

#11 lore raw

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

On Fri, Jul 05, 2024 at 12:52:41AM +0900, Masahiro Yamada wrote:
[...]

Quoted 5 lines

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

#12 lore raw

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

In reply to Masahiro Yamada

Fix the following rpmbuild warning:

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

---
v2: move the changelog stub generator to mkspec (masahiroy)

 scripts/package/mkspec | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
scripts/package/mkspec +22 -0
index ce201bfa8377..6abbfef700fd 100755
@@ -28,3 +28,25 @@ cat<<EOF
 EOF
 
 cat "${srctree}/scripts/package/kernel.spec"
+
+# collect the user's name and email addr for the changelog entry
+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
+	buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
+	email="${name}@${buildhost}"
+fi
+
+cat << EOF
+
+%changelog
+* $(LC_ALL=C; date +'%a %b %d %Y') ${name} <${email}> - ${KERNELRELEASE}
+- Custom built Linux kernel.
+EOF
Signature · 1 line
2.45.1
#13 lore raw

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

Quoted 20 lines · Rafael Aquini

Fix the following rpmbuild warning:

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

---
v2: move the changelog stub generator to mkspec (masahiroy)

 scripts/package/mkspec | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
scripts/package/mkspec +0 -0
index ce201bfa8377..6abbfef700fd 100755

scripts/package/mkspec cat<<EOF · line 32

Quoted 5 lines
scripts/package/mkspec +2 -0
@@ -28,3 +28,25 @@ cat<<EOF
 EOF
 
 cat "${srctree}/scripts/package/kernel.spec"
+
+# collect the user's name and email addr for the changelog entry

"addr" -> "address"

scripts/package/mkspec cat<<EOF · line 44

Quoted 12 lines
scripts/package/mkspec +12 -0
+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
+       buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
+       email="${name}@${buildhost}"

This is not what I suggested.

My intention was to avoid spaces in the email address.

Consider this scenario:

- git config user.name returns "Foo Bar".

- There is no configuration for git config user.email

The email will be set to "Foo Bar@some-hostname".

I am not sure if a space is allowed in an email address, but I have never seen such an address.

Quoted 11 lines
scripts/package/mkspec +8 -1
+fi
+
+cat << EOF
+
+%changelog
+* $(LC_ALL=C; date +'%a %b %d %Y') ${name} <${email}> - ${KERNELRELEASE}
+- Custom built Linux kernel.
+EOF
--

2.45.1

--
Best Regards
Masahiro Yamada

#14 lore raw

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

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      source_date_epoch_from_changelog set but %changelog is missing
---
 scripts/package/mkspec | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
scripts/package/mkspec +23 -0
index ce201bfa8377..e45fdb12fbc7 100755
@@ -28,3 +28,26 @@ cat<<EOF
 EOF
 
 cat "${srctree}/scripts/package/kernel.spec"
+
+# collect the user's name and email address for the changelog entry
+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
+	buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
+	builduser=${KBUILD_BUILD_USER:-$(id -nu)}
+	email="${builduser}@${buildhost}"
+fi
+
+cat << EOF
+
+%changelog
+* $(LC_ALL=C; date +'%a %b %d %Y') ${name} <${email}> - ${KERNELRELEASE}
+- Custom built Linux kernel.
+EOF
Signature · 1 line
2.45.1
#15 lore raw

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

Quoted 32 lines · Rafael Aquini

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      source_date_epoch_from_changelog set but %changelog is missing
---
 scripts/package/mkspec | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
scripts/package/mkspec +11 -0
index ce201bfa8377..e45fdb12fbc7 100755
@@ -28,3 +28,26 @@ cat<<EOF
 EOF
 
 cat "${srctree}/scripts/package/kernel.spec"
+
+# collect the user's name and email address for the changelog entry
+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
+

scripts/package/mkspec cat<<EOF · line 51

Quoted 10 lines
scripts/package/mkspec +10 -0
+if [ ! "${email:+set}" ]; then
+       buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
+       builduser=${KBUILD_BUILD_USER:-$(id -nu)}
+       email="${builduser}@${buildhost}"
+fi
+
+cat << EOF
+
+%changelog
+* $(LC_ALL=C; date +'%a %b %d %Y') ${name} <${email}> - ${KERNELRELEASE}

I am not sure whether the version is required or not.

In the following guide, not all entries have the version.

https://jfearn.fedorapeople.org/en-US/RPM/4/html/RPM_Guide/ch09s06.html

If you want to add the version, perhaps is it better to follow the fedora convention?

The spec file of Fedora looks as follows.
The version is enclosed in the square brackets.

%changelog
* Wed Dec 13 2023 Augusto Caringi <[email protected]> [6.6.7-0]
- Add rhbz#2253632 rhbz#2253633 to BugsFixed (Justin M. Forbes)
- Turn on DRM_ACCEL drivers for Fedora (Justin M. Forbes)
- Linux v6.6.7

Or, is this not important because there is no strict format?

Quoted 6 lines
scripts/package/mkspec +2 -1
+- Custom built Linux kernel.
+EOF
--

2.45.1

Signature · 2 lines
Best Regards
Masahiro Yamada
#16 lore raw

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

Quoted 68 lines · Masahiro Yamada
Quoted 32 lines · Rafael Aquini

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      source_date_epoch_from_changelog set but %changelog is missing
---
 scripts/package/mkspec | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
scripts/package/mkspec +11 -0
index ce201bfa8377..e45fdb12fbc7 100755
@@ -28,3 +28,26 @@ cat<<EOF
 EOF
 
 cat "${srctree}/scripts/package/kernel.spec"
+
+# collect the user's name and email address for the changelog entry
+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
+

scripts/package/mkspec cat<<EOF · line 51

Quoted 10 lines
scripts/package/mkspec +10 -0
+if [ ! "${email:+set}" ]; then
+       buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
+       builduser=${KBUILD_BUILD_USER:-$(id -nu)}
+       email="${builduser}@${buildhost}"
+fi
+
+cat << EOF
+
+%changelog
+* $(LC_ALL=C; date +'%a %b %d %Y') ${name} <${email}> - ${KERNELRELEASE}

I am not sure whether the version is required or not.

In the following guide, not all entries have the version.

https://jfearn.fedorapeople.org/en-US/RPM/4/html/RPM_Guide/ch09s06.html

If you want to add the version, perhaps is it better to follow the fedora convention?

The spec file of Fedora looks as follows.
The version is enclosed in the square brackets.

%changelog
* Wed Dec 13 2023 Augusto Caringi <[email protected]> [6.6.7-0]
- Add rhbz#2253632 rhbz#2253633 to BugsFixed (Justin M. Forbes)
- Turn on DRM_ACCEL drivers for Fedora (Justin M. Forbes)
- Linux v6.6.7

Quoted 1 line

Or, is this not important because there is no strict format?

Darn, I've been using the "- release" pattern for my RPMs for quite a long time, as circa 2010 that was the suggestion. I guess I just got used to it and never really noticed the change along the way.

There's not a strict format, though, and it's just nice to have the version showing in there.
I have no strong feelings about the format we should be going to go with, so I'll leave it up to you.

What is the format you'd prefer for the changelog entry? Leave it as it is in this patch, or adopt the Fedora standard?

I'll wait for your input before refreshing this patch (or not)

Cheers,
-- Rafael

#17 lore raw

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

Quoted 82 lines · Rafael Aquini
Quoted 68 lines · Masahiro Yamada
Quoted 32 lines · Rafael Aquini

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      source_date_epoch_from_changelog set but %changelog is missing
---
 scripts/package/mkspec | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
scripts/package/mkspec +11 -0
index ce201bfa8377..e45fdb12fbc7 100755
@@ -28,3 +28,26 @@ cat<<EOF
 EOF
 
 cat "${srctree}/scripts/package/kernel.spec"
+
+# collect the user's name and email address for the changelog entry
+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
+

scripts/package/mkspec cat<<EOF · line 51

Quoted 10 lines
scripts/package/mkspec +10 -0
+if [ ! "${email:+set}" ]; then
+       buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
+       builduser=${KBUILD_BUILD_USER:-$(id -nu)}
+       email="${builduser}@${buildhost}"
+fi
+
+cat << EOF
+
+%changelog
+* $(LC_ALL=C; date +'%a %b %d %Y') ${name} <${email}> - ${KERNELRELEASE}

I am not sure whether the version is required or not.

In the following guide, not all entries have the version.

https://jfearn.fedorapeople.org/en-US/RPM/4/html/RPM_Guide/ch09s06.html

If you want to add the version, perhaps is it better to follow the fedora convention?

The spec file of Fedora looks as follows.
The version is enclosed in the square brackets.

%changelog
* Wed Dec 13 2023 Augusto Caringi <[email protected]> [6.6.7-0]
- Add rhbz#2253632 rhbz#2253633 to BugsFixed (Justin M. Forbes)
- Turn on DRM_ACCEL drivers for Fedora (Justin M. Forbes)
- Linux v6.6.7

Quoted 1 line

Or, is this not important because there is no strict format?

Darn, I've been using the "- release" pattern for my RPMs for quite a long time, as circa 2010 that was the suggestion. I guess I just got used to it and never really noticed the change along the way.

There's not a strict format, though, and it's just nice to have the version showing in there.
I have no strong feelings about the format we should be going to go with, so I'll leave it up to you.

Quoted 4 lines

What is the format you'd prefer for the changelog entry? Leave it as it is in this patch, or adopt the Fedora standard?

I'll wait for your input before refreshing this patch (or not)

My preference is to get rid of the version number from %changelog because this is an upstream snapshot source package, and there is only one entry.

The version number is already expressed in the
"Version:" field.

Signature · 2 lines
Best Regards
Masahiro Yamada
#18 lore raw

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

Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      source_date_epoch_from_changelog set but %changelog is missing
---
 scripts/package/mkspec | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
scripts/package/mkspec +23 -0
index ce201bfa8377..e8e01330266b 100755
@@ -28,3 +28,26 @@ cat<<EOF
 EOF
 
 cat "${srctree}/scripts/package/kernel.spec"
+
+# collect the user's name and email address for the changelog entry
+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
+	buildhost=${KBUILD_BUILD_HOST:-$(hostname -f 2>/dev/null || hostname)}
+	builduser=${KBUILD_BUILD_USER:-$(id -nu)}
+	email="${builduser}@${buildhost}"
+fi
+
+cat << EOF
+
+%changelog
+* $(LC_ALL=C; date +'%a %b %d %Y') ${name} <${email}>
+- Custom built Linux kernel.
+EOF
Signature · 1 line
2.45.1
#19 lore raw

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

Quoted 10 lines · Rafael Aquini

Fix the following rpmbuild warning:

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

---

Applied to linux-kbuild.
Thanks!

Signature · 2 lines
Best Regards
Masahiro Yamada
#20 lore raw

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

Quoted 9 lines · Masahiro Yamada
Quoted 8 lines · Rafael Aquini

Fix the following rpmbuild warning:

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

---

Applied to linux-kbuild.
Thanks!

Thank you.