#include "sqlite3.h"
#include "zpm.h"
+#include "lib/buffer.h"
struct config {
struct zpm *log; /* logging db will be attached as "log" */
unsigned long ops_update, ops_update_completed;
unsigned long ops_install, ops_install_completed;
int progress; /* type of progress meter */
+ struct zpm_buffer note;
};
struct nitem {
};
static void usage() {
- printf("usage: zpm $scriptname [-fncC] args ...\n");
+ printf("usage: zpm syncfs ...\n");
}
static void warn(char *fmt, ...) {
fprintf(stderr, "\n");
}
+static void add_to_note(struct config *cf, char *fmt, ...) {
+ va_list ap;
+
+ va_start(ap, fmt);
+ zpm_buffer_appendvf(&cf->note, fmt, ap);
+ va_end(ap);
+}
+
static void pdots(int len, int ch, int was, int now, int total) {
was = len * was / total;
if (now > total) {
n->ohash = COL("ohash");
n->mds = COL("mds");
n->omds = COL("omds");
- n->pkglist = COL("pkglist");
+ n->pkglist = COL("pkgid");
if (n->ftype == 'r') {
n->hash = COL("hash");
save_config_file(conf, &nitem, save);
}
if (note) {
- zpm_note_add(conf->log, nitem.pkglist, nitem.path, nitem.hash,
- note, nitem.hash);
+ fprintf(stderr, "%s (%s) '%s' ", nitem.pkglist,
+ nitem.hash, nitem.path);
+ fprintf(stderr, note, nitem.hash);
+ fprintf(stderr, "\n");
+
+ zpm_note_add(conf->log, nitem.pkglist, nitem.path,
+ nitem.hash, note, nitem.hash);
}
} else {
if (save) {
if (update) {
if (!exist) {
/* warn, it should exist */
+ add_to_note(conf, "%s missing, installing\n", nitem.dest);
fprintf(stderr, "%s missing, installing\n", nitem.dest);
return install(conf, &nitem, 3);
}
}
if (conf->reverse) {
sqlite3_str_appendall(s," order by length(path) desc, path desc");
+ } else {
+ sqlite3_str_appendall(s," order by length(path), path");
}
sql = sqlite3_str_value(s);
conf.overwrite = 0;
conf.accept = 0;
conf.acceptdir = 1;
+ zpm_buffer_init(&conf.note);
if (geteuid() != 0) {
conf.setuser = 0;
/* TODO set conf var to finalize error reporting */
if (conf.verbose) {
- fprintf(stderr, "syncing filesystem %s (ldb %s) from %s\n",
+ fprintf(stderr, "syncing filesystem %s (ldb %s)\n",
conf.rootdir ? conf.rootdir : "/",
- localdbfile, pkgdbfile);
+ localdbfile);
}
conf.errors = 0;
runstage(&conf, "new", check_existing);
}
- if (conf.verbose) {
+ if (conf.verbose && !conf.errors) {
fprintf(stderr, "beginning %ssync\n", conf.dryrun ?
"dryrun " : "");
}
zpm_close(&localdb);
zpm_close(conf.src);
+ /* TODO add the note */
+ zpm_buffer_free(&conf.note);
return conf.errors ? 1 : 0;
}