aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin
diff options
context:
space:
mode:
authorJordan K. Hubbard <jkh@FreeBSD.org>1993-09-05 22:36:54 +0000
committerJordan K. Hubbard <jkh@FreeBSD.org>1993-09-05 22:36:54 +0000
commit81bbfca32cfc5a19c049f9d0fd8b2d6453c30a6f (patch)
tree8c019f9e3a294a7a0589c307897574564f1fd4d7 /usr.sbin
parent6d1dd8f2f8d145d626f701847b6738965b7532b3 (diff)
downloadsrc-81bbfca32cfc5a19c049f9d0fd8b2d6453c30a6f.tar.gz
src-81bbfca32cfc5a19c049f9d0fd8b2d6453c30a6f.zip
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.
Notes
Notes: svn path=/head/; revision=392
Diffstat (limited to 'usr.sbin')
-rw-r--r--usr.sbin/pkg_install/info/info.h1
-rw-r--r--usr.sbin/pkg_install/info/main.c9
-rw-r--r--usr.sbin/pkg_install/info/perform.c14
-rw-r--r--usr.sbin/pkg_install/info/pkg_info.17
4 files changed, 26 insertions, 5 deletions
diff --git a/usr.sbin/pkg_install/info/info.h b/usr.sbin/pkg_install/info/info.h
index 272ae79d02ce..6a131344ca69 100644
--- a/usr.sbin/pkg_install/info/info.h
+++ b/usr.sbin/pkg_install/info/info.h
@@ -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);
diff --git a/usr.sbin/pkg_install/info/main.c b/usr.sbin/pkg_install/info/main.c
index 595a87465b99..a049799c51f7 100644
--- a/usr.sbin/pkg_install/info/main.c
+++ b/usr.sbin/pkg_install/info/main.c
@@ -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);
diff --git a/usr.sbin/pkg_install/info/perform.c b/usr.sbin/pkg_install/info/perform.c
index f70a60446289..418adb33c4f0 100644
--- a/usr.sbin/pkg_install/info/perform.c
+++ b/usr.sbin/pkg_install/info/perform.c
@@ -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;
diff --git a/usr.sbin/pkg_install/info/pkg_info.1 b/usr.sbin/pkg_install/info/pkg_info.1
index 18434c9919b6..a08d2146a444 100644
--- a/usr.sbin/pkg_install/info/pkg_info.1
+++ b/usr.sbin/pkg_install/info/pkg_info.1
@@ -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.