# Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS)
# Distributed under the GPL v2
+ 11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org> catalyst,
+ modules/catalyst/arch/__init__.py, +modules/catalyst/output.py,
+ modules/catalyst/support.py, modules/catalyst/target/__init__.py,
+ modules/catalyst/target/generic_stage.py:
+ Move msg(), warn(), and die() to catalyst.output and update all references
+
+ 11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org> catalyst:
+ Load defaults into myconf before parsing config
+
11 Jan 2009; Andrew Gaffney <agaffney@gentoo.org> catalyst:
Condense code that checks for various things in 'options' to use a loop
import catalyst.util
import catalyst.target
from catalyst.support import *
+from catalyst.output import *
__maintainer__="Chris Gianelloni <wolf31o2@gentoo.org>"
__version__="2.99"
print "Using command line specified Catalyst configuration file, " + myconfig
config_file = myconfig
else:
- print "!!! catalyst: specified configuration file " + myconfig + " does not exist"
- sys.exit(1)
+ die("specified configuration file " + myconfig + " does not exist")
# next, try the default location
elif os.path.exists("/etc/catalyst/catalyst.conf"):
# can't find a config file (we are screwed), so bail out
else:
- print "!!! catalyst: Could not find a suitable configuration file"
- sys.exit(1)
+ die("Could not find a suitable configuration file")
# Load the default config values into myconf
for x in confdefaults:
myconf.update(myconfig.get_values())
except:
- print "!!! catalyst: Unable to parse configuration file, "+myconfig
- sys.exit(1)
+ die("Unable to parse configuration file, " + myconfig)
# now, load up the values into conf_values so that we can use them
for x in confdefaults.keys():
except:
catalyst.util.print_traceback()
- print "!!! catalyst: Error encountered during run of target " + addlargs["target"]
-# sys.exit(1)
+ warn("Error encountered during run of target " + addlargs["target"])
raise
def verify_digest_and_hash_functions():
if os.getuid() != 0:
# catalyst cannot be run as a normal user due to chroots, mounts, etc
- print "!!! catalyst: This script requires root privileges to operate"
- sys.exit(2)
+ die("This script requires root privileges to operate", 2)
# parse out the command line arguments
try:
# check preconditions
if len(opts) == 0:
- print "!!! catalyst: please specify one of either -f or -C\n"
+ warn("please specify one of either -f or -C\n")
usage()
sys.exit(2)
if o in ("-s", "--snapshot"):
if len(sys.argv) < 3:
- print "!!! catalyst: missing snapshot identifier\n"
+ warn("missing snapshot identifier")
usage()
sys.exit(2)
else:
conf_values["CLEAR_AUTORESUME"] = "1"
if not run:
- print "!!! catalyst: please specify one of either -f or -C\n"
+ warn("please specify one of either -f or -C")
usage()
sys.exit(2)
cmdline.parse_lines(mycmdline)
addlargs.update(cmdline.get_values())
except CatalystError:
- print "!!! catalyst: Could not parse commandline, exiting."
- sys.exit(1)
+ die("Could not parse commandline, exiting.")
if not "target" in addlargs:
raise CatalystError, "Required value \"target\" not specified."
import os
import imp
import catalyst.util
-
-# This is only until we move all the output stuff into catalyst.output
-from catalyst.support import msg
+from catalyst.output import warn
def find_arch_modules(self):
search_dir = os.path.abspath(os.path.dirname(__file__))
for x in find_arch_modules():
arch_modules[x] = catalyst.util.load_module("catalyst.arch." + x)
if arch_modules[x] is None:
- msg("Cannot import catalyst.arch." + x + ". This usually only " + \
+ warn("Cannot import catalyst.arch." + x + ". This usually only " + \
"happens due to a syntax error, which should be reported as " \
"a bug.")
return arch_modules
--- /dev/null
+"""
+This module contains miscellaneous functions for outputting messages
+"""
+
+def msg(mymsg, verblevel=1):
+ if verbosity >= verblevel:
+ print mymsg
+
+def warn(msg):
+ print "!!! catalyst: " + msg
+
+def die(msg, exitcode=1):
+ warn(msg)
+ sys.exit(exitcode)
+
import sys,string,os,types,re,signal,traceback,time
+from catalyst.output import warn
#import md5,sha
+
selinux_capable = False
#userpriv_capable = (os.getuid() == 0)
#fakeroot_capable = False
print "!!! catalyst lock file in use: "+message
print
-def die(msg=None):
- warn(msg)
- sys.exit(1)
-
-def warn(msg):
- print "!!! catalyst: "+msg
-
-
def find_binary(myc):
"""look through the environmental path for an executable file named whatever myc is"""
# this sucks. badly.
makeconf={}
return makeconf
-def msg(mymsg,verblevel=1):
- if verbosity>=verblevel:
- print mymsg
-
def pathcompare(path1,path2):
# Change double slashes to slash
path1 = re.sub(r"//",r"/",path1)
import os
import imp
import catalyst.util
-
-# This is only until we move all the output stuff into catalyst.output
-from catalyst.support import msg
+from catalyst.output import warn
def find_target_modules():
search_dir = os.path.abspath(os.path.dirname(__file__))
for x in find_target_modules():
target_modules[x] = catalyst.util.load_module("catalyst.target." + x)
if target_modules[x] is None:
- msg("Cannot import catalyst.target." + x + ". This usually only " + \
+ warn("Cannot import catalyst.target." + x + ". This usually only " + \
"happens due to a syntax error, which should be reported as " \
"a bug.")
return target_modules
from stat import *
import catalyst.lock
import catalyst.arch
+from catalyst.output import warn
class generic_stage_target(generic_target):