pkgsrc-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[pkgsrc/trunk]: pkgsrc/pkgtools/mksandbox Import mksandbox-1.0 as pkgtools/mk...
details: https://anonhg.NetBSD.org/pkgsrc/rev/3555db8bd337
branches: trunk
changeset: 608034:3555db8bd337
user: wiz <wiz%pkgsrc.org@localhost>
date: Sun Aug 26 10:31:23 2012 +0000
description:
Import mksandbox-1.0 as pkgtools/mksandbox.
A small shell script to set up a sandbox (usually for a pkgsrc bulk
build), using null mounts.
The file lived in pkgsrc/mk/bulk/mksandbox, but is worthy of its own
package IMHO. New: with manpage.
diffstat:
pkgtools/mksandbox/DESCR | 2 +
pkgtools/mksandbox/Makefile | 34 ++
pkgtools/mksandbox/PLIST | 3 +
pkgtools/mksandbox/files/mksandbox | 438 +++++++++++++++++++++++++++++++++++
pkgtools/mksandbox/files/mksandbox.8 | 84 ++++++
5 files changed, 561 insertions(+), 0 deletions(-)
diffs (truncated from 581 to 300 lines):
diff -r 7a9eb304d788 -r 3555db8bd337 pkgtools/mksandbox/DESCR
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/mksandbox/DESCR Sun Aug 26 10:31:23 2012 +0000
@@ -0,0 +1,2 @@
+A small shell script to set up a sandbox (usually for a pkgsrc bulk
+build), using null mounts.
diff -r 7a9eb304d788 -r 3555db8bd337 pkgtools/mksandbox/Makefile
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/mksandbox/Makefile Sun Aug 26 10:31:23 2012 +0000
@@ -0,0 +1,34 @@
+# $NetBSD: Makefile,v 1.1 2012/08/26 10:31:23 wiz Exp $
+
+DISTNAME= mksandbox-1.0
+CATEGORIES= pkgtools
+MASTER_SITES= # none
+DISTFILES= # none
+
+MAINTAINER= pkgsrc-users%NetBSD.org@localhost
+HOMEPAGE= http://www.NetBSD.org/docs/pkgsrc/bulk.html#setting-up-a-sandbox
+COMMENT= Tool for creating sandboxes
+LICENSE= original-bsd
+
+PKG_DESTDIR_SUPPORT= user-destdir
+
+WRKSRC= ${WRKDIR}
+NO_BUILD= yes
+USE_LANGUAGES= # none
+INSTALLATION_DIRS= sbin ${PKGMANDIR}/man8
+
+do-extract:
+ cd ${FILESDIR} && cp mksandbox mksandbox.8 ${WRKSRC}/
+
+.include "../../mk/bsd.prefs.mk"
+
+SUBST_CLASSES+= up
+SUBST_STAGE.up= do-configure
+SUBST_FILES.up= mksandbox mksandbox.8
+SUBST_SED.up+= -e 's,/usr/pkgsrc,${PKGSRCDIR},g'
+
+do-install:
+ ${INSTALL_SCRIPT} ${WRKSRC}/mksandbox ${DESTDIR}${PREFIX}/sbin/
+ ${INSTALL_MAN} ${WRKSRC}/mksandbox.8 ${DESTDIR}${PREFIX}/${PKGMANDIR}/man8
+
+.include "../../mk/bsd.pkg.mk"
diff -r 7a9eb304d788 -r 3555db8bd337 pkgtools/mksandbox/PLIST
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/mksandbox/PLIST Sun Aug 26 10:31:23 2012 +0000
@@ -0,0 +1,3 @@
+@comment $NetBSD: PLIST,v 1.1 2012/08/26 10:31:23 wiz Exp $
+sbin/mksandbox
+man/man8/mksandbox.8
diff -r 7a9eb304d788 -r 3555db8bd337 pkgtools/mksandbox/files/mksandbox
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/pkgtools/mksandbox/files/mksandbox Sun Aug 26 10:31:23 2012 +0000
@@ -0,0 +1,438 @@
+#! /bin/sh
+
+# $NetBSD: mksandbox,v 1.1 2012/08/26 10:31:23 wiz Exp $
+#
+#
+# Copyright (c) 2002 Alistair G. Crooks. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# 3. All advertising materials mentioning features or use of this software
+# must display the following acknowledgement:
+# This product includes software developed by Alistair G. Crooks
+# for the NetBSD project.
+# 4. The name of the author may not be used to endorse or promote
+# products derived from this software without specific prior written
+# permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
+# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
+# GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+
+# Usage: mksandbox [--pkgsrc=dir] [--src=srcdir] [--xsrc=xsrcdir] [--without-x] [--verbose] sandbox-dir
+#
+# A small shell script to set up a sandbox (usually for a pkgsrc bulk
+# build), using null mounts.
+
+pkgsrc=/usr/pkgsrc
+src=/usr/src
+xsrc=/usr/xsrc
+with_x=yes
+
+kernel=""
+sandboxWriteDirs=""
+sandboxMountDirs="/bin /sbin /lib /libexec /usr/X11R7 /usr/bin /usr/games /usr/include /usr/lib /usr/libdata /usr/libexec /usr/lkm /usr/share /usr/sbin /var/mail"
+sandboxEmptyDirs="/var/run /var/log /var/spool/lock /var/spool/mqueue"
+sandboxEmptyFiles="/var/run/utmp /var/run/utmpx /var/log/wtmp /var/log/wtmpx /var/log/lastlog /var/log/lastlogx"
+
+usage()
+{
+ echo "Usage: mksandbox [--mounthost=host] [--pkgsrc=dir] [--src=srcdir] [--xsrc=xsrcdir] [--without-x] [--verbose] sandbox-dir"
+ exit 1
+}
+
+err()
+{
+ echo "error: $1"
+ exit 1
+}
+
+# by default, don't require src and xsrc to be available
+need_src=no
+need_xsrc=no
+
+opsys=`uname -s`
+case "$opsys" in
+Darwin)
+ bmakeprog=bmake
+ chmodprog=/bin/chmod
+ chownprog=/usr/sbin/chown
+ cpprog=/bin/cp
+ gtarprog=/usr/bin/gnutar
+ idprog=/usr/bin/id
+ kernel=/mach_kernel
+ mkdirprog="/bin/mkdir -p"
+ 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 /usr/X11 /System/Library /Library"
+ sandboxWriteDirs="$sandboxWriteDirs /Library/Server/Mail/Data"
+ ;;
+FreeBSD)
+ bmakeprog=bmake
+ chmodprog=/bin/chmod
+ chownprog=/usr/sbin/chown
+ cpprog=/bin/cp
+ gtarprog=/usr/bin/tar
+ idprog=/usr/bin/id
+ mkdirprog="/bin/mkdir -p"
+ mountflags="-t nullfs"
+ mountprog=/sbin/mount
+ paxprog=/bin/pax
+ sedprog=/usr/bin/sed
+ ;;
+Interix)
+ echo >&2 "This script cannot be used on Interix; a different procedure is required."
+ echo >&2 "(To be documented.)"
+ exit 1
+ ;;
+Linux)
+ bmakeprog=bmake
+ chmodprog=/bin/chmod
+ chownprog=/bin/chown
+ cpprog=/bin/cp
+ gtarprog=/bin/tar
+ idprog=/usr/bin/id
+ mkdirprog="/bin/mkdir -p"
+ mountflags="--bind"
+ if [ -f /bin/mount ]; then
+ mountprog=/bin/mount
+ else
+ mountprog=/sbin/mount
+ fi
+ paxprog=""
+ sedprog=/bin/sed
+ sandboxMountDirs="$sandboxMountDirs /proc /usr/kerberos"
+ ;;
+NetBSD)
+ bmakeprog=make
+ chmodprog=/bin/chmod
+ chownprog=/usr/sbin/chown
+ cpprog=/bin/cp
+ gtarprog=/usr/bin/tar
+ idprog=/usr/bin/id
+ kernel=/netbsd
+ mkdirprog="/bin/mkdir -p"
+ mountflags="-t null"
+ mountprog=/sbin/mount
+ paxprog=/bin/pax
+ sedprog=/usr/bin/sed
+ need_src=yes
+ need_xsrc=yes
+ ;;
+SunOS)
+ bmakeprog=bmake
+ chmodprog=/usr/bin/chmod
+ chownprog=/usr/bin/chown
+ cpprog=/usr/bin/cp
+ gtarprog=""
+ idprog=/usr/xpg4/bin/id
+ mkdirprog="/usr/bin/mkdir -p"
+ mountflags="-F lofs"
+ mountprog=/sbin/mount
+ paxprog=/bin/pax
+ sedprog=/usr/xpg4/bin/sed
+ sandboxMountDirs="/bin /sbin /kernel /lib /proc /opt/SUNWspro /usr/X11R6 /usr/5bin /usr/bin /usr/ccs /usr/dt /usr/games /usr/include /usr/lib /usr/openwin /usr/share /usr/sbin /usr/sadm
/usr/ucb /usr/ucblib /usr/xpg4 /var/mail /var/sadm"
+ sandboxEmptyDirs="$sandboxEmptyDirs /usr/tmp /var/tmp"
+ ;;
+*)
+ echo "Unknown Operating System ($opsys) - good luck"
+ bmakeprog=bmake
+ chmodprog=chmod
+ chownprog=chown
+ cpprog=cp
+ gtarprog="tar"
+ idprog="id"
+ mkdirprog="mkdir -p"
+ mountflags="-t null"
+ mountprog=mount
+ paxprog=pax
+ sedprog=sed
+ ;;
+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=||'` ;;
+ --without-x) with_x=no ;;
+ --verbose) set -x ;;
+ -*) usage ;;
+ *) break ;;
+ esac
+ shift
+done
+
+if [ $# -ne 1 ]; then
+ usage
+fi
+
+if [ "$with_x" = "no" ]; then
+ need_xsrc=no
+fi
+
+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
+
+if [ ! -d $src -a "$need_src" = "yes" ]; then
+ err "source directory $src does not exist."
+fi
+
+if [ ! -d $xsrc -a "$need_xsrc" = "yes" ]; then
+ err "xsrc directory $xsrc does not exist."
+fi
+
+sandbox=$1
+sandbox_script="$sandbox/sandbox"
+
+packages=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=PACKAGES)`
+distfiles=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=DISTDIR)`
+localbase=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=LOCALBASE)`
+pkg_dbdir=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=PKG_DBDIR)`
+localpatches=`(cd $pkgsrc/pkgtools/lintpkgsrc; $bmakeprog show-var VARNAME=LOCALPATCHES)`
+
+test -d "$localpatches" || echo "WARNING: LOCALPATCHES directory does not exist - ignoring"
+
+$mkdirprog $sandbox
+cat > $sandbox_script <<EOS
+#! /bin/sh -
+mounthost=$mounthost
+opsys=$opsys
+sandbox=$sandbox
+
+r3() {
+ _R=
+ while [ \$# -ge 3 ]
+ do
+ _R="\$1 \$2 \$3 \$_R"
+ shift; shift; shift
+ done
+ echo "\$_R"
+}
+
+fses="\\
+EOS
+
+if [ ! -z "$kernel" ]; then
Home |
Main Index |
Thread Index |
Old Index