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

Subscribers

People subscribed via source and target branches