#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <stdarg.h>
+#include <stdio.h>
#include <glob.h>
int dbrepos;
};
+void trace(int level, struct search_ctl *ctl, char *fmt, ...) {
+ va_list ap;
+
+ if (level <= ctl->verbose) {
+ va_start(ap, fmt);
+ vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ }
+}
+
char *pathcat(char *dir, char *path) {
size_t dirlen = 0, pathlen = 0;
char *cat;
unsigned int i;
if (opt->localdb) {
+ trace(1, opt, "checking local database for installed %s\n", pkgstr);
installed = zpm_findpkg(opt->zpmdb, pkgstr, "status = 'installed'");
if (installed) {
+ trace(1, opt, "found installed %s as %s\n", pkgstr, installed);
latest = installed;
pkgfile = opt->zpmdb->path;
}
+
if (!opt->onlylocalinstalled) {
+ trace(1, opt, "checking local database for any %s\n", pkgstr);
found = zpm_findpkg(opt->zpmdb, pkgstr, NULL);
if (found) {
+ trace(1, opt, "found %s as %s\n", pkgstr, installed);
rv = zpm_vercmp(found, latest);
if (rv == 1) {
latest = found;
#endif
}
+ trace(1, opt, "checking repositories\n");
for (i = 0; i < opt->repos.gl_pathc; i++) {
+ trace(1, opt, "checking repo/pkg %s\n", opt->repos.gl_pathv[i]);
if (!opt->matchallpkgfile
&& !strstr(opt->repos.gl_pathv[i], pkgstr)
&& !strstr(opt->repos.gl_pathv[i], ".repo")
) {
+ trace(1, opt, "skipping repo/pkg %s\n", opt->repos.gl_pathv[i]);
continue;
}
found = checkfile(pkgstr, opt->repos.gl_pathv[i], 0);
+ trace(1, opt, "found %s\n", found);
if (found) {
+ trace(1, opt, "comparing found %s to latest (%s)\n", found, latest);
rv = zpm_vercmp(found, latest);
if (rv == 1) {
latest = found;
pkgfile = strdup(opt->repos.gl_pathv[i]);
}
+ trace(1, opt, "latest %s\n", latest);
}
}
if (installed) {
pkg->installed = !strcmp(latest, installed);
}
+ trace(1, opt, "set up pkgloc = {%s, %s, %d}\n", pkg->id, pkg->file, pkg->installed);
}
return pkg;