Merge lp:~aptdaemon-developers/python-apt/fix-cannot-locate-file into lp:~mvo/python-apt/debian-sid-mirrored

Proposed by Sebastian Heinlein
Status: Merged
Merged at revision: 584
Proposed branch: lp:~aptdaemon-developers/python-apt/fix-cannot-locate-file
Merge into: lp:~mvo/python-apt/debian-sid-mirrored
Diff against target: 98 lines (+70/-2)
3 files modified
apt/cache.py (+1/-0)
python/depcache.cc (+1/-2)
tests/test_lp659438.py (+68/-0)
To merge this branch: bzr merge lp:~aptdaemon-developers/python-apt/fix-cannot-locate-file
Reviewer Review Type Date Requested Status
Michael Vogt Pending
Review via email: mp+102146@code.launchpad.net

Description of the change

Highly requested fix for aptdaemon hanging on cancelled debconf questions!

To post a comment you must log in.
Revision history for this message
Michael Vogt (mvo) wrote :

Thanks a lot for finding this bug! I think the fix is not ideal as it will init the depcache twice,
we probably want to export pkgApplyStatus instead.

The code in python-apt cache.cc creates a new pkgCacheFile() and runs Open() on that which will in
turn run pkgDepCache.init(). But it will not run "pkgApplyStatus()" (maybe it should?).

Revision history for this message
Michael Vogt (mvo) wrote :

I think this commit here:
http://bazaar.launchpad.net/~mvo/python-apt/mvo/revision/600
will have the same effect without the need to call "Init()" twice, if you could help me how to reproduce
the actual error I'm happy to merge it and create a python-apt regression test. For some reason the test
inside aptdaemon does not fail for me, even without a updated python-apt :/

Revision history for this message
Sebastian Heinlein (glatzor) wrote :

Hello Michael,

Attached is a regression test for python-apt: It needs to be copied to
the tests directory since it re-uses the test-repo.

Cheers,

Sebastian

583. By Sebastian Heinlein

Add a regression test

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'apt/cache.py'
2--- apt/cache.py 2012-03-28 08:19:51 +0000
3+++ apt/cache.py 2012-04-17 18:39:19 +0000
4@@ -144,6 +144,7 @@
5
6 self._cache = apt_pkg.Cache(progress)
7 self._depcache = apt_pkg.DepCache(self._cache)
8+ self._depcache.init(progress)
9 self._records = apt_pkg.PackageRecords(self._cache)
10 self._list = apt_pkg.SourceList()
11 self._list.read_main_list()
12
13=== modified file 'python/depcache.cc'
14--- python/depcache.cc 2011-11-10 16:20:58 +0000
15+++ python/depcache.cc 2012-04-17 18:39:19 +0000
16@@ -568,8 +568,7 @@
17 {
18 {"init",PkgDepCacheInit,METH_VARARGS,
19 "init(progress: apt.progress.base.OpProgress)\n\n"
20- "Initialize the depcache (done automatically when constructing\n"
21- "the object)."},
22+ "Initialize the depcache."},
23 {"get_candidate_ver",PkgDepCacheGetCandidateVer,METH_VARARGS,
24 "get_candidate_ver(pkg: apt_pkg.Package) -> apt_pkg.Version\n\n"
25 "Return the candidate version for the package, normally the version\n"
26
27=== added file 'tests/test_lp659438.py'
28--- tests/test_lp659438.py 1970-01-01 00:00:00 +0000
29+++ tests/test_lp659438.py 2012-04-17 18:39:19 +0000
30@@ -0,0 +1,68 @@
31+#!/usr/bin/env python
32+# -*- coding: utf-8 -*-
33+"""Regression test for LP: #981896, LP: #659438"""
34+# Copyright (C) 2012 Sebastian Heinlein <devel@glatzor.de>
35+#
36+# Licensed under the GNU General Public License Version 2
37+#
38+# This program is free software; you can redistribute it and/or modify
39+# it under the terms of the GNU General Public License as published by
40+# the Free Software Foundation; either version 2 of the License, or
41+# at your option) any later version.
42+#
43+# This program is distributed in the hope that it will be useful,
44+# but WITHOUT ANY WARRANTY; without even the implied warranty of
45+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
46+# GNU General Public License for more details.
47+#
48+# You should have received a copy of the GNU General Public License
49+# along with this program; if not, write to the Free Software
50+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
51+# Licensed under the GNU General Public License Version 2
52+
53+__author__ = "Sebastian Heinlein <devel@glatzor.de>"
54+
55+import os
56+import shutil
57+import tempfile
58+import unittest
59+
60+import apt_pkg
61+import apt
62+
63+
64+class RegressionTestCase(unittest.TestCase):
65+
66+ """Test suite for LP: #981896, LP: #659438
67+ 'Cannot locate a file for package X'
68+ """
69+
70+ def setUp(self):
71+ apt_pkg.init_config()
72+ chroot_path = tempfile.mkdtemp()
73+ self.addCleanup(lambda: shutil.rmtree(chroot_path))
74+ # Create a damaged status file
75+ self.cache = apt.cache.Cache(rootdir=chroot_path)
76+ with open(apt_pkg.config.find_file("Dir::State::status"),
77+ "a") as status:
78+ status.write("""Package: abrowser
79+Status: install reinstreq half-installed
80+Priority: optional
81+Section: admin
82+Version: 3.6.9+build1+nobinonly-0ubuntu1""")
83+ sources_list_path = apt_pkg.config.find_file("Dir::Etc::sourcelist")
84+ repo_path = os.path.abspath("./data/test-repo")
85+ with open(sources_list_path, "w") as sources_list:
86+ sources_list.write("deb copy:%s /\n" % repo_path)
87+ # os.makedirs(os.path.join(chroot_path, "etc/apt/sources.list.d/"))
88+ self.cache.update(sources_list=sources_list_path)
89+ self.cache.open()
90+
91+ def test_survive_reqreinst(self):
92+ """Test that we survive a package in require reinstallation state"""
93+ self.assertEqual(self.cache.required_download, 82324L)
94+
95+if __name__ == "__main__":
96+ unittest.main()
97+
98+# vim: ts=4 et sts=4

Subscribers

People subscribed via source and target branches