1 |
This also allows cleaning up a few funcs from the support module |
2 |
as they were only lightly used in stagebase. |
3 |
--- |
4 |
catalyst/base/stagebase.py | 262 ++++++++++++++++++++++----------------------- |
5 |
catalyst/defaults.py | 2 - |
6 |
catalyst/support.py | 16 +-- |
7 |
3 files changed, 128 insertions(+), 152 deletions(-) |
8 |
|
9 |
diff --git a/catalyst/base/stagebase.py b/catalyst/base/stagebase.py |
10 |
index 3ce7dba..e7514e2 100644 |
11 |
--- a/catalyst/base/stagebase.py |
12 |
+++ b/catalyst/base/stagebase.py |
13 |
@@ -13,10 +13,11 @@ from snakeoil import fileutils |
14 |
|
15 |
from DeComp.compress import CompressMap |
16 |
|
17 |
+from catalyst import log |
18 |
from catalyst.defaults import (SOURCE_MOUNT_DEFAULTS, TARGET_MOUNT_DEFAULTS, |
19 |
PORT_LOGDIR_CLEAN) |
20 |
-from catalyst.support import (CatalystError, msg, file_locate, normpath, |
21 |
- cmd, warn, list_bashify, read_makeconf, ismount, file_check) |
22 |
+from catalyst.support import (CatalystError, file_locate, normpath, |
23 |
+ cmd, list_bashify, read_makeconf, ismount, file_check) |
24 |
from catalyst.base.targetbase import TargetBase |
25 |
from catalyst.base.clearbase import ClearBase |
26 |
from catalyst.base.genbase import GenBase |
27 |
@@ -97,7 +98,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
28 |
# This message should probably change a bit, since everything in |
29 |
# the dir should load just fine. If it doesn't, it's probably a |
30 |
# syntax error in the module |
31 |
- msg("Can't find/load " + x + ".py plugin in " + arch_dir) |
32 |
+ log.warning("Can't find/load %s.py plugin in %s", x, arch_dir) |
33 |
|
34 |
if "chost" in self.settings: |
35 |
hostmachine = self.settings["chost"].split("-")[0] |
36 |
@@ -123,23 +124,22 @@ class StageBase(TargetBase, ClearBase, GenBase): |
37 |
try: |
38 |
self.arch=self.subarchmap[self.settings["subarch"]](self.settings) |
39 |
except KeyError: |
40 |
- print "Invalid subarch: "+self.settings["subarch"] |
41 |
- print "Choose one of the following:", |
42 |
- for x in self.subarchmap: |
43 |
- print x, |
44 |
- print |
45 |
- sys.exit(2) |
46 |
- |
47 |
- print "Using target:",self.settings["target"] |
48 |
+ log.critical( |
49 |
+ 'Invalid subarch: %s\n' |
50 |
+ 'Choose one of the following:\n' |
51 |
+ ' %s', |
52 |
+ self.settings['subarch'], ' '.join(self.subarchmap)) |
53 |
+ |
54 |
+ log.notice('Using target: %s', self.settings['target']) |
55 |
# Print a nice informational message |
56 |
if self.settings["buildarch"]==self.settings["hostarch"]: |
57 |
- print "Building natively for",self.settings["hostarch"] |
58 |
+ log.info('Building natively for %s', self.settings['hostarch']) |
59 |
elif self.settings["crosscompile"]: |
60 |
- print "Cross-compiling on",self.settings["buildarch"],\ |
61 |
- "for different machine type",self.settings["hostarch"] |
62 |
+ log.info('Cross-compiling on %s for different machine type %s', |
63 |
+ self.settings['buildarch'], self.settings['hostarch']) |
64 |
else: |
65 |
- print "Building on",self.settings["buildarch"],\ |
66 |
- "for alternate personality type",self.settings["hostarch"] |
67 |
+ log.info('Building on %s for alternate personality type %s', |
68 |
+ self.settings['buildarch'], self.settings['hostarch']) |
69 |
|
70 |
# This must be set first as other set_ options depend on this |
71 |
self.set_spec_prefix() |
72 |
@@ -218,15 +218,13 @@ class StageBase(TargetBase, ClearBase, GenBase): |
73 |
# the command line). |
74 |
if "pkgcache" in self.settings["options"]: |
75 |
self.set_pkgcache_path() |
76 |
- print "Location of the package cache is "+\ |
77 |
- self.settings["pkgcache_path"] |
78 |
+ log.info('Location of the package cache is %s', self.settings['pkgcache_path']) |
79 |
self.mounts.append("packagedir") |
80 |
self.mountmap["packagedir"] = self.settings["pkgcache_path"] |
81 |
|
82 |
if "kerncache" in self.settings["options"]: |
83 |
self.set_kerncache_path() |
84 |
- print "Location of the kerncache is "+\ |
85 |
- self.settings["kerncache_path"] |
86 |
+ log.info('Location of the kerncache is %s', self.settings['kerncache_path']) |
87 |
self.mounts.append("kerncache") |
88 |
self.mountmap["kerncache"] = self.settings["kerncache_path"] |
89 |
|
90 |
@@ -344,8 +342,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
91 |
"/builds/"+self.settings["target_subpath"]) |
92 |
if "autoresume" in self.settings["options"]\ |
93 |
and self.resume.is_enabled("setup_target_path"): |
94 |
- print \ |
95 |
- "Resume point detected, skipping target path setup operation..." |
96 |
+ log.notice('Resume point detected, skipping target path setup operation...') |
97 |
else: |
98 |
# First clean up any existing target stuff |
99 |
# XXX WTF are we removing the old tarball before we start building the |
100 |
@@ -406,8 +403,8 @@ class StageBase(TargetBase, ClearBase, GenBase): |
101 |
self.settings["fstype"]="normal" |
102 |
for x in self.valid_values: |
103 |
if x == self.settings["spec_prefix"]+"/fstype": |
104 |
- print "\n"+self.settings["spec_prefix"]+\ |
105 |
- "/fstype is being set to the default of \"normal\"\n" |
106 |
+ log.info('%s/fstype is being set to the default of "normal"', |
107 |
+ self.settings['spec_prefix']) |
108 |
|
109 |
def set_fsops(self): |
110 |
if "fstype" in self.settings: |
111 |
@@ -435,13 +432,14 @@ class StageBase(TargetBase, ClearBase, GenBase): |
112 |
self.settings["hash_map"].generate_hash( |
113 |
self.settings["source_path"], |
114 |
hash_=self.settings["hash_function"]) |
115 |
- print "Source path set to "+self.settings["source_path"] |
116 |
+ log.info('Source path set to %s', self.settings['source_path']) |
117 |
if os.path.isdir(self.settings["source_path"]): |
118 |
- print "\tIf this is not desired, remove this directory or turn off" |
119 |
- print "\tseedcache in the options of catalyst.conf the source path" |
120 |
- print "\twill then be "+\ |
121 |
- normpath(self.settings["storedir"]+"/builds/"+\ |
122 |
- self.settings["source_subpath"]+"\n") |
123 |
+ log.warning( |
124 |
+ 'If this is not desired, remove this directory or turn off\n' |
125 |
+ 'seedcache in the options of catalyst.conf the source path\n' |
126 |
+ 'will then be %s', |
127 |
+ normpath(self.settings['storedir'] + '/builds/' + |
128 |
+ self.settings['source_subpath'])) |
129 |
|
130 |
def set_dest_path(self): |
131 |
if "root_path" in self.settings: |
132 |
@@ -458,7 +456,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
133 |
self.settings["snapshot_path"]= file_check(normpath(self.settings["storedir"]+\ |
134 |
"/snapshots/" + self.settings["snapshot_name"] + |
135 |
self.settings["snapshot"])) |
136 |
- print "*** SNAPSHOT_PATH set to:", self.settings["snapshot_path"] |
137 |
+ log.info('SNAPSHOT_PATH set to: %s', self.settings['snapshot_path']) |
138 |
self.settings["snapshot_path_hash"] = \ |
139 |
self.settings["hash_map"].generate_hash( |
140 |
self.settings["snapshot_path"], |
141 |
@@ -474,7 +472,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
142 |
self.settings["snapshot"])) |
143 |
self.snapcache_lock=\ |
144 |
LockDir(self.settings["snapshot_cache_path"]) |
145 |
- print "Setting snapshot cache to "+self.settings["snapshot_cache_path"] |
146 |
+ log.info('Setting snapshot cache to %s', self.settings['snapshot_cache_path']) |
147 |
|
148 |
def set_chroot_path(self): |
149 |
""" |
150 |
@@ -493,7 +491,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
151 |
self.settings["version_stamp"]) |
152 |
)) |
153 |
if "autoresume" in self.settings["options"]: |
154 |
- print "The autoresume path is " + self.settings["autoresume_path"] |
155 |
+ log.info('The autoresume path is %s', self.settings['autoresume_path']) |
156 |
self.resume = AutoResume(self.settings["autoresume_path"], mode=0755) |
157 |
|
158 |
def set_controller_file(self): |
159 |
@@ -582,8 +580,8 @@ class StageBase(TargetBase, ClearBase, GenBase): |
160 |
if type(self.settings["portage_overlay"])==types.StringType: |
161 |
self.settings["portage_overlay"]=\ |
162 |
self.settings["portage_overlay"].split() |
163 |
- print "portage_overlay directories are set to: \""+\ |
164 |
- ' '.join(self.settings["portage_overlay"])+"\"" |
165 |
+ log.info('portage_overlay directories are set to: %s', |
166 |
+ ' '.join(self.settings['portage_overlay'])) |
167 |
|
168 |
def set_overlay(self): |
169 |
if self.settings["spec_prefix"]+"/overlay" in self.settings: |
170 |
@@ -639,7 +637,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
171 |
del self.settings[self.settings["spec_prefix"]+"/gk_mainargs"] |
172 |
|
173 |
def kill_chroot_pids(self): |
174 |
- print "Checking for processes running in chroot and killing them." |
175 |
+ log.info('Checking for processes running in chroot and killing them.') |
176 |
|
177 |
# Force environment variables to be exported so script can see them |
178 |
self.setup_environment() |
179 |
@@ -659,23 +657,23 @@ class StageBase(TargetBase, ClearBase, GenBase): |
180 |
if not os.path.exists(self.settings["chroot_path"]): |
181 |
return |
182 |
|
183 |
- #print "self.mounts =", self.mounts |
184 |
+ log.debug('self.mounts = %s', self.mounts) |
185 |
for x in self.mounts: |
186 |
target = normpath(self.settings["chroot_path"] + self.target_mounts[x]) |
187 |
- #print "mount_safety_check() x =", x, target |
188 |
+ log.debug('mount_safety_check() x = %s %s', x, target) |
189 |
if not os.path.exists(target): |
190 |
continue |
191 |
|
192 |
if ismount(target): |
193 |
# Something is still mounted |
194 |
try: |
195 |
- print target + " is still mounted; performing auto-bind-umount...", |
196 |
+ log.warning('%s is still mounted; performing auto-bind-umount...', target) |
197 |
# Try to umount stuff ourselves |
198 |
self.unbind() |
199 |
if ismount(target): |
200 |
raise CatalystError("Auto-unbind failed for " + target) |
201 |
else: |
202 |
- print "Auto-unbind successful..." |
203 |
+ log.notice('Auto-unbind successful...') |
204 |
except CatalystError: |
205 |
raise CatalystError("Unable to auto-unbind " + target) |
206 |
|
207 |
@@ -691,8 +689,9 @@ class StageBase(TargetBase, ClearBase, GenBase): |
208 |
'auto-ext': False, |
209 |
} |
210 |
|
211 |
- display_msg="\nStarting %(mode)s from %(source)s\nto "+\ |
212 |
- "%(destination)s (This may take some time) ...\n" |
213 |
+ display_msg = ( |
214 |
+ 'Starting %(mode)s from %(source)s\nto ' |
215 |
+ '%(destination)s (this may take some time) ..') |
216 |
|
217 |
error_msg="'%(mode)s' extraction of %(source)s to %(destination)s failed." |
218 |
|
219 |
@@ -702,7 +701,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
220 |
unpack_info['mode'] = "rsync" |
221 |
else: |
222 |
# SEEDCACHE is a not a directory, try untar'ing |
223 |
- print "Referenced SEEDCACHE does not appear to be a directory, trying to untar..." |
224 |
+ log.notice('Referenced SEEDCACHE does not appear to be a directory, trying to untar...') |
225 |
unpack_info['source'] = file_check(unpack_info['source']) |
226 |
else: |
227 |
# No SEEDCACHE, use tar |
228 |
@@ -764,7 +763,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
229 |
|
230 |
if invalid_snapshot: |
231 |
if "autoresume" in self.settings["options"]: |
232 |
- print "No Valid Resume point detected, cleaning up..." |
233 |
+ log.notice('No Valid Resume point detected, cleaning up...') |
234 |
|
235 |
self.clear_autoresume() |
236 |
self.clear_chroot() |
237 |
@@ -779,11 +778,11 @@ class StageBase(TargetBase, ClearBase, GenBase): |
238 |
if "kerncache" in self.settings["options"]: |
239 |
ensure_dirs(self.settings["kerncache_path"],mode=0755) |
240 |
|
241 |
- print display_msg %(unpack_info) |
242 |
+ log.notice('%s', display_msg % unpack_info) |
243 |
|
244 |
# now run the decompressor |
245 |
if not self.decompressor.extract(unpack_info): |
246 |
- print error_msg %(unpack_info) |
247 |
+ log.error('%s', error_msg % unpack_info) |
248 |
|
249 |
if "source_path_hash" in self.settings: |
250 |
self.resume.enable("unpack", |
251 |
@@ -791,7 +790,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
252 |
else: |
253 |
self.resume.enable("unpack") |
254 |
else: |
255 |
- print "Resume point detected, skipping unpack operation..." |
256 |
+ log.notice('Resume point detected, skipping unpack operation...') |
257 |
|
258 |
def unpack_snapshot(self): |
259 |
unpack=True |
260 |
@@ -808,8 +807,8 @@ class StageBase(TargetBase, ClearBase, GenBase): |
261 |
|
262 |
target_portdir = normpath(self.settings["chroot_path"] + |
263 |
self.settings["repo_basedir"] + "/" + self.settings["repo_name"]) |
264 |
- print self.settings["chroot_path"] |
265 |
- print "unpack(), target_portdir = " + target_portdir |
266 |
+ log.info('%s', self.settings['chroot_path']) |
267 |
+ log.info('unpack(), target_portdir = %s', target_portdir) |
268 |
if "snapcache" in self.settings["options"]: |
269 |
snapshot_cache_hash_path = pjoin( |
270 |
self.settings['snapshot_cache_path'], 'catalyst-hash') |
271 |
@@ -819,16 +818,16 @@ class StageBase(TargetBase, ClearBase, GenBase): |
272 |
|
273 |
cleanup_msg="Cleaning up invalid snapshot cache at \n\t"+\ |
274 |
self.settings["snapshot_cache_path"]+\ |
275 |
- " (This can take a long time)..." |
276 |
+ " (this can take a long time)..." |
277 |
cleanup_errmsg="Error removing existing snapshot cache directory." |
278 |
|
279 |
if self.settings["snapshot_path_hash"]==snapshot_cache_hash: |
280 |
- print "Valid snapshot cache, skipping unpack of portage tree..." |
281 |
+ log.info('Valid snapshot cache, skipping unpack of portage tree...') |
282 |
unpack=False |
283 |
else: |
284 |
cleanup_errmsg="Error removing existing snapshot directory." |
285 |
cleanup_msg=\ |
286 |
- "Cleaning up existing portage tree (This can take a long time)..." |
287 |
+ 'Cleaning up existing portage tree (this can take a long time)...' |
288 |
unpack_info['destination'] = normpath( |
289 |
self.settings["chroot_path"] + self.settings["repo_basedir"]) |
290 |
unpack_info['mode'] = self.decompressor.determine_mode( |
291 |
@@ -838,30 +837,29 @@ class StageBase(TargetBase, ClearBase, GenBase): |
292 |
and os.path.exists(target_portdir) \ |
293 |
and self.resume.is_enabled("unpack_portage") \ |
294 |
and self.settings["snapshot_path_hash"] == snapshot_hash: |
295 |
- print \ |
296 |
- "Valid Resume point detected, skipping unpack of portage tree..." |
297 |
+ log.notice('Valid Resume point detected, skipping unpack of portage tree...') |
298 |
unpack = False |
299 |
|
300 |
if unpack: |
301 |
if "snapcache" in self.settings["options"]: |
302 |
self.snapcache_lock.write_lock() |
303 |
if os.path.exists(target_portdir): |
304 |
- print cleanup_msg |
305 |
+ log.info('%s', cleanup_msg) |
306 |
cleanup_cmd = "rm -rf " + target_portdir |
307 |
- print "unpack() cleanup_cmd = " + cleanup_cmd |
308 |
+ log.info('unpack() cleanup_cmd = %s', cleanup_cmd) |
309 |
cmd(cleanup_cmd,cleanup_errmsg,env=self.env) |
310 |
ensure_dirs(target_portdir, mode=0755) |
311 |
|
312 |
- print "Unpacking portage tree (This can take a long time) ..." |
313 |
+ log.notice('Unpacking portage tree (this can take a long time) ...') |
314 |
if not self.decompressor.extract(unpack_info): |
315 |
- print unpack_errmsg %(unpack_info) |
316 |
+ log.error('%s', unpack_errmsg % unpack_info) |
317 |
|
318 |
if "snapcache" in self.settings["options"]: |
319 |
myf = open(snapshot_cache_hash_path, 'w') |
320 |
myf.write(self.settings["snapshot_path_hash"]) |
321 |
myf.close() |
322 |
else: |
323 |
- print "Setting snapshot autoresume point" |
324 |
+ log.info('Setting snapshot autoresume point') |
325 |
self.resume.enable("unpack_portage", |
326 |
data=self.settings["snapshot_path_hash"]) |
327 |
|
328 |
@@ -871,12 +869,11 @@ class StageBase(TargetBase, ClearBase, GenBase): |
329 |
def config_profile_link(self): |
330 |
if "autoresume" in self.settings["options"] \ |
331 |
and self.resume.is_enabled("config_profile_link"): |
332 |
- print \ |
333 |
- "Resume point detected, skipping config_profile_link operation..." |
334 |
+ log.notice('Resume point detected, skipping config_profile_link operation...') |
335 |
else: |
336 |
# TODO: zmedico and I discussed making this a directory and pushing |
337 |
# in a parent file, as well as other user-specified configuration. |
338 |
- print "Configuring profile link..." |
339 |
+ log.info('Configuring profile link...') |
340 |
cmd("rm -f " + self.settings["chroot_path"] + |
341 |
self.settings["port_conf"] + "/make.profile", |
342 |
"Error zapping profile link",env=self.env) |
343 |
@@ -892,10 +889,10 @@ class StageBase(TargetBase, ClearBase, GenBase): |
344 |
def setup_confdir(self): |
345 |
if "autoresume" in self.settings["options"] \ |
346 |
and self.resume.is_enabled("setup_confdir"): |
347 |
- print "Resume point detected, skipping setup_confdir operation..." |
348 |
+ log.notice('Resume point detected, skipping setup_confdir operation...') |
349 |
else: |
350 |
if "portage_confdir" in self.settings: |
351 |
- print "Configuring %s..." % self.settings["port_conf"] |
352 |
+ log.info('Configuring %s...', self.settings['port_conf']) |
353 |
cmd("rsync -a " + self.settings["portage_confdir"] + "/ " + |
354 |
self.settings["chroot_path"] + self.settings["port_conf"], |
355 |
"Error copying %s" % self.settings["port_conf"], |
356 |
@@ -907,7 +904,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
357 |
if "portage_overlay" in self.settings: |
358 |
for x in self.settings["portage_overlay"]: |
359 |
if os.path.exists(x): |
360 |
- print "Copying overlay dir " +x |
361 |
+ log.info('Copying overlay dir %s', x) |
362 |
cmd("mkdir -p "+self.settings["chroot_path"]+\ |
363 |
self.settings["local_overlay"],\ |
364 |
"Could not make portage_overlay dir",env=self.env) |
365 |
@@ -921,7 +918,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
366 |
for x in self.settings[self.settings["spec_prefix"]+\ |
367 |
"/root_overlay"]: |
368 |
if os.path.exists(x): |
369 |
- print "Copying root_overlay: "+x |
370 |
+ log.info('Copying root_overlay: %s', x) |
371 |
cmd("rsync -a "+x+"/ "+\ |
372 |
self.settings["chroot_path"],\ |
373 |
self.settings["spec_prefix"]+"/root_overlay: "+x+\ |
374 |
@@ -933,7 +930,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
375 |
def bind(self): |
376 |
for x in self.mounts: |
377 |
_cmd = '' |
378 |
- #print "bind(); x =", x |
379 |
+ log.debug('bind(); x = %s', x) |
380 |
target = normpath(self.settings["chroot_path"] + self.target_mounts[x]) |
381 |
ensure_dirs(target, mode=0755) |
382 |
|
383 |
@@ -942,7 +939,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
384 |
ensure_dirs(self.mountmap[x], mode=0755) |
385 |
|
386 |
src=self.mountmap[x] |
387 |
- #print "bind(); src =", src |
388 |
+ log.debug('bind(); src = %s', src) |
389 |
if "snapcache" in self.settings["options"] and x == "portdir": |
390 |
self.snapcache_lock.read_lock() |
391 |
if os.uname()[0] == "FreeBSD": |
392 |
@@ -960,9 +957,9 @@ class StageBase(TargetBase, ClearBase, GenBase): |
393 |
_cmd = "mount -t tmpfs -o noexec,nosuid,nodev shm " + target |
394 |
else: |
395 |
_cmd = "mount --bind " + src + " " + target |
396 |
- #print "bind(); _cmd =", _cmd |
397 |
+ log.debug('bind(); _cmd = %s', _cmd) |
398 |
cmd(_cmd, "Bind mounting Failed", env=self.env, fail_func=self.unbind) |
399 |
- #print "bind(); finished :D" |
400 |
+ log.debug('bind(); finished :D') |
401 |
|
402 |
def unbind(self): |
403 |
ouch=0 |
404 |
@@ -981,15 +978,15 @@ class StageBase(TargetBase, ClearBase, GenBase): |
405 |
retval=os.system("umount " + target) |
406 |
|
407 |
if retval!=0: |
408 |
- warn("First attempt to unmount: " + target + " failed.") |
409 |
- warn("Killing any pids still running in the chroot") |
410 |
+ log.warning('First attempt to unmount failed: %s', target) |
411 |
+ log.warning('Killing any pids still running in the chroot') |
412 |
|
413 |
self.kill_chroot_pids() |
414 |
|
415 |
retval2 = os.system("umount " + target) |
416 |
if retval2!=0: |
417 |
ouch=1 |
418 |
- warn("Couldn't umount bind mount: " + target) |
419 |
+ log.warning("Couldn't umount bind mount: %s", target) |
420 |
|
421 |
if "snapcache" in self.settings["options"] and x == "/usr/portage": |
422 |
try: |
423 |
@@ -1019,9 +1016,9 @@ class StageBase(TargetBase, ClearBase, GenBase): |
424 |
self.override_asflags() |
425 |
if "autoresume" in self.settings["options"] \ |
426 |
and self.resume.is_enabled("chroot_setup"): |
427 |
- print "Resume point detected, skipping chroot_setup operation..." |
428 |
+ log.notice('Resume point detected, skipping chroot_setup operation...') |
429 |
else: |
430 |
- print "Setting up chroot..." |
431 |
+ log.notice('Setting up chroot...') |
432 |
|
433 |
cmd("cp /etc/resolv.conf " + self.settings["chroot_path"] + "/etc/", |
434 |
"Could not copy resolv.conf into place.",env=self.env) |
435 |
@@ -1033,13 +1030,12 @@ class StageBase(TargetBase, ClearBase, GenBase): |
436 |
"Can't find envscript " + self.settings["envscript"], |
437 |
print_traceback=True) |
438 |
|
439 |
- print "\nWarning!!!!" |
440 |
- print "\tOverriding certain env variables may cause catastrophic failure." |
441 |
- print "\tIf your build fails look here first as the possible problem." |
442 |
- print "\tCatalyst assumes you know what you are doing when setting" |
443 |
- print "\t\tthese variables." |
444 |
- print "\tCatalyst Maintainers use VERY minimal envscripts if used at all" |
445 |
- print "\tYou have been warned\n" |
446 |
+ log.warning( |
447 |
+ 'Overriding certain env variables may cause catastrophic failure.\n' |
448 |
+ 'If your build fails look here first as the possible problem.\n' |
449 |
+ 'Catalyst assumes you know what you are doing when setting these variables.\n' |
450 |
+ 'Catalyst Maintainers use VERY minimal envscripts, if used at all.\n' |
451 |
+ 'You have been warned.') |
452 |
|
453 |
cmd("cp "+self.settings["envscript"]+" "+\ |
454 |
self.settings["chroot_path"]+"/tmp/envscript",\ |
455 |
@@ -1113,10 +1109,10 @@ class StageBase(TargetBase, ClearBase, GenBase): |
456 |
myusevars = sorted(set(myusevars)) |
457 |
myf.write('USE="' + ' '.join(myusevars) + '"\n') |
458 |
if '-*' in myusevars: |
459 |
- print "\nWarning!!! " |
460 |
- print "\tThe use of -* in "+self.settings["spec_prefix"]+\ |
461 |
- "/use will cause portage to ignore" |
462 |
- print "\tpackage.use in the profile and portage_confdir. You've been warned!" |
463 |
+ log.warning( |
464 |
+ 'The use of -* in %s/use will cause portage to ignore\n' |
465 |
+ 'package.use in the profile and portage_confdir.\n' |
466 |
+ "You've been warned!", self.settings['spec_prefix']) |
467 |
|
468 |
myuseexpandvars={} |
469 |
if "HOSTUSEEXPAND" in self.settings: |
470 |
@@ -1141,7 +1137,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
471 |
def fsscript(self): |
472 |
if "autoresume" in self.settings["options"] \ |
473 |
and self.resume.is_enabled("fsscript"): |
474 |
- print "Resume point detected, skipping fsscript operation..." |
475 |
+ log.notice('Resume point detected, skipping fsscript operation...') |
476 |
else: |
477 |
if "fsscript" in self.settings: |
478 |
if os.path.exists(self.settings["controller_file"]): |
479 |
@@ -1152,7 +1148,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
480 |
def rcupdate(self): |
481 |
if "autoresume" in self.settings["options"] \ |
482 |
and self.resume.is_enabled("rcupdate"): |
483 |
- print "Resume point detected, skipping rcupdate operation..." |
484 |
+ log.notice('Resume point detected, skipping rcupdate operation...') |
485 |
else: |
486 |
if os.path.exists(self.settings["controller_file"]): |
487 |
cmd(self.settings["controller_file"]+" rc-update",\ |
488 |
@@ -1162,10 +1158,10 @@ class StageBase(TargetBase, ClearBase, GenBase): |
489 |
def clean(self): |
490 |
if "autoresume" in self.settings["options"] \ |
491 |
and self.resume.is_enabled("clean"): |
492 |
- print "Resume point detected, skipping clean operation..." |
493 |
+ log.notice('Resume point detected, skipping clean operation...') |
494 |
else: |
495 |
for x in self.settings["cleanables"]: |
496 |
- print "Cleaning chroot: "+x+"... " |
497 |
+ log.notice('Cleaning chroot: %s', x) |
498 |
cmd("rm -rf "+self.settings["destpath"]+x,"Couldn't clean "+\ |
499 |
x,env=self.env) |
500 |
|
501 |
@@ -1197,7 +1193,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
502 |
def empty(self): |
503 |
if "autoresume" in self.settings["options"] \ |
504 |
and self.resume.is_enabled("empty"): |
505 |
- print "Resume point detected, skipping empty operation..." |
506 |
+ log.notice('Resume point detected, skipping empty operation...') |
507 |
else: |
508 |
if self.settings["spec_prefix"]+"/empty" in self.settings: |
509 |
if type(self.settings[self.settings["spec_prefix"]+\ |
510 |
@@ -1208,9 +1204,9 @@ class StageBase(TargetBase, ClearBase, GenBase): |
511 |
for x in self.settings[self.settings["spec_prefix"]+"/empty"]: |
512 |
myemp=self.settings["destpath"]+x |
513 |
if not os.path.isdir(myemp) or os.path.islink(myemp): |
514 |
- print x,"not a directory or does not exist, skipping 'empty' operation." |
515 |
+ log.warning('not a directory or does not exist, skipping "empty" operation: %s', x) |
516 |
continue |
517 |
- print "Emptying directory",x |
518 |
+ log.info('Emptying directory %s', x) |
519 |
# stat the dir, delete the dir, recreate the dir and set |
520 |
# the proper perms and ownership |
521 |
mystat=os.stat(myemp) |
522 |
@@ -1223,13 +1219,13 @@ class StageBase(TargetBase, ClearBase, GenBase): |
523 |
def remove(self): |
524 |
if "autoresume" in self.settings["options"] \ |
525 |
and self.resume.is_enabled("remove"): |
526 |
- print "Resume point detected, skipping remove operation..." |
527 |
+ log.notice('Resume point detected, skipping remove operation...') |
528 |
else: |
529 |
if self.settings["spec_prefix"]+"/rm" in self.settings: |
530 |
for x in self.settings[self.settings["spec_prefix"]+"/rm"]: |
531 |
# We're going to shell out for all these cleaning |
532 |
# operations, so we get easy glob handling. |
533 |
- print "livecd: removing "+x |
534 |
+ log.notice('livecd: removing %s', x) |
535 |
os.system("rm -rf "+self.settings["chroot_path"]+x) |
536 |
try: |
537 |
if os.path.exists(self.settings["controller_file"]): |
538 |
@@ -1243,7 +1239,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
539 |
def preclean(self): |
540 |
if "autoresume" in self.settings["options"] \ |
541 |
and self.resume.is_enabled("preclean"): |
542 |
- print "Resume point detected, skipping preclean operation..." |
543 |
+ log.notice('Resume point detected, skipping preclean operation...') |
544 |
else: |
545 |
try: |
546 |
if os.path.exists(self.settings["controller_file"]): |
547 |
@@ -1264,9 +1260,9 @@ class StageBase(TargetBase, ClearBase, GenBase): |
548 |
|
549 |
if "autoresume" in self.settings["options"] \ |
550 |
and self.resume.is_enabled("capture"): |
551 |
- print "Resume point detected, skipping capture operation..." |
552 |
+ log.notice('Resume point detected, skipping capture operation...') |
553 |
else: |
554 |
- print "Capture target in a tarball" |
555 |
+ log.notice('Capture target in a tarball') |
556 |
# Remove filename from path |
557 |
mypath = os.path.dirname(self.settings["target_path"]) |
558 |
|
559 |
@@ -1283,29 +1279,30 @@ class StageBase(TargetBase, ClearBase, GenBase): |
560 |
target_filename = ".".join([self.settings["target_path"].rstrip('/'), |
561 |
self.compressor.extension(pack_info['mode'])]) |
562 |
|
563 |
- print "Creating stage tarball... mode:", \ |
564 |
- self.settings["compression_mode"] |
565 |
+ log.notice('Creating stage tarball... mode: %s', |
566 |
+ self.settings['compression_mode']) |
567 |
|
568 |
if self.compressor.compress(pack_info): |
569 |
self.gen_contents_file(target_filename) |
570 |
self.gen_digest_file(target_filename) |
571 |
self.resume.enable("capture") |
572 |
else: |
573 |
- print "Couldn't create stage tarball:", target_filename |
574 |
+ log.warning("Couldn't create stage tarball: %s", target_filename) |
575 |
|
576 |
def run_local(self): |
577 |
if "autoresume" in self.settings["options"] \ |
578 |
and self.resume.is_enabled("run_local"): |
579 |
- print "Resume point detected, skipping run_local operation..." |
580 |
+ log.notice('Resume point detected, skipping run_local operation...') |
581 |
else: |
582 |
try: |
583 |
if os.path.exists(self.settings["controller_file"]): |
584 |
- print "run_local() starting controller script..." |
585 |
+ log.info('run_local() starting controller script...') |
586 |
cmd(self.settings["controller_file"]+" run",\ |
587 |
"run script failed.",env=self.env) |
588 |
self.resume.enable("run_local") |
589 |
else: |
590 |
- print "run_local() no controller_file found...", self.settings["controller_file"] |
591 |
+ log.info('run_local() no controller_file found... %s', |
592 |
+ self.settings['controller_file']) |
593 |
|
594 |
except CatalystError: |
595 |
self.unbind() |
596 |
@@ -1318,9 +1315,9 @@ class StageBase(TargetBase, ClearBase, GenBase): |
597 |
fixed. We need this to use the os.system() call since we can't |
598 |
specify our own environ |
599 |
""" |
600 |
- #print "setup_environment(); settings =", list(self.settings) |
601 |
+ log.debug('setup_environment(); settings = %r', self.settings) |
602 |
for x in list(self.settings): |
603 |
- #print "setup_environment(); processing:", x |
604 |
+ log.debug('setup_environment(); processing: %s', x) |
605 |
if x == "options": |
606 |
#self.env['clst_' + x] = ' '.join(self.settings[x]) |
607 |
for opt in self.settings[x]: |
608 |
@@ -1367,7 +1364,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
609 |
|
610 |
if "makeopts" in self.settings: |
611 |
self.env["MAKEOPTS"]=self.settings["makeopts"] |
612 |
- #print "setup_environment(); env =", self.env |
613 |
+ log.debug('setup_environment(); env = %r', self.env) |
614 |
|
615 |
def run(self): |
616 |
self.chroot_lock.write_lock() |
617 |
@@ -1386,33 +1383,30 @@ class StageBase(TargetBase, ClearBase, GenBase): |
618 |
return |
619 |
|
620 |
if "purgeonly" in self.settings["options"]: |
621 |
- print "StageBase: run() purgeonly" |
622 |
+ log.info('StageBase: run() purgeonly') |
623 |
self.purge() |
624 |
|
625 |
if "purge" in self.settings["options"]: |
626 |
- print "StageBase: run() purge" |
627 |
+ log.info('StageBase: run() purge') |
628 |
self.purge() |
629 |
|
630 |
failure = False |
631 |
for x in self.settings["action_sequence"]: |
632 |
- print "--- Running action sequence: "+x |
633 |
+ log.notice('--- Running action sequence: %s', x) |
634 |
sys.stdout.flush() |
635 |
try: |
636 |
getattr(self, x)() |
637 |
except LockInUse: |
638 |
- print "Error, unable to aquire the lock..." |
639 |
- print " Catalyst aborting...." |
640 |
+ log.error('Unable to aquire the lock...') |
641 |
failure = True |
642 |
break |
643 |
- except Exception as error: |
644 |
- print "Exception running action sequence %s" % x |
645 |
- print "Error:", str(error) |
646 |
- print " Catalyst aborting...." |
647 |
+ except Exception: |
648 |
+ log.error('Exception running action sequence %s', x, exc_info=True) |
649 |
failure = True |
650 |
break |
651 |
|
652 |
if failure: |
653 |
- print "Cleaning up... Running unbind()" |
654 |
+ log.notice('Cleaning up... Running unbind()') |
655 |
self.unbind() |
656 |
return False |
657 |
return True |
658 |
@@ -1421,7 +1415,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
659 |
def unmerge(self): |
660 |
if "autoresume" in self.settings["options"] \ |
661 |
and self.resume.is_enabled("unmerge"): |
662 |
- print "Resume point detected, skipping unmerge operation..." |
663 |
+ log.notice('Resume point detected, skipping unmerge operation...') |
664 |
else: |
665 |
if self.settings["spec_prefix"]+"/unmerge" in self.settings: |
666 |
if type(self.settings[self.settings["spec_prefix"]+\ |
667 |
@@ -1442,7 +1436,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
668 |
cmd(self.settings["controller_file"]+\ |
669 |
" unmerge "+ myunmerge,"Unmerge script failed.",\ |
670 |
env=self.env) |
671 |
- print "unmerge shell script" |
672 |
+ log.info('unmerge shell script') |
673 |
except CatalystError: |
674 |
self.unbind() |
675 |
raise |
676 |
@@ -1451,9 +1445,9 @@ class StageBase(TargetBase, ClearBase, GenBase): |
677 |
def target_setup(self): |
678 |
if "autoresume" in self.settings["options"] \ |
679 |
and self.resume.is_enabled("target_setup"): |
680 |
- print "Resume point detected, skipping target_setup operation..." |
681 |
+ log.notice('Resume point detected, skipping target_setup operation...') |
682 |
else: |
683 |
- print "Setting up filesystems per filesystem type" |
684 |
+ log.notice('Setting up filesystems per filesystem type') |
685 |
cmd(self.settings["controller_file"]+\ |
686 |
" target_image_setup "+ self.settings["target_path"],\ |
687 |
"target_image_setup script failed.",env=self.env) |
688 |
@@ -1462,7 +1456,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
689 |
def setup_overlay(self): |
690 |
if "autoresume" in self.settings["options"] \ |
691 |
and self.resume.is_enabled("setup_overlay"): |
692 |
- print "Resume point detected, skipping setup_overlay operation..." |
693 |
+ log.notice('Resume point detected, skipping setup_overlay operation...') |
694 |
else: |
695 |
if self.settings["spec_prefix"]+"/overlay" in self.settings: |
696 |
for x in self.settings[self.settings["spec_prefix"]+"/overlay"]: |
697 |
@@ -1476,7 +1470,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
698 |
def create_iso(self): |
699 |
if "autoresume" in self.settings["options"] \ |
700 |
and self.resume.is_enabled("create_iso"): |
701 |
- print "Resume point detected, skipping create_iso operation..." |
702 |
+ log.notice('Resume point detected, skipping create_iso operation...') |
703 |
else: |
704 |
# Create the ISO |
705 |
if "iso" in self.settings: |
706 |
@@ -1487,20 +1481,19 @@ class StageBase(TargetBase, ClearBase, GenBase): |
707 |
self.gen_digest_file(self.settings["iso"]) |
708 |
self.resume.enable("create_iso") |
709 |
else: |
710 |
- print "WARNING: livecd/iso was not defined." |
711 |
- print "An ISO Image will not be created." |
712 |
+ log.warning('livecd/iso was not defined. An ISO Image will not be created.') |
713 |
|
714 |
def build_packages(self): |
715 |
build_packages_resume = pjoin(self.settings["autoresume_path"], |
716 |
"build_packages") |
717 |
if "autoresume" in self.settings["options"] \ |
718 |
and self.resume.is_enabled("build_packages"): |
719 |
- print "Resume point detected, skipping build_packages operation..." |
720 |
+ log.notice('Resume point detected, skipping build_packages operation...') |
721 |
else: |
722 |
if self.settings["spec_prefix"]+"/packages" in self.settings: |
723 |
if "autoresume" in self.settings["options"] \ |
724 |
and self.resume.is_enabled("build_packages"): |
725 |
- print "Resume point detected, skipping build_packages operation..." |
726 |
+ log.notice('Resume point detected, skipping build_packages operation...') |
727 |
else: |
728 |
mypack=\ |
729 |
list_bashify(self.settings[self.settings["spec_prefix"]\ |
730 |
@@ -1520,7 +1513,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
731 |
'''Build all configured kernels''' |
732 |
if "autoresume" in self.settings["options"] \ |
733 |
and self.resume.is_enabled("build_kernel"): |
734 |
- print "Resume point detected, skipping build_kernel operation..." |
735 |
+ log.notice('Resume point detected, skipping build_kernel operation...') |
736 |
else: |
737 |
if "boot/kernel" in self.settings: |
738 |
try: |
739 |
@@ -1544,7 +1537,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
740 |
"Build a single configured kernel by name" |
741 |
if "autoresume" in self.settings["options"] \ |
742 |
and self.resume.is_enabled("build_kernel_"+kname): |
743 |
- print "Resume point detected, skipping build_kernel for "+kname+" operation..." |
744 |
+ log.notice('Resume point detected, skipping build_kernel for %s operation...', kname) |
745 |
return |
746 |
self._copy_kernel_config(kname=kname) |
747 |
|
748 |
@@ -1579,7 +1572,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
749 |
if "boot/kernel/"+kname+"/initramfs_overlay" in self.settings: |
750 |
if os.path.exists(self.settings["chroot_path"]+\ |
751 |
"/tmp/initramfs_overlay/"): |
752 |
- print "Cleaning up temporary overlay dir" |
753 |
+ log.notice('Cleaning up temporary overlay dir') |
754 |
cmd("rm -R "+self.settings["chroot_path"]+\ |
755 |
"/tmp/initramfs_overlay/",env=self.env) |
756 |
|
757 |
@@ -1615,9 +1608,8 @@ class StageBase(TargetBase, ClearBase, GenBase): |
758 |
if "boot/kernel/"+kname+"/initramfs_overlay" in self.settings: |
759 |
if os.path.exists(self.settings["boot/kernel/"+\ |
760 |
kname+"/initramfs_overlay"]): |
761 |
- print "Copying initramfs_overlay dir "+\ |
762 |
- self.settings["boot/kernel/"+kname+\ |
763 |
- "/initramfs_overlay"] |
764 |
+ log.notice('Copying initramfs_overlay dir %s', |
765 |
+ self.settings['boot/kernel/' + kname + '/initramfs_overlay']) |
766 |
|
767 |
cmd("mkdir -p "+\ |
768 |
self.settings["chroot_path"]+\ |
769 |
@@ -1635,7 +1627,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
770 |
def bootloader(self): |
771 |
if "autoresume" in self.settings["options"] \ |
772 |
and self.resume.is_enabled("bootloader"): |
773 |
- print "Resume point detected, skipping bootloader operation..." |
774 |
+ log.notice('Resume point detected, skipping bootloader operation...') |
775 |
else: |
776 |
try: |
777 |
cmd(self.settings["controller_file"]+\ |
778 |
@@ -1649,7 +1641,7 @@ class StageBase(TargetBase, ClearBase, GenBase): |
779 |
def livecd_update(self): |
780 |
if "autoresume" in self.settings["options"] \ |
781 |
and self.resume.is_enabled("livecd_update"): |
782 |
- print "Resume point detected, skipping build_packages operation..." |
783 |
+ log.notice('Resume point detected, skipping build_packages operation...') |
784 |
else: |
785 |
try: |
786 |
cmd(self.settings["controller_file"]+\ |
787 |
diff --git a/catalyst/defaults.py b/catalyst/defaults.py |
788 |
index 5db7ab6..666afca 100644 |
789 |
--- a/catalyst/defaults.py |
790 |
+++ b/catalyst/defaults.py |
791 |
@@ -22,8 +22,6 @@ valid_config_file_values.extend([ "distcc", "envscript", |
792 |
"compression_mode", "decompressor_search_order", |
793 |
]) |
794 |
|
795 |
-verbosity = 1 |
796 |
- |
797 |
confdefaults={ |
798 |
"archdir": "%(PythonDir)s/arch", |
799 |
"compression_mode": 'lbzip2_x', |
800 |
diff --git a/catalyst/support.py b/catalyst/support.py |
801 |
index c629025..6b1e727 100644 |
802 |
--- a/catalyst/support.py |
803 |
+++ b/catalyst/support.py |
804 |
@@ -8,7 +8,7 @@ import traceback |
805 |
import time |
806 |
from subprocess import Popen |
807 |
|
808 |
-from catalyst.defaults import verbosity, valid_config_file_values |
809 |
+from catalyst.defaults import valid_config_file_values |
810 |
|
811 |
BASH_BINARY = "/bin/bash" |
812 |
|
813 |
@@ -40,15 +40,6 @@ class CatalystError(Exception): |
814 |
print |
815 |
|
816 |
|
817 |
-def die(msg=None): |
818 |
- warn(msg) |
819 |
- sys.exit(1) |
820 |
- |
821 |
- |
822 |
-def warn(msg): |
823 |
- print "!!! catalyst: "+msg |
824 |
- |
825 |
- |
826 |
def cmd(mycmd, myexc="", env=None, debug=False, fail_func=None): |
827 |
if env is None: |
828 |
env = {} |
829 |
@@ -186,11 +177,6 @@ def read_makeconf(mymakeconffile): |
830 |
return makeconf |
831 |
|
832 |
|
833 |
-def msg(mymsg,verblevel=1): |
834 |
- if verbosity>=verblevel: |
835 |
- print mymsg |
836 |
- |
837 |
- |
838 |
def pathcompare(path1,path2): |
839 |
# Change double slashes to slash |
840 |
path1 = re.sub(r"//",r"/",path1) |
841 |
-- |
842 |
2.5.2 |