Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-1-4]: src/usr.sbin/pkg_install/admin Pull up revisions 1.12-1.13 ...
details: https://anonhg.NetBSD.org/src/rev/048a38ee0b29
branches: netbsd-1-4
changeset: 470821:048a38ee0b29
user: he <he%NetBSD.org@localhost>
date: Mon Jul 31 18:18:32 2000 +0000
description:
Pull up revisions 1.12-1.13 (requested by hubertf):
Update pkg_install tools by bringing in bug fixes and feature
additions since the last release. Fixes PR#10083 and PR#10687
and a number of problems not formally reported.
diffstat:
usr.sbin/pkg_install/admin/main.c | 124 ++++++++++++++++++++++++++++++++++---
1 files changed, 111 insertions(+), 13 deletions(-)
diffs (210 lines):
diff -r 77472defe36d -r 048a38ee0b29 usr.sbin/pkg_install/admin/main.c
--- a/usr.sbin/pkg_install/admin/main.c Mon Jul 31 18:18:28 2000 +0000
+++ b/usr.sbin/pkg_install/admin/main.c Mon Jul 31 18:18:32 2000 +0000
@@ -1,8 +1,8 @@
-/* $NetBSD: main.c,v 1.3.2.4 2000/02/22 22:50:03 he Exp $ */
+/* $NetBSD: main.c,v 1.3.2.5 2000/07/31 18:18:32 he Exp $ */
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: main.c,v 1.3.2.4 2000/02/22 22:50:03 he Exp $");
+__RCSID("$NetBSD: main.c,v 1.3.2.5 2000/07/31 18:18:32 he Exp $");
#endif
/*
@@ -53,6 +53,7 @@
extern const char *__progname; /* from crt0.o */
int filecnt;
+int pkgcnt;
/*
* Assumes CWD is in /var/db/pkg/<pkg>!
@@ -144,6 +145,8 @@
}
free_plist(&Plist);
fclose(f);
+
+ pkgcnt++;
}
static void
@@ -155,8 +158,8 @@
plist_t *p;
char *PkgName, dir[FILENAME_MAX], *dirp = NULL;
char *PkgDBDir = NULL, file[FILENAME_MAX];
- int pkgcnt = 0;
+ pkgcnt = 0;
filecnt = 0;
if (unlink(_pkgdb_getPKGDB_FILE()) != 0 && errno != ENOENT)
@@ -275,8 +278,8 @@
{
DIR *dp;
struct dirent *de;
- int pkgcnt = 0;
+ pkgcnt = 0;
filecnt = 0;
setbuf(stdout, NULL);
@@ -329,6 +332,14 @@
return 0;
}
+static int
+lspattern_fn(const char *pkg, char *data)
+{
+ printf("%s/%s\n", data, pkg);
+
+ return 0;
+}
+
int
main(int argc, char *argv[])
{
@@ -338,6 +349,7 @@
if (strcasecmp(argv[1], "rebuild") == 0) {
rebuild();
+ printf("Done.\n");
} else if (strcasecmp(argv[1], "check") == 0) {
@@ -346,7 +358,6 @@
if (*argv != NULL) {
/* args specified */
- int pkgcnt = 0;
int rc;
filecnt = 0;
@@ -363,16 +374,27 @@
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);
+ if (rc == -1) {
+ /* found nothing - try 'pkg-[0-9]*' */
+ char try[FILENAME_MAX];
+
+ snprintf(try, sizeof(try), "%s-[0-9]*", *argv);
+ if (findmatchingname(_pkgdb_getPKGDB_DIR(), try,
+ checkpattern_fn, NULL) <= 0) {
- check1pkg(*argv);
- printf(".");
+ errx(1, "cannot find package %s", *argv);
+ } else {
+ /* nothing to do - all the work is/was
+ * done in checkpattern_fn() */
+ }
+ } else {
+ check1pkg(*argv);
+ printf(".");
- chdir("..");
+ chdir("..");
+ }
}
- pkgcnt++;
argv++;
}
@@ -383,6 +405,84 @@
} else {
checkall();
}
+ printf("Done.\n");
+
+ } else if (strcasecmp(argv[1], "lsall") == 0) {
+ int saved_wd;
+
+ argv++; /* argv[0] */
+ argv++; /* "check" */
+
+ /* preserve cwd */
+ saved_wd=open(".", O_RDONLY);
+ if (saved_wd == -1)
+ err(1, "Cannot save working dir");
+
+ while (*argv != NULL) {
+ /* args specified */
+ int rc;
+ char *basep, *dir;
+ char *cwd;
+ char base[FILENAME_MAX];
+
+ dir = dirname_of(*argv);
+ basep = basename_of(*argv);
+ snprintf(base, sizeof(base), "%s.tgz", basep);
+
+ fchdir(saved_wd);
+ rc = chdir(dir);
+ if (rc == -1)
+ err(1, "Cannot chdir to %s", _pkgdb_getPKGDB_DIR());
+
+ cwd = getwd(NULL);
+ if (findmatchingname(cwd, base, lspattern_fn, cwd) == -1)
+ errx(1, "Error in findmatchingname(\"%s\", \"%s\", ...)",
+ cwd, base);
+ free(cwd);
+
+ argv++;
+ }
+
+ close(saved_wd);
+
+ } else if (strcasecmp(argv[1], "lsbest") == 0) {
+ int saved_wd;
+
+ argv++; /* argv[0] */
+ argv++; /* "check" */
+
+ /* preserve cwd */
+ saved_wd=open(".", O_RDONLY);
+ if (saved_wd == -1)
+ err(1, "Cannot save working dir");
+
+ while (*argv != NULL) {
+ /* args specified */
+ int rc;
+ char *basep, *dir;
+ char *cwd;
+ char base[FILENAME_MAX];
+ char *p;
+
+ dir = dirname_of(*argv);
+ basep = basename_of(*argv);
+ snprintf(base, sizeof(base), "%s.tgz", basep);
+
+ fchdir(saved_wd);
+ rc = chdir(dir);
+ if (rc == -1)
+ err(1, "Cannot chdir to %s", _pkgdb_getPKGDB_DIR());
+
+ cwd = getwd(NULL);
+ p = findbestmatchingname(cwd, base);
+ if (p)
+ printf("%s/%s\n", cwd, p);
+ free(cwd);
+
+ argv++;
+ }
+
+ close(saved_wd);
} else if (strcasecmp(argv[1], "list") == 0 ||
strcasecmp(argv[1], "dump") == 0) {
@@ -450,8 +550,6 @@
usage();
}
- printf("Done.\n");
-
return 0;
}
Home |
Main Index |
Thread Index |
Old Index