backportpackage: fix automatic selection of the target release.

Signed-off-by: Mattia Rizzolo <mattia@debian.org>
This commit is contained in:
Mattia Rizzolo 2021-12-05 15:49:31 +01:00
parent 3ef7c4a569
commit 7fc6788b35
No known key found for this signature in database
GPG Key ID: 0816B9E18C762BAD
2 changed files with 11 additions and 2 deletions

View File

@ -29,7 +29,7 @@ from urllib.parse import quote
import lsb_release import lsb_release
from httplib2 import Http, HttpLib2Error from httplib2 import Http, HttpLib2Error
from distro_info import DebianDistroInfo from distro_info import DebianDistroInfo, UbuntuDistroInfo
from ubuntutools.archive import (DebianSourcePackage, from ubuntutools.archive import (DebianSourcePackage,
UbuntuSourcePackage, DownloadError) UbuntuSourcePackage, DownloadError)
@ -398,9 +398,15 @@ def main(args):
if not opts.dest_releases: if not opts.dest_releases:
distinfo = lsb_release.get_distro_information() distinfo = lsb_release.get_distro_information()
try: try:
opts.dest_releases = [distinfo['CODENAME']] current_distro = distinfo['ID']
except KeyError: except KeyError:
error('No destination release specified and unable to guess yours.') error('No destination release specified and unable to guess yours.')
if current_distro == "Ubuntu":
opts.dest_releases = [UbuntuDistroInfo().lts()]
if current_distro == "Debian":
opts.dest_releases = [DebianDistroInfo().stable()]
else:
error(f"Unknown distribution {current_distro}, can't guess target release")
if opts.workdir: if opts.workdir:
workdir = os.path.expanduser(opts.workdir) workdir = os.path.expanduser(opts.workdir)

3
debian/changelog vendored
View File

@ -10,6 +10,9 @@ ubuntu-dev-tools (0.187) UNRELEASED; urgency=medium
Closes: #968316 Closes: #968316
* backportpackage: * backportpackage:
+ Support backporting to Debian releases. LP: #974132 + Support backporting to Debian releases. LP: #974132
+ Fix the guessing algorithm for the target release:
- for Debian: pick the current stable release.
- for Ubuntu: pick the current LTS release.
[ Unit 193 ] [ Unit 193 ]
* backportpackage: * backportpackage: