summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2011-04-04 18:07:10 +0200
committerMichael Vogt <michael.vogt@ubuntu.com>2011-04-04 18:07:10 +0200
commit52475d3ddc835c3b543d98ee1c16df4989a4112d (patch)
treed2049afad1a8f39187fed2a60e1482cfc0a9cd65
parentc26142274b74c53e80c4680822711e2e804c6fb0 (diff)
parent9dd02cdd42eccb8c4e52f08c334df22a31c8d256 (diff)
downloadpython-apt-52475d3ddc835c3b543d98ee1c16df4989a4112d.tar.gz
merged from debian-sid
-rw-r--r--apt/cache.py27
-rw-r--r--apt/package.py42
-rw-r--r--debian/changelog44
-rw-r--r--debian/control2
-rw-r--r--debian/python3-apt-dbg.files1
-rw-r--r--debian/python3-apt-dbg.install1
-rwxr-xr-xdebian/rules11
-rw-r--r--doc/source/library/apt_pkg.rst21
-rw-r--r--python/cache.cc31
-rw-r--r--tests/test_apt_cache.py4
-rw-r--r--tests/test_debfile.py3
11 files changed, 162 insertions, 25 deletions
diff --git a/apt/cache.py b/apt/cache.py
index 4b917236..bfa41edc 100644
--- a/apt/cache.py
+++ b/apt/cache.py
@@ -65,6 +65,7 @@ class Cache(object):
self._callbacks = {}
self._weakref = weakref.WeakValueDictionary()
self._set = set()
+ self._fullnameset = set()
self._sorted_set = None
if memonly:
# force apt to build its caches in memory
@@ -129,9 +130,13 @@ class Cache(object):
self._list = apt_pkg.SourceList()
self._list.read_main_list()
self._set.clear()
+ self._fullnameset.clear()
self._sorted_set = None
self._weakref.clear()
+ self._have_multi_arch = bool(apt_pkg.config.value_list("APT::" +
+ "Architectures"))
+
progress.op = _("Building data structures")
i = last = 0
size = len(self._cache.packages)
@@ -141,7 +146,9 @@ class Cache(object):
last = i
# drop stuff with no versions (cruft)
if pkg.has_versions:
- self._set.add(pkg.name)
+ self._set.add(pkg.get_fullname(pretty=True))
+ if self._have_multi_arch:
+ self._fullnameset.add(pkg.get_fullname(pretty=False))
i += 1
@@ -153,7 +160,7 @@ class Cache(object):
try:
return self._weakref[key]
except KeyError:
- if key in self._set:
+ if key in self._set or key in self._fullnameset:
key = str(key)
pkg = self._weakref[key] = Package(self, self._cache[key])
return pkg
@@ -174,10 +181,10 @@ class Cache(object):
raise StopIteration
def has_key(self, key):
- return (key in self._set)
+ return (key in self._set or key in self._fullnameset)
def __contains__(self, key):
- return (key in self._set)
+ return (key in self._set or key in self._fullnameset)
def __len__(self):
return len(self._set)
@@ -191,10 +198,11 @@ class Cache(object):
marked_keep = self._depcache.marked_keep
for pkg in self._cache.packages:
if not marked_keep(pkg):
+ name = pkg.get_fullname(pretty=True)
try:
- changes.append(self._weakref[pkg.name])
+ changes.append(self._weakref[name])
except KeyError:
- package = self._weakref[pkg.name] = Package(self, pkg)
+ package = self._weakref[name] = Package(self, pkg)
changes.append(package)
return changes
@@ -233,7 +241,7 @@ class Cache(object):
for pkg in self._cache.packages:
cand = get_candidate_ver(pkg)
if cand and not cand.downloadable and pkg.inst_state in states:
- reqreinst.add(pkg.name)
+ reqreinst.add(pkg.get_fullname(pretty=True))
return reqreinst
def _run_fetcher(self, fetcher):
@@ -318,10 +326,11 @@ class Cache(object):
for provides, providesver, version in vp.provides_list:
pkg = version.parent_pkg
if not candidate_only or (version == get_candidate_ver(pkg)):
+ name = pkg.get_fullname(pretty=True)
try:
- providers.add(self._weakref[pkg.name])
+ providers.add(self._weakref[name])
except KeyError:
- package = self._weakref[pkg.name] = Package(self, pkg)
+ package = self._weakref[name] = Package(self, pkg)
providers.add(package)
return list(providers)
diff --git a/apt/package.py b/apt/package.py
index f16ac2a4..d7d5d167 100644
--- a/apt/package.py
+++ b/apt/package.py
@@ -374,9 +374,9 @@ class Version(object):
def source_name(self):
"""Return the name of the source package."""
try:
- return self._records.source_pkg or self.package.name
+ return self._records.source_pkg or self.package.shortname
except IndexError:
- return self.package.name
+ return self.package.shortname
@property
def source_version(self):
@@ -549,7 +549,7 @@ class Version(object):
dsc = None
record = self._records
- source_name = record.source_pkg or self.package.name
+ source_name = record.source_pkg or self.package.shortname
source_version = record.source_ver or self._cand.ver_str
source_lookup = src.lookup(source_name)
@@ -674,7 +674,8 @@ class Package(object):
self._changelog = "" # Cached changelog
def __repr__(self):
- return '<Package: name:%r id:%r>' % (self._pkg.name, self._pkg.id)
+ return '<Package: name:%r architecture=%r id:%r>' % (self._pkg.name,
+ self._pkg.architecture, self._pkg.id)
def candidate(self):
"""Return the candidate version of the package.
@@ -706,7 +707,30 @@ class Package(object):
@property
def name(self):
- """Return the name of the package."""
+ """Return the name of the package, possibly including architecture.
+
+ If the package is not part of the system's preferred architecture,
+ return the same as :attr:`fullname`, otherwise return the same
+ as :attr:`shortname`
+
+ .. versionchanged:: 0.7.100.3
+ As part of multi-arch, this field now may include architecture
+ information.
+ """
+ return self._pkg.get_fullname(True)
+
+ @property
+ def fullname(self):
+ """Return the name of the package, including architecture.
+
+ .. versionadded:: 0.7.100.3"""
+ return self._pkg.get_fullname(False)
+
+ @property
+ def shortname(self):
+ """Return the name of the package, without architecture.
+
+ .. versionadded:: 0.7.100.3"""
return self._pkg.name
@property
@@ -757,13 +781,15 @@ class Package(object):
"""
return getattr(self.installed, 'dependencies', [])
- @DeprecatedProperty
def architecture(self):
"""Return the Architecture of the package.
- .. deprecated:: 0.7.9
+ .. versionchanged:: 0.7.100.3
+ This is now the package's architecture in the multi-arch sense,
+ previously it was the architecture of the candidate version
+ and deprecated.
"""
- return getattr(self.candidate, "architecture", None)
+ return self._pkg.architecture
@DeprecatedProperty
def candidateDownloadable(self): #pylint: disable-msg=C0103
diff --git a/debian/changelog b/debian/changelog
index 6d79aef8..235a38da 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,47 @@
+python-apt (0.7.100.3ubuntu1) natty; urgency=low
+
+ * merge fixes from debian-sid, most notably the fixes
+ to support multiarch (thanks to Julian Andres Klode)
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Mon, 04 Apr 2011 16:15:15 +0200
+
+python-apt (0.7.100.3) unstable; urgency=low
+
+ [ Barry Warsaw ]
+ * PyFetchProgress::Pulse(): When ignoring a false return value from
+ PyArg_Parse() after running the simple callback pulse(), there can be
+ an exception on the stack, which must be cleared. (LP: #711225)
+
+ [ Michael Vogt ]
+ * python/arfile.cc, apt/debfile.py:
+ - add support for .xz archives
+ * tests/test_debfile.py:
+ - add test for xz compression
+ * update priority of python3-apt to match the archive
+
+ [ Julian Andres Klode ]
+ * python/cache.cc:
+ - Add Package.get_fullname() and Package.architecture
+ * apt/cache.py, apt/package.py:
+ - Add architecture property to apt.Package (LP: #703472)
+ - Change apt.Package.name to use get_fullname(pretty=True) (LP: #740072)
+ * tests/test_debfile.py:
+ - Disable multi-arch for the test, it fails when run via test_all.py
+ - Fix mixed tab/spaces indentation in xz test
+ * tests/test_apt_cache.py:
+ - Package records 'Package' field now corresponds to shortname
+ * debian/python3-apt-dbg.install
+ - Do not try to install old-style debugging files.
+ * debian/rules:
+ - Support the nocheck build option and ignore test failures on hurd
+ (Closes: #610448)
+ - Move Python 3 debug files before installing other files (Closes: #619528)
+
+ [ Scott Kitterman ]
+ * Removed ${python:Breaks} - No longer used in dh_python2
+
+ -- Julian Andres Klode <jak@debian.org> Mon, 04 Apr 2011 12:52:03 +0200
+
python-apt (0.7.100.2ubuntu4) natty; urgency=low
* fix incorrect tab, this fixes a FTBFS
diff --git a/debian/control b/debian/control
index dbfe644f..7b052bfc 100644
--- a/debian/control
+++ b/debian/control
@@ -24,7 +24,7 @@ Package: python-apt
Architecture: any
Depends: ${python:Depends}, ${shlibs:Depends}, ${misc:Depends}, python-apt-common
Recommends: lsb-release, iso-codes
-Breaks: debdelta (<< 0.28~), packagekit-backend-apt (<= 0.4.8-0ubuntu4), ${python:Breaks}
+Breaks: debdelta (<< 0.28~), packagekit-backend-apt (<= 0.4.8-0ubuntu4)
Provides: ${python:Provides}
Suggests: python-apt-dbg, python-gtk2, python-vte, python-apt-doc
XB-Python-Version: ${python:Versions}
diff --git a/debian/python3-apt-dbg.files b/debian/python3-apt-dbg.files
new file mode 100644
index 00000000..88cbfcb0
--- /dev/null
+++ b/debian/python3-apt-dbg.files
@@ -0,0 +1 @@
+usr/lib/python3*/*/*d*.so
diff --git a/debian/python3-apt-dbg.install b/debian/python3-apt-dbg.install
deleted file mode 100644
index 011ab164..00000000
--- a/debian/python3-apt-dbg.install
+++ /dev/null
@@ -1 +0,0 @@
-usr/lib/python3*/*/*_d.so
diff --git a/debian/rules b/debian/rules
index a38b4605..5428375d 100755
--- a/debian/rules
+++ b/debian/rules
@@ -11,6 +11,10 @@ export SHELL = env PATH=$(PATH) sh
override_dh_auto_build:
dh_auto_build
+override_dh_install:
+ dh_movefiles
+ dh_install
+
override_dh_installdocs:
set -e; if [ -z $(filter -a,$(DH_INTERNAL_OPTIONS)) ]; then \
python setup.py build_sphinx; \
@@ -28,10 +32,15 @@ override_dh_strip:
override_dh_compress:
dh_compress -X.js -X_static/* -X _sources/* -X_sources/*/* -X.inv
+# We ignore failures on hurd, since its locking is broken
override_dh_auto_test:
+ifeq (,$(findstring nocheck, $(DEB_BUILD_OPTIONS)))
set -e; for python in $(shell pyversions -r); do \
- $$python tests/test_all.py -q; \
+ $$python tests/test_all.py -q || [ "$(DEB_BUILD_ARCH_OS)" = "hurd" ]; \
done;
+else
+ @echo "** tests disabled"
+endif
override_dh_python2:
dh_python2 -N python-apt-common
diff --git a/doc/source/library/apt_pkg.rst b/doc/source/library/apt_pkg.rst
index 81358bac..426cb97e 100644
--- a/doc/source/library/apt_pkg.rst
+++ b/doc/source/library/apt_pkg.rst
@@ -437,18 +437,35 @@ Resolving Dependencies with :class:`ProblemResolver`
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. class:: Package
- Represent a package. A package is uniquely identified by its name
- and each package can have zero or more versions which can be
+ Represent a package. A package is uniquely identified by its name and
+ architecture and each package can have zero or more versions which can be
accessed via the :attr:`version_list` property. Packages can be
installed and removed by a :class:`DepCache` object.
Attributes:
+ .. attribute: architecture
+
+ The architecture of the package. This is relevant on multi-arch
+ systems only. Please note that if a package is Architecture: all,
+ this value is not "all", but the architecture of the package file
+ it comes from.
+
+ .. versionadded:: 0.7.100.3
+
.. attribute:: current_ver
The version currently installed as a :class:`Version` object, or None
if the package is not installed.
+ .. method:: get_fullname([pretty: bool = False]) -> str
+
+ Get the full name of the package, including the architecture. If
+ *pretty* is ``True``, the architecture is omitted for native packages,
+ that is, an amd64 "apt" package on an amd64 system would give "apt".
+
+ .. versionadded:: 0.7.100.3
+
.. attribute:: has_provides
A boolean value determining whether the list available via the
diff --git a/python/cache.cc b/python/cache.cc
index cd51fcc3..190d4f27 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -509,6 +509,7 @@ PyTypeObject PyPackageList_Type =
}
MkGet(PackageGetName,PyString_FromString(Pkg.Name()))
+MkGet(PackageGetArch,PyString_FromString(Pkg.Arch()))
MkGet(PackageGetSection,Safe_FromString(Pkg.Section()))
MkGet(PackageGetRevDependsList,CppPyObject_NEW<RDepListStruct>(Owner,
&PyDependencyList_Type, Pkg.RevDependsList()))
@@ -524,6 +525,25 @@ MkGet(PackageGetImportant,PyBool_FromLong((Pkg->Flags & pkgCache::Flag::Importan
#undef MkGet
#undef Owner
+static const char PackageGetFullName_doc[] =
+ "get_fullname([pretty: bool = False]) -> str\n\n"
+ "Get the full name of the package, including the architecture. If\n"
+ "'pretty' is True, the architecture is omitted for native packages,\n"
+ "that is, and amd64 apt package on an amd64 system would give 'apt'.";
+static PyObject *PackageGetFullName(PyObject *Self,PyObject *Args,PyObject *kwds)
+{
+ pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self);
+ char pretty = 0;
+ char *kwlist[] = {"pretty", 0};
+
+ if (PyArg_ParseTupleAndKeywords(Args, kwds, "|b", kwlist,
+ &pretty) == 0)
+ return 0;
+
+
+ return CppPyString(Pkg.FullName(pretty));
+}
+
static PyObject *PackageGetVersionList(PyObject *Self,void*)
{
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(Self);
@@ -565,9 +585,18 @@ static PyObject *PackageGetCurrentVer(PyObject *Self,void*)
Pkg.CurrentVer());
}
+
+static PyMethodDef PackageMethods[] =
+{
+ {"get_fullname",(PyCFunction)PackageGetFullName,METH_VARARGS|METH_KEYWORDS,
+ PackageGetFullName_doc},
+ {}
+};
+
static PyGetSetDef PackageGetSet[] = {
{"name",PackageGetName,0,
"The name of the package."},
+ {"architecture",PackageGetArch,0, "The architecture of the package."},
{"section",PackageGetSection,0,
"The section of the package."},
{"rev_depends_list",PackageGetRevDependsList,0,
@@ -656,7 +685,7 @@ PyTypeObject PyPackage_Type =
0, // tp_weaklistoffset
0, // tp_iter
0, // tp_iternext
- 0, // tp_methods
+ PackageMethods, // tp_methods
0, // tp_members
PackageGetSet, // tp_getset
};
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py
index cfb3ab99..cccfc9c8 100644
--- a/tests/test_apt_cache.py
+++ b/tests/test_apt_cache.py
@@ -47,10 +47,10 @@ class TestAptCache(unittest.TestCase):
# particular, when using compressed indexes, it should not use
# tons of seek operations
r = pkg.candidate.record
- self.assertEqual(r['Package'], pkg.name)
+ self.assertEqual(r['Package'], pkg.shortname)
self.assert_('Version' in r)
self.assert_(len(r['Description']) > 0)
- self.assert_(str(r).startswith('Package: %s\n' % pkg.name))
+ self.assert_(str(r).startswith('Package: %s\n' % pkg.shortname))
def test_get_provided_packages(self):
cache = apt.Cache()
diff --git a/tests/test_debfile.py b/tests/test_debfile.py
index 426bccde..5f6d1aa2 100644
--- a/tests/test_debfile.py
+++ b/tests/test_debfile.py
@@ -47,6 +47,9 @@ class TestDebfilee(unittest.TestCase):
def setUp(self):
apt_pkg.init_config()
apt_pkg.config.set("APT::Architecture","i386")
+ # FIXME: When run via test_all.py, the tests fail without this if it
+ # is set in the system.
+ apt_pkg.config.clear("APT::Architectures")
apt_pkg.config.set("Dir::State::status",
"./data/test_debs/var/lib/dpkg/status")
apt_pkg.config.set("Dir::State::lists",