Skip to content

restore-new-distro: lsb_release.get_lsb_information doesn't work #5

@martinvonwittich

Description

@martinvonwittich

I get the following error message when trying to use restore-new-distro:

host ~ # DEBIAN_FRONTEND=noninteractive apt-clone restore-new-distro --simulate /old/apt.apt-clone.tar.gz stretch
Traceback (most recent call last):
  File "/usr/bin/apt-clone", line 136, in <module>
    codename = lsb_release.get_lsb_information()["CODENAME"]
KeyError: 'CODENAME'

Apparently get_lsb_information() will only attempt to read $LSB_ETC_LSB_RELEASE or /etc/lsb-release; if that file doesn't exist, it won't return anything at all (see /usr/lib/python3/dist-packages/lsb_release.py). You probably want get_distro_information() instead:

host ~ # diff -u =apt-clone apt-clone2 
--- /usr/bin/apt-clone  2015-11-13 21:11:38.000000000 +0100
+++ apt-clone2  2018-04-04 15:32:47.412898874 +0200
@@ -133,7 +133,7 @@
         # we are not yet on the new release its fine to remove installed
         # pkgs as part of the upgrade
         import lsb_release
-        codename = lsb_release.get_lsb_information()["CODENAME"]
+        codename = lsb_release.get_distro_information()["CODENAME"]
         if (args.new_distro_codename and args.new_distro_codename == codename):
             protect_installed = True
         else:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions