X-Git-Url: https://pd.if.org/git/?a=blobdiff_plain;f=zpm-syncfs.c;h=ce0c0bb85f20fa5777a092f0dec92e8731b12b0e;hb=3d50a117df2b79941e77dfe074cabff95f7f3fdc;hp=f603fa78bca65a9744a709737f6c7dfaa3c93626;hpb=f961fc7796670b908f59b09b17284f9caf47f8af;p=zpackage diff --git a/zpm-syncfs.c b/zpm-syncfs.c index f603fa7..ce0c0bb 100644 --- a/zpm-syncfs.c +++ b/zpm-syncfs.c @@ -556,7 +556,7 @@ static int read_item(struct config *conf, int ncols, char **vals, char **cols, } gr = getgrnam(val); if (!gr) { - seterror(conf, "no group entry"); + seterror(conf, "no group entry for %s", val); return 0; } n->gid = gr->gr_gid; @@ -607,9 +607,11 @@ static int set_md(struct config *conf, struct nitem *item) { int success = 0; if (conf->dryrun) { - printf("chmod %o %s\n", item->mode, item->dest); + if (item->ftype != 'l') { + printf("chmod %o %s\n", item->mode, item->dest); + } if (conf->setuser && conf->setgroup) { - printf("chown %d:%d %s\n", item->uid, item->gid, + printf("lchown %d:%d %s\n", item->uid, item->gid, item->dest); } printf("mtime %.0f %s\n", (double)item->mtime, item->dest); @@ -617,17 +619,20 @@ static int set_md(struct config *conf, struct nitem *item) { return success; } - rv = chmod(item->dest, item->mode); + /* can't chmod a symlink */ + if (item->ftype != 'l') { + rv = chmod(item->dest, item->mode); - if (rv == -1) { - setsyserr(conf, "can't chmod %o %s", item->mode, item->dest); - return conf->errabort; + if (rv == -1) { + setsyserr(conf, "can't chmod %o %s", item->mode, item->dest); + return conf->errabort; + } } if (conf->setuser && conf->setgroup) { - rv = chown(item->dest, item->uid, item->gid); + rv = lchown(item->dest, item->uid, item->gid); if (rv == -1) { - setsyserr(conf, "can't chown %s", item->dest); + setsyserr(conf, "can't lchown %s", item->dest); return conf->errabort; } } @@ -676,9 +681,13 @@ static int install(struct config *conf, struct nitem *item, unsigned int flags) printf("rmdir %s\n", item->dest); } - printf("install %c%o %d:%d %s -> %s\n", item->ftype, - item->mode, item->uid, item->gid, item->path, + printf("install %c%o %d:%d %s", item->ftype, + item->mode, item->uid, item->gid, item->dest); + if (item->ftype == 'l') { + printf(" -> %s", item->target); + } + printf("\n"); fflush(stdout); return success; } @@ -862,6 +871,12 @@ static int install_files(void *f, int ncols, char **vals, char **cols) { return conf->errabort; } +#if 0 + int64_t used, high; + used = sqlite3_memory_used()/1024/1024; + high = sqlite3_memory_highwater(0)/1024/1024; + fprintf(stderr, "memory = %ld MB / %ld MB\n", used, high); +#endif if (conf->verbose && !conf->dryrun) { fprintf(stderr, "%s '%c' %s\n", nitem.opstr, nitem.ftype, nitem.dest); @@ -1293,6 +1308,7 @@ int main(int ac, char **av){ conf.log = &localdb; if (pkgdbfile) { + /* TODO open read-only */ if (!zpm_open(&pkgdb, pkgdbfile)) { fprintf(stderr, "can't open src db %s\n", localdbfile); exit(EXIT_FAILURE);