sourceslist.SourcesList doesn't reuse disabled sources entries

Bug #1042916 reported by Sami Jaktholm
20
This bug affects 3 people
Affects Status Importance Assigned to Milestone
python-apt (Ubuntu)
Fix Released
Medium
Sami Jaktholm

Bug Description

If sourceslist contains a disabled entry (commented out) and the exactly same entry is added with sourceslist.SourcesList.add method, new entry is created instead of enabling the disabled duplicate.

Steps to reproduce:
1. Add a repository:
  # apt-add-repository 'deb http://ppa.launchpad.net/videolan/stable-daily/ubuntu precise main'
2. Edit sources.list and comment out the newly added entry
3. Add it again:
 # apt-add-repository 'deb http://ppa.launchpad.net/videolan/stable-daily/ubuntu precise main'
4. Notice the duplicated lines: one disabled, the other enabled

What should happen:
4. The disabled line is now enabled.

Why this happens:
On line 316 the condition 'set(source.comps) == comps' will always be False (at least with python 2.7 and 3.2) as you can see doing following in a python shell:
>>> set([]) == []
False
>>> set(["precise", "main"]) == ["precise", "main"] # this was the case in the example above.
False

ProblemType: Bug
DistroRelease: Ubuntu 12.04
Package: python-apt 0.8.3ubuntu7
ProcVersionSignature: Ubuntu 3.2.0-29.46-generic 3.2.24
Uname: Linux 3.2.0-29-generic x86_64
ApportVersion: 2.0.1-0ubuntu12
Architecture: amd64
Date: Tue Aug 28 22:02:45 2012
InstallationMedia: Ubuntu 12.04 LTS "Precise Pangolin" - Release amd64 (20120425)
ProcEnviron:
 TERM=xterm
 PATH=(custom, no user)
 LANG=fi_FI.UTF-8
 SHELL=/bin/bash
SourcePackage: python-apt
UpgradeStatus: No upgrade log present (probably fresh install)

Related branches

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

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

Changed in python-apt (Ubuntu):
status: New → Confirmed
Revision history for this message
Sami Jaktholm (sjakthol) wrote :

Here's a patch fixing this bug with a test case. It based against lp:python-apt but should apply nicely to Precise and Quantal packaging branches too.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "fix_enable_disabled.patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-reviewers team please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Sami Jaktholm (sjakthol)
Changed in python-apt (Ubuntu):
assignee: nobody → sampo555 (sampo555)
status: Confirmed → In Progress
Revision history for this message
Edward Donovan (edward.donovan) wrote :

Tested the patch; it works well here. Thanks!

I have a question, too:

I see that ubuntu-release-upgrader keeps its own copy of sourceslist.py, in the python3-distupgrade binary package. Shall we try to patch that, now? Or leave it to be inherited later?

Thanks.

Revision history for this message
Sami Jaktholm (sjakthol) wrote :

I don't exactly know the inner workings of the release upgrader but it seems that the sourceslist.py in the release upgrader is copied to the package at build time as it's just a symbolic link to sourceslist.py of python3-apt.

So as long as the fix gets into python-apt, it's also going to be in ubuntu-release-upgrader too...

Revision history for this message
Edward Donovan (edward.donovan) wrote :

Ah, thanks. I don't know when that might be built next, but it would be a pretty non-critical fix, for that critical package, anyway. I think...

Changed in python-apt (Ubuntu):
importance: Undecided → Medium
Revision history for this message
Brian Murray (brian-murray) wrote :

I'm removing the ubuntu-release-upgrader task as it is unnecessary.

no longer affects: ubuntu-release-upgrader (Ubuntu)
Changed in python-apt (Ubuntu):
status: In Progress → Fix Committed
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package python-apt - 0.8.7ubuntu1

---------------
python-apt (0.8.7ubuntu1) quantal; urgency=low

  [ James Hunt ]
  * python/cache.cc: PkgCacheGetIsMultiArch(): Return calculated
    value rather than a random one.

  [ Michael Vogt ]
  * merged fixes from the debian-sid branch

python-apt (0.8.8) UNRELEASED; urgency=low

  [ Program translation updates ]
  * po/pl.po: Polish (Michał Kułach) (closes: #684308)

  [ Michael Vogt ]
  * merged lp:~sampo555/python-apt/fix_1042916 reuse existing but
    disabled sources.list entries instead of duplicating them.
    Thanks to "sampo555", LP: #1042916

python-apt (0.8.7) unstable; urgency=low

  [ Translation updates ]
  * po/es.po: Spanish translation updated by Omar Campagne (closes: #679285)
  * po/ja.po: Japanese translation updated by Kenshi Muto (closes: #679652)

  [ Jakub Wilk ]
  * Fix typos: the the -> the (closes: #679432)

  [ Julian Andres Klode ]
  * apt/auth.py:
    - Do not merge stdout and stderr (Closes: #678706)
    - Forward stderr from apt-key to our stderr if non-empty
 -- Michael Vogt <email address hidden> Mon, 01 Oct 2012 13:47:43 +0200

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

Other bug subscribers