Break out more repeated (path1 + path2)'s...
authorBrian Dolbec <dolsen@gentoo.org>
Tue, 12 Feb 2013 04:06:01 +0000 (20:06 -0800)
committerBrian Dolbec <dolsen@gentoo.org>
Fri, 1 Mar 2013 06:48:50 +0000 (22:48 -0800)
Just do it once and use the temp variable.
Comment out some debug print's.
Fix options conversion for export to bash.

catalyst/base/stagebase.py
catalyst/defaults.py

index 7a02f63f8c5b639a2bdd4b5bbed83ae766f5b676..4b24d9a706464438c64a1a0a286dcc3d6078dfba 100644 (file)
@@ -619,11 +619,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
                """
                self.setup_environment()
 
-               if os.path.exists(self.settings["sharedir"]+\
-                       "/targets/support/kill-chroot-pids.sh"):
-                       cmd("/bin/bash "+self.settings["sharedir"]+\
-                               "/targets/support/kill-chroot-pids.sh",\
-                               "kill-chroot-pids script failed.",env=self.env)
+               killcmd = normpath(self.settings["sharedir"] +
+                       self.settings["shdir"] + "/support/kill-chroot-pids.sh")
+               if os.path.exists(killcmd):
+                       cmd(killcmd, "kill-chroot-pids script failed.",env=self.env)
 
        def mount_safety_check(self):
                #mypath=self.settings["chroot_path"]
@@ -637,10 +636,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
                if not os.path.exists(self.settings["chroot_path"]):
                        return
 
-               print "self.mounts =", self.mounts
+               #print "self.mounts =", self.mounts
                for x in self.mounts:
                        target = normpath(self.settings["chroot_path"] + self.target_mounts[x])
-                       print "mount_safety_check() x =", x, target
+                       #print "mount_safety_check() x =", x, target
                        if not os.path.exists(target):
                                continue
 
@@ -1009,8 +1008,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
                                "Couldn't umount one or more bind-mounts; aborting for safety.")
 
        def chroot_setup(self):
-               self.makeconf=read_makeconf(self.settings["chroot_path"]+\
-                       "/etc/portage/make.conf")
+               self.makeconf=read_makeconf(normpath(self.settings["chroot_path"]+
+                       self.settings["make.conf"]))
                self.override_cbuild()
                self.override_chost()
                self.override_cflags()
@@ -1022,8 +1021,6 @@ class StageBase(TargetBase, ClearBase, GenBase):
                else:
                        print "Setting up chroot..."
 
-                       #self.makeconf=read_makeconf(self.settings["chroot_path"]+"/etc/portage/make.conf")
-
                        cmd("cp /etc/resolv.conf "+self.settings["chroot_path"]+"/etc",\
                                "Could not copy resolv.conf into place.",env=self.env)
 
@@ -1058,8 +1055,8 @@ class StageBase(TargetBase, ClearBase, GenBase):
                                        "Could not copy /etc/hosts",env=self.env)
 
                        """ Modify and write out make.conf (for the chroot) """
-                       makepath = normpath(self.settings["chroot_path"]+\
-                               "/etc/portage/make.conf")
+                       makepath = normpath(self.settings["chroot_path"] +
+                               self.settings["make.conf"])
                        cmd("rm -f " + makepath,\
                                "Could not remove " + makepath, env=self.env)
                        myf=open(makepath, "w")
@@ -1108,9 +1105,10 @@ class StageBase(TargetBase, ClearBase, GenBase):
                                myf.write('PORTDIR_OVERLAY="/usr/local/portage"\n')
 
                        myf.close()
-                       cmd("cp "+self.settings["chroot_path"]+"/etc/portage/make.conf "+\
-                               self.settings["chroot_path"]+"/etc/portage/make.conf.catalyst",\
-                               "Could not backup /etc/portage/make.conf",env=self.env)
+                       makepath = normpath(self.settings["chroot_path"] +
+                               self.settings["make.conf"])
+                       cmd("cp " + makepath + " " + makepath + ".catalyst",\
+                               "Could not backup " + self.settings["make.conf"],env=self.env)
                        touch(self.settings["autoresume_path"]+"chroot_setup")
 
        def fsscript(self):
@@ -1261,14 +1259,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
                        touch(self.settings["autoresume_path"]+"capture")
 
        def run_local(self):
-               print "run_local()"
+               #print "run_local()"
                if "autoresume" in self.settings["options"] \
                        and os.path.exists(self.settings["autoresume_path"]+"run_local"):
                        print "Resume point detected, skipping run_local operation..."
                else:
                        try:
                                if os.path.exists(self.settings["controller_file"]):
-                                       print "run_local() starting fresh..."
+                                       print "run_local() starting controller script..."
                                        cmd(self.settings["controller_file"]+" run",\
                                                "run script failed.",env=self.env)
                                        touch(self.settings["autoresume_path"]+"run_local")
@@ -1286,7 +1284,14 @@ class StageBase(TargetBase, ClearBase, GenBase):
                fixed. We need this to use the os.system() call since we can't
                specify our own environ
                """
-               for x in self.settings.keys():
+               #print "setup_environment(); settings =", list(self.settings)
+               for x in list(self.settings):
+                       #print "setup_environment(); processing:", x
+                       if x == "options":
+                               #self.env['clst_' + x] = ' '.join(self.settings[x])
+                               for opt in self.settings[x]:
+                                       self.env['clst_' + opt.upper()] = "true"
+                               continue
                        """ Sanitize var names by doing "s|/-.|_|g" """
                        varname="clst_"+string.replace(x,"/","_")
                        varname=string.replace(varname,"-","_")
@@ -1300,11 +1305,12 @@ class StageBase(TargetBase, ClearBase, GenBase):
                                self.env[varname]=string.join(self.settings[x])
                        elif type(self.settings[x])==types.BooleanType:
                                if self.settings[x]:
-                                       self.env[varname]="true"
+                                       self.env[varname] = "true"
                                else:
-                                       self.env[varname]="false"
+                                       self.env[varname] = "false"
                if "makeopts" in self.settings:
                        self.env["MAKEOPTS"]=self.settings["makeopts"]
+               #print "setup_environment(); env =", self.env
 
        def run(self):
                #print "StageBase: run() !!!!!!!! options =", self.settings["options"]
@@ -1334,7 +1340,7 @@ class StageBase(TargetBase, ClearBase, GenBase):
                        #print "StageBase: run() purge"
                        self.purge()
 
-               print "--- Running action sequences:", self.settings["action_sequence"]
+               #print "--- Running action sequences:", self.settings["action_sequence"]
                for x in self.settings["action_sequence"]:
                        print "--- Running action sequence: "+x
                        sys.stdout.flush()
index 76d6ce5522838db2bdb9f8a52a88f4b228fe4c57..c52ab737908dbeb9b22d7573f2114bc32c75a9ba 100644 (file)
@@ -60,6 +60,7 @@ contents_definitions = {
 confdefaults={
        "storedir": "/var/tmp/catalyst",
        "sharedir": "/usr/lib/catalyst",
+       "shdir": "/usr/lib/catalyst/targets/",
        "distdir": "/usr/portage/distfiles",
        "repo_name": "portage",
        "portdir": "/usr/portage",