Merge lp:~abentley/launchpad/detect-xen into lp:launchpad

Proposed by LaMont Jones
Status: Rejected
Rejected by: Paul Hummer
Proposed branch: lp:~abentley/launchpad/detect-xen
Merge into: lp:launchpad
Diff against target: 82 lines (+47/-1)
1 file modified
lib/canonical/buildd/buildrecipe (+47/-1)
To merge this branch: bzr merge lp:~abentley/launchpad/detect-xen
Reviewer Review Type Date Requested Status
Paul Hummer (community) Disapprove
Review via email: mp+38867@code.launchpad.net

Description of the change

launchpad-buildd releases from launchpad/devel, not launchpad.

To post a comment you must log in.
Revision history for this message
Paul Hummer (rockstar) :
review: Approve
Revision history for this message
Paul Hummer (rockstar) wrote :

After talking with Aaron, I think there's a social change that needs to occur. We should be deploying from db-stable, and really, we should break out the buildd code into its own branch, since it's causing so many problems.

review: Disapprove

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/canonical/buildd/buildrecipe'
2--- lib/canonical/buildd/buildrecipe 2010-09-09 14:12:02 +0000
3+++ lib/canonical/buildd/buildrecipe 2010-10-19 18:01:48 +0000
4@@ -7,10 +7,12 @@
5 __metaclass__ = type
6
7
8+import errno
9 import os
10 import pwd
11+import re
12 import socket
13-from subprocess import call
14+from subprocess import call, Popen, PIPE
15 import sys
16
17
18@@ -21,6 +23,26 @@
19 RETCODE_FAILURE_BUILD_SOURCE_PACKAGE = 203
20
21
22+class NotVirtualized(Exception):
23+ """Exception raised when not running in a virtualized environment."""
24+
25+
26+class NoXenDetect(NotVirtualized):
27+ """xen-detect not installed."""
28+
29+ def __init__(self):
30+ NotVirtualized.__init__(self, 'xen-detect is not installed.')
31+
32+
33+class BadXenDetect(NotVirtualized):
34+ """xen-detect's output not not indicate that we are virtualized."""
35+
36+ def __init__(self, xen_detect_output):
37+ NotVirtualized.__init__(
38+ self, 'Bad xen-detect output: %s' % xen_detect_output)
39+ self.xen_detect_output = xen_detect_output
40+
41+
42 class RecipeBuilder:
43 """Builds a package from a recipe."""
44
45@@ -64,6 +86,12 @@
46 As a side-effect, sets self.source_dir_relative.
47 :return: a retcode from `bzr dailydeb`.
48 """
49+ try:
50+ ensure_virtualized()
51+ except NotVirtualized, e:
52+ sys.stderr.write('Aborting on failed virtualization check:\n')
53+ sys.stderr.write(str(e))
54+ return 1
55 assert not os.path.exists(self.tree_path)
56 recipe_path = os.path.join(self.work_dir, 'recipe')
57 manifest_path = os.path.join(self.tree_path, 'manifest')
58@@ -159,6 +187,24 @@
59 return os.path.join(
60 os.environ["HOME"], "build-" + build_id, *extra)
61
62+
63+def ensure_virtualized():
64+ """Raise an exception if not running in a virtualized environment.
65+
66+ Raises if unsure, or if not running under Xen.
67+ """
68+ try:
69+ proc = Popen(['xen-detect'], stdout=PIPE)
70+ except OSError, e:
71+ if e.errno != errno.ENOENT:
72+ raise
73+ raise NoXenDetect()
74+ status_code = proc.wait()
75+ output = proc.stdout.read()
76+ if not re.match('Running in .* context on Xen', output):
77+ raise BadXenDetect(output)
78+
79+
80 if __name__ == '__main__':
81 builder = RecipeBuilder(*sys.argv[1:])
82 if builder.buildTree() != 0: