1993-08-26 01:19:55 +00:00
|
|
|
/*
|
|
|
|
* FreeBSD install - a package for the installation and maintainance
|
|
|
|
* of non-core utilities.
|
|
|
|
*
|
|
|
|
* Jordan K. Hubbard
|
|
|
|
* 18 July 1993
|
|
|
|
*
|
|
|
|
* This is the create module.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2002-04-01 09:39:07 +00:00
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
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"
|
|
|
|
|
2003-04-17 09:56:05 +00:00
|
|
|
static char Options[] = "YNOhjvyzf:p:P:C: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;
|
2003-04-17 09:56:05 +00:00
|
|
|
char *Conflicts = 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;
|
2002-04-20 21:20:58 +00:00
|
|
|
enum zipper Zipper = GZIP;
|
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;
|
|
|
|
|
2003-04-17 09:56:05 +00:00
|
|
|
case 'C':
|
|
|
|
Conflicts = optarg;
|
|
|
|
break;
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
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':
|
2002-04-20 21:20:58 +00:00
|
|
|
case 'j':
|
|
|
|
Zipper = BZIP2;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'z':
|
|
|
|
Zipper = GZIP;
|
2001-01-22 12:01:55 +00:00
|
|
|
break;
|
|
|
|
|
2001-10-08 17:01:35 +00:00
|
|
|
case 'b':
|
2001-10-25 07:56:20 +00:00
|
|
|
InstalledPkg = optarg;
|
2001-10-08 17:01:35 +00:00
|
|
|
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",
|
2003-04-17 09:56:05 +00:00
|
|
|
"usage: pkg_create [-YNOhvy] [-P pkgs] [-C conflicts] [-p prefix] [-f contents] ",
|
|
|
|
" [-i iscript] [-I piscript] [-k dscript] [-K pdscript] ",
|
|
|
|
" [-r rscript] [-t template] [-X excludefile] ",
|
|
|
|
" [-D displayfile] [-m mtreefile] [-o origin] ",
|
|
|
|
" -c comment -d description -f packlist pkg-filename",
|
2001-10-08 17:01:35 +00:00
|
|
|
" pkg_create [-YNhvy] -b pkg-name [pkg-filename]");
|
1993-08-26 01:19:55 +00:00
|
|
|
exit(1);
|
|
|
|
}
|