From 35ed8dfdd8502b7369c03af1d137d7d967156846 Mon Sep 17 00:00:00 2001 From: Daniel Robbins Date: Mon, 12 Jan 2004 08:19:46 +0000 Subject: [PATCH] will hopefully fix the python<->bash linkage with ">" and "<" git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@146 d1e1f19c-881f-0410-ab34-b69fee027534 --- modules/catalyst_support.py | 16 +++++++++++++++- modules/targets.py | 24 ++++++++---------------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/modules/catalyst_support.py b/modules/catalyst_support.py index 1cc5d1cb..76c109fe 100644 --- a/modules/catalyst_support.py +++ b/modules/catalyst_support.py @@ -1,7 +1,21 @@ # Distributed under the GNU General Public License version 2 # Copyright 2003-2004 Gentoo Technologies, Inc. -import sys,string,os +import sys,string,os,types + +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) + #escape ">" and "<" for the shell (using backslash) + mypack=string.replace(mypack,">","\\>") + mypack=string.replace(mypack,"<","\\<") + return mypack required_config_file_values=["storedir","sharedir","distdir","portdir"] valid_config_file_values=required_config_file_values[:] diff --git a/modules/targets.py b/modules/targets.py index 06b6232f..3444ef50 100644 --- a/modules/targets.py +++ b/modules/targets.py @@ -385,10 +385,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=self.settings["grp/"+pkgset+"/packages"] - for x in range(0,len(mypackages)): - mypackages[x]='"'+mypackages[x]+'"' - mypackages=string.join(mypackages) + mypackages=list_bashify(self.settings["grp/"+pkgset+"/packages"]) try: cmd("/bin/bash "+self.settings["sharedir"]+"/targets/grp/grp.sh run "+self.settings["grp/"+pkgset+"/type"]+" "+pkgset+" "+mypackages) except CatalystError: @@ -405,7 +402,7 @@ class tinderbox_target(generic_stage_target): #tinderbox #example call: "grp.sh run xmms vim sys-apps/gleep" try: - cmd("/bin/bash "+self.settings["sharedir"]+"/targets/tinderbox/tinderbox.sh run "+string.join(self.settings["tinderbox/packages"])) + cmd("/bin/bash "+self.settings["sharedir"]+"/targets/tinderbox/tinderbox.sh run "+list_bashify(self.settings["tinderbox/packages"])) except CatalystError: self.unbind() raise CatalystError,"Tinderbox aborting due to error." @@ -417,14 +414,7 @@ class livecd_stage1_target(generic_stage_target): generic_stage_target.__init__(self,spec,addlargs) def run_local(self): - mypack=self.settings["livecd/packages"][:] - 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) - #escape ">" and "<" for the shell (using backslash) - mypack=string.replace(mypack,">","\\>") - mypack=string.replace(mypack,"<","\\<") + mypack=list_bashify(self.settings["livecd/packages"]) try: cmd("/bin/bash "+self.settings["sharedir"]+"/targets/livecd-stage1/livecd-stage1.sh run "+mypack) except CatalystError: @@ -450,9 +440,11 @@ class livecd_stage2_target(generic_stage_target): mynames=self.settings["boot/kernel"] if type(mynames)==types.StringType: mynames=[mynames] - args=`len(mynames)` + args=[] + args.append(`len(mynames)`) for x in mynames: - args=args+" "+x+" "+self.settings["boot/kernel/"+x+"/sources"] + args.append(x) + args.append(self.settings["boot/kernel/"+x+"/sources"]) if not os.path.exists(self.settings["boot/kernel/"+x+"/config"]): self.unbind() raise CatalystError, "Can't find kernel config: "+self.settings["boot/kernel/"+x+"/config"] @@ -461,7 +453,7 @@ class livecd_stage2_target(generic_stage_target): self.unbind() raise CatalystError, "Couldn't copy kernel config: "+self.settings["boot/kernel/"+x+"/config"] try: - cmd("/bin/bash "+self.settings["livecd/runscript"]+" run "+args,"runscript failed") + cmd("/bin/bash "+self.settings["livecd/runscript"]+" run "+list_bashify(args),"runscript failed") except CatalystError: self.unbind() raise CatalystError,"livecd-stage2 build aborting due to error." -- 2.26.2