diff options
Diffstat (limited to 'UpdateManager/Common/aptsources.py')
| -rw-r--r-- | UpdateManager/Common/aptsources.py | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/UpdateManager/Common/aptsources.py b/UpdateManager/Common/aptsources.py index 85a1ebdf..09673376 100644 --- a/UpdateManager/Common/aptsources.py +++ b/UpdateManager/Common/aptsources.py @@ -1,10 +1,12 @@ # aptsource.py.in - parse sources.list # -# Copyright (c) 2004,2005 Canonical +# Copyright (c) 2004-2006 Canonical # 2004 Michiel Sikkes +# 2006 Sebastian Heinlein # # Author: Michiel Sikkes <michiel@eyesopened.nl> # Michael Vogt <mvo@debian.org> +# Sebastian Heinlein # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -29,11 +31,12 @@ import glob import shutil import time import os.path +import sys #import pdb -from UpdateManager.Common.DistInfo import DistInfo - +#from UpdateManager.Common.DistInfo import DistInfo +from DistInfo import DistInfo # some global helpers def is_mirror(master_uri, compare_uri): @@ -90,6 +93,14 @@ class SourceEntry: self.template = None self.children = [] + def __eq__(self, other): + return (self.disabled == other.disabled and + self.type == other.type and + self.uri == other.uri and + self.dist == other.dist and + self.comps == other.comps) + + # works mostely like split but takes [] into account def mysplit(self, line): line = string.strip(line) @@ -244,6 +255,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 @@ -615,7 +638,7 @@ class Distribution: def enable_component(self, sourceslist, comp): """ - Disable a component in all main, child and source code sources + Enable a component in all main, child and source code sources (excluding cdrom based sources) sourceslist: an aptsource.sources_list |
