};
static void usage() {
- printf("usage: zpm foreach-path [-fncC] args ...\n");
+ printf("usage: zpm verify [-f file] -eF [pkgid ...]\n");
}
static char *column(char *col, int ncols, char **vals, char **cols) {
jsw_atrav_t *list;
int i, errors = 0;
- pkglist = jsw_anew(afind_strcmp, (dup_f)strdup, (rel_f)free);
struct config conf = { 0 };
+ /* TODO could do nothing for the dup */
+ pkglist = jsw_anew(afind_strcmp, (dup_f)strdup, (rel_f)free);
+
conf.dbfile = "/var/lib/zpm/local.db";
if ((s = getenv("ZPMDB"))) {
char *errmsg = 0;
if (argn < ac) {
+ for (i = argn; i < ac; i++) {
+ pkgid = zpm_findpkg(&pkg, av[i], "status = 'installed'");
+ if (!pkgid) {
+ if (conf.skipuninstalled) {
+ continue;
+ }
+ fprintf(stderr, "no installed package: %s\n", av[i]);
+ errors++;
+ free(pkgid);
+ pkgid = 0;
+ continue;
+ }
+ if (!jsw_ainsert(pkglist, pkgid)) {
+ fprintf(stderr, "pkglist insert failed\n");
+ exit(EXIT_FAILURE);
+ }
+ free(pkgid);
+ }
} else {
fprintf(stderr, "must specify pkgid\n");
usage();
exit(EXIT_FAILURE);
}
- for (i = argn; i < ac; i++) {
- pkgid = zpm_findpkg(&pkg, av[i], "status = 'installed'");
- if (!pkgid) {
- if (conf.skipuninstalled) {
- continue;
- }
- fprintf(stderr, "no installed package: %s\n", av[i]);
- errors++;
- free(pkgid);
- pkgid = 0;
- continue;
- }
+ list = jsw_atnew();
+
+ for (pkgid = jsw_atfirst(list, pkglist); pkgid; pkgid = jsw_atnext(list)) {
+ conf.pkgid = pkgid;
if (!zpm_foreach_path(&pkg, pkgid, 0, count_plan, &conf, &errmsg)) {
if (errmsg) {
if (pkg.error == 1) {
fprintf(stderr, "unable to allocate memory\n");
}
- fprintf(stderr, "unable to plan\n");
exit(EXIT_FAILURE);
}
- if (!jsw_ainsert(pkglist, pkgid)) {
- fprintf(stderr, "pkglist insert failed\n");
- exit(EXIT_FAILURE);
- }
- free(pkgid);
}
+
if (errors) {
exit(EXIT_FAILURE);
}