diff options
| author | hubertf <hubertf@NetBSD.org> | 1999-03-22 05:02:39 +0000 |
|---|---|---|
| committer | hubertf <hubertf@NetBSD.org> | 1999-03-22 05:02:39 +0000 |
| commit | 04417da1663ee41a9933b1e6bdb0efa1f8896470 (patch) | |
| tree | 4ee9164b79dff77224ff535089e2be208c0e207d /usr.sbin/pkg_install/admin | |
| parent | 6c70403fe8d4617944779e3d9dc3ffd2985dd131 (diff) | |
Replace static array of packages given to pkg_perform() with linear
list, using chopss' list functions (moved to lib/lpkg.c and
lib/lib.h).
Properly handle wildcards in arguments to "pkg_info", "pkg_delete" and
"pkg_admin check".
Some other minor cleanups.
Diffstat (limited to 'usr.sbin/pkg_install/admin')
| -rw-r--r-- | usr.sbin/pkg_install/admin/main.c | 59 | ||||
| -rw-r--r-- | usr.sbin/pkg_install/admin/pkg_admin.1 | 8 |
2 files changed, 49 insertions, 18 deletions
diff --git a/usr.sbin/pkg_install/admin/main.c b/usr.sbin/pkg_install/admin/main.c index 9eadafb930e..490fc3d9557 100644 --- a/usr.sbin/pkg_install/admin/main.c +++ b/usr.sbin/pkg_install/admin/main.c @@ -1,8 +1,8 @@ -/* $NetBSD: main.c,v 1.2 1999/03/03 00:35:16 hubertf Exp $ */ +/* $NetBSD: main.c,v 1.3 1999/03/22 05:02:40 hubertf Exp $ */ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: main.c,v 1.2 1999/03/03 00:35:16 hubertf Exp $"); +__RCSID("$NetBSD: main.c,v 1.3 1999/03/22 05:02:40 hubertf Exp $"); #endif /* @@ -51,10 +51,12 @@ void usage(void); extern const char *__progname; /* from crt0.o */ +int filecnt; + /* * assumes CWD is in /var/db/pkg/<pkg>! */ -static void check1pkg(const char *pkgdir, int *filecnt) +static void check1pkg(const char *pkgdir) { FILE *f; plist_t *p; @@ -103,7 +105,7 @@ static void check1pkg(const char *pkgdir, int *filecnt) } } - (*filecnt)++; + filecnt++; } break; case PLIST_CWD: @@ -150,7 +152,9 @@ static void rebuild(void) plist_t *p; char *PkgName, dir[FILENAME_MAX], *dirp=NULL; char *PkgDBDir=NULL, file[FILENAME_MAX]; - int filecnt=0, pkgcnt=0; + int pkgcnt=0; + + filecnt=0; if (unlink(_pkgdb_getPKGDB_FILE()) != 0 && errno!=ENOENT) err(1, "unlink %s", _pkgdb_getPKGDB_FILE()); @@ -268,8 +272,10 @@ static void checkall(void) { DIR *dp; struct dirent *de; - int filecnt=0, pkgcnt=0; + int pkgcnt=0; + filecnt = 0; + setbuf(stdout, NULL); chdir(_pkgdb_getPKGDB_DIR()); @@ -286,7 +292,7 @@ static void checkall(void) chdir(de->d_name); - check1pkg(de->d_name, &filecnt); + check1pkg(de->d_name); printf("."); chdir(".."); @@ -303,6 +309,22 @@ static void checkall(void) pkgcnt, (pkgcnt==1)?"":"s"); } +static int +checkpattern_fn(const char *pkg, char *data) +{ + int rc; + + rc = chdir(pkg); + if (rc == -1) + err(1, "Cannot chdir to %s/%s", _pkgdb_getPKGDB_DIR(), pkg); + + check1pkg(pkg); + printf("."); + + chdir(".."); + + return 0; +} int main(int argc, char *argv[]) { @@ -320,9 +342,11 @@ int main(int argc, char *argv[]) if (*argv != NULL) { /* args specified */ - int filecnt=0, pkgcnt=0; + int pkgcnt=0; int rc; - + + filecnt = 0; + setbuf(stdout, NULL); rc = chdir(_pkgdb_getPKGDB_DIR()); @@ -330,14 +354,19 @@ int main(int argc, char *argv[]) err(1, "Cannot chdir to %s", _pkgdb_getPKGDB_DIR()); while (*argv != NULL) { + if (ispkgpattern(*argv)){ + if (findmatchingname(_pkgdb_getPKGDB_DIR(), *argv, checkpattern_fn, NULL) == 0) + errx(1, "No matching pkg for %s.", *argv); + }else { rc = chdir(*argv); - if (rc == -1) - err(1, "Cannot chdir to %s/%s", _pkgdb_getPKGDB_DIR(), *argv); - - check1pkg(*argv, &filecnt); - printf("."); + if (rc == -1) + err(1, "Cannot chdir to %s/%s", _pkgdb_getPKGDB_DIR(), *argv); - chdir(".."); + check1pkg(*argv); + printf("."); + + chdir(".."); + } pkgcnt++; argv++; diff --git a/usr.sbin/pkg_install/admin/pkg_admin.1 b/usr.sbin/pkg_install/admin/pkg_admin.1 index 7d0f757386d..3ef1fd492e9 100644 --- a/usr.sbin/pkg_install/admin/pkg_admin.1 +++ b/usr.sbin/pkg_install/admin/pkg_admin.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: pkg_admin.1,v 1.3 1999/03/10 08:20:26 erh Exp $ +.\" $NetBSD: pkg_admin.1,v 1.4 1999/03/22 05:02:40 hubertf Exp $ .\" .\" Copyright (c) 1999 Hubert Feyrer. All rights reserved. .\" @@ -66,9 +66,11 @@ Use this command to check the files belonging to some or all of the packages installed on the local machine against their MD5 checksum noted in their +CONTENTS files. If no additional argument is given, the files of all installed packages are installed, else only the named -packages will be ckecked. +packages will be ckecked (wildcards can be used here, see +.Xr pkg_info 1 +). .Pp -The named packages' +CONTENTS files will be parsed and the MD5 +The packages' +CONTENTS files will be parsed and the MD5 checksum will be checked for every file found. A warning message is printed if the expected checksum differs from the checksum of the file on disk. |
