From: Chris Gianelloni Date: Wed, 11 Oct 2006 13:51:41 +0000 (+0000) Subject: Added initial Gentoo/FreeBSD support. Patch from Diego Pettenò and attached to bug #150351. git-svn-id: svn+ssh://svn.gentoo.org/var/svnroot/catalyst/trunk@1180 d1e1f19c-881f-0410-ab34-b69fee027534 --- diff --git a/AUTHORS b/AUTHORS index 4caceae1..0679cc4d 100644 --- a/AUTHORS +++ b/AUTHORS @@ -18,3 +18,4 @@ Matsuu Takuto Joshua Kinard Lars Weiler Andrew Gaffney +Diego Pettenò diff --git a/ChangeLog b/ChangeLog index a58e9e23..efb30091 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,12 @@ # Copyright 2002-2006 Gentoo Foundation; Distributed under the GPL v2 # $Header: /var/cvsroot/gentoo/src/catalyst/ChangeLog,v 1.664 2006/10/02 20:41:53 wolf31o2 Exp $ + 11 Oct 2006; Chris Gianelloni AUTHORS, + modules/generic_stage_target.py, targets/stage1/stage1-controller.sh, + targets/support/chroot-functions.sh: + Added initial Gentoo/FreeBSD support. Patch from Diego Pettenò + and attached to bug #150351. + 02 Oct 2006; Chris Gianelloni README, arch/alpha.py, arch/amd64.py, arch/arm.py, arch/hppa.py, arch/ia64.py, arch/mips.py, arch/ppc.py, arch/ppc64.py, arch/s390.py, arch/sh.py, arch/sparc.py, diff --git a/modules/generic_stage_target.py b/modules/generic_stage_target.py index c20defad..b5b2e7ec 100644 --- a/modules/generic_stage_target.py +++ b/modules/generic_stage_target.py @@ -162,14 +162,16 @@ class generic_stage_target(generic_target): # setup our mount points if self.settings.has_key("SNAPCACHE"): - self.mounts=[ "/proc","/dev","/dev/pts","/usr/portage","/usr/portage/distfiles" ] + self.mounts=[ "/proc","/dev","/usr/portage","/usr/portage/distfiles" ] self.mountmap={"/proc":"/proc", "/dev":"/dev", "/dev/pts":"/dev/pts",\ "/usr/portage":self.settings["snapshot_cache_path"]+"/portage",\ "/usr/portage/distfiles":self.settings["distdir"]} else: - self.mounts=[ "/proc","/dev","/dev/pts","/usr/portage/distfiles" ] + self.mounts=[ "/proc","/dev","/usr/portage/distfiles" ] self.mountmap={"/proc":"/proc", "/dev":"/dev", "/dev/pts":"/dev/pts",\ "/usr/portage/distfiles":self.settings["distdir"]} + if os.uname()[0] == "Linux": + self.mounts.append("/dev/pts") self.set_mounts() @@ -769,7 +771,13 @@ class generic_stage_target(generic_target): src=self.mountmap[x] if self.settings.has_key("SNAPCACHE") and x == "/usr/portage": self.snapshot_lock_object.read_lock() - retval=os.system("mount --bind "+src+" "+self.settings["chroot_path"]+x) + if os.uname()[0] == "FreeBSD": + if src == "/dev": + retval=os.system("mount -t devfs none "+self.settings["chroot_path"]+x) + else: + retval=os.system("mount_nullfs "+src+" "+self.settings["chroot_path"]+x) + else: + retval=os.system("mount --bind "+src+" "+self.settings["chroot_path"]+x) if retval!=0: self.unbind() raise CatalystError,"Couldn't bind mount "+src @@ -789,7 +797,7 @@ class generic_stage_target(generic_target): # it's not mounted, continue continue - retval=os.system("umount "+mypath+x) + retval=os.system("umount "+os.path.join(mypath,x.lstrip(os.path.sep))) if retval!=0: warn("First attempt to unmount: "+mypath+x+" failed.") @@ -1282,6 +1290,8 @@ class generic_stage_target(generic_target): # the proper perms and ownership mystat=os.stat(myemp) #cmd("rm -rf "+myemp, "Could not remove existing file: "+myemp,env=self.env) + if os.uname()[0] == "FreeBSD": # There's no easy way to change flags recursively in python + os.system("chflags -R noschg "+myemp) shutil.rmtree(myemp) os.makedirs(myemp,0755) os.chown(myemp,mystat[ST_UID],mystat[ST_GID]) diff --git a/targets/stage1/stage1-controller.sh b/targets/stage1/stage1-controller.sh index 2a264e3e..52f81587 100755 --- a/targets/stage1/stage1-controller.sh +++ b/targets/stage1/stage1-controller.sh @@ -55,10 +55,10 @@ case $1 in # 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 {} \; + find . -iname "*.py[co]" -exec rm -f {} \; # Cleanup all .a files except libgcc.a, *_nonshared.a and # /usr/lib/portage/bin/*.a - find -type f -iname "*.a" | grep -v 'libgcc.a' | grep -v 'nonshared.a' \ + find . -type f -iname "*.a" | grep -v 'libgcc.a' | grep -v 'nonshared.a' \ | grep -v '/usr/lib/portage/bin/' | grep -v 'libgcc_eh.a' | xargs \ rm -f ;; diff --git a/targets/support/chroot-functions.sh b/targets/support/chroot-functions.sh index 63b72578..43ff0474 100755 --- a/targets/support/chroot-functions.sh +++ b/targets/support/chroot-functions.sh @@ -214,7 +214,11 @@ function copy_symlink() { [ ! -e ${clst_root_path}/${1} ] && \ cp -vfdp ${1} ${clst_root_path}/${1} - TARGET=`readlink -f ${1}` + if [[ -n $(type -p realpath) ]]; then + TARGET=`realpath ${1}` + else + TARGET=`readlink -f ${1}` + fi if [ -h ${TARGET} ] then copy_symlink ${TARGET} ${STACK}