]> pd.if.org Git - zpackage/blobdiff - zpm-syncfs.c
add makefile as shell dependency
[zpackage] / zpm-syncfs.c
index 7422ece7a505cb59cff5afddc0ca154057d86880..0b88928d456ae875bd940a8d1fdabdf65c0f30ec 100644 (file)
@@ -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\n", item->ftype,
+               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;
        }
@@ -1293,6 +1302,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);