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