diff options
| -rw-r--r-- | UpdateManager/Common/aptsources.py | 12 | ||||
| -rw-r--r-- | tests/test_aptsources.py | 4 |
2 files changed, 14 insertions, 2 deletions
diff --git a/UpdateManager/Common/aptsources.py b/UpdateManager/Common/aptsources.py index b5fa050d..f8ce474b 100644 --- a/UpdateManager/Common/aptsources.py +++ b/UpdateManager/Common/aptsources.py @@ -252,6 +252,18 @@ class SourcesList: The method will search for existing matching repos and will try to reuse them as far as possible """ + # check if we have this source already in the sources.list + for source in self.list: + if source.disabled == False and source.invalid == False and \ + source.type == type and uri == source.uri and \ + source.dist == dist: + for new_comp in comps: + if new_comp in source.comps: + # we have this component already, delete it from the new_comps + # list + del comps[comps.index(new_comp)] + if len(comps) == 0: + return source for source in self.list: # if there is a repo with the same (type, uri, dist) just add the # components diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 4d7e6a0b..e8b97263 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -44,8 +44,7 @@ class TestAptSources(unittest.TestCase): "edgy", ["restricted"]) self.assertTrue(sources.list == before.list) - # test to add something new: universe - before = copy.deepcopy(sources) + # test to add something new: multiverse sources.add("deb","http://de.archive.ubuntu.com/ubuntu/", "edgy", ["multiverse"]) @@ -75,6 +74,7 @@ class TestAptSources(unittest.TestCase): found_universe += 1 if c == "something": found_something += 1 + #print "\n".join([s.str() for s in sources]) self.assertEqual(found_something, 1) self.assertEqual(found_universe, 1) |
