Fix invalid Debian codename
Sometimes codename is n/a
which is not right.
I noticed that codename is come from _lsb_release()
in aptsources/distro.py
.
However lsb_release -a
may give a wrong result.
Maybe we could try cat /etc/debian_version
. All Debian derives should have this file.
# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description: Debian GNU/Linux 9.6 (n/a)
Release: 9.6
Codename: n/a
# cat /etc/debian_version
buster/sid
# cut -f1 -d'/' /etc/debian_version
buster
# cat /etc/issue
Debian GNU/Linux buster/sid \n \l
# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux buster/sid"
NAME="Debian GNU/Linux"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"
Traceback (most recent call last):
File "/usr/bin/add-apt-repository", line 95, in <module>
sp = SoftwareProperties(options=options)
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 109, in __init__
self.reload_sourceslist()
File "/usr/lib/python3/dist-packages/softwareproperties/SoftwareProperties.py", line 599, in reload_sourceslist
self.distro.get_sources(self.sourceslist)
File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 93, in get_sources
(self.id, self.codename))
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Debian/n/a