several stage fixes
authorDaniel Robbins <drobbins@gentoo.org>
Wed, 5 Nov 2003 17:03:57 +0000 (17:03 +0000)
committerDaniel Robbins <drobbins@gentoo.org>
Wed, 5 Nov 2003 17:03:57 +0000 (17:03 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@44 d1e1f19c-881f-0410-ab34-b69fee027534

modules/targets.py
targets/stage1/build.sh
targets/stage1/stage1-chroot.sh

index ea820cb8b3673f93ec04ade1028a319ffae960ac..d401aa0cd37adfe0ee831514a8f81ae7b2edc0a6 100644 (file)
@@ -132,31 +132,44 @@ class generic_stage_target(generic_target):
 
        def chroot_setup(self):
                cmd("cp /etc/resolv.conf "+self.settings["chroot_path"]+"/etc","Could not copy resolv.conf into place.")
-               #Ugly bunch of sed commands to get /etc/make.conf to hold the correct default values for the stage
-               #we're building. This way, when a user uses a pentium4 stage3, it is set up to compile for pentium4
-               #using the CFLAGS and USE settings we used. It's possible that this would look nicer written in
-               #python, even without using regexes which aren't really necessary.
-               mycmds=[]
-               mycmds.append("sed -i -e '/# catalyst start/,/# catalyst stop/d'")
-               mycmds.append("sed -i -e 's:^CFLAGS=:#&:' -e 's:^CXXFLAGS=:#&:' -e 's:^CHOST=:#&:' -e 's:^USE=:#&:'")
-               sedcmd="sed -i -e '5i\\' -e '# catalyst start\\' -e '# these settings were added by the catalyst build script"
-               sedcmd+=" that automatically built this stage\\' -e 'CFLAGS=\""+self.settings["CFLAGS"]+"\"\\'"
+               myconf=open(self.settings["chroot_path"]+"/etc/make.conf","r")
+               mylines=myconf.readlines()
+               myconf.close()
+               pos = 0
+               while pos < len(mylines):
+                       if mylines[pos][:16]=="# catalyst start":
+                               while (pos < len(mylines)) and mylines[pos][:14]!="# catalyst end":
+                                       del mylines[pos]
+                       elif (mylines[pos][:7]=="CFLAGS=") or (mylines[pos][:6]=="CHOST=") or (mylines[pos][:4]=="USE="):
+                               mylines[pos]="#"+mylines[pos]
+                       pos += 1
+               pos = 0
+               while (pos < len(mylines)) and mylines[pos][0]=="#":
+                       pos += 1
+               cmds=["","# catalyst start","# These settings were added by the catalyst build script that automatically built this stage",
+               'CFLAGS="'+self.settings["CFLAGS"]+'"',
+               'CHOST="'+self.settings["CHOST"]+'"']
+               if self.settings.has_key("HOSTUSE"):
+                       cmds.append('USE="'+self.settings["HOSTUSE"]+'"')
+               else:
+                       cmds.append('USE=""')
                if self.settings.has_key("CXXFLAGS"):
-                       sedcmd+=" -e 'CXXFLAGS=\""+self.settings["CXXFLAGS"]+"\"\\'"
+                       cmds.append('CXXFLAGS="'+self.settings["CXXFLAGS"]+'"')
                else:
-                       sedcmd+=" -e 'CXXFLAGS=\"${CFLAGS}\"\\'"
-               sedcmd+=" -e 'CHOST=\""+self.settings["CHOST"]+"\"\\'"
-               if self.settings.has_key("HOSTUSE"):
-                       sedcmd+=" -e 'USE=\""+string.join(self.settings["HOSTUSE"])+"\"\\'"
-               sedcmd+=" -e '# catalyst end\\' -e ''"
-               mycmds.append(sedcmd)
-               for x in mycmds:
-                       mycmd=x+" "+self.settings["chroot_path"]+"/etc/make.conf"
-                       cmd(mycmd,"Sed command failed: "+mycmd)
+                       cmds.append('CXXFLAGS="$CFLAGS"')
+               cmds.append("# catalyst end")
 
+               for x in cmds:
+                       mylines.insert(pos,x+"\n")
+                       pos += 1
+
+               myconf=open(self.settings["chroot_path"]+"/etc/make.conf","w")
+               myconf.write(string.join(mylines))      
+               myconf.close()
+               
        def clean(self):
                destpath=self.settings["chroot_path"]
-               cleanables=["/etc/resolv.conf","/usr/portage","/var/tmp/*","/tmp/*","/root/*"]
+               cleanables=["/etc/resolv.conf","/usr/portage","/var/tmp/*","/tmp/*","/root/*","/root/.ccache"]
                if self.settings["target"]=="stage1":
                        destpath+="/tmp/stage1root"
                        #this next stuff can eventually be integrated into the python and glibc ebuilds themselves (USE="build"):
@@ -166,7 +179,11 @@ class generic_stage_target(generic_target):
                cmd(self.settings["storedir"]+"/targets/"+self.settings["target"]+"/"+self.settings["target"]+".sh clean","clean script failed.")
        
        def preclean(self):
-               cmd(self.settings["storedir"]+"/targets/"+self.settings["target"]+"/"+self.settings["target"]+".sh preclean","preclean script failed.")
+               try:
+                       cmd(self.settings["storedir"]+"/targets/"+self.settings["target"]+"/"+self.settings["target"]+".sh preclean","preclean script failed.")
+               except:
+                       self.unbind()
+                       raise
 
        def capture(self):
                """capture target in a tarball"""
index dd06e4d5c03b88577017d993bcec3c0b4a83e820..086e02c2a5543246c36842363b16090d9455076b 100755 (executable)
@@ -1,9 +1,9 @@
 #!/bin/bash
 # Copyright 1999-2003 Gentoo Technologies, Inc.
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/Attic/build.sh,v 1.4 2003/10/30 19:42:56 drobbins Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/Attic/build.sh,v 1.5 2003/11/05 17:03:57 drobbins Exp $
 
-for x in `cat /usr/portage/profiles/${clst_rel_type}-${clst_mainarch}-${clst_rel_version}/packages.build`
+for x in `cat /usr/portage/profiles/${clst_rel_type}-${clst_mainarch}-${clst_rel_version}/packages.build | grep -v '^#'`
 do
        myp=$(grep -E "${x}(-[^[:space:]]*)?[[:space:]]*$" /usr/portage/profiles/${clst_rel_type}-${clst_mainarch}-${clst_rel_version}/packages | grep -v '^#' | sed -e 's:^\*::' | cat )
        if [ "$myp" = "" ]
index 045ebd018209f0504fd8535dedd5406dd6029c74..5589e2217ad33138f4a31621552dd22bcc25c0f5 100755 (executable)
@@ -14,14 +14,7 @@ case $1 in
                install -d $ROOT
                if [ -n "${clst_PKGCACHE}" ]
                then
-                       echo 
-                       echo "PKGCACHE IS SET"
-                       echo
                        export EMERGE_OPTS="--usepkg --buildpkg"
-               else
-                       echo 
-                       echo "PKGCACHE IS NOT SET"
-                       echo
                fi
                for x in $(/tmp/build.sh)
                do