- make findfileconflicts ignore ghost files, like rpm does
authorMichael Schroeder <mls@suse.de>
Wed, 25 May 2011 12:03:41 +0000 (14:03 +0200)
committerMichael Schroeder <mls@suse.de>
Wed, 25 May 2011 12:03:41 +0000 (14:03 +0200)
ext/pool_fileconflicts.c
ext/repo_rpmdb.c
ext/repo_rpmdb.h

index c36e967..a1a1a57 100644 (file)
@@ -332,7 +332,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
        cbdata.create = 0;
       handle = (*handle_cb)(pool, p, handle_cbdata);
       if (handle)
-        rpm_iterate_filelist(handle, 0, findfileconflicts_cb, &cbdata);
+        rpm_iterate_filelist(handle, RPM_ITERATE_FILELIST_NOGHOSTS, findfileconflicts_cb, &cbdata);
     }
 
   POOL_DEBUG(SAT_DEBUG_STATS, "filemap size: %d used %d\n", cbdata.cflmapn + 1, cbdata.cflmapused);
@@ -370,7 +370,7 @@ pool_findfileconflicts(Pool *pool, Queue *pkgs, int cutoff, Queue *conflicts, vo
       int pidx = cbdata.lookat.elements[i + 1];
       int iterflags;
 
-      iterflags = RPM_ITERATE_FILELIST_WITHMD5;
+      iterflags = RPM_ITERATE_FILELIST_WITHMD5 | RPM_ITERATE_FILELIST_NOGHOSTS;
       if (pool->obsoleteusescolors)
        iterflags |= RPM_ITERATE_FILELIST_WITHCOL;
       p = pkgs->elements[pidx];
index c679bc1..0755fac 100644 (file)
@@ -71,6 +71,7 @@
 #define TAG_FILEMODES          1030
 #define TAG_FILEMD5S           1035
 #define TAG_FILELINKTOS                1036
+#define TAG_FILEFLAGS          1037
 #define TAG_SOURCERPM          1044
 #define TAG_PROVIDENAME                1047
 #define TAG_REQUIREFLAGS       1048
 #define DEP_STRONG             (1 << 27)
 #define DEP_PRE                        ((1 << 6) | (1 << 9) | (1 << 10) | (1 << 11) | (1 << 12))
 
+#define FILEFLAG_GHOST         (1 <<  6)
+
 
 #ifdef RPM5
 # define RPM_INDEX_SIZE 4
@@ -1980,6 +1983,7 @@ rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, const char *
   char **lt = 0;
   unsigned int *di, diidx;
   unsigned int *co = 0;
+  unsigned int *ff = 0;
   unsigned int lastdir;
   int lastdirl;
   unsigned int *fm;
@@ -2049,10 +2053,27 @@ rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, const char *
          return;
        }
     }
+  if ((flags & RPM_ITERATE_FILELIST_NOGHOSTS) != 0)
+    {
+      ff = headint32array(rpmhead, TAG_FILEFLAGS, &cnt2);
+      if (!ff || cnt != cnt2)
+       {
+         sat_free(ff);
+         sat_free(co);
+         sat_free(md);
+         sat_free(fm);
+         sat_free(di);
+         sat_free(bn);
+         sat_free(dn);
+         return;
+       }
+    }
   lastdir = dcnt;
   lastdirl = 0;
   for (i = 0; i < cnt; i++)
     {
+      if (ff && (ff[i] & FILEFLAG_GHOST) != 0)
+       continue;
       diidx = di[i];
       if (diidx >= dcnt)
        continue;
@@ -2092,7 +2113,7 @@ rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, const char *
            }
          if (!md5p)
            {
-             sprintf(md5, "%08x%08x", (fm[i] >> 12) & 65535, 0);
+             sprintf(md5, "%08x%08x%08x%08x", (fm[i] >> 12) & 65535, 0, 0, 0);
              md5p = md5;
            }
        }
@@ -2106,6 +2127,7 @@ rpm_iterate_filelist(void *rpmhandle, int flags, void (*cb)(void *, const char *
   sat_free(bn);
   sat_free(dn);
   sat_free(co);
+  sat_free(ff);
 }
 
 char *
index ba21c0f..c5903b8 100644 (file)
@@ -27,6 +27,7 @@ void repo_add_pubkeys(Repo *repo, const char **keys, int nkeys, int flags);
 #define RPM_ITERATE_FILELIST_ONLYDIRS  (1 << 0)
 #define RPM_ITERATE_FILELIST_WITHMD5   (1 << 1)
 #define RPM_ITERATE_FILELIST_WITHCOL   (1 << 2)
+#define RPM_ITERATE_FILELIST_NOGHOSTS  (1 << 3)
 
 void *rpm_byrpmdbid(Id rpmdbid, const char *rootdir, void **statep);
 void *rpm_byfp(FILE *fp, const char *name, void **statep);