From 3bf6b76611bf0b148d495e2e4aae08546e54fa94 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 18 Oct 2010 11:51:44 +0200 Subject: fix compat issues with python3 --- aptsources/distro.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'aptsources/distro.py') diff --git a/aptsources/distro.py b/aptsources/distro.py index 23192f50..d4b65645 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -22,6 +22,7 @@ # USA import gettext +import logging import re import os import sys @@ -451,9 +452,9 @@ def _lsb_release(): # Convert to unicode string, needed for Python 3.1 out = out.decode("utf-8") result.update(l.split(":\t") for l in out.split("\n") if ':\t' in l) - except OSError, exc: + except OSError as exc: if exc.errno != errno.ENOENT: - print 'WARNING: lsb_release failed, using defaults:', exc + logging.warn('lsb_release failed, using defaults:' % exc) return result -- cgit v1.2.3 From 67130f4b702a750f777042e4ad557bef9364f997 Mon Sep 17 00:00:00 2001 From: Stéphane Graber Date: Tue, 12 Apr 2011 10:49:58 -0400 Subject: releasing version 0.7.100.3ubuntu4 --- aptsources/distro.py | 3 +++ debian/changelog | 6 ++++++ 2 files changed, 9 insertions(+) (limited to 'aptsources/distro.py') diff --git a/aptsources/distro.py b/aptsources/distro.py index d4b65645..41c86981 100644 --- a/aptsources/distro.py +++ b/aptsources/distro.py @@ -337,6 +337,9 @@ class Distribution(object): for source in sources: add_component_only_once(source, comps_per_dist) + for source in self.source_code_sources: + add_component_only_once(source, comps_per_sdist) + # check if there is a main source code source at all if self.get_source_code == True: if len(self.source_code_sources) < 1: diff --git a/debian/changelog b/debian/changelog index 70fc2c12..695d59a4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +python-apt (0.7.100.3ubuntu4) natty; urgency=low + + * Update enable_component to also apply to -src entries (LP: #758732) + + -- Stéphane Graber Tue, 12 Apr 2011 10:49:34 -0400 + python-apt (0.7.100.3ubuntu3) natty; urgency=low [ Michael Vogt ] -- cgit v1.2.3 From bbe36232eb04a191d8fefee5bc65710e4347c0dd Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 28 Sep 2011 16:25:09 +0200 Subject: add concept of "ParentComponent" for e.g. ubuntu/multiverse that needs universe enabled as well (plus add test) LP: #829284 --- aptsources/distinfo.py | 11 ++++++++++- aptsources/distro.py | 14 ++++++++++++-- data/templates/Ubuntu.info.in | 4 ++++ debian/changelog | 8 ++++++++ tests/test_aptsources.py | 23 +++++++++++++++++++++++ 5 files changed, 57 insertions(+), 3 deletions(-) (limited to 'aptsources/distro.py') 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 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/" -- cgit v1.2.3