Merge lp:~aptdaemon-developers/aptdaemon/non-blocking-lintian into lp:aptdaemon

Proposed by Sebastian Heinlein
Status: Merged
Merged at revision: 697
Proposed branch: lp:~aptdaemon-developers/aptdaemon/non-blocking-lintian
Merge into: lp:aptdaemon
Diff against target: 69 lines (+19/-22)
2 files modified
aptdaemon/worker.py (+17/-21)
tests/test_worker.py (+2/-1)
To merge this branch: bzr merge lp:~aptdaemon-developers/aptdaemon/non-blocking-lintian
Reviewer Review Type Date Requested Status
Aptdaemon Developers Pending
Review via email: mp+75886@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'aptdaemon/worker.py'
2--- aptdaemon/worker.py 2011-09-07 06:51:27 +0000
3+++ aptdaemon/worker.py 2011-09-18 08:20:27 +0000
4@@ -1123,26 +1123,22 @@
5 fatal_args = ["/usr/bin/lintian", "--tags-from-file",
6 tags_fatal_file, "--no-override", path]
7 for lintian_args in (nonfatal_args, fatal_args):
8- pid, master = os.forkpty()
9- if pid == 0:
10- mainloop.quit()
11- os.seteuid(uid)
12- os.execv("/usr/bin/lintian", lintian_args)
13- os._exit(2)
14- else:
15- output_fd = os.fdopen(master)
16- try:
17- output = output_fd.read()
18- except IOError:
19- output = ""
20- finally:
21- output_fd.close()
22- pid, status = os.waitpid(pid, 0)
23- #FIXME: Add an error to catch return state 2 (failure)
24- if os.WEXITSTATUS(status) == 1:
25- raise TransactionFailed(ERROR_INVALID_PACKAGE_FILE,
26- "Lintian check results for %s:"
27- "\n%s" % (path, output))
28+ proc = subprocess.Popen(lintian_args,
29+ stderr=subprocess.STDOUT,
30+ stdout=subprocess.PIPE, close_fds=True,
31+ preexec_fn=lambda: os.setuid(uid))
32+ while proc.poll() is None:
33+ while gobject.main_context_default().pending():
34+ gobject.main_context_default().iteration()
35+ time.sleep(0.05)
36+ #FIXME: Add an error to catch return state 2 (failure)
37+ if proc.returncode == 1:
38+ stdout = unicode(proc.stdout.read(),
39+ sys.stdin.encoding or "UTF-8",
40+ errors="replace")
41+ raise TransactionFailed(ERROR_INVALID_PACKAGE_FILE,
42+ "Lintian check results for %s:"
43+ "\n%s" % (path, stdout))
44 try:
45 deb = apt.debfile.DebPackage(path, self._cache)
46 except IOError:
47@@ -1153,7 +1149,7 @@
48 raise TransactionFailed(ERROR_DEP_RESOLUTION_FAILED,
49 deb._failure_string)
50 return deb
51-
52+
53 def clean(self, trans):
54 """Clean the download directories.
55
56
57=== modified file 'tests/test_worker.py'
58--- tests/test_worker.py 2011-08-25 22:10:35 +0000
59+++ tests/test_worker.py 2011-09-18 08:20:27 +0000
60@@ -254,7 +254,8 @@
61 try:
62 self.worker.simulate(trans)
63 except errors.TransactionFailed, error:
64- self.assertEqual(error.code, enums.ERROR_INVALID_PACKAGE_FILE)
65+ self.assertEqual(error.code, enums.ERROR_INVALID_PACKAGE_FILE,
66+ error)
67 else:
68 raise Exception("Lintian failed to detect a broken package")
69 # Now allow to install invalid packages

Subscribers

People subscribed via source and target branches

to status/vote changes: