summaryrefslogtreecommitdiff
path: root/apt/package.py
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2010-06-01 17:08:24 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2010-06-01 17:08:24 +0200
commite74ead9f918b38bfe8ae5cfe941df4057dcc509e (patch)
tree9f678aa2510cb1df272cd5beca5cf551794e6307 /apt/package.py
parent5a062bb328348cd3a2ac693b579d35d0ce8e11f0 (diff)
parent50f9df7e415deb9bb6156ef8f596b6d4d49b23a4 (diff)
downloadpython-apt-e74ead9f918b38bfe8ae5cfe941df4057dcc509e.tar.gz
* merge from debian bzr, remaining changes:
- different mirror list * data/templates/gNewSense.info.in, data/templates/gNewSense.mirrors: - add gNewSense template and mirrors, thanks to Karl Goetz * apt/cache.py: - Make Cache.get_changes() much (~35x) faster (Closes: #578074). - Make Cache.req_reinstall_pkgs much faster as well. - Make Cache.get_providing_packages() about 1000 times faster. - Use has_versions and has_provides from apt_pkg.Package where possible. * apt/package.py: - Decode using utf-8 in installed_files (LP: #407953). - Fix fetch_source() to work when source name = binary name (LP: #552400). - Merge a patch from Sebastian Heinlein to make get_changelog() only check sources where source version >= binary version (Closes: #581831). - Add Version.source_version and enhance Sebastian's patch to make use of it, in order to find the best changelog for the package. * python: - Return bool instead of int to Python where possible, looks better. - Document every class, function, property. * python/cache.cc: - Check that 2nd argument to Cache.update() really is a SourceList object. - Fix PackageFile.not_automatic to use NotAutomatic instead of NotSource. - Add Package.has_versions to see which packages have at least one version, and Package.has_provides for provides. - Add rich compare methods to the Version object. * python/generic.cc: - Fix a memory leak when using old attribute names. - Map ArchiveURI property to archive_uri * python/progress.cc: - Do not pass arguments to InstallProgress.wait_child(). * doc: - Update the long documentation. * debian/control: - Change priority to standard, keep -doc and -dev on optional. * utils/migrate-0.8.py: - Open files in universal newline support and pass filename to ast.parse. - Add has_key to the list of deprecated functions. - Don't abort if parsing failed. - do not require files to end in .py if they are passed on the command line or if they contain python somewhere in the shebang line. * apt/cache.py: - make cache open silent by default (use apt.progress.base.OpProgress) * tests/data/aptsources_ports/sources.list: - fix ports test-data * tests/test_apt_cache.py: - add simple test for basic cache/dependency iteration
Diffstat (limited to 'apt/package.py')
-rw-r--r--apt/package.py49
1 files changed, 27 insertions, 22 deletions
diff --git a/apt/package.py b/apt/package.py
index 342fb5cf..7dcead02 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -379,6 +379,14 @@ class Version(object):
return self.package.name
@property
+ def source_version(self):
+ """Return the version of the source package."""
+ try:
+ return self._records.source_ver or self._cand.ver_str
+ except IndexError:
+ return self._cand.ver_str
+
+ @property
def priority(self):
"""Return the priority of the package, as string."""
return self._cand.priority_str
@@ -1006,34 +1014,31 @@ class Package(object):
src_section = "main"
# use the section of the candidate as a starting point
section = self.candidate.section
-
- # get the source version, start with the binaries version
- bin_ver = self.candidate.version
- src_ver = self.candidate.version
- #print "bin: %s" % binver
+
+ # get the source version
+ src_ver = self.candidate.source_version
+
try:
- # FIXME: This try-statement is too long ...
# 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
+ # sources.list otherwise we fall back to the binary version number
src_records = apt_pkg.SourceRecords()
- src_rec = src_records.lookup(src_pkg)
- if src_rec:
- src_ver = src_records.version
- #if apt_pkg.VersionCompare(binver, srcver) > 0:
- # srcver = binver
- if not src_ver:
- src_ver = bin_ver
- #print "srcver: %s" % src_ver
- section = src_records.section
- #print "srcsect: %s" % section
- else:
- # fail into the error handler
- raise SystemError
except SystemError:
- src_ver = bin_ver
+ pass
+ else:
+ while src_records.lookup(src_pkg):
+ if not src_records.version:
+ continue
+ if self.candidate.source_version == src_records.version:
+ # Direct match, use it and do not do more lookups.
+ src_ver = src_records.version
+ section = src_records.section
+ break
+ if apt_pkg.version_compare(src_records.version, src_ver) > 0:
+ # The version is higher, it seems to match.
+ src_ver = src_records.version
+ section = src_records.section
section_split = section.split("/", 1)
if len(section_split) > 1: