From c90a61acad3b7ee6d3e81dbeb75e56ba324b1eb4 Mon Sep 17 00:00:00 2001 From: Daniel Robbins Date: Mon, 3 Nov 2003 02:43:55 +0000 Subject: [PATCH] various stage fixes git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@41 d1e1f19c-881f-0410-ab34-b69fee027534 --- arch/ppc.py | 1 + modules/targets.py | 32 +++++++++++++++++---- targets/stage1/stage1-chroot.sh | 49 ++++++++++----------------------- targets/stage1/stage1.sh | 36 +++++++++++++++++++++--- targets/stage2/stage2.sh | 5 +++- targets/stage3/stage3.sh | 8 +++--- 6 files changed, 81 insertions(+), 50 deletions(-) diff --git a/arch/ppc.py b/arch/ppc.py index e3f3d9ba..0c06b14f 100644 --- a/arch/ppc.py +++ b/arch/ppc.py @@ -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}) diff --git a/modules/targets.py b/modules/targets.py index 38e147e1..e0c2ab1f 100644 --- a/modules/targets.py +++ b/modules/targets.py @@ -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() diff --git a/targets/stage1/stage1-chroot.sh b/targets/stage1/stage1-chroot.sh index 25a89d15..671942bd 100755 --- a/targets/stage1/stage1-chroot.sh +++ b/targets/stage1/stage1-chroot.sh @@ -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 diff --git a/targets/stage1/stage1.sh b/targets/stage1/stage1.sh index e20c63f0..57de781c 100755 --- a/targets/stage1/stage1.sh +++ b/targets/stage1/stage1.sh @@ -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 diff --git a/targets/stage2/stage2.sh b/targets/stage2/stage2.sh index 28956b38..0afb13b5 100755 --- a/targets/stage2/stage2.sh +++ b/targets/stage2/stage2.sh @@ -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 ;; diff --git a/targets/stage3/stage3.sh b/targets/stage3/stage3.sh index f6bb06bb..a6714c2f 100755 --- a/targets/stage3/stage3.sh +++ b/targets/stage3/stage3.sh @@ -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 ;; -- 2.26.2