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
=== modified file 'lib/canonical/buildd/buildrecipe'
--- lib/canonical/buildd/buildrecipe 2010-09-09 14:12:02 +0000
+++ lib/canonical/buildd/buildrecipe 2010-10-19 18:01:48 +0000
@@ -7,10 +7,12 @@
7__metaclass__ = type7__metaclass__ = type
88
99
10import errno
10import os11import os
11import pwd12import pwd
13import re
12import socket14import socket
13from subprocess import call15from subprocess import call, Popen, PIPE
14import sys16import sys
1517
1618
@@ -21,6 +23,26 @@
21RETCODE_FAILURE_BUILD_SOURCE_PACKAGE = 20323RETCODE_FAILURE_BUILD_SOURCE_PACKAGE = 203
2224
2325
26class NotVirtualized(Exception):
27 """Exception raised when not running in a virtualized environment."""
28
29
30class NoXenDetect(NotVirtualized):
31 """xen-detect not installed."""
32
33 def __init__(self):
34 NotVirtualized.__init__(self, 'xen-detect is not installed.')
35
36
37class BadXenDetect(NotVirtualized):
38 """xen-detect's output not not indicate that we are virtualized."""
39
40 def __init__(self, xen_detect_output):
41 NotVirtualized.__init__(
42 self, 'Bad xen-detect output: %s' % xen_detect_output)
43 self.xen_detect_output = xen_detect_output
44
45
24class RecipeBuilder:46class RecipeBuilder:
25 """Builds a package from a recipe."""47 """Builds a package from a recipe."""
2648
@@ -64,6 +86,12 @@
64 As a side-effect, sets self.source_dir_relative.86 As a side-effect, sets self.source_dir_relative.
65 :return: a retcode from `bzr dailydeb`.87 :return: a retcode from `bzr dailydeb`.
66 """88 """
89 try:
90 ensure_virtualized()
91 except NotVirtualized, e:
92 sys.stderr.write('Aborting on failed virtualization check:\n')
93 sys.stderr.write(str(e))
94 return 1
67 assert not os.path.exists(self.tree_path)95 assert not os.path.exists(self.tree_path)
68 recipe_path = os.path.join(self.work_dir, 'recipe')96 recipe_path = os.path.join(self.work_dir, 'recipe')
69 manifest_path = os.path.join(self.tree_path, 'manifest')97 manifest_path = os.path.join(self.tree_path, 'manifest')
@@ -159,6 +187,24 @@
159 return os.path.join(187 return os.path.join(
160 os.environ["HOME"], "build-" + build_id, *extra)188 os.environ["HOME"], "build-" + build_id, *extra)
161189
190
191def ensure_virtualized():
192 """Raise an exception if not running in a virtualized environment.
193
194 Raises if unsure, or if not running under Xen.
195 """
196 try:
197 proc = Popen(['xen-detect'], stdout=PIPE)
198 except OSError, e:
199 if e.errno != errno.ENOENT:
200 raise
201 raise NoXenDetect()
202 status_code = proc.wait()
203 output = proc.stdout.read()
204 if not re.match('Running in .* context on Xen', output):
205 raise BadXenDetect(output)
206
207
162if __name__ == '__main__':208if __name__ == '__main__':
163 builder = RecipeBuilder(*sys.argv[1:])209 builder = RecipeBuilder(*sys.argv[1:])
164 if builder.buildTree() != 0:210 if builder.buildTree() != 0: