Initial rearrangement of the python directories
authorBrian Dolbec <dolsen@gentoo.org>
Fri, 11 Jan 2013 02:56:28 +0000 (18:56 -0800)
committerW. Trevor King <wking@tremily.us>
Sun, 15 Dec 2013 04:25:04 +0000 (20:25 -0800)
New minimal start script, moving the original catalyst script to catalyst/main.py.
Add __init__.py's to modules and arch sub-pkgs.
Update the module loading paths for the new locations.
Fix catalyst_support import to new location and specify imported modules.

35 files changed:
bin/catalyst [new file with mode: 0755]
catalyst/__init__.py [moved from modules/catalyst/__init__.py with 100% similarity]
catalyst/arch/__init__.py [new file with mode: 0644]
catalyst/arch/alpha.py [moved from arch/alpha.py with 100% similarity]
catalyst/arch/amd64.py [moved from arch/amd64.py with 100% similarity]
catalyst/arch/arm.py [moved from arch/arm.py with 100% similarity]
catalyst/arch/hppa.py [moved from arch/hppa.py with 100% similarity]
catalyst/arch/ia64.py [moved from arch/ia64.py with 100% similarity]
catalyst/arch/mips.py [moved from arch/mips.py with 100% similarity]
catalyst/arch/powerpc.py [moved from arch/powerpc.py with 100% similarity]
catalyst/arch/s390.py [moved from arch/s390.py with 100% similarity]
catalyst/arch/sh.py [moved from arch/sh.py with 100% similarity]
catalyst/arch/sparc.py [moved from arch/sparc.py with 100% similarity]
catalyst/arch/x86.py [moved from arch/x86.py with 100% similarity]
catalyst/config.py [moved from modules/catalyst/config.py with 100% similarity]
catalyst/main.py [moved from catalyst with 91% similarity]
catalyst/modules/__init__.py [new file with mode: 0644]
catalyst/modules/builder.py [moved from modules/builder.py with 100% similarity]
catalyst/modules/catalyst_lock.py [moved from modules/catalyst_lock.py with 100% similarity]
catalyst/modules/catalyst_support.py [moved from modules/catalyst_support.py with 100% similarity]
catalyst/modules/embedded_target.py [moved from modules/embedded_target.py with 100% similarity]
catalyst/modules/generic_stage_target.py [moved from modules/generic_stage_target.py with 99% similarity]
catalyst/modules/generic_target.py [moved from modules/generic_target.py with 100% similarity]
catalyst/modules/grp_target.py [moved from modules/grp_target.py with 100% similarity]
catalyst/modules/livecd_stage1_target.py [moved from modules/livecd_stage1_target.py with 100% similarity]
catalyst/modules/livecd_stage2_target.py [moved from modules/livecd_stage2_target.py with 100% similarity]
catalyst/modules/netboot2_target.py [moved from modules/netboot2_target.py with 100% similarity]
catalyst/modules/netboot_target.py [moved from modules/netboot_target.py with 100% similarity]
catalyst/modules/snapshot_target.py [moved from modules/snapshot_target.py with 100% similarity]
catalyst/modules/stage1_target.py [moved from modules/stage1_target.py with 100% similarity]
catalyst/modules/stage2_target.py [moved from modules/stage2_target.py with 100% similarity]
catalyst/modules/stage3_target.py [moved from modules/stage3_target.py with 100% similarity]
catalyst/modules/stage4_target.py [moved from modules/stage4_target.py with 100% similarity]
catalyst/modules/tinderbox_target.py [moved from modules/tinderbox_target.py with 100% similarity]
catalyst/util.py [moved from modules/catalyst/util.py with 100% similarity]

diff --git a/bin/catalyst b/bin/catalyst
new file mode 100755 (executable)
index 0000000..a4e55db
--- /dev/null
@@ -0,0 +1,46 @@
+#!/usr/bin/python -OO
+
+# Maintained in full by:
+# Catalyst Team <catalyst@gentoo.org>
+# Release Engineering Team <releng@gentoo.org>
+# Andrew Gaffney <agaffney@gentoo.org>
+# Chris Gianelloni <wolf31o2@wolf31o2.org>
+# $Id$
+
+
+from __future__ import print_function
+
+import sys
+
+__maintainer__="Catalyst <catalyst@gentoo.org>"
+__version__="2.0.12.2"
+
+
+# This block ensures that ^C interrupts are handled quietly.
+try:
+       import signal
+
+       def exithandler(signum,frame):
+               signal.signal(signal.SIGINT, signal.SIG_IGN)
+               signal.signal(signal.SIGTERM, signal.SIG_IGN)
+               print()
+               sys.exit(1)
+
+       signal.signal(signal.SIGINT, exithandler)
+       signal.signal(signal.SIGTERM, exithandler)
+       signal.signal(signal.SIGPIPE, signal.SIG_DFL)
+
+except KeyboardInterrupt:
+       print()
+       sys.exit(1)
+
+
+from catalyst.main import main
+
+try:
+       main()
+except KeyboardInterrupt:
+       print("Aborted.")
+       sys.exit(130)
+sys.exit(0)
+
diff --git a/catalyst/arch/__init__.py b/catalyst/arch/__init__.py
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
similarity index 100%
rename from arch/alpha.py
rename to catalyst/arch/alpha.py
similarity index 100%
rename from arch/amd64.py
rename to catalyst/arch/amd64.py
similarity index 100%
rename from arch/arm.py
rename to catalyst/arch/arm.py
similarity index 100%
rename from arch/hppa.py
rename to catalyst/arch/hppa.py
similarity index 100%
rename from arch/ia64.py
rename to catalyst/arch/ia64.py
similarity index 100%
rename from arch/mips.py
rename to catalyst/arch/mips.py
similarity index 100%
rename from arch/powerpc.py
rename to catalyst/arch/powerpc.py
similarity index 100%
rename from arch/s390.py
rename to catalyst/arch/s390.py
similarity index 100%
rename from arch/sh.py
rename to catalyst/arch/sh.py
similarity index 100%
rename from arch/sparc.py
rename to catalyst/arch/sparc.py
similarity index 100%
rename from arch/x86.py
rename to catalyst/arch/x86.py
similarity index 91%
rename from catalyst
rename to catalyst/main.py
index 4ea4248db2c92b1708035bf446f88dfe804f8638..fcd924259c392855473fba5aa6c86af706183bff 100755 (executable)
--- a/catalyst
@@ -15,8 +15,14 @@ import getopt
 import pdb
 import os.path
 
-import modules.catalyst.config
-import modules.catalyst.util
+__selfpath__ = os.path.abspath(os.path.dirname(__file__))
+
+sys.path.append(__selfpath__ + "/modules")
+
+import catalyst.config
+import catalyst.util
+from catalyst.modules.catalyst_support import (required_build_targets,
+       valid_build_targets, CatalystError, hash_map, find_binary, LockInUse)
 
 __maintainer__="Catalyst <catalyst@gentoo.org>"
 __version__="2.0.15"
@@ -100,7 +106,7 @@ def parse_config(myconfig):
        # now, try and parse the config file "config_file"
        try:
 #              execfile(config_file, myconf, myconf)
-               myconfig = modules.catalyst.config.ConfigParser(config_file)
+               myconfig = catalyst.config.ConfigParser(config_file)
                myconf.update(myconfig.get_values())
 
        except:
@@ -116,6 +122,9 @@ def parse_config(myconfig):
                        print "Setting",x,"to default value \""+confdefaults[x]+"\""
                        conf_values[x]=confdefaults[x]
 
+       # add our python base directory to use for loading target arch's
+       conf_values["PythonDir"] = __selfpath__
+
        # parse out the rest of the options from the config file
        if "autoresume" in string.split(conf_values["options"]):
                print "Autoresuming support enabled."
@@ -189,30 +198,32 @@ def import_modules():
        targetmap={}
 
        try:
+               module_dir = __selfpath__ + "/modules/"
                for x in required_build_targets:
                        try:
-                               fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
-                               module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
+                               fh = open(module_dir + x + ".py")
+                               module = imp.load_module(x, fh, "modules/" + x + ".py",
+                                       (".py", "r", imp.PY_SOURCE))
                                fh.close()
 
                        except IOError:
-                               raise CatalystError,"Can't find "+x+".py plugin in "+\
-                                       conf_values["sharedir"]+"/modules/"
-
+                               raise CatalystError, "Can't find " + x + ".py plugin in " + \
+                                       module_dir
                for x in valid_build_targets:
                        try:
-                               fh=open(conf_values["sharedir"]+"/modules/"+x+".py")
-                               module=imp.load_module(x,fh,"modules/"+x+".py",(".py","r",imp.PY_SOURCE))
+                               fh = open(module_dir + x + ".py")
+                               module = imp.load_module(x, fh, "modules/" + x + ".py",
+                                       (".py", "r", imp.PY_SOURCE))
                                module.register(targetmap)
                                fh.close()
 
                        except IOError:
-                               raise CatalystError,"Can't find "+x+".py plugin in "+\
-                                       conf_values["sharedir"]+"/modules/"
+                               raise CatalystError,"Can't find " + x + ".py plugin in " + \
+                                       module_dir
 
        except ImportError:
                print "!!! catalyst: Python modules not found in "+\
-                       conf_values["sharedir"]+"/modules; exiting."
+                       module_dir + "; exiting."
                sys.exit(1)
 
        return targetmap
@@ -231,7 +242,7 @@ def build_target(addlargs, targetmap):
                print "!!! catalyst: Error encountered during run of target " + addlargs["target"]
                sys.exit(1)
 
-if __name__ == "__main__":
+def main():
        targetmap={}
 
        version()
@@ -332,8 +343,6 @@ if __name__ == "__main__":
 
        # import configuration file and import our main module using those settings
        parse_config(myconfig)
-       sys.path.append(conf_values["sharedir"]+"/modules")
-       from catalyst_support import *
 
        # Start checking that digests are valid now that the hash_map was imported
        # from catalyst_support
@@ -380,12 +389,12 @@ if __name__ == "__main__":
        addlargs={}
 
        if myspecfile:
-               spec = modules.catalyst.config.SpecParser(myspecfile)
+               spec = catalyst.config.SpecParser(myspecfile)
                addlargs.update(spec.get_values())
 
        if mycmdline:
                try:
-                       cmdline = modules.catalyst.config.ConfigParser()
+                       cmdline = catalyst.config.ConfigParser()
                        cmdline.parse_lines(mycmdline)
                        addlargs.update(cmdline.get_values())
                except CatalystError:
diff --git a/catalyst/modules/__init__.py b/catalyst/modules/__init__.py
new file mode 100644 (file)
index 0000000..8b13789
--- /dev/null
@@ -0,0 +1 @@
+
similarity index 99%
rename from modules/generic_stage_target.py
rename to catalyst/modules/generic_stage_target.py
index 8c983e1411da7968d3d664ba3c322dbd474e39d2..6be49648f2100a849a6163decfb5ae6617ecb049 100644 (file)
@@ -48,16 +48,16 @@ class generic_stage_target(generic_target):
                self.archmap = {}
                self.subarchmap = {}
                machinemap = {}
-               for x in [x[:-3] for x in os.listdir(self.settings["sharedir"]+\
-                       "/arch/") if x.endswith(".py")]:
+               arch_dir = self.settings["PythonDir"] + "/arch/"
+               for x in [x[:-3] for x in os.listdir(arch_dir) if x.endswith(".py")]:
                        try:
-                               fh=open(self.settings["sharedir"]+"/arch/"+x+".py")
+                               fh=open(arch_dir + x + ".py")
                                """
                                This next line loads the plugin as a module and assigns it to
                                archmap[x]
                                """
-                               self.archmap[x]=imp.load_module(x,fh,"arch/"+x+\
-                                       ".py",(".py","r",imp.PY_SOURCE))
+                               self.archmap[x]=imp.load_module(x,fh,"../arch/" + x + ".py",
+                                       (".py", "r", imp.PY_SOURCE))
                                """
                                This next line registers all the subarches supported in the
                                plugin
@@ -75,8 +75,7 @@ class generic_stage_target(generic_target):
                                the dir should load just fine. If it doesn't, it's probably a
                                syntax error in the module
                                """
-                               msg("Can't find/load "+x+".py plugin in "+\
-                                       self.settings["sharedir"]+"/arch/")
+                               msg("Can't find/load " + x + ".py plugin in " + arch_dir)
 
                if "chost" in self.settings:
                        hostmachine = self.settings["chost"].split("-")[0]
similarity index 100%
rename from modules/catalyst/util.py
rename to catalyst/util.py