From a3c87e78aa0b3bcbbc1f6ad26427f2bc579167b3 Mon Sep 17 00:00:00 2001 From: Gioele Barabucci Date: Wed, 28 Sep 2022 08:18:52 +0200 Subject: [PATCH] backportpackage: Run lsb_release as command if the Python module is not available --- backportpackage | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/backportpackage b/backportpackage index 320486b..13a7a5e 100755 --- a/backportpackage +++ b/backportpackage @@ -27,7 +27,10 @@ import sys import tempfile from urllib.parse import quote -import lsb_release +try: + import lsb_release +except ImportError: + lsb_release = None from httplib2 import Http, HttpLib2Error from distro_info import DebianDistroInfo, UbuntuDistroInfo @@ -396,11 +399,17 @@ def main(args): Launchpad.login_anonymously(service=opts.lpinstance) if not opts.dest_releases: - distinfo = lsb_release.get_distro_information() - try: - current_distro = distinfo['ID'] - except KeyError: - error('No destination release specified and unable to guess yours.') + if lsb_release: + distinfo = lsb_release.get_distro_information() + try: + current_distro = distinfo['ID'] + except KeyError: + error('No destination release specified and unable to guess yours.') + else: + err, current_distro = subprocess.getstatusoutput('lsb_release --id --short') + if err: + error('Could not run lsb_release to retrieve distribution') + if current_distro == "Ubuntu": opts.dest_releases = [UbuntuDistroInfo().lts()] if current_distro == "Debian":