diff options
-rwxr-xr-x | mk/bulk/mksandbox | 51 |
1 files changed, 50 insertions, 1 deletions
diff --git a/mk/bulk/mksandbox b/mk/bulk/mksandbox index a45d938b6a5..88c9847d9f9 100755 --- a/mk/bulk/mksandbox +++ b/mk/bulk/mksandbox @@ -1,6 +1,6 @@ #! /bin/sh -# $NetBSD: mksandbox,v 1.5 2002/08/12 14:47:07 seb Exp $ +# $NetBSD: mksandbox,v 1.6 2002/08/12 15:19:49 seb Exp $ # # # Copyright (c) 2002 Alistair G. Crooks. All rights reserved. @@ -118,6 +118,7 @@ if [ `id -u` -ne 0 ]; then fi sandbox=$1 +sandbox_script="$sandbox/sandbox" packages=`(cd $pkgsrc/pkgtools/pkglint; $bmakeprog show-var VARNAME=PACKAGES)` distfiles=`(cd $pkgsrc/pkgtools/pkglint; $bmakeprog show-var VARNAME=DISTDIR)` @@ -125,6 +126,11 @@ localbase=`(cd $pkgsrc/pkgtools/pkglint; $bmakeprog show-var VARNAME=LOCALBASE)` pkg_dbdir=`(cd $pkgsrc/pkgtools/pkglint; $bmakeprog show-var VARNAME=PKG_DBDIR)` $mkdirprog $sandbox +cat > $sandbox_script <<EOS +#! /bin/sh - +sandbox=$sandbox +fses="\\ +EOS echo "Copying the kernel" $cpprog /netbsd $sandbox @@ -162,6 +168,7 @@ for d in /bin \ /var/mail; do \ $mkdirprog $sandbox$d; \ $mountprog -r -t null $d $sandbox$d; \ + echo "$d $d ro \\" >> $sandbox_script done echo "Making /tmp in $sandbox" @@ -171,15 +178,57 @@ $chmodprog 1777 $sandbox/tmp $sandbox/var/tmp echo "Mount $src from $sandbox" $mkdirprog $sandbox/usr/src $mountprog -r -t null $src $sandbox/usr/src +echo "$src /usr/src ro \\" >> $sandbox_script echo "Mount $pkgsrc from $sandbox" $mkdirprog $sandbox/usr/pkgsrc $mountprog -t null $pkgsrc $sandbox/usr/pkgsrc +echo "$pkgsrc /usr/pkgsrc rw \\" >> $sandbox_script echo "Mounting $packages and $distfiles from $sandbox" $mkdirprog $sandbox/$packages $sandbox/$distfiles $mountprog -t null $packages $sandbox/$packages $mountprog -t null $distfiles $sandbox/$distfiles +echo "$packages $packages rw \\" >> $sandbox_script +echo "$distfiles $distfiles rw \\" >> $sandbox_script + +cat >> $sandbox_script <<EOS +" +case x\$1 in + xmount) + set dummy \$fses + shift + while [ \$# -ge 3 ]; do + fs=\$1; shift + mntpoint=\$1; shift + rwro=\$1; shift + case \$rwro in + ro) mount -r -t null \$fs \$sandbox/\$mntpoint || exit 1 ;; + rw) mount -t null \$fs \$sandbox/\$mntpoint || exit 1 ;; + esac + done + ;; + xumount) + set dummy \$fses + shift + while [ \$# -ge 3 ]; do + fs=\$1; shift + mntpoint=\$1; shift + dummy=\$1; shift + umount \$sandbox/\$mntpoint + done + ;; + *) + if [ \$# -eq 0 ]; then + set dummy /bin/sh + shift + fi + chroot \$sandbox "\$@" + ;; +esac +EOS + +chmod +x $sandbox_script echo "Sandbox creation is now complete" |