summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Vogt <michael.vogt@ubuntu.com>2012-05-04 10:03:14 -0700
committerMichael Vogt <michael.vogt@ubuntu.com>2012-05-04 10:03:14 -0700
commit0bec8751cd24d4308f5f5727b0197101619a70f2 (patch)
tree9cce6bee1a6bd9772047ead44fb34d82696125b8
parent0165191e08c650bb81c06660845114cec3738dce (diff)
parent8c17defbb7ef82f5791cf37973c9b26a367359ea (diff)
downloadpython-apt-0bec8751cd24d4308f5f5727b0197101619a70f2.tar.gz
merged from the mvo branch
-rw-r--r--debian/changelog8
-rw-r--r--po/python-apt.pot10
-rw-r--r--python/cache.cc7
-rw-r--r--tests/test_lp659438.py74
4 files changed, 93 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog
index c1b12cc8..63f72fa5 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,11 @@
+python-apt (0.8.5) UNRELEASED; urgency=low
+
+ * python/cache.cc:
+ - ensure that pkgApplyStatus is called when the cache is opened
+ (thanks to Sebastian Heinlein for finding this bug), LP: #659438
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 17 Apr 2012 14:09:24 +0200
+
python-apt (0.8.4) unstable; urgency=low
[ Michael Vogt ]
diff --git a/po/python-apt.pot b/po/python-apt.pot
index bde5f9c1..00637f52 100644
--- a/po/python-apt.pot
+++ b/po/python-apt.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2012-02-06 14:56+0100\n"
+"POT-Creation-Date: 2012-04-17 21:15+0200\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -455,11 +455,11 @@ msgstr ""
msgid "Invalid unicode in description for '%s' (%s). Please report."
msgstr ""
-#: ../apt/package.py:1085 ../apt/package.py:1191
+#: ../apt/package.py:1088 ../apt/package.py:1194
msgid "The list of changes is not available"
msgstr ""
-#: ../apt/package.py:1197
+#: ../apt/package.py:1200
#, python-format
msgid ""
"The list of changes is not available yet.\n"
@@ -468,7 +468,7 @@ msgid ""
"until the changes become available or try again later."
msgstr ""
-#: ../apt/package.py:1204
+#: ../apt/package.py:1207
msgid ""
"Failed to download the list of changes. \n"
"Please check your Internet connection."
@@ -606,6 +606,6 @@ msgstr ""
msgid "Please insert a Disc in the drive and press enter"
msgstr ""
-#: ../apt/cache.py:158
+#: ../apt/cache.py:157
msgid "Building data structures"
msgstr ""
diff --git a/python/cache.cc b/python/cache.cc
index 191e2204..c51bd4af 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -198,11 +198,13 @@ static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args)
}
//std::cout << "new cache is " << (pkgCache*)(*Cache) << std::endl;
+
+ // ensure that the states are correct (LP: #659438)
+ pkgApplyStatus(*Cache);
// update the cache pointer after the cache was rebuild
((CppPyObject<pkgCache*> *)Self)->Object = (pkgCache*)(*Cache);
-
Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -401,6 +403,9 @@ static PyObject *PkgCacheNew(PyTypeObject *type,PyObject *Args,PyObject *kwds)
return HandleErrors();
}
+ // ensure that the states are correct (LP: #659438)
+ pkgApplyStatus(*Cache);
+
CppPyObject<pkgCacheFile*> *CacheFileObj =
CppPyObject_NEW<pkgCacheFile*>(0,&PyCacheFile_Type, Cache);
diff --git a/tests/test_lp659438.py b/tests/test_lp659438.py
new file mode 100644
index 00000000..01edf3bd
--- /dev/null
+++ b/tests/test_lp659438.py
@@ -0,0 +1,74 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+"""Regression test for LP: #981896, LP: #659438"""
+# Copyright (C) 2012 Sebastian Heinlein <devel@glatzor.de>
+#
+# Licensed under the GNU General Public License Version 2
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+# Licensed under the GNU General Public License Version 2
+
+__author__ = "Sebastian Heinlein <devel@glatzor.de>"
+
+import os
+import shutil
+import tempfile
+import unittest
+
+import apt_pkg
+import apt
+
+
+class RegressionTestCase(unittest.TestCase):
+
+ """Test suite for LP: #981896, LP: #659438
+ 'Cannot locate a file for package X'
+ """
+
+ def setUp(self):
+ apt_pkg.init_config()
+ chroot_path = tempfile.mkdtemp()
+ self.addCleanup(lambda: shutil.rmtree(chroot_path))
+ # Create a damaged status file
+ self.cache = apt.cache.Cache(rootdir=chroot_path)
+ with open(apt_pkg.config.find_file("Dir::State::status"),
+ "a") as status:
+ status.write("""Package: abrowser
+Status: install reinstreq half-installed
+Priority: optional
+Section: admin
+Version: 3.6.9+build1+nobinonly-0ubuntu1""")
+ sources_list_path = apt_pkg.config.find_file("Dir::Etc::sourcelist")
+ repo_path = os.path.abspath("./data/test-repo")
+ with open(sources_list_path, "w") as sources_list:
+ sources_list.write("deb copy:%s /\n" % repo_path)
+ # os.makedirs(os.path.join(chroot_path, "etc/apt/sources.list.d/"))
+ self.cache.update(sources_list=sources_list_path)
+ self.cache.open()
+
+ def tearDown(self):
+ # this resets the rootdir apt_pkg.config to ensure it does not
+ # "pollute" the later tests
+ cache = apt.cache.Cache(rootdir="/")
+
+ def test_survive_reqreinst(self):
+ """Test that we survive a package in require reinstallation state"""
+ # this should be 82324L but python3.2 gets unhappy about the "L"
+ self.assertEqual(self.cache.required_download, 82324)
+
+if __name__ == "__main__":
+ unittest.main()
+
+# vim: ts=4 et sts=4