2005-11-05 16:11:02 +03:00
|
|
|
/* $NetBSD: main.c,v 1.28 2005/11/05 13:11:02 wiz Exp $ */
|
1997-06-05 16:59:18 +04:00
|
|
|
|
2005-11-05 16:11:02 +03:00
|
|
|
#if HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
#include <nbcompat.h>
|
|
|
|
#if HAVE_SYS_CDEFS_H
|
1997-10-17 18:53:18 +04:00
|
|
|
#include <sys/cdefs.h>
|
2005-11-05 16:11:02 +03:00
|
|
|
#endif
|
1997-06-05 12:54:23 +04:00
|
|
|
#ifndef lint
|
1997-06-05 16:59:18 +04:00
|
|
|
#if 0
|
1997-10-16 04:31:32 +04:00
|
|
|
static const char *rcsid = "from FreeBSD Id: main.c,v 1.17 1997/10/08 07:46:23 charnier Exp";
|
1997-06-05 16:59:18 +04:00
|
|
|
#else
|
2005-11-05 16:11:02 +03:00
|
|
|
__RCSID("$NetBSD: main.c,v 1.28 2005/11/05 13:11:02 wiz Exp $");
|
1997-06-05 16:59:18 +04:00
|
|
|
#endif
|
1997-06-05 12:54:23 +04: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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2005-11-05 16:11:02 +03:00
|
|
|
#if HAVE_ERR_H
|
1997-10-16 04:31:32 +04:00
|
|
|
#include <err.h>
|
2005-11-05 16:11:02 +03:00
|
|
|
#endif
|
1997-06-05 12:54:23 +04:00
|
|
|
#include "lib.h"
|
|
|
|
#include "create.h"
|
|
|
|
|
2003-09-02 11:34:47 +04:00
|
|
|
static const char Options[] = "B:C:D:EFI:K:L:OP:RS:UVX:b:c:d:f:hi:k:lm:n:p:r:s:t:v";
|
1997-06-05 12:54:23 +04:00
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
char *Prefix = NULL;
|
|
|
|
char *Comment = NULL;
|
|
|
|
char *Desc = NULL;
|
|
|
|
char *Display = NULL;
|
|
|
|
char *Install = NULL;
|
|
|
|
char *DeInstall = NULL;
|
|
|
|
char *Contents = NULL;
|
|
|
|
char *Require = NULL;
|
|
|
|
char *ExcludeFrom = NULL;
|
|
|
|
char *Mtree = NULL;
|
|
|
|
char *Pkgdeps = NULL;
|
|
|
|
char *Pkgcfl = NULL;
|
|
|
|
char *BuildVersion = NULL;
|
|
|
|
char *BuildInfo = NULL;
|
1999-11-29 22:48:44 +03:00
|
|
|
char *SizePkg = NULL;
|
|
|
|
char *SizeAll = NULL;
|
2003-01-10 14:55:44 +03:00
|
|
|
char *Preserve = NULL;
|
1999-12-20 06:25:57 +03:00
|
|
|
char *SrcDir = NULL;
|
2001-05-21 13:17:28 +04:00
|
|
|
char *realprefix = NULL;
|
2004-12-29 14:34:59 +03:00
|
|
|
char PlayPen[MaxPathSize];
|
1999-08-24 04:48:37 +04:00
|
|
|
size_t PlayPenSize = sizeof(PlayPen);
|
2001-05-18 17:21:38 +04:00
|
|
|
int update_pkgdb = 1;
|
2003-09-02 11:34:47 +04:00
|
|
|
int create_views = 0;
|
1999-08-24 04:48:37 +04:00
|
|
|
int Dereference = 0;
|
|
|
|
int PlistOnly = 0;
|
|
|
|
int RelativeLinks = 0;
|
|
|
|
int ReorderDirs = 0;
|
|
|
|
Boolean File2Pkg = FALSE;
|
1997-06-05 12:54:23 +04:00
|
|
|
|
1998-10-12 16:03:24 +04:00
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
2001-05-28 11:59:53 +04:00
|
|
|
fprintf(stderr, "%s\n%s\n%s\n%s\n%s\n%s\n",
|
2003-09-02 11:34:47 +04:00
|
|
|
"usage: pkg_create [-ORUEhlVv] [-P dpkgs] [-C cpkgs] [-p prefix] [-f contents]",
|
1999-08-24 04:48:37 +04:00
|
|
|
" [-i iscript] [-k dscript] [-r rscript] [-t template]",
|
|
|
|
" [-X excludefile] [-D displayfile] [-m mtreefile]",
|
|
|
|
" [-b build-version-file] [-B build-info-file]",
|
2001-05-21 13:17:28 +04:00
|
|
|
" [-I realprefix]",
|
1999-08-24 04:48:37 +04:00
|
|
|
" -c comment -d description -f packlist pkg-name");
|
|
|
|
exit(1);
|
1998-10-12 16:03:24 +04:00
|
|
|
}
|
1997-10-16 04:31:32 +04:00
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
1999-08-24 04:48:37 +04:00
|
|
|
int ch;
|
|
|
|
lpkg_head_t pkgs;
|
|
|
|
lpkg_t *lpp;
|
|
|
|
|
2003-06-05 17:15:43 +04:00
|
|
|
setprogname(argv[0]);
|
1999-08-24 04:48:37 +04:00
|
|
|
while ((ch = getopt(argc, argv, Options)) != -1)
|
|
|
|
switch (ch) {
|
|
|
|
case 'v':
|
|
|
|
Verbose = TRUE;
|
|
|
|
break;
|
|
|
|
|
2003-09-02 11:34:47 +04:00
|
|
|
case 'E':
|
|
|
|
create_views = 1;
|
|
|
|
break;
|
|
|
|
|
2001-05-21 13:17:28 +04:00
|
|
|
case 'I':
|
|
|
|
realprefix = optarg;
|
|
|
|
break;
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
case 'O':
|
|
|
|
PlistOnly = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'R':
|
|
|
|
ReorderDirs = 1;
|
|
|
|
break;
|
|
|
|
|
2001-05-18 17:21:38 +04:00
|
|
|
case 'U':
|
|
|
|
update_pkgdb = 0;
|
|
|
|
break;
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
case 'p':
|
|
|
|
Prefix = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 's':
|
1999-11-29 22:48:44 +03:00
|
|
|
SizePkg = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'S':
|
|
|
|
SizeAll = optarg;
|
1999-08-24 04:48:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'f':
|
|
|
|
Contents = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
Comment = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
Desc = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'i':
|
|
|
|
Install = optarg;
|
|
|
|
break;
|
|
|
|
|
2003-09-02 11:34:47 +04:00
|
|
|
case 'K':
|
|
|
|
_pkgdb_setPKGDB_DIR(optarg);
|
|
|
|
break;
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
case 'k':
|
|
|
|
DeInstall = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'l':
|
|
|
|
RelativeLinks = 1;
|
|
|
|
break;
|
|
|
|
|
1999-12-20 06:25:57 +03:00
|
|
|
case 'L':
|
|
|
|
SrcDir = optarg;
|
|
|
|
break;
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
case 'r':
|
|
|
|
Require = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 't':
|
2003-07-14 10:17:54 +04:00
|
|
|
strlcpy(PlayPen, optarg, sizeof(PlayPen));
|
1999-08-24 04:48:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'X':
|
|
|
|
ExcludeFrom = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'h':
|
|
|
|
Dereference = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'D':
|
|
|
|
Display = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'm':
|
|
|
|
Mtree = optarg;
|
|
|
|
break;
|
|
|
|
|
2003-01-10 14:55:44 +03:00
|
|
|
case 'n':
|
|
|
|
Preserve = optarg;
|
|
|
|
break;
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
case 'P':
|
|
|
|
Pkgdeps = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'C':
|
|
|
|
Pkgcfl = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'b':
|
|
|
|
BuildVersion = optarg;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'B':
|
|
|
|
BuildInfo = optarg;
|
|
|
|
break;
|
|
|
|
|
2001-03-05 19:53:12 +03:00
|
|
|
case 'V':
|
|
|
|
show_version();
|
|
|
|
/* NOTREACHED */
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
usage();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
TAILQ_INIT(&pkgs);
|
|
|
|
|
|
|
|
/* Get all the remaining package names, if any */
|
|
|
|
while (*argv) {
|
|
|
|
lpp = alloc_lpkg(*argv);
|
|
|
|
TAILQ_INSERT_TAIL(&pkgs, lpp, lp_link);
|
|
|
|
argv++;
|
1997-06-05 12:54:23 +04:00
|
|
|
}
|
|
|
|
|
1999-08-24 04:48:37 +04:00
|
|
|
/* If no packages, yelp */
|
|
|
|
lpp = TAILQ_FIRST(&pkgs);
|
|
|
|
if (lpp == NULL)
|
|
|
|
warnx("missing package name"), usage();
|
|
|
|
lpp = TAILQ_NEXT(lpp, lp_link);
|
|
|
|
if (lpp != NULL)
|
|
|
|
warnx("only one package name allowed ('%s' extraneous)",
|
|
|
|
lpp->lp_name),
|
|
|
|
usage();
|
|
|
|
if (!pkg_perform(&pkgs)) {
|
|
|
|
if (Verbose)
|
|
|
|
warnx("package creation failed");
|
|
|
|
return 1;
|
|
|
|
} else
|
|
|
|
return 0;
|
1997-06-05 12:54:23 +04:00
|
|
|
}
|