summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorglatzor@ubuntu.com <>2006-06-28 20:58:26 +0200
committerglatzor@ubuntu.com <>2006-06-28 20:58:26 +0200
commit0d18962ad55ef1fd31974e46a65fd2fffb4a9baa (patch)
tree6eedd2c842eb2c1badebfe380fc80f372ab21bd8
parentcda38bff6b4daf1a5d630675875c0e0043c82e2f (diff)
downloadpython-apt-0d18962ad55ef1fd31974e46a65fd2fffb4a9baa.tar.gz
* start merging my old repo rewrite stuff
-rw-r--r--SoftwareProperties/aptsources.py234
-rw-r--r--UpdateManager/Common/DistInfo.py69
-rw-r--r--channels/Ubuntu.info.in152
3 files changed, 270 insertions, 185 deletions
diff --git a/SoftwareProperties/aptsources.py b/SoftwareProperties/aptsources.py
index 74ef2f4a..5735960b 100644
--- a/SoftwareProperties/aptsources.py
+++ b/SoftwareProperties/aptsources.py
@@ -89,6 +89,7 @@ class SourceEntry:
file = apt_pkg.Config.FindDir("Dir::Etc")+apt_pkg.Config.Find("Dir::Etc::sourcelist")
self.file = file
self.parse(line)
+ self.template = None
# works mostely like split but takes [] into account
def mysplit(self, line):
@@ -207,6 +208,7 @@ class SourceEntry:
class SourcesList:
def __init__(self):
self.list = [] # of Type SourceEntries
+ self.matcher = SourceEntryMatcher()
self.refresh()
def refresh(self):
@@ -219,6 +221,10 @@ class SourcesList:
partsdir = apt_pkg.Config.FindDir("Dir::Etc::sourceparts")
for file in glob.glob("%s/*.list" % partsdir):
self.load(file)
+ # check if the source item fits a predefined template
+ for source in self.list:
+ if source.invalid == False:
+ self.matcher.match(source)
def __iter__(self):
for entry in self.list:
@@ -241,7 +247,9 @@ class SourcesList:
if comment != "":
line = "%s #%s\n" %(line,comment)
line = line + "\n"
- self.list.insert(pos, SourceEntry(line))
+ new_entry = SourceEntry(line)
+ self.matcher.match(new_entry)
+ self.list.insert(pos, new_entry)
def remove(self, source_entry):
self.list.remove(source_entry)
@@ -271,12 +279,16 @@ class SourcesList:
def load(self,file):
""" (re)load the current sources """
- f = open(file, "r")
- lines = f.readlines()
- for line in lines:
- source = SourceEntry(line,file)
- self.list.append(source)
- f.close()
+ try:
+ f = open(file, "r")
+ lines = f.readlines()
+ for line in lines:
+ source = SourceEntry(line,file)
+ self.list.append(source)
+ except:
+ print "could not open file '%s'" % file
+ else:
+ f.close()
def save(self):
""" save the current sources """
@@ -288,6 +300,41 @@ class SourcesList:
for f in files:
files[f].close()
+ def check_for_relations(self, sources_list):
+ """get all parent and child channels in the sources list"""
+ parents = []
+ used_child_templates = {}
+ for source in sources_list:
+ # try to avoid checking uninterressting sources
+ if source.template == None:
+ continue
+ # set up a dict with all used child templates and corresponding
+ # source entries
+ if source.template.child == True:
+ key = source.template
+ if not used_child_templates.has_key(key):
+ used_child_templates[key] = []
+ temp = used_child_templates[key]
+ temp.append(source)
+ else:
+ # store each source with children aka. a parent :)
+ if len(source.template.children) > 0:
+ parents.append(source)
+ #print self.used_child_templates
+ #print self.parents
+ return (parents, used_child_templates)
+
+ def check_for_endangered_dists(self):
+ """set the components of a child source to the ones of the parent channel"""
+ (parents, used_child_templates) = self.check_for_relations(self.list)
+ # the magical part
+ for mother in parents:
+ for child_template in mother.template.children:
+ if used_child_templates.has_key(child_template):
+ for child in used_child_templates[child_template]:
+ if child.type == mother.type:
+ child.comps = mother.comps
+
# templates for the add dialog
class SourceEntryTemplate(SourceEntry):
def __init__(self,a_type,uri,dist,description,comps):
@@ -354,121 +401,20 @@ class SourceEntryMatcher:
self.comps_descriptions = l_comps_descr
def __init__(self):
- _ = gettext.gettext
- self.type_list = []
- self.type_list.append(self.MatchType("^deb$",_("Binary")))
- self.type_list.append(self.MatchType("^deb-src$",_("Source")))
-
- self.dist_list = []
-
- 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.06",
- ".*",
- _("CD disk with Ubuntu 6.06 LTS"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist("cdrom:\[Ubuntu.*5.10",
- ".*",
- _("CD disk with Ubuntu 5.10"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist("cdrom:\[Ubuntu.*5.04",
- ".*",
- _("CD disk with Ubuntu 5.04"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist("cdrom:\[Ubuntu.*4.10",
- ".*",
- _("CD disk with Ubuntu 4.10"),
- ubuntu_comps, ubuntu_comps_descr))
- # URIs
- # Warty
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^warty$",
- "Ubuntu 4.10",
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*security.ubuntu.com/ubuntu",
- "^warty-security$",
- _("Ubuntu 4.10 Security Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^warty-security$",
- _("Ubuntu 4.10 Security Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^warty-updates$",
- _("Ubuntu 4.10 Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^warty-backports$",
- _("Ubuntu 4.10 Backports"),
- ubuntu_comps, ubuntu_comps_descr))
- # Hoary
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^hoary-security$",
- _("Ubuntu 5.04 Security Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*security.ubuntu.com/ubuntu",
- "^hoary-security$",
- _("Ubuntu 5.04 Security Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^hoary$",
- "Ubuntu 5.04",
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^hoary-updates$",
- _("Ubuntu 5.04 Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^hoary-backports$",
- _("Ubuntu 5.04 Backports"),
- ubuntu_comps, ubuntu_comps_descr))
- # Breezy
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^breezy-security$",
- _("Ubuntu 5.10 Security Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*security.ubuntu.com/ubuntu",
- "^breezy-security$",
- _("Ubuntu 5.10 Security Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^breezy$",
- "Ubuntu 5.10",
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^breezy-backports$",
- _("Ubuntu 5.10 Backports"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^breezy-updates$",
- _("Ubuntu 5.10 Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- # dapper
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^dapper-security$",
- _("Ubuntu 6.06 LTS Security Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*security.ubuntu.com/ubuntu",
- "^dapper-security$",
- _("Ubuntu 6.06 LTS Security Updates"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^dapper$",
- "Ubuntu 6.06 LTS",
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^dapper-backports$",
- _("Ubuntu 6.06 LTS Backports"),
- ubuntu_comps, ubuntu_comps_descr))
- self.dist_list.append(self.MatchDist(".*archive.ubuntu.com/ubuntu",
- "^dapper-updates$",
- _("Ubuntu 6.06 LTS Updates"),
- ubuntu_comps, ubuntu_comps_descr))
-
+ self.templates = []
+ # Get the human readable channel and comp names from the channel .infos
+ spec_files = glob.glob("/usr/share/update-manager/channels/*.info")
+ for f in spec_files:
+ f = os.path.basename(f)
+ i = f.find(".info")
+ f = f[0:i]
+ dist = DistInfo(f)
+ for suite in dist.suites:
+ if suite.match_uri != None:
+ self.templates.append(suite)
+
+ # FIXME: The specifications should go into the .info files
+ return
# DEBIAN
debian_comps = ["^main$","^contrib$","^non-free$","^non-US$"]
@@ -518,43 +464,21 @@ class SourceEntryMatcher:
self.dist_list.append(self.MatchDist(".*debian.org/debian-non-US",
"^unstable.*$",
_("Debian Non-US (Unstable)"),
- debian_comps, debian_comps_descr))
+ debian_comps, debian_comps_descr,
+ SOURCE_SYSTEM))
-
-
-
- def match(self,source):
+ def match(self, source):
+ """Add a matching template to the source"""
_ = gettext.gettext
- # some sane defaults first
- type_description = source.type
- dist_description = source.uri + " " + source.dist
- comp_description = ""
- for c in source.comps:
- comp_description = comp_description + " " + c
-
- for t in self.type_list:
- if re.match(t.type, source.type):
- type_description = _(t.description)
- break
-
- for d in self.dist_list:
+ found = False
+ for template in self.templates:
#print "'%s'" %source.uri
- if re.match(d.uri, source.uri) and re.match(d.dist,source.dist):
- dist_description = d.description
- comp_description = ""
- for c in source.comps:
- found = False
- for i in range(len(d.comps)):
- if re.match(d.comps[i], c):
- comp_description = comp_description+"\n"+d.comps_descriptions[i]
- found = True
- if found == False:
- comp_description = comp_description+" "+c
+ if re.search(template.match_uri, source.uri) and \
+ re.match(template.match_name, source.dist):
+ found = True
+ source.template = template
break
-
-
- return (type_description,dist_description,comp_description)
-
+ return found
# some simple tests
if __name__ == "__main__":
diff --git a/UpdateManager/Common/DistInfo.py b/UpdateManager/Common/DistInfo.py
index 102b981c..873d7132 100644
--- a/UpdateManager/Common/DistInfo.py
+++ b/UpdateManager/Common/DistInfo.py
@@ -28,21 +28,29 @@ import ConfigParser
_ = gettext.gettext
class Suite:
- name = None
- description = None
- base_uri = None
- repository_type = None
- components = None
+ def __init__(self):
+ self.name = None
+ self.child = False
+ self.match_name = None
+ self.description = None
+ self.base_uri = None
+ self.type = None
+ self.components = {}
+ self.children = []
+ self.match_uri = None
+ self.distribution = None
+ self.available = True
class Component:
- name = None
- description = None
- enabled = None
+ def __init__(self):
+ self.name = None
+ self.description = None
+ self.enabled = None
class DistInfo:
def __init__(self,
dist = None,
- base_dir = "/usr/share/update-manager/dists"):
+ base_dir = "/usr/share/update-manager/channels"):
self.metarelease_uri = ''
self.suites = []
@@ -73,21 +81,36 @@ class DistInfo:
elif field == 'Suite':
if suite:
if component:
- suite.components.append (component)
+ suite.components["%s" % component.name] = \
+ (component.description, component.enabled)
component = None
self.suites.append (suite)
suite = Suite ()
suite.name = value
- suite.components = []
+ suite.distribution = dist
+ suite.match_name = "^%s$" % value
+ elif field == 'MatchName':
+ suite.match_name = value
+ elif field == 'ParentSuite':
+ suite.child = True
+ for nanny in self.suites:
+ if nanny.name == value:
+ nanny.children.append(suite)
+ elif field == 'Available':
+ suite.available = value
elif field == 'RepositoryType':
- suite.repository_type = value
+ suite.type = value
elif field == 'BaseURI':
suite.base_uri = value
+ suite.match_uri = value
+ elif field == 'MatchURI':
+ suite.match_uri = value
elif field == 'Description':
suite.description = _(value)
elif field == 'Component':
if component:
- suite.components.append (component)
+ suite.components["%s" % component.name] = \
+ (component.description, component.enabled)
component = Component ()
component.name = value
elif field == 'Enabled':
@@ -96,20 +119,24 @@ class DistInfo:
component.description = _(value)
if suite:
if component:
- suite.components.append (component)
+ suite.components["%s" % component.name] = \
+ (component.description, component.enabled)
component = None
self.suites.append (suite)
suite = None
if __name__ == "__main__":
- d = DistInfo ("Debian", "../../channels")
+ d = DistInfo ("Ubuntu", "../../channels")
print d.changelogs_uri
for suite in d.suites:
- print suite.name
- print suite.description
- print suite.base_uri
+ print "\nSuite: %s" % suite.name
+ print "Desc: %s" % suite.description
+ print "BaseURI: %s" % suite.base_uri
+ print "MatchURI: %s" % suite.match_uri
for component in suite.components:
- print component.name
- print component.description
- print component.enabled
+ print " %s - %s - %s " % (component.name,
+ component.description,
+ component.enabled)
+ for child in suite.children:
+ print " %s" % child.description
diff --git a/channels/Ubuntu.info.in b/channels/Ubuntu.info.in
index 94833aca..4bda6077 100644
--- a/channels/Ubuntu.info.in
+++ b/channels/Ubuntu.info.in
@@ -3,7 +3,8 @@ _ChangelogURI: http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/chang
Suite: dapper
RepositoryType: deb
BaseURI: http://archive.ubuntu.com/ubuntu/
-_Description: Ubuntu 6.06 LTS
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 6.04 'Dapper Drake'
Component: main
Enabled: 1
_CompDescription: Officially supported
@@ -17,11 +18,44 @@ Component: multiverse
Enabled: 0
_CompDescription: Non-free (Multiverse)
+Suite: dapper
+MatchName: .*
+BaseURI: cdrom:\[Ubuntu.*6.04
+_Description: Cdrom with Ubuntu 6.04 'Dapper Drake'
+Available: False
+Component: main
+Enabled: 1
+_CompDescription: Oficially supported
+Component: restricted
+Enabled: 1
+_CompDescription: Restricted copyright
+
Suite: dapper-security
+ParentSuite: dapper
RepositoryType: deb
BaseURI: http://security.ubuntu.com/ubuntu/
-_Description: Ubuntu 6.06 LTS Security Updates
-Component: main
+MatchURI: archive.ubuntu.com/ubuntu/|security.ubuntu.com
+_Description: Ubuntu 6.04 Security Updates
+
+Suite: dapper-updates
+ParentSuite: dapper
+RepositoryType: deb
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 6.04 Updates
+
+Suite: dapper-backports
+ParentSuite: dapper
+RepositoryType: deb
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 6.04 Backports
+
+Suite: dapper-backports
+RepositoryType: deb
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 5.10 'Breezy Badger'
Enabled: 1
_CompDescription: Officially supported
Component: restricted
@@ -34,13 +68,47 @@ Component: multiverse
Enabled: 0
_CompDescription: Non-free (Multiverse)
-Suite: dapper-updates
+Suite: breezy
+MatchName: .*
+BaseURI: cdrom:\[Ubuntu.*5.10
+_Description: Cdrom with Ubuntu 5.10 'Breezy Badger'
+Available: False
+Component: main
+Enabled: 1
+_CompDescription: Oficially supported
+Component: restricted
+Enabled: 1
+_CompDescription: Restricted copyright
+
+Suite: breezy-security
+ParentSuite: breezy
+RepositoryType: deb
+BaseURI: http://security.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/|security.ubuntu.com
+_Description: Ubuntu 5.10 Security Updates
+
+Suite: breezy-updates
+ParentSuite: breezy
+RepositoryType: deb
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 5.10 Updates
+
+Suite: breezy-backports
+ParentSuite: breezy
+RepositoryType: deb
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 5.10 Backports
+
+Suite: hoary
RepositoryType: deb
BaseURI: http://archive.ubuntu.com/ubuntu/
-_Description: Ubuntu 6.06 LTS Updates
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 5.04 'Hoary Hedgehog'
Component: main
Enabled: 1
-_CompDescription: Officially supported
+_CompDescription: Oficially supported
Component: restricted
Enabled: 1
_CompDescription: Restricted copyright
@@ -51,13 +119,47 @@ Component: multiverse
Enabled: 0
_CompDescription: Non-free (Multiverse)
-Suite: dapper-backports
+Suite: hoary
+MatchName: .*
+BaseURI: cdrom:\[Ubuntu.*5.04
+_Description: Cdrom with Ubuntu 5.04 'Hoary Hedgehog'
+Available: False
+Component: main
+Enabled: 1
+_CompDescription: Oficially supported
+Component: restricted
+Enabled: 1
+_CompDescription: Restricted copyright
+
+Suite: hoary-security
+ParentSuite: hoary
+RepositoryType: deb
+BaseURI: http://security.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/|security.ubuntu.com
+_Description: Ubuntu 5.04 Security Updates
+
+Suite: hoary-updates
+ParentSuite: hoary
+RepositoryType: deb
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 5.04 Updates
+
+Suite: hoary-backports
+ParentSuite: hoary
+RepositoryType: deb
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 5.04 Backports
+
+Suite: warty
RepositoryType: deb
BaseURI: http://archive.ubuntu.com/ubuntu/
-_Description: Ubuntu 6.06 LTS Backports
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 4.10 'Warty Warthog'
Component: main
Enabled: 1
-_CompDescription: Officially supported
+_CompDescription: Oficially supported
Component: restricted
Enabled: 1
_CompDescription: Restricted copyright
@@ -68,3 +170,35 @@ Component: multiverse
Enabled: 0
_CompDescription: Non-free (Multiverse)
+Suite: warty
+MatchName: .*
+BaseURI: cdrom:\[Ubuntu.*4.10
+_Description: Cdrom with Ubuntu 4.10 'Warty Warthog'
+Available: False
+Component: main
+Enabled: 1
+_CompDescription: Oficially supported
+Component: restricted
+Enabled: 1
+_CompDescription: Restricted copyright
+
+Suite: warty-security
+ParentSuite: warty
+RepositoryType: deb
+BaseURI: http://security.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/|security.ubuntu.com
+_Description: Ubuntu 4.10 Security Updates
+
+Suite: warty-updates
+ParentSuite: warty
+RepositoryType: deb
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 4.10 Updates
+
+Suite: warty-backports
+ParentSuite: warty
+RepositoryType: deb
+BaseURI: http://archive.ubuntu.com/ubuntu/
+MatchURI: archive.ubuntu.com/ubuntu/
+_Description: Ubuntu 4.10 Backports