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

Rafael Aquini posted 1 patch 1 year, 8 months ago
There is a newer version of this series
scripts/package/kernel.spec | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
[PATCH] kbuild: rpm-pkg: fix rpmbuild warnings for kernel.spec
Posted by Rafael Aquini 1 year, 8 months ago
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.

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

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index e095eb1e290e..4d58b29c03ad 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -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
-- 
2.45.1
Re: [PATCH] kbuild: rpm-pkg: fix rpmbuild warnings for kernel.spec
Posted by Masahiro Yamada 1 year, 8 months ago
On Tue, Jun 11, 2024 at 1:39 AM Rafael Aquini <aquini@redhat.com> wrote:
>
> 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.
>
> Signed-off-by: Rafael Aquini <aquini@redhat.com>
> ---
>  scripts/package/kernel.spec | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index e095eb1e290e..4d58b29c03ad 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -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.




>  # _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.



>  Provides: kernel-headers = %{version}
>  %description headers
>  Kernel-headers includes the C header files that specify the interface
> --
> 2.45.1
>


-- 
Best Regards
Masahiro Yamada
Re: [PATCH] kbuild: rpm-pkg: fix rpmbuild warnings for kernel.spec
Posted by Rafael Aquini 1 year, 8 months ago
On Wed, Jun 12, 2024 at 12:00:18AM +0900, Masahiro Yamada wrote:
> On Tue, Jun 11, 2024 at 1:39 AM Rafael Aquini <aquini@redhat.com> wrote:
> >
> > 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.
> >
> > Signed-off-by: Rafael Aquini <aquini@redhat.com>
> > ---
> >  scripts/package/kernel.spec | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> > index e095eb1e290e..4d58b29c03ad 100644
> > --- a/scripts/package/kernel.spec
> > +++ b/scripts/package/kernel.spec
> > @@ -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.
>

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

Re: [PATCH] kbuild: rpm-pkg: fix rpmbuild warnings for kernel.spec
Posted by Masahiro Yamada 1 year, 8 months ago
On Wed, Jun 12, 2024 at 1:03 AM Rafael Aquini <aquini@redhat.com> wrote:
>
> On Wed, Jun 12, 2024 at 12:00:18AM +0900, Masahiro Yamada wrote:
> > On Tue, Jun 11, 2024 at 1:39 AM Rafael Aquini <aquini@redhat.com> wrote:
> > >
> > > 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.
> > >
> > > Signed-off-by: Rafael Aquini <aquini@redhat.com>
> > > ---
> > >  scripts/package/kernel.spec | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> > > index e095eb1e290e..4d58b29c03ad 100644
> > > --- a/scripts/package/kernel.spec
> > > +++ b/scripts/package/kernel.spec
> > > @@ -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.
> >
>
> 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.




-- 
Best Regards
Masahiro Yamada
[PATCH 0/2] kbuild: rpm-pkg: fix rpmbuild warnings for kernel.spec
Posted by Rafael Aquini 1 year, 8 months ago
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(-)

-- 
2.45.1
[PATCH 1/2] kbuild: rpm-pkg: make sure to have versioned 'Obsoletes' for kernel.spec
Posted by Rafael Aquini 1 year, 8 months ago
Fix the following rpmbuild warning:

  $ make srcrpm-pkg
  ...
  RPM build warnings:
      line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers

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

diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
index e095eb1e290e..19e458341f45 100644
--- a/scripts/package/kernel.spec
+++ b/scripts/package/kernel.spec
@@ -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
-- 
2.45.1
Re: [PATCH 1/2] kbuild: rpm-pkg: make sure to have versioned 'Obsoletes' for kernel.spec
Posted by Masahiro Yamada 1 year, 7 months ago
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:
>       line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
>
> Signed-off-by: Rafael Aquini <aquini@redhat.com>
> ---
>  scripts/package/kernel.spec | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index e095eb1e290e..19e458341f45 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -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
> --
> 2.45.1
>
>

Applied to linux-kbuild.
Thanks!


-- 
Best Regards
Masahiro Yamada
Re: [PATCH 1/2] kbuild: rpm-pkg: make sure to have versioned 'Obsoletes' for kernel.spec
Posted by Nathan Chancellor 1 year, 8 months ago
On Tue, Jun 11, 2024 at 05:11:21PM -0400, Rafael Aquini wrote:
> Fix the following rpmbuild warning:
> 
>   $ make srcrpm-pkg
>   ...
>   RPM build warnings:
>       line 34: It's not recommended to have unversioned Obsoletes: Obsoletes: kernel-headers
> 
> Signed-off-by: Rafael Aquini <aquini@redhat.com>

