1993-08-26 01:19:55 +00:00
|
|
|
#ifndef lint
|
1997-03-31 05:11:47 +00:00
|
|
|
static char *rcsid = "$Id: main.c,v 1.12 1997/02/22 16:09:41 peter Exp $";
|
1993-08-26 01:19:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* FreeBSD install - a package for the installation and maintainance
|
|
|
|
* of non-core utilities.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* Jordan K. Hubbard
|
|
|
|
* 18 July 1993
|
|
|
|
*
|
|
|
|
* This is the add module.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "lib.h"
|
|
|
|
#include "info.h"
|
|
|
|
|
1994-12-06 00:51:50 +00:00
|
|
|
static char Options[] = "acdDe:fikrRpLqImvhl:";
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
int Flags = 0;
|
|
|
|
Boolean AllInstalled = FALSE;
|
1993-09-08 01:46:59 +00:00
|
|
|
Boolean Quiet = FALSE;
|
1993-09-03 23:01:17 +00:00
|
|
|
char *InfoPrefix = "";
|
1995-10-25 15:38:37 +00:00
|
|
|
char PlayPen[FILENAME_MAX];
|
1993-09-05 22:36:54 +00:00
|
|
|
char *CheckPkg = NULL;
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int ch;
|
|
|
|
char **pkgs, **start;
|
|
|
|
char *prog_name = argv[0];
|
|
|
|
|
|
|
|
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 'a':
|
|
|
|
AllInstalled = TRUE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'v':
|
|
|
|
Verbose = TRUE;
|
|
|
|
/* Reasonable definition of 'everything' */
|
|
|
|
Flags = SHOW_COMMENT | SHOW_DESC | SHOW_PLIST | SHOW_INSTALL |
|
1994-12-06 00:51:50 +00:00
|
|
|
SHOW_DEINSTALL | SHOW_REQUIRE | SHOW_DISPLAY | SHOW_MTREE;
|
1993-08-26 01:19:55 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'I':
|
|
|
|
Flags |= SHOW_INDEX;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'p':
|
|
|
|
Flags |= SHOW_PREFIX;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
Flags |= SHOW_COMMENT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
Flags |= SHOW_DESC;
|
|
|
|
break;
|
|
|
|
|
1994-12-06 00:51:50 +00:00
|
|
|
case 'D':
|
|
|
|
Flags |= SHOW_DISPLAY;
|
|
|
|
break;
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
case 'f':
|
|
|
|
Flags |= SHOW_PLIST;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'i':
|
|
|
|
Flags |= SHOW_INSTALL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'k':
|
|
|
|
Flags |= SHOW_DEINSTALL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'r':
|
|
|
|
Flags |= SHOW_REQUIRE;
|
|
|
|
break;
|
|
|
|
|
1994-12-06 00:51:50 +00:00
|
|
|
case 'R':
|
|
|
|
Flags |= SHOW_REQBY;
|
|
|
|
break;
|
|
|
|
|
1993-09-08 01:46:59 +00:00
|
|
|
case 'L':
|
|
|
|
Flags |= SHOW_FILES;
|
|
|
|
break;
|
|
|
|
|
1994-12-06 00:51:50 +00:00
|
|
|
case 'm':
|
|
|
|
Flags |= SHOW_MTREE;
|
|
|
|
break;
|
|
|
|
|
1993-09-03 23:01:17 +00:00
|
|
|
case 'l':
|
|
|
|
InfoPrefix = optarg;
|
|
|
|
break;
|
|
|
|
|
1993-09-08 01:46:59 +00:00
|
|
|
case 'q':
|
|
|
|
Quiet = TRUE;
|
|
|
|
break;
|
|
|
|
|
1993-09-05 04:54:24 +00:00
|
|
|
case 't':
|
1995-10-25 15:38:37 +00:00
|
|
|
strcpy(PlayPen, optarg);
|
1993-09-05 04:54:24 +00:00
|
|
|
break;
|
|
|
|
|
1993-09-05 22:36:54 +00:00
|
|
|
case 'e':
|
|
|
|
CheckPkg = optarg;
|
|
|
|
break;
|
|
|
|
|
1993-08-26 01:19:55 +00:00
|
|
|
case 'h':
|
|
|
|
case '?':
|
|
|
|
default:
|
|
|
|
usage(prog_name, NULL);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
1995-05-30 03:57:47 +00:00
|
|
|
argc -= optind;
|
1993-08-26 01:19:55 +00:00
|
|
|
argv += optind;
|
|
|
|
|
|
|
|
/* Set some reasonable defaults */
|
|
|
|
if (!Flags)
|
1994-12-06 00:51:50 +00:00
|
|
|
Flags = SHOW_COMMENT | SHOW_DESC | SHOW_REQBY;
|
1993-08-26 01:19:55 +00:00
|
|
|
|
|
|
|
/* Get all the remaining package names, if any */
|
|
|
|
while (*argv)
|
|
|
|
*pkgs++ = *argv++;
|
|
|
|
|
|
|
|
/* If no packages, yelp */
|
1993-09-05 22:36:54 +00:00
|
|
|
if (pkgs == start && !AllInstalled && !CheckPkg)
|
1993-08-26 01:19:55 +00:00
|
|
|
usage(prog_name, "Missing package name(s)");
|
|
|
|
*pkgs = NULL;
|
|
|
|
return pkg_perform(start);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
usage(const char *name, const char *fmt, ...)
|
|
|
|
{
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, fmt);
|
|
|
|
if (fmt) {
|
|
|
|
fprintf(stderr, "%s: ", name);
|
|
|
|
vfprintf(stderr, fmt, args);
|
|
|
|
fprintf(stderr, "\n\n");
|
|
|
|
}
|
|
|
|
va_end(args);
|
|
|
|
fprintf(stderr, "Usage: %s [args] pkg [ .. pkg ]\n", name);
|
|
|
|
fprintf(stderr, "Where args are one or more of:\n\n");
|
|
|
|
fprintf(stderr, "-a show all installed packages (if any)\n");
|
|
|
|
fprintf(stderr, "-I print 'index' of packages\n");
|
|
|
|
fprintf(stderr, "-c print `one line comment'\n");
|
|
|
|
fprintf(stderr, "-d print description\n");
|
1994-12-06 00:51:50 +00:00
|
|
|
fprintf(stderr, "-D print install notice\n");
|
1993-08-26 01:19:55 +00:00
|
|
|
fprintf(stderr, "-f show packing list\n");
|
|
|
|
fprintf(stderr, "-i show install script\n");
|
|
|
|
fprintf(stderr, "-k show deinstall script\n");
|
|
|
|
fprintf(stderr, "-r show requirements script\n");
|
1994-12-06 00:51:50 +00:00
|
|
|
fprintf(stderr, "-R show packages depending on this package\n");
|
1993-08-26 01:19:55 +00:00
|
|
|
fprintf(stderr, "-p show prefix\n");
|
1993-09-03 23:01:17 +00:00
|
|
|
fprintf(stderr, "-l <str> Prefix each info catagory with <str>\n");
|
1994-12-06 00:51:50 +00:00
|
|
|
fprintf(stderr, "-L show intalled files\n");
|
|
|
|
fprintf(stderr, "-q minimal output (``quiet'' mode)\n");
|
1993-08-26 01:19:55 +00:00
|
|
|
fprintf(stderr, "-v show all information\n");
|
1993-09-05 04:54:24 +00:00
|
|
|
fprintf(stderr, "-t temp use temp as template for mktemp()\n");
|
1994-06-01 05:15:00 +00:00
|
|
|
fprintf(stderr, "-e pkg returns 0 if pkg is installed, 1 otherwise\n");
|
1994-12-06 00:51:50 +00:00
|
|
|
fprintf(stderr, "\n[no args = -c -d -R]\n");
|
1993-08-26 01:19:55 +00:00
|
|
|
exit(1);
|
|
|
|
}
|