From 6c5d462cc34e99363a9846823719e6582edac64b Mon Sep 17 00:00:00 2001 From: Andrew Gaffney Date: Sun, 11 Jan 2009 15:42:21 -0600 Subject: [PATCH] Move list_bashify() from catalyst.support to catalyst.util --- ChangeLog | 7 +++++++ modules/catalyst/output.py | 2 ++ modules/catalyst/support.py | 12 ------------ modules/catalyst/target/generic_stage.py | 4 ++-- modules/catalyst/target/grp.py | 3 ++- modules/catalyst/target/netboot.py | 5 +++-- modules/catalyst/target/netboot2.py | 3 ++- modules/catalyst/target/tinderbox.py | 3 ++- modules/catalyst/util.py | 12 ++++++++++++ 9 files changed, 32 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index 288a43cb..4afc247d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -2,6 +2,13 @@ # Copyright 2002-2009 Gentoo Foundation; 2008-2009 Various authors (see AUTHORS) # Distributed under the GPL v2 + 11 Jan 2009; Andrew Gaffney + modules/catalyst/output.py, modules/catalyst/support.py, + modules/catalyst/target/generic_stage.py, modules/catalyst/target/grp.py, + modules/catalyst/target/netboot.py, modules/catalyst/target/netboot2.py, + modules/catalyst/target/tinderbox.py, modules/catalyst/util.py: + Move list_bashify() from catalyst.support to catalyst.util + 11 Jan 2009; Andrew Gaffney modules/catalyst/support.py, modules/catalyst/target/generic_stage.py, modules/catalyst/target/livecd_stage2.py, modules/catalyst/util.py: diff --git a/modules/catalyst/output.py b/modules/catalyst/output.py index b9dd95d5..27dac0a4 100644 --- a/modules/catalyst/output.py +++ b/modules/catalyst/output.py @@ -2,6 +2,8 @@ This module contains miscellaneous functions for outputting messages """ +import sys + def msg(mymsg, verblevel=1): if verbosity >= verblevel: print mymsg diff --git a/modules/catalyst/support.py b/modules/catalyst/support.py index 2c209121..44911a10 100644 --- a/modules/catalyst/support.py +++ b/modules/catalyst/support.py @@ -205,18 +205,6 @@ valid_config_file_values.append("SEEDCACHE") verbosity=1 -def list_bashify(mylist): - if type(mylist)==types.StringType: - mypack=[mylist] - else: - mypack=mylist[:] - for x in range(0,len(mypack)): - # surround args with quotes for passing to bash, - # allows things like "<" to remain intact - mypack[x]="'"+mypack[x]+"'" - mypack=string.join(mypack) - return mypack - def list_to_string(mylist): if type(mylist)==types.StringType: mypack=[mylist] diff --git a/modules/catalyst/target/generic_stage.py b/modules/catalyst/target/generic_stage.py index 89710fda..2f5c97fd 100644 --- a/modules/catalyst/target/generic_stage.py +++ b/modules/catalyst/target/generic_stage.py @@ -1331,8 +1331,8 @@ class generic_stage_target(generic_target): "build_packages"): print "Resume point detected, skipping build_packages operation..." else: - mypack=\ - list_bashify(self.settings[self.settings["spec_prefix"]\ + mypack = \ + catalyst.util.list_bashify(self.settings[self.settings["spec_prefix"] \ +"/packages"]) try: cmd("/bin/bash "+self.settings["controller_file"]+\ diff --git a/modules/catalyst/target/grp.py b/modules/catalyst/target/grp.py index b4832160..4b9428b7 100644 --- a/modules/catalyst/target/grp.py +++ b/modules/catalyst/target/grp.py @@ -6,6 +6,7 @@ The builder class for GRP (Gentoo Reference Platform) builds. import os,types,glob from catalyst.support import * from generic_stage import * +import catalyst.util class grp_target(generic_stage_target): def __init__(self,spec,addlargs): @@ -49,7 +50,7 @@ class grp_target(generic_stage_target): def run_local(self): for pkgset in self.settings["grp"]: # example call: "grp.sh run pkgset cd1 xmms vim sys-apps/gleep" - mypackages=list_bashify(self.settings["grp/"+pkgset+"/packages"]) + mypackages = catalyst.util.list_bashify(self.settings["grp/"+pkgset+"/packages"]) try: cmd("/bin/bash "+self.settings["controller_file"]+" run "+self.settings["grp/"+pkgset+"/type"]\ +" "+pkgset+" "+mypackages,env=self.env) diff --git a/modules/catalyst/target/netboot.py b/modules/catalyst/target/netboot.py index f00627af..bb026372 100644 --- a/modules/catalyst/target/netboot.py +++ b/modules/catalyst/target/netboot.py @@ -6,6 +6,7 @@ Builder class for a netboot build. import os,string,types from catalyst.support import * from generic_stage import * +import catalyst.util class netboot_target(generic_stage_target): def __init__(self,spec,addlargs): @@ -58,7 +59,7 @@ class netboot_target(generic_stage_target): # def build_packages(self): # # build packages # if "netboot/packages" in self.settings: -# mypack=list_bashify(self.settings["netboot/packages"]) +# mypack = catalyst.util.list_bashify(self.settings["netboot/packages"]) # try: # cmd("/bin/bash "+self.settings["controller_file"]+" packages "+mypack,env=self.env) # except CatalystError: @@ -102,7 +103,7 @@ class netboot_target(generic_stage_target): try: cmd("/bin/bash "+self.settings["controller_file"]+\ - " image " + list_bashify(myfiles),env=self.env) + " image " + catalyst.util.list_bashify(myfiles),env=self.env) except CatalystError: self.unbind() raise CatalystError,"netboot build aborting due to error." diff --git a/modules/catalyst/target/netboot2.py b/modules/catalyst/target/netboot2.py index c6965d47..f0827761 100644 --- a/modules/catalyst/target/netboot2.py +++ b/modules/catalyst/target/netboot2.py @@ -6,6 +6,7 @@ Builder class for a netboot build, version 2 import os,string,types from catalyst.support import * from generic_stage import * +import catalyst.util class netboot2_target(generic_stage_target): def __init__(self,spec,addlargs): @@ -85,7 +86,7 @@ class netboot2_target(generic_stage_target): try: cmd("/bin/bash "+self.settings["controller_file"]+\ - " image " + list_bashify(myfiles),env=self.env) + " image " + catalyst.util.list_bashify(myfiles),env=self.env) except CatalystError: self.unbind() raise CatalystError,"Failed to copy files to image!" diff --git a/modules/catalyst/target/tinderbox.py b/modules/catalyst/target/tinderbox.py index 85ba6abb..7b4a6f30 100644 --- a/modules/catalyst/target/tinderbox.py +++ b/modules/catalyst/target/tinderbox.py @@ -5,6 +5,7 @@ builder class for the tinderbox target from catalyst.support import * from generic_stage import * +import catalyst.util class tinderbox_target(generic_stage_target): def __init__(self,spec,addlargs): @@ -19,7 +20,7 @@ class tinderbox_target(generic_stage_target): try: if os.path.exists(self.settings["controller_file"]): cmd("/bin/bash "+self.settings["controller_file"]+" run "+\ - list_bashify(self.settings["tinderbox/packages"]),"run script failed.",env=self.env) + catalyst.util.list_bashify(self.settings["tinderbox/packages"]),"run script failed.",env=self.env) except CatalystError: self.unbind() diff --git a/modules/catalyst/util.py b/modules/catalyst/util.py index 1f90e65f..c27f5f06 100644 --- a/modules/catalyst/util.py +++ b/modules/catalyst/util.py @@ -45,3 +45,15 @@ def readfile(file): return None #raise CatalystError, "Could not read file " + file +def list_bashify(mylist): + if isinstance(mylist, str): + mypack = [mylist] + else: + mypack = mylist[:] + for x in range(0,len(mypack)): + # surround args with quotes for passing to bash, + # allows things like "<" to remain intact + mypack[x] = "'" + mypack[x] + "'" + mypack = "".join(mypack) + return mypack + -- 2.26.2