Tested-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  scripts/package/kernel.spec | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/package/kernel.spec b/scripts/package/kernel.spec
> index e095eb1e290e..19e458341f45 100644
> --- a/scripts/package/kernel.spec
> +++ b/scripts/package/kernel.spec
> @@ -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
> -- 
> 2.45.1
>
[PATCH 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Rafael Aquini 1 year, 8 months ago
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
Re: [PATCH 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Masahiro Yamada 1 year, 7 months ago
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
Re: [PATCH 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Rafael Aquini 1 year, 7 months ago
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
[PATCH v2 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Rafael Aquini 1 year, 7 months ago
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>
---
v2: move the changelog stub generator to mkspec (masahiroy)

 scripts/package/mkspec | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index ce201bfa8377..6abbfef700fd 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -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
-- 
2.45.1
Re: [PATCH v2 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Masahiro Yamada 1 year, 7 months ago
On Fri, Jul 5, 2024 at 4:36 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>
> ---
> v2: move the changelog stub generator to mkspec (masahiroy)
>
>  scripts/package/mkspec | 22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index ce201bfa8377..6abbfef700fd 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -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"






> +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.









> +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
[PATCH v3 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Rafael Aquini 1 year, 7 months ago
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/mkspec | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index ce201bfa8377..e45fdb12fbc7 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -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
-- 
2.45.1
Re: [PATCH v3 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Masahiro Yamada 1 year, 7 months ago
On Sun, Jul 7, 2024 at 1:45 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/mkspec | 23 +++++++++++++++++++++++
>  1 file changed, 23 insertions(+)
>
> diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> index ce201bfa8377..e45fdb12fbc7 100755
> --- a/scripts/package/mkspec
> +++ b/scripts/package/mkspec
> @@ -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}


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 <acaringi@redhat.com> [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?



> +- Custom built Linux kernel.
> +EOF
> --
> 2.45.1
>
>


-- 
Best Regards
Masahiro Yamada
Re: [PATCH v3 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Rafael Aquini 1 year, 7 months ago
On Tue, Jul 16, 2024 at 01:32:56AM +0900, Masahiro Yamada wrote:
> On Sun, Jul 7, 2024 at 1:45 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/mkspec | 23 +++++++++++++++++++++++
> >  1 file changed, 23 insertions(+)
> >
> > diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> > index ce201bfa8377..e45fdb12fbc7 100755
> > --- a/scripts/package/mkspec
> > +++ b/scripts/package/mkspec
> > @@ -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}
> 
> 
> 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 <acaringi@redhat.com> [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?

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

Re: [PATCH v3 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Masahiro Yamada 1 year, 7 months ago
On Tue, Jul 16, 2024 at 6:21 AM Rafael Aquini <aquini@redhat.com> wrote:
>
> On Tue, Jul 16, 2024 at 01:32:56AM +0900, Masahiro Yamada wrote:
> > On Sun, Jul 7, 2024 at 1:45 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/mkspec | 23 +++++++++++++++++++++++
> > >  1 file changed, 23 insertions(+)
> > >
> > > diff --git a/scripts/package/mkspec b/scripts/package/mkspec
> > > index ce201bfa8377..e45fdb12fbc7 100755
> > > --- a/scripts/package/mkspec
> > > +++ b/scripts/package/mkspec
> > > @@ -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}
> >
> >
> > 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 <acaringi@redhat.com> [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?
>
> 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)


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.





-- 
Best Regards
Masahiro Yamada
[PATCH v4 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Rafael Aquini 1 year, 7 months ago
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/mkspec | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/scripts/package/mkspec b/scripts/package/mkspec
index ce201bfa8377..e8e01330266b 100755
--- a/scripts/package/mkspec
+++ b/scripts/package/mkspec
@@ -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
-- 
2.45.1
Re: [PATCH v4 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Masahiro Yamada 1 year, 6 months ago
On Tue, Jul 16, 2024 at 9:25 PM 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>
> ---

Applied to linux-kbuild.
Thanks!


-- 
Best Regards
Masahiro Yamada
Re: [PATCH v4 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Rafael Aquini 1 year, 6 months ago
On Thu, Jul 18, 2024 at 02:10:13AM +0900, Masahiro Yamada wrote:
> On Tue, Jul 16, 2024 at 9:25 PM 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>
> > ---
> 
> Applied to linux-kbuild.
> Thanks!
> 
>

Thank you.

Re: [PATCH 2/2] kbuild: rpm-pkg: introduce a simple changelog section for kernel.spec
Posted by Rafael Aquini 1 year, 7 months ago
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!