summaryrefslogtreecommitdiff
path: root/UpdateManager
diff options
context:
space:
mode:
Diffstat (limited to 'UpdateManager')
-rw-r--r--UpdateManager/Common/DistInfo.py76
-rw-r--r--UpdateManager/UpdateManager.py95
2 files changed, 104 insertions, 67 deletions
diff --git a/UpdateManager/Common/DistInfo.py b/UpdateManager/Common/DistInfo.py
index 102b981c..7d2d37ad 100644
--- a/UpdateManager/Common/DistInfo.py
+++ b/UpdateManager/Common/DistInfo.py
@@ -28,21 +28,30 @@ 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 = ""
+ self.description = ""
+ self.description_long = ""
+ 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,43 +82,68 @@ class DistInfo:
elif field == 'Suite':
if suite:
if component:
- suite.components.append (component)
+ suite.components["%s" % component.name] = \
+ (component.description, component.enabled,
+ component.description_long)
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.description_long)
component = Component ()
component.name = value
elif field == 'Enabled':
component.enabled = bool(int(value))
elif field == 'CompDescription':
component.description = _(value)
+ elif field == 'CompDescriptionLong':
+ component.description_long = _(value)
if suite:
if component:
- suite.components.append (component)
+ suite.components["%s" % component.name] = \
+ (component.description, component.enabled,
+ component.description_long)
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 - %s" % (component,
+ suite.components[component][0],
+ suite.components[component][1],
+ suite.components[component][2])
+ for child in suite.children:
+ print " %s" % child.description
diff --git a/UpdateManager/UpdateManager.py b/UpdateManager/UpdateManager.py
index 54d85801..109e4d0c 100644
--- a/UpdateManager/UpdateManager.py
+++ b/UpdateManager/UpdateManager.py
@@ -83,11 +83,19 @@ CHANGELOGS_URI="http://changelogs.ubuntu.com/changelogs/pool/%s/%s/%s/%s_%s/chan
class MyCache(apt.Cache):
def __init__(self, progress):
apt.Cache.__init__(self, progress)
+ self._initDepCache()
assert self._depcache.BrokenCount == 0 and self._depcache.DelCount == 0
self.all_changes = {}
+ def _initDepCache(self):
+ #apt_pkg.Config.Set("Debug::pkgPolicy","1")
+ #self.depcache = apt_pkg.GetDepCache(self.cache)
+ #self._depcache = apt_pkg.GetDepCache(self._cache)
+ self._depcache.ReadPinFile()
+ if os.path.exists(SYNAPTIC_PINFILE):
+ self._depcache.ReadPinFile(SYNAPTIC_PINFILE)
+ self._depcache.Init()
def clean(self):
- for pkg in self:
- pkg.markKeep()
+ self._initDepCache()
def saveDistUpgrade(self):
""" this functions mimics a upgrade but will never remove anything """
self._depcache.Upgrade(True)
@@ -95,38 +103,40 @@ class MyCache(apt.Cache):
self.clean()
assert self._depcache.BrokenCount == 0 and self._depcache.DelCount == 0
self._depcache.Upgrade()
-
+
def get_changelog(self, name, lock):
# don't touch the gui in this function, it needs to be thread-safe
pkg = self[name]
- # get the src package name
+ # get the src package name
srcpkg = pkg.sourcePackageName
# assume "main" section
src_section = "main"
# use the section of the candidate as a starting point
- section = pkg._depcache.GetCandidateVer(pkg._pkg).Section
-
- # get the source version, start with the binaries version
- srcver = pkg.candidateVersion
- try:
- # try to get the source version of the pkg, this differs
- # for some (e.g. libnspr4 on ubuntu)
- srcrecords = apt_pkg.GetPkgSrcRecords()
- srcrec = srcrecords.Lookup(srcpkg)
- if srcrec:
- srcver = srcrecords.Version
- #print "srcver: %s" % srcver
- section = srcrecords.Section
- #print "srcsect: %s" % section
- except SystemError, e:
- # catch errors and ignore them,
- # this feature only works if deb-src are in the sources.list
- # otherwise we fall back to the binary version number
- pass
-
-
+ section = pkg._depcache.GetCandidateVer(pkg._pkg).Section
+
+ # get the source version, start with the binaries version
+ binver = pkg.candidateVersion
+ #print "bin: %s" % binver
+ try:
+ # try to get the source version of the pkg, this differs
+ # for some (e.g. libnspr4 on ubuntu)
+ # this feature only works if the correct deb-src are in the
+ # sources.list
+ # otherwise we fall back to the binary version number
+ srcrecords = apt_pkg.GetPkgSrcRecords()
+ srcrec = srcrecords.Lookup(srcpkg)
+ if srcrec:
+ srcver = srcrecords.Version
+ if apt_pkg.VersionCompare(binver, srcver) > 0:
+ srcver = binver
+ #print "srcver: %s" % srcver
+ section = srcrecords.Section
+ #print "srcsect: %s" % section
+ except SystemError, e:
+ srcver = binver
+
l = section.split("/")
if len(l) > 1:
src_section = l[0]
@@ -143,7 +153,7 @@ class MyCache(apt.Cache):
try:
uri = CHANGELOGS_URI % (src_section,prefix,srcpkg,srcpkg, srcver)
- #print "Trying: %s " % uri
+ # print "Trying: %s " % uri
changelog = urllib2.urlopen(uri)
#print changelog.read()
# do only get the lines that are new
@@ -153,23 +163,26 @@ class MyCache(apt.Cache):
i=0
while True:
line = changelog.readline()
- #print line
if line == "":
break
match = re.match(regexp,line)
if match:
- # FIXME: the installed version can have a epoch, but th
- # changelog does not have one, we do a dumb
- # approach here and just strip it away, but I'm
- # sure that this can lead to problems
- installed = pkg.installedVersion
- if installed and ":" in installed:
- installed = installed.split(":",1)[1]
- if installed and apt_pkg.VersionCompare(match.group(1),installed) <= 0:
+ # FIXME: the installed version can have a epoch, but th
+ # changelog does not have one, we do a dumb
+ # approach here and just strip it away, but I'm
+ # sure that this can lead to problems
+ installed = pkg.installedVersion
+ if installed and ":" in installed:
+ installed = installed.split(":",1)[1]
+ if installed and \
+ apt_pkg.VersionCompare(match.group(1),installed)<=0:
break
- # EOF (shouldn't really happen)
+ # EOF (shouldn't really happen)
alllines = alllines + line
+ # Print an error if we failed to extract a changelog
+ if len(alllines) == 0:
+ alllines = _("The list of changes is not available")
# only write if we where not canceld
if lock.locked():
self.all_changes[name] = [alllines, srcpkg]
@@ -187,9 +200,6 @@ class MyCache(apt.Cache):
if lock.locked():
lock.release()
-
-
-
class UpdateList:
def __init__(self, parent_window):
self.pkgs = []
@@ -753,13 +763,6 @@ class UpdateManager(SimpleGladeApp):
sys.exit(1)
else:
progress.hide()
- #apt_pkg.Config.Set("Debug::pkgPolicy","1")
- #self.depcache = apt_pkg.GetDepCache(self.cache)
- self.cache._depcache.ReadPinFile()
- if os.path.exists(SYNAPTIC_PINFILE):
- self.cache._depcache.ReadPinFile(SYNAPTIC_PINFILE)
- self.cache._depcache.Init()
-
def check_auto_update(self):
# Check if automatic update is enabled. If not show a dialog to inform