1998-12-31 03:04:07 +03:00
|
|
|
/* $NetBSD: main.c,v 1.13 1998/12/31 00:04:07 tron Exp $ */
|
1997-06-05 16:59:18 +04:00
|
|
|
|
1997-10-17 18:53:18 +04:00
|
|
|
#include <sys/cdefs.h>
|
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 char *rcsid = "from FreeBSD Id: main.c,v 1.14 1997/10/08 07:47:26 charnier Exp";
|
1997-06-05 16:59:18 +04:00
|
|
|
#else
|
1998-12-31 03:04:07 +03:00
|
|
|
__RCSID("$NetBSD: main.c,v 1.13 1998/12/31 00:04:07 tron 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.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1998-12-31 03:04:07 +03:00
|
|
|
#include <sys/ioctl.h>
|
|
|
|
|
|
|
|
#include <termios.h>
|
1997-10-16 04:31:32 +04:00
|
|
|
#include <err.h>
|
1998-12-31 03:04:07 +03:00
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
#include "lib.h"
|
|
|
|
#include "info.h"
|
|
|
|
|
1998-10-21 13:54:09 +04:00
|
|
|
static char Options[] = "aBbcDde:fIikLl:mpqRrvh";
|
1997-06-05 12:54:23 +04:00
|
|
|
|
1997-11-17 15:08:59 +03:00
|
|
|
int Flags = 0;
|
|
|
|
Boolean AllInstalled = FALSE;
|
1997-06-05 12:54:23 +04:00
|
|
|
Boolean Quiet = FALSE;
|
|
|
|
char *InfoPrefix = "";
|
|
|
|
char PlayPen[FILENAME_MAX];
|
1998-10-08 16:57:58 +04:00
|
|
|
size_t PlayPenSize = sizeof(PlayPen);
|
1997-06-05 12:54:23 +04:00
|
|
|
char *CheckPkg = NULL;
|
1998-12-31 03:04:07 +03:00
|
|
|
size_t termwidth = 0;
|
1997-06-05 12:54:23 +04:00
|
|
|
|
1998-10-12 16:03:24 +04:00
|
|
|
static void
|
|
|
|
usage(void)
|
|
|
|
{
|
|
|
|
fprintf(stderr, "%s\n%s\n%s\n",
|
1998-10-21 13:54:09 +04:00
|
|
|
"usage: pkg_info [-BbcDdfIikLmpqRrvh] [-e package] [-l prefix]",
|
1998-10-12 16:03:24 +04:00
|
|
|
" pkg-name [pkg-name ...]",
|
|
|
|
" pkg_info -a [flags]");
|
|
|
|
exit(1);
|
|
|
|
}
|
1997-10-16 04:31:32 +04:00
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
int
|
|
|
|
main(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int ch;
|
|
|
|
char **pkgs, **start;
|
|
|
|
|
|
|
|
pkgs = start = argv;
|
|
|
|
while ((ch = getopt(argc, argv, Options)) != -1)
|
|
|
|
switch(ch) {
|
|
|
|
case 'a':
|
|
|
|
AllInstalled = TRUE;
|
|
|
|
break;
|
|
|
|
|
1998-10-21 13:54:09 +04:00
|
|
|
case 'B':
|
|
|
|
Flags |= SHOW_BUILD_INFO;
|
|
|
|
break;
|
|
|
|
|
1998-10-13 21:08:28 +04:00
|
|
|
case 'b':
|
|
|
|
Flags |= SHOW_BUILD_VERSION;
|
|
|
|
break;
|
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
case 'c':
|
|
|
|
Flags |= SHOW_COMMENT;
|
|
|
|
break;
|
|
|
|
|
1998-08-23 14:16:19 +04:00
|
|
|
case 'D':
|
|
|
|
Flags |= SHOW_DISPLAY;
|
|
|
|
break;
|
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
case 'd':
|
|
|
|
Flags |= SHOW_DESC;
|
|
|
|
break;
|
|
|
|
|
1998-08-23 14:16:19 +04:00
|
|
|
case 'e':
|
|
|
|
CheckPkg = optarg;
|
1997-06-05 12:54:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'f':
|
|
|
|
Flags |= SHOW_PLIST;
|
|
|
|
break;
|
|
|
|
|
1998-08-23 14:16:19 +04:00
|
|
|
case 'I':
|
|
|
|
Flags |= SHOW_INDEX;
|
|
|
|
break;
|
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
case 'i':
|
|
|
|
Flags |= SHOW_INSTALL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'k':
|
|
|
|
Flags |= SHOW_DEINSTALL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'L':
|
|
|
|
Flags |= SHOW_FILES;
|
|
|
|
break;
|
|
|
|
|
1998-08-23 14:16:19 +04:00
|
|
|
case 'l':
|
|
|
|
InfoPrefix = optarg;
|
|
|
|
break;
|
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
case 'm':
|
|
|
|
Flags |= SHOW_MTREE;
|
|
|
|
break;
|
|
|
|
|
1998-08-23 14:16:19 +04:00
|
|
|
case 'p':
|
|
|
|
Flags |= SHOW_PREFIX;
|
1997-06-05 12:54:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'q':
|
|
|
|
Quiet = TRUE;
|
|
|
|
break;
|
|
|
|
|
1998-08-23 14:16:19 +04:00
|
|
|
case 'R':
|
|
|
|
Flags |= SHOW_REQBY;
|
1997-06-05 12:54:23 +04:00
|
|
|
break;
|
|
|
|
|
1998-08-23 14:16:19 +04:00
|
|
|
case 'r':
|
|
|
|
Flags |= SHOW_REQUIRE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'v':
|
|
|
|
Verbose = TRUE;
|
|
|
|
/* Reasonable definition of 'everything' */
|
|
|
|
Flags = SHOW_COMMENT | SHOW_DESC | SHOW_PLIST | SHOW_INSTALL |
|
1998-10-03 20:24:07 +04:00
|
|
|
SHOW_DEINSTALL | SHOW_REQUIRE | SHOW_DISPLAY | SHOW_MTREE |
|
|
|
|
SHOW_REQBY;
|
1997-06-05 12:54:23 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'h':
|
|
|
|
case '?':
|
|
|
|
default:
|
1997-10-16 04:31:32 +04:00
|
|
|
usage();
|
1998-08-23 14:16:19 +04:00
|
|
|
/* NOTREACHED */
|
1997-06-05 12:54:23 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
argc -= optind;
|
|
|
|
argv += optind;
|
|
|
|
|
1997-11-17 15:08:59 +03:00
|
|
|
if (argc == 0 && !Flags) {
|
|
|
|
/* No argument or flags specified - assume -Ia */
|
|
|
|
Flags = SHOW_INDEX;
|
|
|
|
AllInstalled = TRUE;
|
|
|
|
}
|
|
|
|
|
1997-06-05 12:54:23 +04:00
|
|
|
/* Set some reasonable defaults */
|
|
|
|
if (!Flags)
|
|
|
|
Flags = SHOW_COMMENT | SHOW_DESC | SHOW_REQBY;
|
|
|
|
|
|
|
|
/* Get all the remaining package names, if any */
|
|
|
|
while (*argv)
|
|
|
|
*pkgs++ = *argv++;
|
|
|
|
|
|
|
|
/* If no packages, yelp */
|
|
|
|
if (pkgs == start && !AllInstalled && !CheckPkg)
|
1997-10-16 04:31:32 +04:00
|
|
|
warnx("missing package name(s)"), usage();
|
1997-06-05 12:54:23 +04:00
|
|
|
*pkgs = NULL;
|
1998-12-31 03:04:07 +03:00
|
|
|
|
|
|
|
if (isatty(STDOUT_FILENO)) {
|
|
|
|
const char *p;
|
|
|
|
struct winsize win;
|
|
|
|
|
|
|
|
if ((p = getenv("COLUMNS")) != NULL)
|
|
|
|
termwidth = atoi(p);
|
|
|
|
else if (ioctl(STDOUT_FILENO, TIOCGWINSZ, &win) == 0 &&
|
|
|
|
win.ws_col > 0)
|
|
|
|
termwidth = win.ws_col;
|
|
|
|
}
|
|
|
|
|
|
|
|
exit(pkg_perform(start));
|
|
|
|
/* NOTREACHED */
|
1997-06-05 12:54:23 +04:00
|
|
|
}
|