1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-22 15:47:37 +00:00

Added -e flag to pkg_info. Now you can test to see whether a package

is installed or not rather easily (useful for install scripts that want
to check for prerequisite packages).  See man page for details.
This commit is contained in:
Jordan K. Hubbard 1993-09-05 22:36:54 +00:00
parent 6d1dd8f2f8
commit 81bbfca32c
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=392
4 changed files with 26 additions and 5 deletions

View File

@ -36,6 +36,7 @@ extern int Flags;
extern Boolean AllInstalled;
extern char *InfoPrefix;
extern char *PlayPen;
extern char *CheckPkg;
extern void show_file(char *, char *);
extern void show_plist(char *, Package *, plist_t);

View File

@ -26,12 +26,13 @@ static char *rcsid = "$Header: /usr1/cvs/jkh/pkg_install/info/main.c,v 1.5 1993/
#include "lib.h"
#include "info.h"
static char Options[] = "acdfikrpIvhl:";
static char Options[] = "acde:fikrpIvhl:";
int Flags = 0;
Boolean AllInstalled = FALSE;
char *InfoPrefix = "";
char *PlayPen = NULL;
char *CheckPkg = NULL;
int
main(int argc, char **argv)
@ -94,6 +95,10 @@ main(int argc, char **argv)
PlayPen = optarg;
break;
case 'e':
CheckPkg = optarg;
break;
case 'h':
case '?':
default:
@ -113,7 +118,7 @@ main(int argc, char **argv)
*pkgs++ = *argv++;
/* If no packages, yelp */
if (pkgs == start && !AllInstalled)
if (pkgs == start && !AllInstalled && !CheckPkg)
usage(prog_name, "Missing package name(s)");
*pkgs = NULL;
return pkg_perform(start);

View File

@ -37,7 +37,7 @@ pkg_perform(char **pkgs)
signal(SIGINT, cleanup);
/* Overriding action? */
if (AllInstalled) {
if (AllInstalled || CheckPkg) {
if (isdir(LOG_DIR)) {
DIR *dirp;
struct dirent *dp;
@ -45,10 +45,18 @@ pkg_perform(char **pkgs)
dirp = opendir(LOG_DIR);
if (dirp) {
for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp)) {
if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, ".."))
err_cnt += pkg_do(dp->d_name);
if (strcmp(dp->d_name, ".") && strcmp(dp->d_name, "..")) {
if (CheckPkg) {
if (!strcmp(dp->d_name, CheckPkg))
return 0;
}
else
err_cnt += pkg_do(dp->d_name);
}
}
(void)closedir(dirp);
if (CheckPkg)
return 1;
}
else
++err_cnt;

View File

@ -63,6 +63,13 @@ Show the de-install script (if any) for each package.
.B \-r
Show the requirements script (if any) for each package.
.TP
.BI "\-e\ " pkg-name
If the package identified by
.I pkg-name
is currently installed, return 0, otherwise return 1. This option
allows you to easily test for the presence of another (perhaps
prerequisite) package from a script.
.TP
.BI "\-l\ " str
Prefix each catagory of information shown with
.I str.