From 57273a1a9bfab89cafa4797a5ca8fddb14d17dde Mon Sep 17 00:00:00 2001 From: Eric Edgar Date: Thu, 5 May 2005 21:16:06 +0000 Subject: [PATCH] Fix bug 65284. More flexible spec parsing. Should handle cases where no spaces are after :. Better handling of comments ( ie preprocessed and stripped off ). Unset empty keys. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@651 d1e1f19c-881f-0410-ab34-b69fee027534 --- ChangeLog | 8 ++- catalyst | 5 +- modules/catalyst_support.py | 104 +++++++++++++++++++++--------------- 3 files changed, 72 insertions(+), 45 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec8e6703..60e5ae27 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ # Copyright 2002-2005 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.256 2005/05/03 15:57:37 rocket Exp $ +# $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.257 2005/05/05 21:16:06 rocket Exp $ + + 05 May 2005; Eric Edgar catalyst, + modules/catalyst_support.py: + Fix bug 65284. More flexible spec parsing. Should handle cases where no + spaces are after :. Better handling of comments ( ie preprocessed and + stripped off ). Unset empty keys. 03 May 2005; Eric Edgar catalyst, targets/support/kill-chroot-pids.sh: diff --git a/catalyst b/catalyst index feb86bec..8c49dd01 100755 --- a/catalyst +++ b/catalyst @@ -1,7 +1,7 @@ #!/usr/bin/python # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.79 2005/05/03 15:57:37 rocket Exp $ +# $Header: /var/cvsroot/gentoo/src/catalyst/catalyst,v 1.80 2005/05/05 21:16:06 rocket Exp $ # Maintained in full by: # Eric Edgar @@ -349,6 +349,9 @@ if __name__ == "__main__": except KeyboardInterrupt: print "\nCatalyst build aborted due to user interrupt ( Ctrl-C )" sys.exit(2) + except KeyError: + print "\nproblem with command line or spec file ( Key Error )" + sys.exit(2) except: print "Catalyst aborting ...." sys.exit(2) diff --git a/modules/catalyst_support.py b/modules/catalyst_support.py index a710ce76..3d741ca9 100644 --- a/modules/catalyst_support.py +++ b/modules/catalyst_support.py @@ -1,6 +1,6 @@ # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.45 2005/04/27 21:04:02 rocket Exp $ +# $Header: /var/cvsroot/gentoo/src/catalyst/modules/catalyst_support.py,v 1.46 2005/05/05 21:16:06 rocket Exp $ import sys,string,os,types,re,signal,traceback,md5,time # a function to turn a string of non-printable characters into a string of @@ -200,54 +200,72 @@ defined are not preserved. In other words, "foo", "bar", "oni" ordering is prese def parse_spec(mylines): myspec={} pos=0 + colon_optional_spaces=re.compile(":") + trailing_comment=re.compile("#.*\n") + newline=re.compile("\n") + leading_white_space=re.compile("\s+") while pos foo:"bar" - myspec[myline[0]]=myline[1] - pos += 1 - elif len(myline)>2: - #foo: bar oni --> foo: [ "bar", "oni" ] - myspec[myline[0]]=myline[1:] - pos += 1 - else: - #foo: - # bar - # oni meep - # --> foo: [ "bar", "oni", "meep" ] - accum=[] - pos += 1 - while (pos0: + + if len(subarray)==1: + # Store as a string if only one element is found. + # this is to keep with original catalyst behavior + # eventually this may go away if catalyst just works + # with arrays. + newarray.append(subarray[0]) else: - #we've hit the next item, break out - break - myspec[myline[0]]=accum + newarray.append(mobjs[1].split()) + + # Else add on to the last key we were working on + else: + myline=mylines[pos].split() + newarray.append(myline) + + pos += 1 + if len(newarray)==2: + myspec[newarray[0]]=newarray[1] + else: + myspec[newarray[0]]=newarray[1:] + + for x in myspec.keys(): + # Convert myspec[x] to an array of strings + newarray=[] + if type(myspec[x])!=types.StringType: + for y in myspec[x]: + newarray.append(y[0]) + myspec[x]=newarray + # Delete empty key pairs + if len(myspec[x])==0: + print "\n\tWARNING: No value set for key: "+x + print "\tdeleting key: "+x+"\n" + del myspec[x] + return myspec def parse_makeconf(mylines): -- 2.26.2