summaryrefslogtreecommitdiff
path: root/UpdateManager
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2006-09-10 12:02:11 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2006-09-10 12:02:11 +0200
commita021109da0fb1e138adc912c44632f0956243769 (patch)
tree0a066ad2e84e7423932a41f9c9e4df7c10719d2d /UpdateManager
parent522d72a3abeacee8b6070481738f9c9edd0a6161 (diff)
downloadpython-apt-a021109da0fb1e138adc912c44632f0956243769.tar.gz
* added new "MirrorsFile" keyword for the DistInfo Tagfile
* look for mirros as well when matching distros
Diffstat (limited to 'UpdateManager')
-rw-r--r--UpdateManager/Common/DistInfo.py11
-rw-r--r--UpdateManager/Common/aptsources.py17
2 files changed, 23 insertions, 5 deletions
diff --git a/UpdateManager/Common/DistInfo.py b/UpdateManager/Common/DistInfo.py
index 79d5356c..81f08200 100644
--- a/UpdateManager/Common/DistInfo.py
+++ b/UpdateManager/Common/DistInfo.py
@@ -24,6 +24,7 @@ import os
import gettext
from os import getenv
import ConfigParser
+import string
_ = gettext.gettext
@@ -38,6 +39,7 @@ class Suite:
self.components = {}
self.children = []
self.match_uri = None
+ self.valid_mirrors = []
self.distribution = None
self.available = True
@@ -107,6 +109,12 @@ class DistInfo:
suite.match_uri = value
elif field == 'MatchURI':
suite.match_uri = value
+ elif field == 'MirrorsFile':
+ suite.valid_mirrors = filter(lambda s:
+ ((s != "") and
+ (not s.startswith("#"))),
+ map(string.strip,
+ open(value)))
elif field == 'Description':
suite.description = _(value)
elif field == 'Component':
@@ -133,13 +141,14 @@ class DistInfo:
if __name__ == "__main__":
- d = DistInfo ("Ubuntu", "../../channels")
+ d = DistInfo ("Ubuntu", "../../data/channels")
print d.changelogs_uri
for suite in d.suites:
print "\nSuite: %s" % suite.name
print "Desc: %s" % suite.description
print "BaseURI: %s" % suite.base_uri
print "MatchURI: %s" % suite.match_uri
+ print "Mirrors: %s" % suite.valid_mirrors
for component in suite.components:
print " %s - %s - %s - %s" % (component,
suite.components[component][0],
diff --git a/UpdateManager/Common/aptsources.py b/UpdateManager/Common/aptsources.py
index 36a9811d..bc6886d9 100644
--- a/UpdateManager/Common/aptsources.py
+++ b/UpdateManager/Common/aptsources.py
@@ -87,7 +87,8 @@ class SourceEntry:
file = apt_pkg.Config.FindDir("Dir::Etc")+apt_pkg.Config.Find("Dir::Etc::sourcelist")
self.file = file # the file that the entry is located in
self.parse(line)
- self.template = None
+ # FIXME: this name is really misleading and already overloaded
+ self.template = None # type DistInfo.Suite
self.children = []
def __eq__(self, other):
@@ -457,12 +458,17 @@ class SourceEntryMatcher:
_ = gettext.gettext
found = False
for template in self.templates:
- #print "'%s'" %source.uri
- if re.search(template.match_uri, source.uri) and \
- re.match(template.match_name, source.dist):
+ if (re.search(template.match_uri, source.uri) and
+ re.match(template.match_name, source.dist)):
found = True
source.template = template
break
+ for mirror in template.valid_mirrors:
+ if (is_mirror(mirror,source.uri) and
+ re.match(template.match_name, source.dist)):
+ found = True
+ source.template = template
+ break
return found
class Distribution:
@@ -717,3 +723,6 @@ if __name__ == "__main__":
print is_mirror("http://archive.ubuntu.com/ubuntu",
"http://de.archive.ubuntu.com/ubuntu/")
+ print is_mirror("http://archive.ubuntu.com/ubuntu/",
+ "http://de.archive.ubuntu.com/ubuntu")
+