~ubuntu-branches/ubuntu/edgy/update-manager/edgy

« back to all changes in this revision

Viewing changes to UpdateManager/Common/aptsources.py

  • Committer: Bazaar Package Importer
  • Author(s): Michael Vogt
  • Date: 2006-09-08 20:33:04 UTC
  • Revision ID: james.westby@ubuntu.com-20060908203304-w9do7u8d239pmw22
Tags: 0.44.8
fix missing /var/log/dist-upgrade

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# aptsource.py.in - parse sources.list
2
2
#  
3
 
#  Copyright (c) 2004,2005 Canonical
 
3
#  Copyright (c) 2004-2006 Canonical
4
4
#                2004 Michiel Sikkes
 
5
#                2006 Sebastian Heinlein
5
6
#  
6
7
#  Author: Michiel Sikkes <michiel@eyesopened.nl>
7
8
#          Michael Vogt <mvo@debian.org>
 
9
#          Sebastian Heinlein
8
10
9
11
#  This program is free software; you can redistribute it and/or 
10
12
#  modify it under the terms of the GNU General Public License as 
29
31
import shutil
30
32
import time
31
33
import os.path
 
34
import sys
32
35
 
33
36
#import pdb
34
37
 
641
644
    sourceslist:  an aptsource.sources_list
642
645
    comp:         the component that should be enabled
643
646
    """
644
 
    # FIXME: we can't just unconditionally add stuff to each line,
645
 
    #        otherwise we need up with multiple components for the
646
 
    #        same repository (see tests/test_aptsources.py for details)
 
647
    def add_component_only_once(source, workpile):
 
648
        """
 
649
        Check if we already added the component to the repository, since
 
650
        a repository could be splitted into different apt lines. If not
 
651
        add the component
 
652
        """
 
653
        if not (workpile.has_key(source.uri) and\
 
654
                source.dist in workpile[source.uri]):
 
655
            if comp not in source.comps:
 
656
                source.comps.append(comp)
 
657
                if workpile.has_key(source.uri):
 
658
                       workpile[source.uri].append(source.dist)
 
659
                else:
 
660
                       workpile[source.uri] = [source.dist]
 
661
 
647
662
    sources = []
648
663
    sources.extend(self.main_sources)
649
664
    sources.extend(self.child_sources)
650
665
    sources.extend(self.source_code_sources)
 
666
    # store repos to which the new component has been added
 
667
    workpile = {}
651
668
    # check if there is a main source at all
652
669
    if len(self.main_sources) < 1:
653
670
        # create a new main source
655
672
    else:
656
673
        # add the comp to all main, child and source code sources
657
674
        for source in sources:
658
 
            if comp not in source.comps:
659
 
                source.comps.append(comp)
 
675
             add_component_only_once(source, workpile)
 
676
 
660
677
    if self.get_source_code == True:
661
678
        for source in self.source_code_sources:
662
 
            if comp not in source.comps: source.comps.append(comp)
 
679
            if comp not in source.comps: 
 
680
                add_component_only_once(source, workpile)
 
681
 
663
682
 
664
683
  def disable_component(self, sourceslist, comp):
665
684
    """