debianize: use debhelper-compat to generate compat file

Message ID 20240131161943.3331272-1-Quirin.Gylstorff@siemens.com
State Superseded, archived
Headers show
Series debianize: use debhelper-compat to generate compat file | expand

Commit Message

Quirin Gylstorff Jan. 31, 2024, 4:08 p.m. UTC
From: Quirin Gylstorff <quirin.gylstorff@siemens.com>

debhelper supports the versions debhelper-compat (= 9) till
debhelper-compat (= 13).

This patch also adds the variable `DEBIAN_COMPAT` to set the compat
to the desired version.

Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
---
 meta/classes/debianize.bbclass | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

Comments

MOESSBAUER, Felix Feb. 1, 2024, 7:26 a.m. UTC | #1
On Wed, 2024-01-31 at 17:08 +0100, 'Quirin Gylstorff' via isar-users
wrote:
> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> 
> debhelper supports the versions debhelper-compat (= 9) till
> debhelper-compat (= 13).
> 
> This patch also adds the variable `DEBIAN_COMPAT` to set the compat
> to the desired version.

Hi Quirin,

thanks for bringing this up. In more and more layers we see people
removing the compat file and manually patching the control. This makes
it much easier.

> 
> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> ---
>  meta/classes/debianize.bbclass | 13 ++-----------
>  1 file changed, 2 insertions(+), 11 deletions(-)
> 
> diff --git a/meta/classes/debianize.bbclass
> b/meta/classes/debianize.bbclass
> index 16f3638d..7de98673 100644
> --- a/meta/classes/debianize.bbclass
> +++ b/meta/classes/debianize.bbclass
> @@ -10,6 +10,7 @@ DEBIAN_BUILD_DEPENDS ??= ""
>  DEBIAN_DEPENDS ??= ""
>  DEBIAN_CONFLICTS ??= ""
>  DEBIAN_MULTI_ARCH ??= "no"
> +DEBIAN_COMPAT ??= "10"

Can we set the default compat version based on the distribution?
E.g. buster: 12, bullseye: 13, bookworm: 13, trixi / sid: 13

Felix

