diff options
| -rw-r--r-- | SoftwareProperties/SoftwareProperties.py | 62 | ||||
| -rw-r--r-- | SoftwareProperties/aptsources.py | 55 |
2 files changed, 99 insertions, 18 deletions
diff --git a/SoftwareProperties/SoftwareProperties.py b/SoftwareProperties/SoftwareProperties.py index 0e9a0f0d..fb9c8b05 100644 --- a/SoftwareProperties/SoftwareProperties.py +++ b/SoftwareProperties/SoftwareProperties.py @@ -260,16 +260,76 @@ class SoftwareProperties(SimpleGladeApp): self.treeview2.append_column(keys_col) def reload_sourceslist(self): + # To store the sources that provide updates + self.sources_updates = [] + # To store the sources that provide securtiy fixes + self.sources_security = [] + # To store the activated components of each dist + self.system_comps = {} + self.source_store.clear() for source in self.sourceslist.list: if source.invalid: continue - (nice_type, nice_dist, nice_comps) = self.matcher.match(source) + (nice_type, nice_dist, nice_comps, special) = self.matcher.match(source) + print "match: %s %s" % (source.dist, special) contents = "<b>%s</b>%s" % (nice_dist, nice_comps) if source.type == "deb-src": contents = "<b>%s</b> - %s %s" % (nice_dist, nice_type, nice_comps) self.source_store.append([not source.disabled, contents, source]) + + # Collect the components of an activated system dist + if special == aptsources.SOURCE_SYSTEM and source.disabled != True: + if self.system_comps.has_key(source.dist): + current = self.system_comps[source.dist] + self.system_comps[source.dist] = (current | set(source.comps)) + else: + self.system_comps[source.dist] = set(source.comps) + + # Collect sources that provide updates + elif special == aptsources.SOURCE_UPDATES: + self.sources_updates.append(source) + elif special == aptsources.SOURCE_SECURITY: + self.sources_security.append(source) + + + print "\n\nSecurity Updates: %s" % self.sources_security + print "\nSystem Sources: %s " % self.sources_system + print "\nUpdates: %s" % self.sources_updates + print "\nSystem Compos: %s " % self.system_comps + + modified = False + # Check if each security source contains all components of + # the same dist + for source in self.sources_security: + print "SecSource: %s" % source.dist + # Skip the "-security" from the dist + # FIXME: Does not work for debian + i = source.dist.find("-") + dist = source.dist[:i] + # Are there any active components for the dist? + if self.system_comps.has_key(dist): + comps_sys = self.system_comps[dist] + comps_sec = set(source.comps) + # Are there components without sec updates? + comps_endangered = comps_sys - comps_sec + print "In Danger: %s " % comps_endangered + if len(comps_endangered) > 0: + # convert the set into a list + comps_new=[] + for comp in comps_endangered: + comps_new.append(comp) + # add a security source with the additional components + print "Adding security updates for %s - %s" % (source.dist, comps_new) + self.sourceslist.add(source.type, source.uri, + source.dist, comps_new, + source.comment) + modified = True + # Reload the sourceslist if we added a new source + if modified == True: + print "modified" + self.reload_sourceslist() def reload_keyslist(self): self.keys_store.clear() diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py index f751cf7c..7cb58168 100644 --- a/SoftwareProperties/aptsources.py +++ b/SoftwareProperties/aptsources.py @@ -32,6 +32,8 @@ import os.path from UpdateManager.Common.DistInfo import DistInfo +(SOURCE_SECURITY, SOURCE_UPDATES, SOURCE_SYSTEM) = range(3) + # actual source.list entries class SourceEntry: @@ -323,12 +325,14 @@ class SourceEntryMatcher: self.description = a_descr class MatchDist: - def __init__(self,a_uri,a_dist, a_descr,l_comps, l_comps_descr): + def __init__(self, a_uri, a_dist, a_descr, l_comps, + l_comps_descr, special=None): self.uri = a_uri self.dist = a_dist self.description = a_descr self.comps = l_comps self.comps_descriptions = l_comps_descr + self.special = special def __init__(self): _ = gettext.gettext @@ -338,23 +342,32 @@ class SourceEntryMatcher: self.dist_list = [] + #UBUNTU ubuntu_comps = ["^main$","^restricted$","^universe$","^multiverse$"] ubuntu_comps_descr = [_("Officially supported"), _("Restricted copyright"), _("Community maintained (Universe)"), _("Non-free (Multiverse)")] # CDs + self.dist_list.append(self.MatchDist("cdrom:\[Ubuntu.*6.04", + ".*", + _("Cdrom with Ubuntu 6.04 'Dapper "\ + "Drake'"), + ubuntu_comps, ubuntu_comps_descr)) self.dist_list.append(self.MatchDist("cdrom:\[Ubuntu.*5.10", ".*", - _("CD disk with Ubuntu 5.10 'Breezy Badger'"), + _("Cdrom with Ubuntu 5.10 'Breezy "\ + "Badger'"), ubuntu_comps, ubuntu_comps_descr)) self.dist_list.append(self.MatchDist("cdrom:\[Ubuntu.*5.04", ".*", - _("CD disk with Ubuntu 5.04 \"Hoary Hedgehog\""), + _("Cdrom with Ubuntu 5.04 'Hoary "\ + "Hedgehog'"), ubuntu_comps, ubuntu_comps_descr)) self.dist_list.append(self.MatchDist("cdrom:\[Ubuntu.*4.10", ".*", - _("CD disk with Ubuntu 4.10 \"Warty Warthog\""), + _("Cdrom with Ubuntu 4.10 'Warty "\ + "Warthog'"), ubuntu_comps, ubuntu_comps_descr)) # URIs # Warty @@ -365,7 +378,8 @@ class SourceEntryMatcher: self.dist_list.append(self.MatchDist(".*security.ubuntu.com/ubuntu", "^warty-security$", _("Ubuntu 4.10 Security Updates"), - ubuntu_comps, ubuntu_comps_descr)) + ubuntu_comps, ubuntu_comps_descr, + SOURCE_SECURITY)) self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu", "^warty-security$", _("Ubuntu 4.10 Security Updates"), @@ -395,36 +409,44 @@ class SourceEntryMatcher: self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu", "^breezy-security$", _("Ubuntu 5.10 Security Updates"), - ubuntu_comps, ubuntu_comps_descr)) + ubuntu_comps, ubuntu_comps_descr, + SOURCE_SECURITY)) self.dist_list.append(self.MatchDist(".*security.ubuntu.com/ubuntu", "^breezy-security$", _("Ubuntu 5.10 Security Updates"), - ubuntu_comps, ubuntu_comps_descr)) + ubuntu_comps, ubuntu_comps_descr, + SOURCE_SECURITY)) self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu", "^breezy$", "Ubuntu 5.10 'Breezy Badger'", - ubuntu_comps, ubuntu_comps_descr)) + ubuntu_comps, ubuntu_comps_descr, + SOURCE_SYSTEM)) self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu", "^breezy-updates$", _("Ubuntu 5.10 Updates"), - ubuntu_comps, ubuntu_comps_descr)) + ubuntu_comps, ubuntu_comps_descr, + SOURCE_UPDATES)) # dapper self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu", "^dapper-security$", _("Ubuntu 6.04 Security Updates"), - ubuntu_comps, ubuntu_comps_descr)) + ubuntu_comps, ubuntu_comps_descr, + SOURCE_SECURITY)) self.dist_list.append(self.MatchDist(".*security.ubuntu.com/ubuntu", "^dapper-security$", _("Ubuntu 6.04 Security Updates"), - ubuntu_comps, ubuntu_comps_descr)) + ubuntu_comps, ubuntu_comps_descr, + SOURCE_SECURITY)) self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu", "^dapper$", "Ubuntu 6.04 'Dapper Drake'", - ubuntu_comps, ubuntu_comps_descr)) + ubuntu_comps, ubuntu_comps_descr, + SOURCE_SYSTEM)) self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu", "^dapper-updates$", _("Ubuntu 6.04 Updates"), - ubuntu_comps, ubuntu_comps_descr)) + ubuntu_comps, ubuntu_comps_descr, + SOURCE_UPDATES)) # DEBIAN @@ -477,12 +499,10 @@ class SourceEntryMatcher: _("Debian Non-US (Unstable)"), debian_comps, debian_comps_descr)) - - - def match(self,source): _ = gettext.gettext # some sane defaults first + special = None type_description = source.type dist_description = source.uri + " " + source.dist # if there is a comment use it instead of the url @@ -503,6 +523,7 @@ class SourceEntryMatcher: if re.match(d.uri, source.uri) and re.match(d.dist, source.dist): dist_description = d.description comp_description = "" + special = d.special for c in source.comps: found = False for i in range(len(d.comps)): @@ -514,7 +535,7 @@ class SourceEntryMatcher: break - return (type_description,dist_description,comp_description) + return (type_description, dist_description, comp_description, special) # some simple tests |
