summaryrefslogtreecommitdiffstats
path: root/usr.sbin/pkg_install
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1993-09-05 22:36:54 +0000
committerjkh <jkh@FreeBSD.org>1993-09-05 22:36:54 +0000
commitc211573e5cf19ca67dd380150a9b0df6c6c46f6e (patch)
tree8c019f9e3a294a7a0589c307897574564f1fd4d7 /usr.sbin/pkg_install
parenta2c1035acbd15c9b68274168b372fc4779c0518a (diff)
downloadFreeBSD-src-c211573e5cf19ca67dd380150a9b0df6c6c46f6e.zip
FreeBSD-src-c211573e5cf19ca67dd380150a9b0df6c6c46f6e.tar.gz
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.
Diffstat (limited to 'usr.sbin/pkg_install')
-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 272ae79..6a13134 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 595a874..a049799 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 f70a604..418adb3 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 18434c9..a08d214 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.
OpenPOWER on IntegriCloud