>  DESCRIPTION ??= "must not be empty"
>  MAINTAINER ??= "Unknown maintainer <unknown@example.com>"
>  
> @@ -60,19 +61,15 @@ EOF
>         fi
>  }
>  
> -deb_create_compat() {
> -       echo 10 > ${S}/debian/compat
> -}
>  
>  deb_create_control() {
> -       compat=$( cat ${S}/debian/compat )
>         cat << EOF > ${S}/debian/control
>  Source: ${BPN}
>  Section: misc
>  Priority: optional
>  Standards-Version: 3.9.6
>  Maintainer: ${MAINTAINER}
> -Build-Depends: debhelper (>= ${compat}), ${DEBIAN_BUILD_DEPENDS}
> +Build-Depends: debhelper-compat (= ${DEBIAN_COMPAT}),
> ${DEBIAN_BUILD_DEPENDS}
>  
>  Package: ${BPN}
>  Architecture: ${DPKG_ARCH}
> @@ -103,12 +100,6 @@ EOF
>  deb_debianize() {
>         install -m 755 -d ${S}/debian
>  
> -       # create the compat-file if there is no file with that name
> in WORKDIR
> -       if [ -f ${WORKDIR}/compat ]; then
> -               install -v -m 644 ${WORKDIR}/compat
> ${S}/debian/compat
> -       else
> -               deb_create_compat
> -       fi
>         # create the control-file if there is no control-file in
> WORKDIR
>         if [ -f ${WORKDIR}/control ]; then
>                 install -v -m 644 ${WORKDIR}/control
> ${S}/debian/control
> -- 
> 2.43.0
>
Quirin Gylstorff Feb. 1, 2024, 9:53 a.m. UTC | #2
On 2/1/24 08:26, Moessbauer, Felix (T CED OES-DE) wrote:
> On Wed, 2024-01-31 at 17:08 +0100, 'Quirin Gylstorff' via isar-users
> wrote:
>> From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>>
>> debhelper supports the versions debhelper-compat (= 9) till
>> debhelper-compat (= 13).
>>
>> This patch also adds the variable `DEBIAN_COMPAT` to set the compat
>> to the desired version.
> 
> Hi Quirin,
> 
> thanks for bringing this up. In more and more layers we see people
> removing the compat file and manually patching the control. This makes
> it much easier.
> 
>>
>> Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
>> ---
>>   meta/classes/debianize.bbclass | 13 ++-----------
>>   1 file changed, 2 insertions(+), 11 deletions(-)
>>
>> diff --git a/meta/classes/debianize.bbclass
>> b/meta/classes/debianize.bbclass
>> index 16f3638d..7de98673 100644
>> --- a/meta/classes/debianize.bbclass
>> +++ b/meta/classes/debianize.bbclass
>> @@ -10,6 +10,7 @@ DEBIAN_BUILD_DEPENDS ??= ""
>>   DEBIAN_DEPENDS ??= ""
>>   DEBIAN_CONFLICTS ??= ""
>>   DEBIAN_MULTI_ARCH ??= "no"
>> +DEBIAN_COMPAT ??= "10"
> 
> Can we set the default compat version based on the distribution?
> E.g. buster: 12, bullseye: 13, bookworm: 13, trixi / sid: 13

I can do we increase the default to 13 and use 12 for buster or each
supported distro separately.

Quirin

> 
> Felix
> 
>>   DESCRIPTION ??= "must not be empty"
>>   MAINTAINER ??= "Unknown maintainer <unknown@example.com>"
>>   
>> @@ -60,19 +61,15 @@ EOF
>>          fi
>>   }
>>   
>> -deb_create_compat() {
>> -       echo 10 > ${S}/debian/compat
>> -}
>>   
>>   deb_create_control() {
>> -       compat=$( cat ${S}/debian/compat )
>>          cat << EOF > ${S}/debian/control
>>   Source: ${BPN}
>>   Section: misc
>>   Priority: optional
>>   Standards-Version: 3.9.6
>>   Maintainer: ${MAINTAINER}
>> -Build-Depends: debhelper (>= ${compat}), ${DEBIAN_BUILD_DEPENDS}
>> +Build-Depends: debhelper-compat (= ${DEBIAN_COMPAT}),
>> ${DEBIAN_BUILD_DEPENDS}
>>   
>>   Package: ${BPN}
>>   Architecture: ${DPKG_ARCH}
>> @@ -103,12 +100,6 @@ EOF
>>   deb_debianize() {
>>          install -m 755 -d ${S}/debian
>>   
>> -       # create the compat-file if there is no file with that name
>> in WORKDIR
>> -       if [ -f ${WORKDIR}/compat ]; then
>> -               install -v -m 644 ${WORKDIR}/compat
>> ${S}/debian/compat
>> -       else
>> -               deb_create_compat
>> -       fi
>>          # create the control-file if there is no control-file in
>> WORKDIR
>>          if [ -f ${WORKDIR}/control ]; then
>>                  install -v -m 644 ${WORKDIR}/control
>> ${S}/debian/control
>> -- 
>> 2.43.0
>>
>
MOESSBAUER, Felix Feb. 1, 2024, 10 a.m. UTC | #3
On Thu, 2024-02-01 at 10:53 +0100, Gylstorff Quirin wrote:
> 
> 
> On 2/1/24 08:26, Moessbauer, Felix (T CED OES-DE) wrote:
> > On Wed, 2024-01-31 at 17:08 +0100, 'Quirin Gylstorff' via isar-
> > users
> > wrote:
> > > From: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> > > 
> > > debhelper supports the versions debhelper-compat (= 9) till
> > > debhelper-compat (= 13).
> > > 
> > > This patch also adds the variable `DEBIAN_COMPAT` to set the
> > > compat
> > > to the desired version.
> > 
> > Hi Quirin,
> > 
> > thanks for bringing this up. In more and more layers we see people
> > removing the compat file and manually patching the control. This
> > makes
> > it much easier.
> > 
> > > 
> > > Signed-off-by: Quirin Gylstorff <quirin.gylstorff@siemens.com>
> > > ---
> > >   meta/classes/debianize.bbclass | 13 ++-----------
> > >   1 file changed, 2 insertions(+), 11 deletions(-)
> > > 
> > > diff --git a/meta/classes/debianize.bbclass
> > > b/meta/classes/debianize.bbclass
> > > index 16f3638d..7de98673 100644
> > > --- a/meta/classes/debianize.bbclass
> > > +++ b/meta/classes/debianize.bbclass
> > > @@ -10,6 +10,7 @@ DEBIAN_BUILD_DEPENDS ??= ""
> > >   DEBIAN_DEPENDS ??= ""
> > >   DEBIAN_CONFLICTS ??= ""
> > >   DEBIAN_MULTI_ARCH ??= "no"
> > > +DEBIAN_COMPAT ??= "10"
> > 
> > Can we set the default compat version based on the distribution?
> > E.g. buster: 12, bullseye: 13, bookworm: 13, trixi / sid: 13
> 
> I can do we increase the default to 13 and use 12 for buster or each
> supported distro separately.

The first option seems to be more future proof. At a second thought, it
might be better to just configure the default in the distro config. By
that, we can easily extend this for other debian based distros like
ubuntu.

Felix

> 
> Quirin
> 
> > 
> > Felix
> > 
> > >   DESCRIPTION ??= "must not be empty"
> > >   MAINTAINER ??= "Unknown maintainer <unknown@example.com>"
> > >   
> > > @@ -60,19 +61,15 @@ EOF
> > >          fi
> > >   }
> > >   
> > > -deb_create_compat() {
> > > -       echo 10 > ${S}/debian/compat
> > > -}
> > >   
> > >   deb_create_control() {
> > > -       compat=$( cat ${S}/debian/compat )
> > >          cat << EOF > ${S}/debian/control
> > >   Source: ${BPN}
> > >   Section: misc
> > >   Priority: optional
> > >   Standards-Version: 3.9.6
> > >   Maintainer: ${MAINTAINER}
> > > -Build-Depends: debhelper (>= ${compat}), ${DEBIAN_BUILD_DEPENDS}
> > > +Build-Depends: debhelper-compat (= ${DEBIAN_COMPAT}),
> > > ${DEBIAN_BUILD_DEPENDS}
> > >   
> > >   Package: ${BPN}
> > >   Architecture: ${DPKG_ARCH}
> > > @@ -103,12 +100,6 @@ EOF
> > >   deb_debianize() {
> > >          install -m 755 -d ${S}/debian
> > >   
> > > -       # create the compat-file if there is no file with that
> > > name
> > > in WORKDIR
> > > -       if [ -f ${WORKDIR}/compat ]; then
> > > -               install -v -m 644 ${WORKDIR}/compat
> > > ${S}/debian/compat
> > > -       else
> > > -               deb_create_compat
> > > -       fi
> > >          # create the control-file if there is no control-file in
> > > WORKDIR
> > >          if [ -f ${WORKDIR}/control ]; then
> > >                  install -v -m 644 ${WORKDIR}/control
> > > ${S}/debian/control
> > > -- 
> > > 2.43.0
> > > 
> >

Patch

diff --git a/meta/classes/debianize.bbclass b/meta/classes/debianize.bbclass
index 16f3638d..7de98673 100644
--- a/meta/classes/debianize.bbclass
+++ b/meta/classes/debianize.bbclass
@@ -10,6 +10,7 @@  DEBIAN_BUILD_DEPENDS ??= ""
 DEBIAN_DEPENDS ??= ""
 DEBIAN_CONFLICTS ??= ""
 DEBIAN_MULTI_ARCH ??= "no"
+DEBIAN_COMPAT ??= "10"
 DESCRIPTION ??= "must not be empty"
 MAINTAINER ??= "Unknown maintainer <unknown@example.com>"
 
@@ -60,19 +61,15 @@  EOF
 	fi
 }
 
-deb_create_compat() {
-	echo 10 > ${S}/debian/compat
-}
 
 deb_create_control() {
-	compat=$( cat ${S}/debian/compat )
 	cat << EOF > ${S}/debian/control
 Source: ${BPN}
 Section: misc
 Priority: optional
 Standards-Version: 3.9.6
 Maintainer: ${MAINTAINER}
-Build-Depends: debhelper (>= ${compat}), ${DEBIAN_BUILD_DEPENDS}
+Build-Depends: debhelper-compat (= ${DEBIAN_COMPAT}), ${DEBIAN_BUILD_DEPENDS}
 
 Package: ${BPN}
 Architecture: ${DPKG_ARCH}
@@ -103,12 +100,6 @@  EOF
 deb_debianize() {
 	install -m 755 -d ${S}/debian
 
-	# create the compat-file if there is no file with that name in WORKDIR
-	if [ -f ${WORKDIR}/compat ]; then
-		install -v -m 644 ${WORKDIR}/compat ${S}/debian/compat
-	else
-		deb_create_compat
-	fi
 	# create the control-file if there is no control-file in WORKDIR
 	if [ -f ${WORKDIR}/control ]; then
 		install -v -m 644 ${WORKDIR}/control ${S}/debian/control