diff mbox series

[u,d,c,b,x,t] UBUNTU: [Packaging] startnewrelease: Add support for backport versioning

Message ID 20190219161748.20999-1-marcelo.cerri@canonical.com
State New
Headers show
Series [u,d,c,b,x,t] UBUNTU: [Packaging] startnewrelease: Add support for backport versioning | expand

Commit Message

Marcelo Henrique Cerri Feb. 19, 2019, 4:17 p.m. UTC
Ignore: yes

Use the parent kernel version as base for the new release version if
the BACKPORT_SUFFIX variable is set in the update.conf file.

Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
---
 debian/rules.d/1-maintainer.mk | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

Comments

Thadeu Lima de Souza Cascardo Feb. 19, 2019, 4:30 p.m. UTC | #1
On Tue, Feb 19, 2019 at 01:17:48PM -0300, Marcelo Henrique Cerri wrote:
> Ignore: yes
> 
> Use the parent kernel version as base for the new release version if
> the BACKPORT_SUFFIX variable is set in the update.conf file.
> 
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>

Acked-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com>

Love it! Please, apply!

> ---
>  debian/rules.d/1-maintainer.mk | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk
> index ee8010ba7fa0..d57145b644d9 100644
> --- a/debian/rules.d/1-maintainer.mk
> +++ b/debian/rules.d/1-maintainer.mk
> @@ -126,10 +126,20 @@ diffupstream:
>  
>  startnewrelease:
>  	dh_testdir
> -	@ver=$$(echo "$(revision)" | perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }'); \
> +	@[ -f "$(DEBIAN)/etc/update.conf" ] && . "$(DEBIAN)/etc/update.conf"; \
> +	if [ -n "$$BACKPORT_SUFFIX" ]; then \
> +		ver="$$(dpkg-parsechangelog -l"$$DEBIAN_MASTER/changelog" -SVersion)~$${BACKPORT_SUFFIX}.1"; \
> +		prev_ver="$$(dpkg-parsechangelog -l"$(DEBIAN)/changelog" -SVersion)"; \
> +		if [ "$${ver%.*}" = "$${prev_ver%.*}" ]; then \
> +			ver="$${ver%.*}.$$(( $${prev_ver##*.} +1 ))"; \
> +		fi; \
> +	else \
> +		ver="$(release)-$$(echo "$(revision)" | \
> +			perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }')"; \
> +	fi; \
>  	now="$(shell date -R)"; \
> -	echo "Creating new changelog set for $(release)-$$ver..."; \
> -	echo -e "$(src_pkg_name) ($(release)-$$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
> +	echo "Creating new changelog set for $$ver..."; \
> +	echo -e "$(src_pkg_name) ($$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Do not edit directly. Autogenerated at release." >> \
>  		$(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Use the printchanges target to see the curent changes." \
> -- 
> 2.17.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Juerg Haefliger Feb. 20, 2019, 9:16 a.m. UTC | #2
On Tue, 19 Feb 2019 13:17:48 -0300
Marcelo Henrique Cerri <marcelo.cerri@canonical.com> wrote:

> Ignore: yes
> 
> Use the parent kernel version as base for the new release version if
> the BACKPORT_SUFFIX variable is set in the update.conf file.
> 
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> ---
>  debian/rules.d/1-maintainer.mk | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk
> index ee8010ba7fa0..d57145b644d9 100644
> --- a/debian/rules.d/1-maintainer.mk
> +++ b/debian/rules.d/1-maintainer.mk
> @@ -126,10 +126,20 @@ diffupstream:
>  
>  startnewrelease:
>  	dh_testdir
> -	@ver=$$(echo "$(revision)" | perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }'); \
> +	@[ -f "$(DEBIAN)/etc/update.conf" ] && . "$(DEBIAN)/etc/update.conf"; \

This being a Makefile, doesn't the above trigger a failure if there's no
$(DEBIAN)/etc/update.conf?

...Juerg

> +	if [ -n "$$BACKPORT_SUFFIX" ]; then \
> +		ver="$$(dpkg-parsechangelog -l"$$DEBIAN_MASTER/changelog" -SVersion)~$${BACKPORT_SUFFIX}.1"; \
> +		prev_ver="$$(dpkg-parsechangelog -l"$(DEBIAN)/changelog" -SVersion)"; \
> +		if [ "$${ver%.*}" = "$${prev_ver%.*}" ]; then \
> +			ver="$${ver%.*}.$$(( $${prev_ver##*.} +1 ))"; \
> +		fi; \
> +	else \
> +		ver="$(release)-$$(echo "$(revision)" | \
> +			perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }')"; \
> +	fi; \
>  	now="$(shell date -R)"; \
> -	echo "Creating new changelog set for $(release)-$$ver..."; \
> -	echo -e "$(src_pkg_name) ($(release)-$$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
> +	echo "Creating new changelog set for $$ver..."; \
> +	echo -e "$(src_pkg_name) ($$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Do not edit directly. Autogenerated at release." >> \
>  		$(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Use the printchanges target to see the curent changes." \
Kleber Sacilotto de Souza Feb. 20, 2019, 10:58 a.m. UTC | #3
On 2/19/19 5:17 PM, Marcelo Henrique Cerri wrote:
> Ignore: yes
>
> Use the parent kernel version as base for the new release version if
> the BACKPORT_SUFFIX variable is set in the update.conf file.
>
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> ---
>  debian/rules.d/1-maintainer.mk | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
>
> diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk
> index ee8010ba7fa0..d57145b644d9 100644
> --- a/debian/rules.d/1-maintainer.mk
> +++ b/debian/rules.d/1-maintainer.mk
> @@ -126,10 +126,20 @@ diffupstream:
>  
>  startnewrelease:
>  	dh_testdir
> -	@ver=$$(echo "$(revision)" | perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }'); \
> +	@[ -f "$(DEBIAN)/etc/update.conf" ] && . "$(DEBIAN)/etc/update.conf"; \
> +	if [ -n "$$BACKPORT_SUFFIX" ]; then \
> +		ver="$$(dpkg-parsechangelog -l"$$DEBIAN_MASTER/changelog" -SVersion)~$${BACKPORT_SUFFIX}.1"; \
What happens if for some (wrong) reason DEBIAN_MASTER is not defined?
> +		prev_ver="$$(dpkg-parsechangelog -l"$(DEBIAN)/changelog" -SVersion)"; \
> +		if [ "$${ver%.*}" = "$${prev_ver%.*}" ]; then \
> +			ver="$${ver%.*}.$$(( $${prev_ver##*.} +1 ))"; \
> +		fi; \
> +	else \
> +		ver="$(release)-$$(echo "$(revision)" | \
> +			perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }')"; \
> +	fi; \
>  	now="$(shell date -R)"; \
> -	echo "Creating new changelog set for $(release)-$$ver..."; \
> -	echo -e "$(src_pkg_name) ($(release)-$$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
> +	echo "Creating new changelog set for $$ver..."; \
> +	echo -e "$(src_pkg_name) ($$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Do not edit directly. Autogenerated at release." >> \
>  		$(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Use the printchanges target to see the curent changes." \


Apart from my comment and Juerg's the script looks good!
Marcelo Henrique Cerri Feb. 20, 2019, 11:15 p.m. UTC | #4
On Wed, Feb 20, 2019 at 10:16:54AM +0100, Juerg Haefliger wrote:
> On Tue, 19 Feb 2019 13:17:48 -0300
> Marcelo Henrique Cerri <marcelo.cerri@canonical.com> wrote:
> 
> > Ignore: yes
> > 
> > Use the parent kernel version as base for the new release version if
> > the BACKPORT_SUFFIX variable is set in the update.conf file.
> > 
> > Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> > ---
> >  debian/rules.d/1-maintainer.mk | 16 +++++++++++++---
> >  1 file changed, 13 insertions(+), 3 deletions(-)
> > 
> > diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk
> > index ee8010ba7fa0..d57145b644d9 100644
> > --- a/debian/rules.d/1-maintainer.mk
> > +++ b/debian/rules.d/1-maintainer.mk
> > @@ -126,10 +126,20 @@ diffupstream:
> >  
> >  startnewrelease:
> >  	dh_testdir
> > -	@ver=$$(echo "$(revision)" | perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }'); \
> > +	@[ -f "$(DEBIAN)/etc/update.conf" ] && . "$(DEBIAN)/etc/update.conf"; \
> 
> This being a Makefile, doesn't the above trigger a failure if there's no
> $(DEBIAN)/etc/update.conf?

No. I don't think Makefile runs the shell with the exit on error flag
set (set -e), but even with that flag, the shell will not abort when the
return code of the && operation is non zero.

I have tested it on the master kernels (those kernels don't have an
update.conf file) and it works fine.

As an example, the following snippet should print "End":

   #!/bin/sh -e
   [ 1 = 0 ] && echo OK
   echo End

The -e description in sh(1) man page:

If not interactive, exit immediately if any untested command
fails. The exit status of a command is considered to be explicitly
tested if the command is used to control an if, elif, while, or until;
or if the command is the left hand operand of an “&&” or “||”
operator.

> 
> ...Juerg
> 
> > +	if [ -n "$$BACKPORT_SUFFIX" ]; then \
> > +		ver="$$(dpkg-parsechangelog -l"$$DEBIAN_MASTER/changelog" -SVersion)~$${BACKPORT_SUFFIX}.1"; \
> > +		prev_ver="$$(dpkg-parsechangelog -l"$(DEBIAN)/changelog" -SVersion)"; \
> > +		if [ "$${ver%.*}" = "$${prev_ver%.*}" ]; then \
> > +			ver="$${ver%.*}.$$(( $${prev_ver##*.} +1 ))"; \
> > +		fi; \
> > +	else \
> > +		ver="$(release)-$$(echo "$(revision)" | \
> > +			perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }')"; \
> > +	fi; \
> >  	now="$(shell date -R)"; \
> > -	echo "Creating new changelog set for $(release)-$$ver..."; \
> > -	echo -e "$(src_pkg_name) ($(release)-$$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
> > +	echo "Creating new changelog set for $$ver..."; \
> > +	echo -e "$(src_pkg_name) ($$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
> >  	echo "  CHANGELOG: Do not edit directly. Autogenerated at release." >> \
> >  		$(DEBIAN)/changelog.new; \
> >  	echo "  CHANGELOG: Use the printchanges target to see the curent changes." \
>
Stefan Bader Feb. 28, 2019, 2:18 p.m. UTC | #5
On 19.02.19 17:17, Marcelo Henrique Cerri wrote:
> Ignore: yes
> 
> Use the parent kernel version as base for the new release version if
> the BACKPORT_SUFFIX variable is set in the update.conf file.
> 
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
Acked-by: Stefan Bader <stefan.bader@canonical.com>
> ---

Though there was just another patch that claimed [ ] && something would return
the return code of the test. Anyhow lets hope this works.. But if not it can be
quickly reverted.

>  debian/rules.d/1-maintainer.mk | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk
> index ee8010ba7fa0..d57145b644d9 100644
> --- a/debian/rules.d/1-maintainer.mk
> +++ b/debian/rules.d/1-maintainer.mk
> @@ -126,10 +126,20 @@ diffupstream:
>  
>  startnewrelease:
>  	dh_testdir
> -	@ver=$$(echo "$(revision)" | perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }'); \
> +	@[ -f "$(DEBIAN)/etc/update.conf" ] && . "$(DEBIAN)/etc/update.conf"; \
> +	if [ -n "$$BACKPORT_SUFFIX" ]; then \
> +		ver="$$(dpkg-parsechangelog -l"$$DEBIAN_MASTER/changelog" -SVersion)~$${BACKPORT_SUFFIX}.1"; \
> +		prev_ver="$$(dpkg-parsechangelog -l"$(DEBIAN)/changelog" -SVersion)"; \
> +		if [ "$${ver%.*}" = "$${prev_ver%.*}" ]; then \
> +			ver="$${ver%.*}.$$(( $${prev_ver##*.} +1 ))"; \
> +		fi; \
> +	else \
> +		ver="$(release)-$$(echo "$(revision)" | \
> +			perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }')"; \
> +	fi; \
>  	now="$(shell date -R)"; \
> -	echo "Creating new changelog set for $(release)-$$ver..."; \
> -	echo -e "$(src_pkg_name) ($(release)-$$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
> +	echo "Creating new changelog set for $$ver..."; \
> +	echo -e "$(src_pkg_name) ($$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Do not edit directly. Autogenerated at release." >> \
>  		$(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Use the printchanges target to see the curent changes." \
>
Juerg Haefliger March 1, 2019, 9:50 a.m. UTC | #6
On Wed, 20 Feb 2019 20:15:14 -0300
Marcelo Henrique Cerri <marcelo.cerri@canonical.com> wrote:

> On Wed, Feb 20, 2019 at 10:16:54AM +0100, Juerg Haefliger wrote:
> > On Tue, 19 Feb 2019 13:17:48 -0300
> > Marcelo Henrique Cerri <marcelo.cerri@canonical.com> wrote:
> >   
> > > Ignore: yes
> > > 
> > > Use the parent kernel version as base for the new release version if
> > > the BACKPORT_SUFFIX variable is set in the update.conf file.
> > > 
> > > Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> > > ---
> > >  debian/rules.d/1-maintainer.mk | 16 +++++++++++++---
> > >  1 file changed, 13 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk
> > > index ee8010ba7fa0..d57145b644d9 100644
> > > --- a/debian/rules.d/1-maintainer.mk
> > > +++ b/debian/rules.d/1-maintainer.mk
> > > @@ -126,10 +126,20 @@ diffupstream:
> > >  
> > >  startnewrelease:
> > >  	dh_testdir
> > > -	@ver=$$(echo "$(revision)" | perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }'); \
> > > +	@[ -f "$(DEBIAN)/etc/update.conf" ] && . "$(DEBIAN)/etc/update.conf"; \  
> > 
> > This being a Makefile, doesn't the above trigger a failure if there's no
> > $(DEBIAN)/etc/update.conf?  
> 
> No. I don't think Makefile runs the shell with the exit on error flag
> set (set -e), but even with that flag, the shell will not abort when the
> return code of the && operation is non zero.

Ah, this line is part of a subshell command. Yes, that makes a difference, so in
that case is should be fine.

 
> I have tested it on the master kernels (those kernels don't have an
> update.conf file) and it works fine.
> 
> As an example, the following snippet should print "End":
> 
>    #!/bin/sh -e
>    [ 1 = 0 ] && echo OK
>    echo End

Well this confuses me. I was always under the impression that the above should
error out on the first line.

 
> The -e description in sh(1) man page:
> 
> If not interactive, exit immediately if any untested command
> fails. The exit status of a command is considered to be explicitly
> tested if the command is used to control an if, elif, while, or until;
> or if the command is the left hand operand of an “&&” or “||”
> operator.

OK. Yes, I see it :-(

Now that I think about I believe where my confusion comes from is that I used
foo && bar in Makefiles which errors out if foo is false so I had to change
those lines to ! foo || bar.

Thanks for solving that mystery :-)

...Juerg


 
> > 
> > ...Juerg
> >   
> > > +	if [ -n "$$BACKPORT_SUFFIX" ]; then \
> > > +		ver="$$(dpkg-parsechangelog -l"$$DEBIAN_MASTER/changelog" -SVersion)~$${BACKPORT_SUFFIX}.1"; \
> > > +		prev_ver="$$(dpkg-parsechangelog -l"$(DEBIAN)/changelog" -SVersion)"; \
> > > +		if [ "$${ver%.*}" = "$${prev_ver%.*}" ]; then \
> > > +			ver="$${ver%.*}.$$(( $${prev_ver##*.} +1 ))"; \
> > > +		fi; \
> > > +	else \
> > > +		ver="$(release)-$$(echo "$(revision)" | \
> > > +			perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }')"; \
> > > +	fi; \
> > >  	now="$(shell date -R)"; \
> > > -	echo "Creating new changelog set for $(release)-$$ver..."; \
> > > -	echo -e "$(src_pkg_name) ($(release)-$$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
> > > +	echo "Creating new changelog set for $$ver..."; \
> > > +	echo -e "$(src_pkg_name) ($$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
> > >  	echo "  CHANGELOG: Do not edit directly. Autogenerated at release." >> \
> > >  		$(DEBIAN)/changelog.new; \
> > >  	echo "  CHANGELOG: Use the printchanges target to see the curent changes." \  
> >   
> 
> 
>
Khalid Elmously March 4, 2019, 5:21 a.m. UTC | #7
On 2019-02-19 13:17:48 , Marcelo Henrique Cerri wrote:
> Ignore: yes
> 
> Use the parent kernel version as base for the new release version if
> the BACKPORT_SUFFIX variable is set in the update.conf file.
> 
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>
> ---
>  debian/rules.d/1-maintainer.mk | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk
> index ee8010ba7fa0..d57145b644d9 100644
> --- a/debian/rules.d/1-maintainer.mk
> +++ b/debian/rules.d/1-maintainer.mk
> @@ -126,10 +126,20 @@ diffupstream:
>  
>  startnewrelease:
>  	dh_testdir
> -	@ver=$$(echo "$(revision)" | perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }'); \
> +	@[ -f "$(DEBIAN)/etc/update.conf" ] && . "$(DEBIAN)/etc/update.conf"; \
> +	if [ -n "$$BACKPORT_SUFFIX" ]; then \
> +		ver="$$(dpkg-parsechangelog -l"$$DEBIAN_MASTER/changelog" -SVersion)~$${BACKPORT_SUFFIX}.1"; \
> +		prev_ver="$$(dpkg-parsechangelog -l"$(DEBIAN)/changelog" -SVersion)"; \
> +		if [ "$${ver%.*}" = "$${prev_ver%.*}" ]; then \
> +			ver="$${ver%.*}.$$(( $${prev_ver##*.} +1 ))"; \
> +		fi; \
> +	else \
> +		ver="$(release)-$$(echo "$(revision)" | \
> +			perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }')"; \
> +	fi; \
>  	now="$(shell date -R)"; \
> -	echo "Creating new changelog set for $(release)-$$ver..."; \
> -	echo -e "$(src_pkg_name) ($(release)-$$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
> +	echo "Creating new changelog set for $$ver..."; \
> +	echo -e "$(src_pkg_name) ($$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Do not edit directly. Autogenerated at release." >> \
>  		$(DEBIAN)/changelog.new; \
>  	echo "  CHANGELOG: Use the printchanges target to see the curent changes." \
> -- 
> 2.17.1
> 
> 
> -- 
> kernel-team mailing list
> kernel-team@lists.ubuntu.com
> https://lists.ubuntu.com/mailman/listinfo/kernel-team
Seth Forshee March 4, 2019, 1:13 p.m. UTC | #8
On Tue, Feb 19, 2019 at 01:17:48PM -0300, Marcelo Henrique Cerri wrote:
> Ignore: yes
> 
> Use the parent kernel version as base for the new release version if
> the BACKPORT_SUFFIX variable is set in the update.conf file.
> 
> Signed-off-by: Marcelo Henrique Cerri <marcelo.cerri@canonical.com>

Applied to disco and unstable, thanks!
diff mbox series

Patch

diff --git a/debian/rules.d/1-maintainer.mk b/debian/rules.d/1-maintainer.mk
index ee8010ba7fa0..d57145b644d9 100644
--- a/debian/rules.d/1-maintainer.mk
+++ b/debian/rules.d/1-maintainer.mk
@@ -126,10 +126,20 @@  diffupstream:
 
 startnewrelease:
 	dh_testdir
-	@ver=$$(echo "$(revision)" | perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }'); \
+	@[ -f "$(DEBIAN)/etc/update.conf" ] && . "$(DEBIAN)/etc/update.conf"; \
+	if [ -n "$$BACKPORT_SUFFIX" ]; then \
+		ver="$$(dpkg-parsechangelog -l"$$DEBIAN_MASTER/changelog" -SVersion)~$${BACKPORT_SUFFIX}.1"; \
+		prev_ver="$$(dpkg-parsechangelog -l"$(DEBIAN)/changelog" -SVersion)"; \
+		if [ "$${ver%.*}" = "$${prev_ver%.*}" ]; then \
+			ver="$${ver%.*}.$$(( $${prev_ver##*.} +1 ))"; \
+		fi; \
+	else \
+		ver="$(release)-$$(echo "$(revision)" | \
+			perl -ne 'if (/^(\d*)\.(\d*)(.*)?$$/) { printf("%d.%d%s\n", $$1 + 1, $$2 +1, $$3) }')"; \
+	fi; \
 	now="$(shell date -R)"; \
-	echo "Creating new changelog set for $(release)-$$ver..."; \
-	echo -e "$(src_pkg_name) ($(release)-$$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
+	echo "Creating new changelog set for $$ver..."; \
+	echo -e "$(src_pkg_name) ($$ver) UNRELEASED; urgency=medium\n" > $(DEBIAN)/changelog.new; \
 	echo "  CHANGELOG: Do not edit directly. Autogenerated at release." >> \
 		$(DEBIAN)/changelog.new; \
 	echo "  CHANGELOG: Use the printchanges target to see the curent changes." \