various stage fixes
authorDaniel Robbins <drobbins@gentoo.org>
Mon, 3 Nov 2003 02:43:55 +0000 (02:43 +0000)
committerDaniel Robbins <drobbins@gentoo.org>
Mon, 3 Nov 2003 02:43:55 +0000 (02:43 +0000)
git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@41 d1e1f19c-881f-0410-ab34-b69fee027534

arch/ppc.py
modules/targets.py
targets/stage1/stage1-chroot.sh
targets/stage1/stage1.sh
targets/stage2/stage2.sh
targets/stage3/stage3.sh

index e3f3d9ba80d1be8e9da4e8d6f58d0f82744d46ac..0c06b14fa79e25f6c03e1809af0e90bdc7f3d55c 100644 (file)
@@ -50,5 +50,6 @@ class arch_g4(generic_ppc):
 
 def register(foo):
        "Inform main catalyst program of the contents of this plugin."
+       #power/ppc can't be used as a subarch name as it has a "/" in it and is used in filenames
        foo.update({"ppc":arch_ppc,"power/ppc":arch_power_ppc,"g3":arch_g3,"g4":arch_g4})
                
index 38e147e1e2b13024a36db7521dc5cf9757422d30..e0c2ab1f942f12fb3c06d32cd81b77aca5dace49 100644 (file)
@@ -75,7 +75,16 @@ class generic_stage_target(generic_target):
                                continue
                        if ismount(mypath+x):
                                #something is still mounted
-                               raise CatalystError, x+" is still mounted; aborting."
+                               try:
+                                       print x+" is still mounted; performing auto-bind-umount..."
+                                       #try to umount stuff ourselves
+                                       self.unbind()
+                                       if ismount(mypath+x):
+                                               raise CatalystError, "Auto-unbind failed for "+x
+                                       else:
+                                               print "Auto-unbind successful, continuing..."
+                               except CatalystError:
+                                       raise CatalystError, "Unable to auto-unbind "+x
                
        def dir_setup(self):
                print "Setting up directories..."
@@ -146,11 +155,16 @@ class generic_stage_target(generic_target):
                        cmd(mycmd,"Sed command failed: "+mycmd)
 
        def clean(self):
-               "do not call without first unbinding; this code needs a cleanup once it stabilizes"
+               destpath=self.settings["chroot_path"]
+               if self.settings["target"]=="stage1":
+                       destpath+="/tmp/stage1root"
                for x in ["/etc/resolv.conf","/usr/portage","/var/tmp/*","/tmp/*","/root/*"]: 
-                       cmd("rm -rf "+self.settings["chroot_path"]+x,"Couldn't clean "+x)
+                       cmd("rm -rf "+destpath+x,"Couldn't clean "+x)
                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.")
+
        def capture(self):
                """capture target in a tarball"""
                mypath=self.settings["target_path"].split("/")
@@ -160,8 +174,11 @@ class generic_stage_target(generic_target):
                if not os.path.exists(mypath):
                        os.makedirs(mypath)
                print "Creating stage tarball..."
-               cmd("tar cjf "+self.settings["target_path"]+" -C "+self.settings["chroot_path"]+" .","Couldn't create stage tarball")
-               
+               if self.settings["target"]=="stage1":
+                       cmd("tar cjf "+self.settings["target_path"]+" -C "+self.settings["chroot_path"]+"/tmp/stage1root .","Couldn't create stage tarball")
+               else:
+                       cmd("tar cjf "+self.settings["target_path"]+" -C "+self.settings["chroot_path"]+" .","Couldn't create stage tarball")
+
        def run(self):
                self.dir_setup()
                self.unpack_and_bind()
@@ -181,7 +198,10 @@ class generic_stage_target(generic_target):
                try:
                        cmd(self.settings["storedir"]+"/targets/"+self.settings["target"]+"/"+self.settings["target"]+".sh run","build script failed")
                finally:
+                       #pre-clean is for stuff that needs to run with bind-mounts still active
+                       self.preclean()
                        self.unbind()
+               #clean is for removing things after bind-mounts are unmounted (general file removal and cleanup)
                self.clean()
                self.capture()
                        
index 25a89d156e01d1c0c310e83e15614820cd7631f6..671942bd38d53f742e44a8e44b1751ff39f06415 100755 (executable)
@@ -4,55 +4,34 @@ env-update
 source /etc/profile
 case $1 in
        build)
-               export ROOT=${2}
-               install -d $ROOT
+               #emerge and enable ccache before we set ROOT
                if [ -n "${clst_CCACHE}" ]
                then
                        export FEATURES="ccache"        
                        emerge --oneshot --nodeps ccache || exit 1
                fi
+               export ROOT=${2}
+               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
                        echo $x >> /tmp/build.log
-                       USE="-* build" emerge --noreplace $x || exit 1
+                       USE="-* build" emerge ${EMERGE_OPTS} --noreplace $x || exit 1
                done
        ;;
 
