mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-18 15:30:21 +00:00
Add -P flag, it does the same as the -p option, except that the
given prefix is also used recursively for the dependency packages, if any. If the -P flag appears after any -p flag on the command line, it overrides it's effect, causing pkg_add to use the given prefix recursively. PR: bin/75742 Submitted by: Frerich Raabe <raabe AT kde DOT org> MFC after: 3 days
This commit is contained in:
parent
71909edec8
commit
3d4e952eef
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=152329
@ -26,6 +26,7 @@
|
||||
typedef enum { NORMAL, MASTER, SLAVE } add_mode_t;
|
||||
|
||||
extern char *Prefix;
|
||||
extern Boolean PrefixRecursive;
|
||||
extern Boolean NoInstall;
|
||||
extern Boolean NoRecord;
|
||||
extern char *Mode;
|
||||
|
@ -27,9 +27,10 @@ __FBSDID("$FreeBSD$");
|
||||
#include "lib.h"
|
||||
#include "add.h"
|
||||
|
||||
static char Options[] = "hvIRfnrp:SMt:C:";
|
||||
static char Options[] = "hvIRfnrp:P:SMt:C:";
|
||||
|
||||
char *Prefix = NULL;
|
||||
Boolean PrefixRecursive = FALSE;
|
||||
char *Chroot = NULL;
|
||||
Boolean NoInstall = FALSE;
|
||||
Boolean NoRecord = FALSE;
|
||||
@ -110,6 +111,12 @@ main(int argc, char **argv)
|
||||
|
||||
case 'p':
|
||||
Prefix = optarg;
|
||||
PrefixRecursive = FALSE;
|
||||
break;
|
||||
|
||||
case 'P':
|
||||
Prefix = optarg;
|
||||
PrefixRecursive = TRUE;
|
||||
break;
|
||||
|
||||
case 'I':
|
||||
@ -310,7 +317,7 @@ static void
|
||||
usage()
|
||||
{
|
||||
fprintf(stderr, "%s\n%s\n",
|
||||
"usage: pkg_add [-vInrfRMS] [-t template] [-p prefix] [-C chrootdir]",
|
||||
"usage: pkg_add [-vInrfRMS] [-t template] [-p prefix] [-P prefix] [-C chrootdir]",
|
||||
" pkg-name [pkg-name ...]");
|
||||
exit(1);
|
||||
}
|
||||
|
@ -297,6 +297,11 @@ pkg_do(char *pkg)
|
||||
char path[FILENAME_MAX], *cp = NULL;
|
||||
|
||||
if (!Fake) {
|
||||
char prefixArg[2 + MAXPATHLEN]; /* "-P" + Prefix */
|
||||
if (PrefixRecursive) {
|
||||
strlcpy(prefixArg, "-P", sizeof(prefixArg));
|
||||
strlcat(prefixArg, Prefix, sizeof(prefixArg));
|
||||
}
|
||||
if (!isURL(pkg) && !getenv("PKG_ADD_BASE")) {
|
||||
const char *ext;
|
||||
|
||||
@ -315,7 +320,7 @@ pkg_do(char *pkg)
|
||||
if (cp) {
|
||||
if (Verbose)
|
||||
printf("Loading it from %s.\n", cp);
|
||||
if (vsystem("%s %s'%s'", PkgAddCmd, Verbose ? "-v " : "", cp)) {
|
||||
if (vsystem("%s %s %s '%s'", PkgAddCmd, Verbose ? "-v " : "", PrefixRecursive ? prefixArg : "", cp)) {
|
||||
warnx("autoload of dependency '%s' failed%s",
|
||||
cp, Force ? " (proceeding anyway)" : "!");
|
||||
if (!Force)
|
||||
@ -338,7 +343,7 @@ pkg_do(char *pkg)
|
||||
if (!Force)
|
||||
++code;
|
||||
}
|
||||
else if (vsystem("(pwd; /bin/cat +CONTENTS) | %s %s-S", PkgAddCmd, Verbose ? "-v " : "")) {
|
||||
else if (vsystem("(pwd; /bin/cat +CONTENTS) | %s %s %s -S", PkgAddCmd, Verbose ? "-v" : "", PrefixRecursive ? prefixArg : "")) {
|
||||
warnx("pkg_add of dependency '%s' failed%s",
|
||||
p->name, Force ? " (proceeding anyway)" : "!");
|
||||
if (!Force)
|
||||
|
@ -15,7 +15,7 @@
|
||||
.\"
|
||||
.\" $FreeBSD$
|
||||
.\"
|
||||
.Dd March 1, 2004
|
||||
.Dd November 12, 2005
|
||||
.Dt PKG_ADD 1
|
||||
.Os
|
||||
.Sh NAME
|
||||
@ -26,6 +26,7 @@
|
||||
.Op Fl vInfrRMS
|
||||
.Op Fl t Ar template
|
||||
.Op Fl p Ar prefix
|
||||
.Op Fl P Ar prefix
|
||||
.Op Fl C Ar chrootdir
|
||||
.Ar pkg-name Op Ar pkg-name ...
|
||||
.Sh DESCRIPTION
|
||||
@ -127,7 +128,29 @@ modes (see the
|
||||
.Fl M
|
||||
and
|
||||
.Fl S
|
||||
options).
|
||||
options). If the
|
||||
.Fl p
|
||||
flag appears after any
|
||||
.Fl P
|
||||
flag on the command line, it overrides it's effect, causing
|
||||
.Nm
|
||||
not to use the given
|
||||
.Ar prefix
|
||||
recursively.
|
||||
.It Fl P Ar prefix
|
||||
Does the same as the
|
||||
.Fl p
|
||||
option, except that the given
|
||||
.Ar prefix
|
||||
is also used recursively for the dependency packages, if any. If the
|
||||
.Fl P
|
||||
flag appears after any
|
||||
.Fl p
|
||||
flag on the command line, it overrides it's effect, causing
|
||||
.Nm
|
||||
to use the given
|
||||
.Ar prefix
|
||||
recursively.
|
||||
.It Fl t Ar template
|
||||
Use
|
||||
.Ar template
|
||||
@ -358,9 +381,10 @@ where
|
||||
.Pa prefix
|
||||
is either the prefix specified with the
|
||||
.Fl p
|
||||
flag or, if no
|
||||
.Fl p
|
||||
flag was specified, the name of the first directory named by a
|
||||
or
|
||||
.Fl P
|
||||
flag or,
|
||||
if neither flag was specified, the name of the first directory named by a
|
||||
.Cm @cwd
|
||||
directive within this package.
|
||||
.It
|
||||
@ -421,12 +445,16 @@ All the scripts are called with the environment variable
|
||||
.Ev PKG_PREFIX
|
||||
set to the installation prefix (see the
|
||||
.Fl p
|
||||
option above).
|
||||
and
|
||||
.Fl P
|
||||
options above).
|
||||
This allows a package author to write a script
|
||||
that reliably performs some action on the directory where the package
|
||||
is installed, even if the user might change it with the
|
||||
.Fl p
|
||||
flag to
|
||||
or
|
||||
.Fl P
|
||||
flags to
|
||||
.Cm pkg_add .
|
||||
.Sh ENVIRONMENT
|
||||
The value of the
|
||||
|
Loading…
Reference in New Issue
Block a user