summaryrefslogtreecommitdiffstats
path: root/usr.sbin
diff options
context:
space:
mode:
authorkensmith <kensmith@FreeBSD.org>2004-03-01 21:58:21 +0000
committerkensmith <kensmith@FreeBSD.org>2004-03-01 21:58:21 +0000
commit370584b78872f5172bdacc16128e7c9ad2d8d160 (patch)
tree0b5a288636fb6557d262c44562a8be7517333ef3 /usr.sbin
parentd48c225260752c53c2b2fbf9ce45062ea73bb7ce (diff)
downloadFreeBSD-src-370584b78872f5172bdacc16128e7c9ad2d8d160.zip
FreeBSD-src-370584b78872f5172bdacc16128e7c9ad2d8d160.tar.gz
Add command line option for chrootdir, all pkg_add(8) operations will be
done inside of chroot(2) to chrootdir. Added to help with sysinstall(8) support of install to alternate root but possibly useful for setting up jails, etc. No objection from: portmgr@ Style(9) abuse due to: entire program violates style(9) Approved by: rwatson (mentor)
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_install/add/main.c16
-rw-r--r--usr.sbin/pkg_install/add/pkg_add.126
2 files changed, 39 insertions, 3 deletions
diff --git a/usr.sbin/pkg_install/add/main.c b/usr.sbin/pkg_install/add/main.c
index b39a547..a993f09 100644
--- a/usr.sbin/pkg_install/add/main.c
+++ b/usr.sbin/pkg_install/add/main.c
@@ -27,9 +27,10 @@ __FBSDID("$FreeBSD$");
#include "lib.h"
#include "add.h"
-static char Options[] = "hvIRfnrp:SMt:";
+static char Options[] = "hvIRfnrp:SMt:C:";
char *Prefix = NULL;
+char *Chroot = NULL;
Boolean NoInstall = FALSE;
Boolean NoRecord = FALSE;
Boolean Remote = FALSE;
@@ -129,6 +130,10 @@ main(int argc, char **argv)
AddMode = MASTER;
break;
+ case 'C':
+ Chroot = optarg;
+ break;
+
case 'h':
case '?':
default:
@@ -210,6 +215,11 @@ main(int argc, char **argv)
warnx("only one package name may be specified with master mode");
usage();
}
+ /* Perform chroot if requested */
+ if (Chroot != NULL) {
+ if (chroot(Chroot))
+ errx(1, "chroot to %s failed", Chroot);
+ }
/* Make sure the sub-execs we invoke get found */
setenv("PATH",
"/sbin:/usr/sbin:/bin:/usr/bin:/usr/X11R6/bin",
@@ -280,7 +290,7 @@ static void
usage()
{
fprintf(stderr, "%s\n%s\n",
- "usage: pkg_add [-vInrfRMS] [-t template] [-p prefix]",
- " pkg-name [pkg-name ...]");
+ "usage: pkg_add [-vInrfRMS] [-t template] [-p prefix] [-C chrootdir]",
+ " pkg-name [pkg-name ...]");
exit(1);
}
diff --git a/usr.sbin/pkg_install/add/pkg_add.1 b/usr.sbin/pkg_install/add/pkg_add.1
index 7940482..e12278b 100644
--- a/usr.sbin/pkg_install/add/pkg_add.1
+++ b/usr.sbin/pkg_install/add/pkg_add.1
@@ -28,6 +28,7 @@
.Op Fl vInfrRMS
.Op Fl t Ar template
.Op Fl p Ar prefix
+.Op Fl C Ar chrootdir
.Ar pkg-name Op Ar pkg-name ...
.Sh DESCRIPTION
The
@@ -188,6 +189,31 @@ in the staging area, the location of which is read as a string
from stdin.
The complete packing list is also read from stdin,
and the contents then acted on as normal.
+.It Fl C Ar chrootdir
+Before doing any operations
+.Xr chroot 2
+to the
+.Ar chrootdir
+directory so that all package files, and the package database, are
+installed to
+.Ar chrootdir .
+Note that
+.Ar chrootdir
+needs to be a fairly complete file system, including everything normally
+needed by
+.Xr pkg_add 8
+to run.
+This flag was added to help support operations done by
+.Xr sysinstall 8
+and is not expected to be useful for much else.
+Be careful that
+.Ar chrootdir
+is properly configured and can not be modified by normal users,
+versions of commands like
+.Xr fetch 1
+may be run inside
+.Ar chrootdir
+as a side-effect.
.El
.Pp
One or more
OpenPOWER on IntegriCloud