summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt/debfile.py2
-rw-r--r--apt/progress/text.py14
-rw-r--r--debian/changelog14
-rw-r--r--python/depcache.cc4
-rw-r--r--tests/test_apt_cache.py6
-rw-r--r--tests/test_debfile.py12
6 files changed, 41 insertions, 11 deletions
diff --git a/apt/debfile.py b/apt/debfile.py
index 0a740c63..996a4cb3 100644
--- a/apt/debfile.py
+++ b/apt/debfile.py
@@ -531,6 +531,8 @@ class DebPackage(object):
return s
def _get_content(self, part, name, auto_decompress=True, auto_hex=True):
+ if name.startswith("./"):
+ name = name[2:]
data = part.extractdata(name)
# check for zip content
if name.endswith(".gz") and auto_decompress:
diff --git a/apt/progress/text.py b/apt/progress/text.py
index 95f18831..d777837c 100644
--- a/apt/progress/text.py
+++ b/apt/progress/text.py
@@ -15,6 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
"""Progress reporting for text interfaces."""
+import os
import sys
import apt_pkg
@@ -107,12 +108,13 @@ class AcquireProgress(base.AcquireProgress, TextProgress):
def _winch(self, *dummy):
"""Signal handler for window resize signals."""
- import fcntl
- import termios
- import struct
- buf = fcntl.ioctl(self._file, termios.TIOCGWINSZ, 8 * ' ')
- dummy, col, dummy, dummy = struct.unpack('hhhh', buf)
- self._width = col - 1 # 1 for the cursor
+ if hasattr(self._file, "fileno") and os.isatty(self._file.fileno()):
+ import fcntl
+ import termios
+ import struct
+ buf = fcntl.ioctl(self._file, termios.TIOCGWINSZ, 8 * ' ')
+ dummy, col, dummy, dummy = struct.unpack('hhhh', buf)
+ self._width = col - 1 # 1 for the cursor
def ims_hit(self, item):
"""Called when an item is update (e.g. not modified on the server)."""
diff --git a/debian/changelog b/debian/changelog
index bf07b285..69356be3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,17 @@
+python-apt (0.7.100.2) UNRELEASED; urgency=low
+
+ * apt/progress/text.py:
+ - only run ioctl for termios.TIOCGWINSZ if the fd is a tty
+ * apt/debfile.py, tests/test_debfile.py:
+ - strip "./" from _get_content and add tests, this fixes a control
+ file extraction bug in gdebi
+ * python/depcache.cc:
+ - when using the actiongroup as a contextmanager incref/decref
+ on enter and leave. this should fix the instablity issues
+ that aptdaemon runs into (LP: #691134)
+
+ -- Michael Vogt <mvo@debian.org> Tue, 07 Dec 2010 13:41:07 +0100
+
python-apt (0.7.100.1) unstable; urgency=low
[ Julian Andres Klode ]
diff --git a/python/depcache.cc b/python/depcache.cc
index 014ad7ae..a84eb615 100644
--- a/python/depcache.cc
+++ b/python/depcache.cc
@@ -989,7 +989,8 @@ static const char *actiongroup__enter__doc =
static PyObject *PkgActionGroupEnter(PyObject *Self,PyObject *Args) {
if (PyArg_ParseTuple(Args,"") == 0)
return 0;
- return Self;
+ Py_INCREF(Self);
+ return Self;
}
static const char *actiongroup__exit__doc =
@@ -999,6 +1000,7 @@ static PyObject *PkgActionGroupExit(PyObject *Self,PyObject *Args) {
pkgDepCache::ActionGroup *ag = GetCpp<pkgDepCache::ActionGroup*>(Self);
if (ag != NULL)
ag->release();
+ Py_DECREF(Self);
Py_RETURN_FALSE;
}
diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py
index 0b33a2e3..cfb3ab99 100644
--- a/tests/test_apt_cache.py
+++ b/tests/test_apt_cache.py
@@ -59,13 +59,13 @@ class TestAptCache(unittest.TestCase):
self.assertTrue(len(l) > 0)
self.assertTrue("postfix" in [p.name for p in l])
# this is a not virtual (transitional) package provided by another
- l = cache.get_providing_packages("scrollkeeper")
+ l = cache.get_providing_packages("git-core")
self.assertEqual(l, [])
# now inlcude nonvirtual packages in the search (rarian-compat
# provides scrollkeeper)
- l = cache.get_providing_packages("scrollkeeper",
+ l = cache.get_providing_packages("git-core",
include_nonvirtual=True)
- self.assertTrue(len(l), 1)
+ self.assertEqual([p.name for p in l], ["git"])
self.assertTrue("mail-transport-agent" in cache["postfix"].candidate.provides)
def test_low_level_pkg_provides(self):
diff --git a/tests/test_debfile.py b/tests/test_debfile.py
index 759639c4..712c4958 100644
--- a/tests/test_debfile.py
+++ b/tests/test_debfile.py
@@ -100,7 +100,17 @@ class TestDebfilee(unittest.TestCase):
deb.open(os.path.join("data", "test_debs", "gdebi-test12.deb"))
content = deb.data_content("usr/bin/binary")
self.assertTrue(content.startswith("Automatically converted to printable ascii:\n\x7fELF "))
-
+ # control file
+ needle = """Package: gdebi-test12
+Version: 1.0
+Architecture: all
+Description: testpackage for gdebi - contains usr/bin/binary for file reading
+ This tests the binary file reading for debfile.py
+"""
+ content = deb.control_content("./control")
+ self.assertEqual(content, needle)
+ content = deb.control_content("control")
+ self.assertEqual(content, needle)
if __name__ == "__main__":
#logging.basicConfig(level=logging.DEBUG)