1993-08-26 01:19:55 +00:00
|
|
|
#ifndef lint
|
1997-10-08 07:48:21 +00:00
|
|
|
static const char rcsid[] =
|
1999-08-28 01:35:59 +00:00
|
|
|
"$FreeBSD$";
|
1993-08-26 01:19:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FreeBSD install - a package for the installation and maintainance
|
|
|
|
* of non-core utilities.
|
|
|
|
*
|
|
|
|
* Jordan K. Hubbard
|
|
|
|
* 18 July 1993
|
|
|
|
*
|
|
|
|
* This is the create module.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1997-10-08 07:48:21 +00:00
|
|
|
#include <err.h>
|
1993-08-26 01:19:55 +00:00
|
|
|
#include "lib.h"
|
|
|
|
#include "create.h"
|
|
|
|
|
2001-10-08 17:01:35 +00:00
|
|
|
static char Options[] = "YNOhvyf:p:P:c:d:i:I:k:K:r:t:X:D:m:s:o:b:";
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
char *Prefix = NULL;
|
|
|
|
char *Comment = NULL;
|
|
|
|
char *Desc = NULL;
|
1997-06-06 12:19:11 +00:00
|
|
|
char *SrcDir = NULL;
|
1994-12-06 00:51:50 +00:00
|
|
|
char *Display = NULL;
|
1993-08-26 01:19:55 +00:00
|
|
|
char *Install = NULL;
|
1998-12-16 13:59:31 +00:00
|
|
|
char *PostInstall = NULL;
|
1993-08-26 01:19:55 +00:00
|
|
|
char *DeInstall = NULL;
|
1998-12-16 13:59:31 +00:00
|
|
|
char *PostDeInstall = NULL;
|
1993-08-26 01:19:55 +00:00
|
|
|
char *Contents = NULL;
|
|
|
|
char *Require = NULL;
|
1993-09-12 20:45:31 +00:00
|
|
|
char *ExcludeFrom = NULL;
|
1994-12-06 00:51:50 +00:00
|
|
|
char *Mtree = NULL;
|
1995-04-09 15:05:01 +00:00
|
|
|
char *Pkgdeps = NULL;
|
2000-10-23 07:01:31 +00:00
|
|
|
char *Origin = NULL;
|
2001-10-08 17:01:35 +00:00
|
|
|
char *InstalledPkg = NULL;
|
1997-06-06 12:19:11 +00:00
|
|
|
char PlayPen[FILENAME_MAX];
|
2001-01-16 08:27:28 +00:00
|
|
|
int Dereference = FALSE;
|
|
|
|
int PlistOnly = FALSE;
|
2001-01-22 12:01:55 +00:00
|
|
|
int UseBzip2 = FALSE;
|
1993-08-26 01:19:55 +00:00
|
|
|
|
1997-10-08 07:48:21 +00:00
|
|
|
static void usage __P((void));
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int ch;
|
2001-10-08 17:01:35 +00:00
|
|
|
char **pkgs, **start, *tmp;
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
pkgs = start = argv;
|
1997-03-31 05:11:47 +00:00
|
|
|
while ((ch = getopt(argc, argv, Options)) != -1)
|
1993-08-26 01:19:55 +00:00
|
|
|
switch(ch) {
|
|
|
|
case 'v':
|
|
|
|
Verbose = TRUE;
|
|
|
|
break;
|
|
|
|
|
1994-04-05 14:05:40 +00:00
|
|
|
case 'N':
|
|
|
|
AutoAnswer = NO;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Y':
|
|
|
|
AutoAnswer = YES;
|
|
|
|
break;
|
|
|
|
|
1995-04-22 00:03:18 +00:00
|
|
|
case 'O':
|
2001-01-16 08:27:28 +00:00
|
|
|
PlistOnly = TRUE;
|
1995-04-22 00:03:18 +00:00
|
|
|
break;
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
case 'p':
|
|
|
|
Prefix = optarg;
|
|
|
|
break;
|
|
|
|
|
1997-06-06 12:19:11 +00:00
|
|
|
case 's':
|
|
|
|
SrcDir = optarg;
|
|
|
|
break;
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
case 'f':
|
|
|
|
Contents = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
Comment = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
Desc = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'i':
|
|
|
|
Install = optarg;
|
|
|
|
break;
|
|
|
|
|
1998-12-16 13:59:31 +00:00
|
|
|
case 'I':
|
|
|
|
PostInstall = optarg;
|
|
|
|
break;
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
case 'k':
|
|
|
|
DeInstall = optarg;
|
|
|
|
break;
|
|
|
|
|
1998-12-16 13:59:31 +00:00
|
|
|
case 'K':
|
|
|
|
PostDeInstall = optarg;
|
|
|
|
break;
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
case 'r':
|
|
|
|
Require = optarg;
|
|
|
|
break;
|
|
|
|
|
1993-09-05 04:54:24 +00:00
|
|
|
case 't':
|
2001-10-16 03:04:15 +00:00
|
|
|
strlcpy(PlayPen, optarg, sizeof(PlayPen));
|
1993-09-05 04:54:24 +00:00
|
|
|
break;
|
|
|
|
|
1993-09-12 20:45:31 +00:00
|
|
|
case 'X':
|
|
|
|
ExcludeFrom = optarg;
|
|
|
|
break;
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
case 'h':
|
2001-01-16 08:27:28 +00:00
|
|
|
Dereference = TRUE;
|
1994-05-19 18:27:41 +00:00
|
|
|
break;
|
|
|
|
|
1994-12-06 00:51:50 +00:00
|
|
|
case 'D':
|
|
|
|
Display = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'm':
|
|
|
|
Mtree = optarg;
|
|
|
|
break;
|
|
|
|
|
1995-04-09 15:05:01 +00:00
|
|
|
case 'P':
|
|
|
|
Pkgdeps = optarg;
|
|
|
|
break;
|
|
|
|
|
2000-10-23 07:01:31 +00:00
|
|
|
case 'o':
|
|
|
|
Origin = optarg;
|
|
|
|
break;
|
|
|
|
|
2001-01-22 12:01:55 +00:00
|
|
|
case 'y':
|
2001-01-24 08:22:53 +00:00
|
|
|
UseBzip2 = TRUE;
|
2001-01-22 12:01:55 +00:00
|
|
|
break;
|
|
|
|
|
2001-10-08 17:01:35 +00:00
|
|
|
case 'b':
|
|
|
|
while ((tmp = strrchr(optarg, (int)'/')) != NULL) {
|
|
|
|
*tmp++ = '\0';
|
|
|
|
/*
|
|
|
|
* If character after the '/' is alphanumeric, then we've
|
|
|
|
* found the package name. Otherwise we've come across
|
|
|
|
* a trailing '/' and need to continue our quest.
|
|
|
|
*/
|
|
|
|
if (isalpha(*tmp)) {
|
|
|
|
InstalledPkg = tmp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
case '?':
|
|
|
|
default:
|
1997-10-08 07:48:21 +00:00
|
|
|
usage();
|
1993-08-26 01:19:55 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1995-05-30 03:57:47 +00:00
|
|
|
argc -= optind;
|
1993-08-26 01:19:55 +00:00
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
/* Get all the remaining package names, if any */
|
|
|
|
while (*argv)
|
|
|
|
*pkgs++ = *argv++;
|
|
|
|
|
|
|
|
/* If no packages, yelp */
|
2001-10-08 17:01:35 +00:00
|
|
|
if ((pkgs == start) && (InstalledPkg == NULL))
|
1997-10-08 07:48:21 +00:00
|
|
|
warnx("missing package name"), usage();
|
1993-08-26 01:19:55 +00:00
|
|
|
*pkgs = NULL;
|
2001-10-08 17:01:35 +00:00
|
|
|
if ((start[0] != NULL) && (start[1] != NULL)) {
|
|
|
|
warnx("only one package name allowed ('%s' extraneous)", start[1]);
|
1997-10-08 07:48:21 +00:00
|
|
|
usage();
|
2001-10-08 17:01:35 +00:00
|
|
|
}
|
|
|
|
if (start[0] == NULL)
|
|
|
|
start[0] = InstalledPkg;
|
1993-08-26 01:19:55 +00:00
|
|
|
if (!pkg_perform(start)) {
|
|
|
|
if (Verbose)
|
1997-10-08 07:48:21 +00:00
|
|
|
warnx("package creation failed");
|
1993-08-26 01:19:55 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
1997-10-08 07:48:21 +00:00
|
|
|
static void
|
|
|
|
usage()
|
1993-08-26 01:19:55 +00:00
|
|
|
{
|
2001-10-08 17:01:35 +00:00
|
|
|
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
|
2001-01-22 12:01:55 +00:00
|
|
|
"usage: pkg_create [-YNOhvy] [-P pkgs] [-p prefix] [-f contents] [-i iscript]",
|
1998-12-16 13:59:31 +00:00
|
|
|
" [-I piscript] [-k dscript] [-K pdscript] [-r rscript] ",
|
|
|
|
" [-t template] [-X excludefile] [-D displayfile] ",
|
2000-10-23 07:01:31 +00:00
|
|
|
" [-m mtreefile] [-o origin] -c comment -d description ",
|
2001-10-08 17:01:35 +00:00
|
|
|
" -f packlist pkg-filename",
|
|
|
|
" pkg_create [-YNhvy] -b pkg-name [pkg-filename]");
|
1993-08-26 01:19:55 +00:00
|
|
|
exit(1);
|
|
|
|
}
|