diff options
Diffstat (limited to 'UpdateManager')
| -rw-r--r-- | UpdateManager/Common/aptsources.py | 33 |
1 files changed, 26 insertions, 7 deletions
diff --git a/UpdateManager/Common/aptsources.py b/UpdateManager/Common/aptsources.py index 8963fd15..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,6 +31,7 @@ import glob import shutil import time import os.path +import sys #import pdb @@ -641,13 +644,27 @@ class Distribution: sourceslist: an aptsource.sources_list comp: the component that should be enabled """ - # FIXME: we can't just unconditionally add stuff to each line, - # otherwise we need up with multiple components for the - # same repository (see tests/test_aptsources.py for details) + def add_component_only_once(source, workpile): + """ + Check if we already added the component to the repository, since + a repository could be splitted into different apt lines. If not + add the component + """ + if not (workpile.has_key(source.uri) and\ + source.dist in workpile[source.uri]): + if comp not in source.comps: + source.comps.append(comp) + if workpile.has_key(source.uri): + workpile[source.uri].append(source.dist) + else: + workpile[source.uri] = [source.dist] + sources = [] sources.extend(self.main_sources) sources.extend(self.child_sources) sources.extend(self.source_code_sources) + # store repos to which the new component has been added + workpile = {} # check if there is a main source at all if len(self.main_sources) < 1: # create a new main source @@ -655,11 +672,13 @@ class Distribution: else: # add the comp to all main, child and source code sources for source in sources: - if comp not in source.comps: - source.comps.append(comp) + add_component_only_once(source, workpile) + if self.get_source_code == True: for source in self.source_code_sources: - if comp not in source.comps: source.comps.append(comp) + if comp not in source.comps: + add_component_only_once(source, workpile) + def disable_component(self, sourceslist, comp): """ |