-       clean)
-               export ROOT=${2}
-               keepers="sys-kernel/linux-headers sys-devel/binutils sys-devel/gcc sys-apps/baselayout sys-libs/glibc virtual/glibc virtual/kernel"
-               if [ ${clst_rel_type} = "hardened" ]
-               then
-                       keepers="${keepers} sys-devel/hardened-gcc"
-               fi
-               # set everything to uid 999 (nouser)
-               cd ${ROOT}
-               install -d var/db/pkg2
-               for x in $keepers
-               do
-                       category=${x%%/*}
-                       package=${x##*/}
-                       [ "`ls var/db/pkg/${x}* 2>/dev/null`" = "" ] && continue
-                       install -d var/db/pkg2/${category}
-                       mv var/db/pkg/${category}/${package}* var/db/pkg2/${category}
-               done
-               rm -rf var/db/pkg
-               mv var/db/pkg2 var/db/pkg
-
-               # clean out man, info and doc files
-               rm -rf usr/share/{man,doc,info}/*
-
-               # zap all .pyc and .pyo files
-               find -iname "*.py[co]" -exec rm -f {} \;
-
-               # cleanup all .a files except libgcc.a, *_nonshared.a and /usr/lib/portage/bin/*.a
-               find -iname "*.a" | `find -iname "*.a" | grep -v 'libgcc.a' | grep -v 'nonshared.a' | grep -v '/usr/lib/portage/bin/' | grep -v 'libgcc_eh.a'` | xargs rm -f
-
-               chroot ${ROOT} /bin/bash << EOF
+       preclean)
+               ${clst_CHROOT} ${2} /bin/bash << EOF
                #now, some finishing touches to initialize gcc-config....
                unset ROOT
                if [ -e /usr/sbin/gcc-config ]
@@ -61,6 +40,6 @@ case $1 in
                        gcc-config \${mythang}; env-update; source /etc/profile
                fi
 EOF
-               ;;
+       ;;              
 esac
        
index e20c63f0a8370e04dcea0549ade31aabd18a899c..57de781c61a1660ad42a670248cd7eeffdbb09f6 100755 (executable)
@@ -1,6 +1,6 @@
 # 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/stage1.sh,v 1.5 2003/10/30 20:00:04 drobbins Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage1/Attic/stage1.sh,v 1.6 2003/11/03 02:43:55 drobbins Exp $
 
 case $1 in
 enter)
@@ -18,10 +18,38 @@ run)
        $clst_CHROOT ${clst_chroot_path} /tmp/stage1-chroot.sh build /tmp/stage1root
        [ $? -ne 0 ] && exit 1
        ;;
-clean)
-       $clst_CHROOT ${clst_chroot_path} /tmp/stage1-chroot.sh clean /tmp/stage1root
+preclean)
+       #preclean runs with bind mounts active -- for running any commands inside chroot
+       $clst_CHROOT ${clst_chroot_path} /tmp/stage1-chroot.sh preclean /tmp/stage1root
        [ $? -ne 0 ] && exit 1
-       echo
+       ;;
+clean)
+       #clean runs after preclean with bind mounts unmounted
+       keepers="sys-kernel/linux-headers sys-devel/binutils sys-devel/gcc sys-apps/baselayout sys-libs/glibc virtual/glibc virtual/kernel"
+       if [ ${clst_rel_type} = "hardened" ]
+       then
+               keepers="${keepers} sys-devel/hardened-gcc"
+       fi
+       # set everything to uid 999 (nouser)
+       cd ${clst_chroot_path}/tmp/stage1root
+       install -d var/db/pkg2 
+       for x in $keepers
+       do
+               category=${x%%/*}
+               package=${x##*/}
+               [ "`ls var/db/pkg/${x}* 2>/dev/null`" = "" ] && continue
+               install -d var/db/pkg2/${category}
+               mv var/db/pkg/${category}/${package}* var/db/pkg2/${category}
+       done
+       rm -rf var/db/pkg
+       mv var/db/pkg2 var/db/pkg
+
+       # clean out man, info and doc files
+       rm -rf usr/share/{man,doc,info}/*
+       # zap all .pyc and .pyo files
+       find -iname "*.py[co]" -exec rm -f {} \;
+       # cleanup all .a files except libgcc.a, *_nonshared.a and /usr/lib/portage/bin/*.a
+       find -iname "*.a" | `find -iname "*.a" | grep -v 'libgcc.a' | grep -v 'nonshared.a' | grep -v '/usr/lib/portage/bin/' | grep -v 'libgcc_eh.a'` | xargs rm -f
        ;;
 *)
        exit 1
index 28956b38b657a1ba56fa94596d517f69133a1eb7..0afb13b555b2d74000c322fe730ea39de117235c 100755 (executable)
@@ -1,6 +1,6 @@
 # Copyright 1999-2003 Gentoo Technologies, Inc.
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage2/Attic/stage2.sh,v 1.4 2003/10/30 21:11:57 drobbins Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage2/Attic/stage2.sh,v 1.5 2003/11/03 02:43:55 drobbins Exp $
 
 case $1 in
 enter)
@@ -39,6 +39,9 @@ clean)
 EOF
        [ $? -ne 0 ] && exit 1 
        ;;
+preclean)
+       exit 0
+       ;;
 *)
        exit 1
        ;;
index f6bb06bbd4e78716ece3f0414163fcb5f1c78a9d..a6714c2f492c195797475cd8f6642c96657e9f46 100755 (executable)
@@ -1,6 +1,6 @@
 # Copyright 1999-2003 Gentoo Technologies, Inc.
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage3/Attic/stage3.sh,v 1.5 2003/10/30 06:21:08 drobbins Exp $
+# $Header: /var/cvsroot/gentoo/src/catalyst/targets/stage3/Attic/stage3.sh,v 1.6 2003/11/03 02:43:55 drobbins Exp $
 
 case $1 in
 enter)
@@ -13,10 +13,7 @@ run)
        cat /etc/make.profile/make.defaults | grep GRP_STAGE23_USE > /tmp/stage23
        source /tmp/stage23
        export USE="-* \${clst_HOSTUSE} \${GRP_STAGE23_USE}"
-       echo
-       echo "USE variables active: \${USE}"
        rm -f /tmp/stage23
-       echo
        if [ -n "${clst_CCACHE}" ]
        then
                export FEATURES="ccache"
@@ -52,6 +49,9 @@ clean)
 EOF
        [ $? -ne 0 ] && exit 1
        ;;
+preclean)
+       exit 0
+       ;;
 *)
        exit 1
        ;;