]> pd.if.org Git - zpackage/commitdiff
add syncfs support for update sync columns
authorNathan Wagner <nw@hydaspes.if.org>
Sat, 20 Oct 2018 02:53:35 +0000 (02:53 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Sat, 3 Nov 2018 12:39:52 +0000 (12:39 +0000)
zpm-syncfs.c

index d2847cf2387f295b9e2d393e94dcd8e29189cbca..218c53812ae22756019f5dfe251ddb3ab438a093 100644 (file)
@@ -41,7 +41,9 @@ struct nitem {
        char *dest;
        char *path;
        char *hash, *ohash;
+       char *mds, *omds;
        char *target;
+       char *pkglist; /* space separated */
        time_t mtime;
        mode_t mode;
        int ftype;
@@ -481,7 +483,11 @@ static int read_item(struct config *conf, int ncols, char **vals, char **cols,
        }
        n->ftype = *val;
 
-       n->ohash = COL("hash");
+       /* these can be null */
+       n->ohash = COL("ohash");
+       n->mds = COL("mds");
+       n->omds = COL("omds");
+       n->pkglist = COL("pkglist");
 
        if (n->ftype == 'r') {
                n->hash = COL("hash");
@@ -776,6 +782,10 @@ static int install_files(void *f, int ncols, char **vals, char **cols) {
                        /* fhash != ohash, install as dest.zpmnew, warn */
                        /* TODO handle replacing config file
                         * with config directory */
+                       /* We don't have the information as to which
+                        * package this is a config file for, so
+                        * we'll need to look it up.
+                        */
                        if (diffs & D_OHASH) {
                                if (strlen(nitem.dest) > sizeof dest - 8) {
                                        return seterror(conf,"config file path too long for install as %s.zpmnew", nitem.dest);
@@ -789,12 +799,28 @@ static int install_files(void *f, int ncols, char **vals, char **cols) {
                /* file exists in filesystem */
                if (sametype) {
                        if (mdsame && hashsame) {
-                               fprintf(stderr, "%s should not be an update", nitem.dest);
-                               /* warn, bug in logic.  This shouldn't
-                                * occur, because if there is nothing
-                                * to do, it shouldn't be listed
-                                * as an update
+                               /* warn, bug in logic.  This shouldn't occur,
+                                * because if there is nothing to do, it
+                                * shouldn't be listed as an update
+                                */
+                               /* could be an update.  We're checking against
+                                * what's actually on disk, not what was
+                                * expected to have been on disk.  So, if
+                                * the admin has modified the file, or if
+                                * it had been installed ignoring the user
+                                * and group, it might be correct on disk
+                                * but not as in the local database
+                                */
+                               /* TODO detect whether this a logic bug or
+                                * an on-disk difference
                                 */
+#if 0
+                               fprintf(stderr, "%s should not be an update\n", nitem.dest);
+                               fprintf(stderr, "old hash: %s\n", nitem.ohash);
+                               fprintf(stderr, "new hash: %s\n", nitem.hash);
+                               fprintf(stderr, "old mds: %s\n", nitem.omds);
+                               fprintf(stderr, "new mds: %s\n", nitem.mds);
+#endif
                                /* do nothing */
                                return 0;
                        }