PERFORCE change 143818 for review
Anders Nore
andenore at FreeBSD.org
Fri Jun 20 13:24:17 UTC 2008
http://perforce.freebsd.org/chv.cgi?CH=143818
Change 143818 by andenore at andenore_laptop on 2008/06/20 13:24:13
pkg_version now uses origin lookups in database, although the speedup
is not as much as I would like.
Affected files ...
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/convert/perform.c#2 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/Makefile#4 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/test.sh#1 add
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/version/Makefile#4 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/version/main.c#3 edit
.. //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/version/perform.c#3 edit
Differences ...
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/convert/perform.c#2 (text+ko) ====
@@ -32,11 +32,6 @@
char tmp[PATH_MAX];
DBT key, data;
- key.size = strlen(pkgname) + 1;
- key.data = pkgname;
- dbsave(&key, &key);
- printf("Package: %s\n", key.data);
-
/*
* Add Which indexing i.e. index files installed by package and they point
* to the installed package (alot of redundant data)
@@ -45,18 +40,35 @@
Package pkg;
PackingList itr;
char *cwd = NULL;
+ Boolean skip = FALSE;
+ pkg.head = pkg.tail = NULL;
+ pkg.name = pkg.origin = NULL;
+
snprintf(tmp, PATH_MAX, "%s/%s/%s", LOG_DIR, pkgname, CONTENTS_FNAME);
fp = fopen(tmp, "r");
if (fp == NULL) {
- warn("%s", tmp);
+ warnx("the package info for package '%s' is corrupt", pkgname);
return 1;
}
- Boolean skip = FALSE;
- pkg.head = pkg.tail = NULL;
read_plist(&pkg, fp);
fclose(fp);
+
+ if (pkg.name == NULL || pkg.origin == NULL) {
+ warnx("%s does not appear to be a valid package!", pkg);
+ return 1;
+ }
+
+ key.size = strlen(pkg.name) + 1;
+ key.data = pkg.name;
+ data.size = strlen(pkg.origin) + 1;
+ data.data = pkg.origin;
+
+ if(!Quiet)
+ printf("Saving package: %s\n", key.data);
+ dbsave(&key, &data);
+
for (itr = pkg.head; itr != pkg.tail; itr = itr->next) {
if (itr->type == PLIST_CWD && skip == FALSE) {
cwd = itr->name;
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/info/Makefile#4 (text+ko) ====
@@ -11,4 +11,7 @@
DPADD= ${LIBINSTALL} ${LIBFETCH} ${LIBMD}
LDADD= ${LIBINSTALL} -lfetch -lmd
+test:
+ ./test.sh
+
.include <bsd.prog.mk>
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/version/Makefile#4 (text+ko) ====
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/version/main.c#3 (text+ko) ====
@@ -44,7 +44,7 @@
if(cacheExists()) {
openDatabase(PKG_DBCACHE_FILE);
-// atexit(closeDatabase);
+ atexit(closeDatabase);
}
if (argc == 4 && !strcmp(argv[1], "-t")) {
==== //depot/projects/soc2008/andenore_pkginstall/src/usr.sbin/pkg_install/version/perform.c#3 (text+ko) ====
@@ -33,6 +33,7 @@
static int pkg_do(char *);
static void show_version(Package, const char *, const char *);
+static char *getPkgName(const char *makefile);
/*
* This is the traditional pkg_perform, except that the argument is _not_
@@ -140,12 +141,11 @@
plist.name = plist.origin = NULL;
if(CacheExists) {
-// DEBUG("Using Cache!\n");
+ DEBUG("Using Cache!\n");
plist.name = pkg;
char *origin = dbgetdata(pkg);
-// printf("pkg = %s :: origin = %s\n", pkg, origin);
+ printf("pkg = %s -> origin = %s\n", pkg, origin);
plist.origin = origin;
-
} else {
DEBUG("Not using cache\n");
/* Suck in the contents list. */
@@ -172,12 +172,16 @@
if (plist.origin != NULL && !UseINDEXOnly) {
snprintf(tmp, PATH_MAX, "%s/%s", PORTS_DIR, plist.origin);
if (isdir(tmp) && chdir(tmp) != FAIL && isfile("Makefile")) {
- if ((latest = vpipe("/usr/bin/make -V PKGNAME", tmp)) == NULL)
- warnx("Failed to get PKGNAME from %s/Makefile!", tmp);
- else
- show_version(plist, latest, "port");
+ snprintf(tmp2, PATH_MAX, "%s/Makefile", tmp);
+ if((latest = getPkgName(tmp2)) == NULL) {
+ if ((latest = vpipe("/usr/bin/make -V PKGNAME", tmp)) == NULL)
+ warnx("Failed to get PKGNAME from %s/Makefile!", tmp);
+ else
+ show_version(plist, latest, "port");
+ }
}
}
+
if (latest == NULL) {
/* Report package as not found in INDEX if the INDEX is not required. */
if (IndexFile == NULL && !UseINDEXOnly)
@@ -423,9 +427,23 @@
return ret;
}
+static char *
+getPkgName(const char *makefile)
+{
+ FILE *fp;
+ fp = fopen(tmp, "r");
+ if (!fp) {
+ warnx("Could not open %s, trying make -V PKGNAME", makefile);
+ return NULL;
+ }
+
+ return NULL;
+}
+
void
cleanup(int sig)
{
if (sig)
exit(1);
}
+
More information about the p4-projects
mailing list