From afda14bfef474fdc491931e9b57a5d5e622edab3 Mon Sep 17 00:00:00 2001 From: jperkin Date: Tue, 3 Jul 2012 12:05:40 +0000 Subject: Update for OSX Lion. OSX hasn't included the ability to loopback mount for a while, so introduce NFS support, configurable via a new --mounthost option, and add additional directories required for proper support. This mostly works, however something is causing name lookups to fail in the chroot and it will currently only look at /etc/hosts. Clue appreciated here. Also fix /dev mounting/unmounting from the sandbox script. --- mk/bulk/mksandbox | 67 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 47 insertions(+), 20 deletions(-) (limited to 'mk') diff --git a/mk/bulk/mksandbox b/mk/bulk/mksandbox index 0826afca6ba..d91a14ed7c2 100755 --- a/mk/bulk/mksandbox +++ b/mk/bulk/mksandbox @@ -1,6 +1,6 @@ #! /bin/sh -# $NetBSD: mksandbox,v 1.53 2012/01/15 13:34:28 ryoon Exp $ +# $NetBSD: mksandbox,v 1.54 2012/07/03 12:05:40 jperkin Exp $ # # # Copyright (c) 2002 Alistair G. Crooks. All rights reserved. @@ -51,7 +51,7 @@ sandboxEmptyFiles="/var/run/utmp /var/run/utmpx /var/log/wtmp /var/log/wtmpx /va usage() { - echo "Usage: mksandbox [--pkgsrc=dir] [--src=srcdir] [--xsrc=xsrcdir] [--without-x] [--verbose] sandbox-dir" + echo "Usage: mksandbox [--mounthost=host] [--pkgsrc=dir] [--src=srcdir] [--xsrc=xsrcdir] [--without-x] [--verbose] sandbox-dir" exit 1 } @@ -75,10 +75,13 @@ Darwin) gtarprog=/usr/bin/gnutar idprog=/usr/bin/id mkdirprog="/bin/mkdir -p" - mountflags="-t null" + mountflags="-t nfs" + mounthost="localhost" mountprog=/sbin/mount paxprog=/bin/pax sedprog=/usr/bin/sed + sandboxEmptyDirs="$sandboxEmptyDirs /var/root" + sandboxMountDirs="$sandboxMountDirs /usr/llvm-gcc-4.2 /System/Library /Library" ;; FreeBSD) bmakeprog=bmake @@ -165,6 +168,7 @@ esac while [ $# -gt 0 ]; do case "$1" in + --mounthost=*) mounthost=`echo $1 | $sedprog -e 's|^--mounthost=||'` ;; --pkgsrc=*) pkgsrc=`echo $1 | $sedprog -e 's|^--pkgsrc=||'` ;; --src=*) src=`echo $1 | $sedprog -e 's|^--src=||'` ;; --xsrc=*) xsrc=`echo $1 | $sedprog -e 's|^--xsrc=||'` ;; @@ -188,6 +192,10 @@ if [ `$idprog -u` -ne 0 ]; then err "You must be root to run this script." fi +if [ -n "$mounthost" ]; then + mounthost="$mounthost:" +fi + if [ ! -d $pkgsrc ]; then err "pkgsrc directory $pkgsrc does not exist." fi @@ -214,6 +222,8 @@ test -d "$localpatches" || echo "WARNING: LOCALPATCHES directory does not exist $mkdirprog $sandbox cat > $sandbox_script <> $sandbox_script + $mountprog $mountflags -r $mounthost$d $sandbox$d; + echo "$mounthost$d $d ro \\" >> $sandbox_script done echo "Making /tmp in $sandbox" @@ -316,8 +326,8 @@ fi echo "Mount $pkgsrc from $sandbox" $mkdirprog $sandbox/usr/pkgsrc -$mountprog $mountflags $pkgsrc $sandbox/usr/pkgsrc -echo "$pkgsrc /usr/pkgsrc rw \\" >> $sandbox_script +$mountprog $mountflags $mounthost$pkgsrc $sandbox/usr/pkgsrc +echo "$mounthost$pkgsrc /usr/pkgsrc rw \\" >> $sandbox_script if [ "$need_xsrc" = "yes" ]; then echo "Mount $xsrc from $sandbox" @@ -329,10 +339,10 @@ fi echo "Mounting $packages and $distfiles from $sandbox" $mkdirprog $sandbox/$packages $sandbox/$distfiles $mkdirprog $packages $distfiles -$mountprog $mountflags $packages $sandbox/$packages -$mountprog $mountflags $distfiles $sandbox/$distfiles -echo "$packages $packages rw \\" >> $sandbox_script -echo "$distfiles $distfiles rw \\" >> $sandbox_script +$mountprog $mountflags $mounthost$packages $sandbox/$packages +$mountprog $mountflags $mounthost$distfiles $sandbox/$distfiles +echo "$mounthost$packages $packages rw \\" >> $sandbox_script +echo "$mounthost$distfiles $distfiles rw \\" >> $sandbox_script if [ -n "$localpatches" ] && [ -d "$localpatches" ]; then echo "Mounting $localpatches from $sandbox" @@ -344,7 +354,7 @@ fi cat >> $sandbox_script <