diff mbox series

kbuild: deb-pkg: require debian_revision when creating source package

Message ID 20250311190124.634007-1-masahiroy@kernel.org (mailing list archive)
State New
Headers show
Series kbuild: deb-pkg: require debian_revision when creating source package | expand

Commit Message

Masahiro Yamada March 11, 2025, 7 p.m. UTC
Debian Policy [1] specifies the version format as follows:

    [epoch:]upstream_version[-debian_revision]

Here, the presence of the debian_revision part indicates a non-native
package, while its absence indicates a native package.

Kbuild adopts the source format 3.0 (quilt), meaning the kernel is a
non-native package and therefore requires the revision portion.

This commit prevents the creation of an invalid source package when
KDEB_PKGVERSION contains no hyphen.

[1]: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/package/mkdebian | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Nicolas Schier March 21, 2025, 5:22 a.m. UTC | #1
On Wed, Mar 12, 2025 at 04:00:26AM +0900, Masahiro Yamada wrote:
> Debian Policy [1] specifies the version format as follows:
> 
>     [epoch:]upstream_version[-debian_revision]
> 
> Here, the presence of the debian_revision part indicates a non-native
> package, while its absence indicates a native package.
> 
> Kbuild adopts the source format 3.0 (quilt), meaning the kernel is a
> non-native package and therefore requires the revision portion.
> 
> This commit prevents the creation of an invalid source package when
> KDEB_PKGVERSION contains no hyphen.
> 
> [1]: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
> 
> Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> ---
> 
>  scripts/package/mkdebian | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> index b6dd98ca860b..193e33bcb989 100755
> --- a/scripts/package/mkdebian
> +++ b/scripts/package/mkdebian
> @@ -94,6 +94,14 @@ set_debarch() {
>  # Create debian/source/ if it is a source package build
>  gen_source ()
>  {
> +	# The Debian Policy requires -debian_revision portion in the version.
> +	# Since the source format 3.0 (quilt) is used here, a hyphen is
> +	# required in the version.
> +	if [ "${KDEB_PKGVERSION:+set}" ] && ! echo "${KDEB_PKGVERSION}" | grep -- '-..*'; then

Thanks.  At first, I thought that the check pattern could be enhanced,
but testing with '--' as version suffix led to 

    dpkg-buildpackage: warning:     debian/changelog(l1): version '6.14rc5+me--' is invalid: revision cannot be empty
    LINE: linux-upstream (6.14rc5+avm--) trixie; urgency=low
    dpkg-buildpackage: info: source package linux-upstream
    dpkg-buildpackage: info: source version unknown
    dpkg-buildpackage: error: version number does not start with digit

thus this is great as it is.

Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>
Masahiro Yamada March 22, 2025, 2:47 p.m. UTC | #2
On Fri, Mar 21, 2025 at 2:22 PM Nicolas Schier <nicolas.schier@linux.dev> wrote:
>
> On Wed, Mar 12, 2025 at 04:00:26AM +0900, Masahiro Yamada wrote:
> > Debian Policy [1] specifies the version format as follows:
> >
> >     [epoch:]upstream_version[-debian_revision]
> >
> > Here, the presence of the debian_revision part indicates a non-native
> > package, while its absence indicates a native package.
> >
> > Kbuild adopts the source format 3.0 (quilt), meaning the kernel is a
> > non-native package and therefore requires the revision portion.
> >
> > This commit prevents the creation of an invalid source package when
> > KDEB_PKGVERSION contains no hyphen.
> >
> > [1]: https://www.debian.org/doc/debian-policy/ch-controlfields.html#version
> >
> > Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
> > ---
> >
> >  scripts/package/mkdebian | 8 ++++++++
> >  1 file changed, 8 insertions(+)
> >
> > diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
> > index b6dd98ca860b..193e33bcb989 100755
> > --- a/scripts/package/mkdebian
> > +++ b/scripts/package/mkdebian
> > @@ -94,6 +94,14 @@ set_debarch() {
> >  # Create debian/source/ if it is a source package build
> >  gen_source ()
> >  {
> > +     # The Debian Policy requires -debian_revision portion in the version.
> > +     # Since the source format 3.0 (quilt) is used here, a hyphen is
> > +     # required in the version.
> > +     if [ "${KDEB_PKGVERSION:+set}" ] && ! echo "${KDEB_PKGVERSION}" | grep -- '-..*'; then
>
> Thanks.  At first, I thought that the check pattern could be enhanced,
> but testing with '--' as version suffix led to
>
>     dpkg-buildpackage: warning:     debian/changelog(l1): version '6.14rc5+me--' is invalid: revision cannot be empty
>     LINE: linux-upstream (6.14rc5+avm--) trixie; urgency=low
>     dpkg-buildpackage: info: source package linux-upstream
>     dpkg-buildpackage: info: source version unknown
>     dpkg-buildpackage: error: version number does not start with digit
>
> thus this is great as it is.

Good point.

The debian tool already rejects incorrect version format.
So, we could simplify the version check to:

  grep -- -


However, on second thought, this patch might be unnecessary
because it is better to leave all the version checks
up to the debian tools.


When KDEB_PKGVERSION does not contain a hyphen,
this warning is shown:

  dpkg-source: warning: non-native package version does not contain a revision

It still produces a source package.
If this is just a warning instead of an error, it is fine.

>
> Reviewed-by: Nicolas Schier <nicolas@fjasle.eu>

Thanks for the review.
diff mbox series

Patch

diff --git a/scripts/package/mkdebian b/scripts/package/mkdebian
index b6dd98ca860b..193e33bcb989 100755
--- a/scripts/package/mkdebian
+++ b/scripts/package/mkdebian
@@ -94,6 +94,14 @@  set_debarch() {
 # Create debian/source/ if it is a source package build
 gen_source ()
 {
+	# The Debian Policy requires -debian_revision portion in the version.
+	# Since the source format 3.0 (quilt) is used here, a hyphen is
+	# required in the version.
+	if [ "${KDEB_PKGVERSION:+set}" ] && ! echo "${KDEB_PKGVERSION}" | grep -- '-..*'; then
+		echo "error: KDEB_PKGVERSION must include a hyphen to create a source package" >&2
+		exit 1
+	fi
+
 	mkdir -p debian/source
 
 	echo "3.0 (quilt)" > debian/source/format