diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2011-09-28 16:25:09 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2011-09-28 16:25:09 +0200 |
| commit | bbe36232eb04a191d8fefee5bc65710e4347c0dd (patch) | |
| tree | 390a370a564a752f1866da2f845f4663d19a6b42 | |
| parent | bb4108a5aee372c75e1743892e2b43b268efb562 (diff) | |
| download | python-apt-bbe36232eb04a191d8fefee5bc65710e4347c0dd.tar.gz | |
add concept of "ParentComponent" for e.g. ubuntu/multiverse
that needs universe enabled as well (plus add test)
LP: #829284
| -rw-r--r-- | aptsources/distinfo.py | 11 | ||||
| -rw-r--r-- | aptsources/distro.py | 14 | ||||
| -rw-r--r-- | data/templates/Ubuntu.info.in | 4 | ||||
| -rw-r--r-- | debian/changelog | 8 | ||||
| -rw-r--r-- | tests/test_aptsources.py | 23 |
5 files changed, 57 insertions, 3 deletions
diff --git a/aptsources/distinfo.py b/aptsources/distinfo.py index dbd28939..c8ec5c46 100644 --- a/aptsources/distinfo.py +++ b/aptsources/distinfo.py @@ -69,10 +69,17 @@ class Template(object): class Component(object): - def __init__(self, name, desc=None, long_desc=None): + def __init__(self, name, desc=None, long_desc=None, parent_component=None): self.name = name self.description = desc self.description_long = long_desc + self.parent_component = parent_component + + def get_parent_component(self): + return self.parent_component + + def set_parent_component(self, parent): + self.parent_component = parent def get_description(self): if self.description_long is not None: @@ -257,6 +264,8 @@ class DistInfo(object): component.set_description(_(value)) elif field == 'CompDescriptionLong': component.set_description_long(_(value)) + elif field == 'ParentComponent': + component.set_parent_component(value) self.finish_template(template, component) template=None component=None diff --git a/aptsources/distro.py b/aptsources/distro.py index 41c86981..f777a4ea 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -291,6 +291,16 @@ class Distribution(object): comp: the component that should be enabled """ + comps = set([comp]) + # look for parent components that we may have to add + for source in self.main_sources: + for c in source.template.components: + if c.name == comp and c.parent_component: + comps.add(c.parent_component) + for c in comps: + self._enable_component(c) + + def _enable_component(self, comp): def add_component_only_once(source, comps_per_dist): """ @@ -298,12 +308,12 @@ class Distribution(object): a repository could be splitted into different apt lines. If not add the component """ - # if we don't that distro, just reutnr (can happen for e.g. + # if we don't have that distro, just return (can happen for e.g. # dapper-update only in deb-src if source.dist not in comps_per_dist: return # if we have seen this component already for this distro, - # return (nothing to do + # return (nothing to do) if comp in comps_per_dist[source.dist]: return # add it diff --git a/data/templates/Ubuntu.info.in b/data/templates/Ubuntu.info.in index 39d9256e..e8afe443 100644 --- a/data/templates/Ubuntu.info.in +++ b/data/templates/Ubuntu.info.in @@ -21,6 +21,7 @@ Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices Component: multiverse +ParentComponent: universe _CompDescription: Restricted software _CompDescriptionLong: Software restricted by copyright or legal issues @@ -139,6 +140,7 @@ Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices Component: multiverse +ParentComponent: universe _CompDescription: Restricted software _CompDescriptionLong: Software restricted by copyright or legal issues @@ -256,6 +258,7 @@ Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices Component: multiverse +ParentComponent: universe _CompDescription: Restricted software _CompDescriptionLong: Software restricted by copyright or legal issues @@ -338,6 +341,7 @@ Component: restricted _CompDescription: Non-free drivers _CompDescriptionLong: Proprietary drivers for devices Component: multiverse +ParentComponent: universe _CompDescription: Restricted software _CompDescriptionLong: Software restricted by copyright or legal issues diff --git a/debian/changelog b/debian/changelog index 3d998dd4..47ff5efd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +python-apt (0.8.0ubuntu8) UNRELEASEDoneiric; urgency=low + + * add concept of "ParentComponent" for e.g. ubuntu/multiverse + that needs universe enabled as well (plus add test) + LP: #829284 + + -- Michael Vogt <michael.vogt@ubuntu.com> Wed, 28 Sep 2011 15:48:23 +0200 + python-apt (0.8.0ubuntu7) oneiric; urgency=low * aptsources/distinfo.py: diff --git a/tests/test_aptsources.py b/tests/test_aptsources.py index 193d3806..dcfb0682 100644 --- a/tests/test_aptsources.py +++ b/tests/test_aptsources.py @@ -160,6 +160,29 @@ class TestAptSources(unittest.TestCase): assert sources.list[8].comps == ["main"] assert sources.list[8].line.strip() == str(sources.list[8]) + def test_enable_component(self): + from subprocess import Popen, PIPE + target = "./data/aptsources/sources.list.enable_comps" + line = "deb http://archive.ubuntu.com/ubuntu lucid main\n" + open(target, "w").write(line) + apt_pkg.config.set("Dir::Etc::sourcelist", target) + sources = aptsources.sourceslist.SourcesList(True, self.templates) + distro = aptsources.distro.get_distro(id="Ubuntu") + # make sure we are using the right distro + distro.codename = "lucid" + distro.id = "Ubuntu" + distro.release = "10.04" + # and get the sources + distro.get_sources(sources) + # test enable_component + comp = "multiverse" + distro.enable_component(comp) + comps = set() + for entry in sources: + comps = comps.union(set(entry.comps)) + self.assertTrue("multiverse" in comps) + self.assertTrue("universe" in comps) + def testDistribution(self): """aptsources: Test distribution detection.""" apt_pkg.config.set("Dir::Etc::sourcelist", "data/aptsources/" |
