hirsute fails on add-apt-repository

Bug #1902540 reported by Christian Ehrhardt 
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
python-apt (Ubuntu)
Fix Released
Undecided
Unassigned
software-properties (Ubuntu)
Invalid
Undecided
Unassigned

Bug Description

On a fully updated hirsute add-apt-repository fails, example:

root@h:~# sudo add-apt-repository ppa:ci-train-ppa-service/4321
Traceback (most recent call last):
  File "/usr/bin/add-apt-repository", line 330, in <module>
    addaptrepo = AddAptRepository()
  File "/usr/bin/add-apt-repository", line 35, in __init__
    self.distro.get_sources(self.sourceslist)
  File "/usr/lib/python3/dist-packages/aptsources/distro.py", line 91, in get_sources
    raise NoDistroTemplateException(
aptsources.distro.NoDistroTemplateException: Error: could not find a distribution template for Ubuntu/hirsute

The PPA seems not to matter (all trigger it) and if I manually add PPA sources list and GPG key it works. So maybe software-properties just needs to learn about hirsute?

Or is there another components (like distro-info or such) that needs a bump for this to work?

Tags: patch
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Download full text (50.5 KiB)

Throwing a debug in the failing code:

        # find the distro template
        for template in self.sourceslist.matcher.templates:
            print("Try '%s': self.is_codename(template.name) '%s' && self.id >> '%s' == '%s' << template.distribution" % (template.name, self.is_codename(template.name), self.id, template.distribution))
            if (self.is_codename(template.name) and
                    template.distribution == self.id):
                print("yeah! found a template")
                self.source_template = template
                break
        if self.source_template is None:
            raise NoDistroTemplateException(
                "Error: could not find a distribution template for %s/%s" %
                (self.id, self.codename))

Gives me:
Try 'bullseye': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'bullseye/updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'bullseye-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'bullseye-proposed-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'buster': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'buster/updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'buster-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'buster-proposed-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'stretch': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'stretch/updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'stretch-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'stretch-proposed-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'jessie': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'jessie/updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'jessie-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'jessie-proposed-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'wheezy': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'wheezy/updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'wheezy-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' == 'Debian' << template.distribution
Try 'wheezy-proposed-updates': self.is_codename(template.name) 'False' && self.id >> 'Ubuntu' ==...

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in software-properties (Ubuntu):
status: New → Confirmed
Revision history for this message
Bryce Harrington (bryce) wrote :

I'm able to reproduce this in a hirsute lxc container I created today.

Interestingly, another hirsute container I created Friday doesn't reproduce this issue even when updated to current.

Revision history for this message
Sergio Durigan Junior (sergiodj) wrote :

I'm also able to reproduce this in a hirsute lxd container today (2020-11-02).

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Yeah still present for me as well in a new hirsute container of today :-/
Thanks for double checking as Bryce/Sergio as that is excluding a lot of caching/net-setup/... questions.

From the debugging I know that the self-detect is right
self.codename == hirsute

But the list in self.sourceslist.matcher.templates does not contain a hirsute.
That comes from /usr/lib/python3/dist-packages/aptsources/sourceslist.py from src:python-apt.
Maybe the bug is over there and adding a task for that can help to trigger the right people (or there maybe is even a bug open already).

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

It seems that data is parsed from /usr/share/python-apt/templates/Ubuntu.info
class SourcesList(object):
    """ represents the full sources.list + sources.list.d file """

    def __init__(self,
                 withMatcher=True,
                 matcherPath="/usr/share/python-apt/templates/"):

Which also is part of Source: python-apt

I added hirsute manually there (as attached) and things started working.

Changed in python-apt (Ubuntu):
status: New → Confirmed
Changed in software-properties (Ubuntu):
status: Confirmed → Invalid
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Ok, I see that there is an upload for it that would fix this in

   1 python-apt (2.1.3ubuntu3) hirsute; urgency=medium
   2
   3 * Add hirsute to the Ubuntu template.
   4
   5 -- Steve Langasek <email address hidden> Mon, 26 Oct 2020 16:28:01 -0700

But it is stuck in excuses breaking apt-clone and sshuttle autopkgtests.
Since Steve (thanks) prepped that upload I'll subscribe him so he can close the bug once python-apt moves.

Changed in python-apt (Ubuntu):
status: Confirmed → Triaged
assignee: nobody → Steve Langasek (vorlon)
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Ok, checking the recent tests it seems that vorlon and juliank are on it already.
So I can hold back (to not make things more confusing) and let them handle it.

The attachment here in comment #6 can serve as a workaround until resolved.

tags: added: patch
Changed in python-apt (Ubuntu):
assignee: Steve Langasek (vorlon) → nobody
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

FYI - Until this migrated into groovy the quick-fix with the attached diff is:
$ wget -q https://launchpadlibrarian.net/505009270/fix-hirsute-python-apt.diff -O - | sudo patch -p1

Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Fixed by https://launchpad.net/ubuntu/+source/python-apt/2.1.3ubuntu3 migrating after some work on dependencies.

Note cloud and lxd images do not yet contain this, so you'll need to update before add-apt-repository or wait another day or two.

Thanks everyone.

Changed in python-apt (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.