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})
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..."
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("/")
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()
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()
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 ]
gcc-config \${mythang}; env-update; source /etc/profile
fi
EOF
- ;;
+ ;;
esac
# 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)
$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
# 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)
EOF
[ $? -ne 0 ] && exit 1
;;
+preclean)
+ exit 0
+ ;;
*)
exit 1
;;
# 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)
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"
EOF
[ $? -ne 0 ] && exit 1
;;
+preclean)
+ exit 0
+ ;;
*)
exit 1
;;