- also implement files.xml parsing for m&m
authorMichael Schroeder <mls@suse.de>
Fri, 30 Mar 2012 17:20:31 +0000 (19:20 +0200)
committerMichael Schroeder <mls@suse.de>
Fri, 30 Mar 2012 17:20:31 +0000 (19:20 +0200)
ext/repo_mdk.c
tools/mdk2solv.c

index 43b6f2e..f8ece96 100644 (file)
@@ -253,6 +253,7 @@ enum state {
   STATE_START,
   STATE_MEDIA_INFO,
   STATE_INFO,
+  STATE_FILES,
   NUMSTATES
 };
 
@@ -267,6 +268,7 @@ struct stateswitch {
 static struct stateswitch stateswitches[] = {
   { STATE_START, "media_info", STATE_MEDIA_INFO, 0 },
   { STATE_MEDIA_INFO, "info", STATE_INFO, 1 },
+  { STATE_MEDIA_INFO, "files", STATE_FILES, 1 },
   { NUMSTATES }
 };
 
@@ -480,6 +482,13 @@ startElement(void *userData, const char *name, const char **atts)
          set_sourcerpm(pd->data, pd->solvable, pd->solvable - pool->solvables, str);
         break;
       }
+    case STATE_FILES:
+      {
+       const char *fn = find_attr("fn", atts);
+       const char *distepoch = find_attr("distepoch", atts);
+       pd->solvable = joinhash_lookup(pd->repo, pd->joinhash, pd->joinhashmask, fn, distepoch);
+        break;
+      }
     default:
       break;
     }
@@ -503,6 +512,35 @@ endElement(void *userData, const char *name)
       if (s && *pd->content)
         repodata_set_str(pd->data, s - pd->pool->solvables, SOLVABLE_DESCRIPTION, pd->content);
       break;
+    case STATE_FILES:
+      if (s && *pd->content)
+       {
+         char *np, *p, *sl;
+         for (p = pd->content; p && *p; p = np)
+           {
+             Id id;
+             np = strchr(p, '\n');
+             if (np)
+               *np++ = 0;
+             if (!*p)
+               continue;
+             sl = strrchr(p, '/');
+             if (sl)
+               {
+                 *sl++ = 0;
+                 id = repodata_str2dir(pd->data, p, 1);
+               }
+             else
+               {
+                 sl = p;
+                 id = 0;
+               }
+             if (!id)
+               id = repodata_str2dir(pd->data, "/", 1);
+             repodata_add_dirstr(pd->data, s - pd->pool->solvables, SOLVABLE_FILELIST, id, sl);
+           }
+       }
+      break;
     default:
       break;
     }
index cec705e..f680f65 100644 (file)
@@ -36,6 +36,7 @@ usage(int status)
           "mdk2solv [-i <infoxml>]\n"
           "  reads a 'synthesis' repository from <stdin> and writes a .solv file to <stdout>\n"
           "  -i : info.xml file for extra attributes\n"
+          "  -f : files.xml file for extra attributes\n"
           "  -h : print help & exit\n"
          );
    exit(status);
@@ -46,10 +47,10 @@ main(int argc, char **argv)
 {
   Pool *pool;
   Repo *repo;
-  char *infofile;
+  char *infofile = 0, *filesfile = 0;
   int c;
 
-  while ((c = getopt(argc, argv, "hi:")) >= 0)
+  while ((c = getopt(argc, argv, "hi:f:")) >= 0)
     {
       switch(c)
        {
@@ -59,6 +60,9 @@ main(int argc, char **argv)
        case 'i':
          infofile = optarg;
          break;
+       case 'f':
+         filesfile = optarg;
+         break;
        default:
          usage(1);
          break;
@@ -78,6 +82,17 @@ main(int argc, char **argv)
       repo_add_mdk_info(repo, fp, REPO_EXTEND_SOLVABLES | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
       fclose(fp);
     }
+  if (filesfile)
+    {
+      FILE *fp = solv_xfopen(filesfile, "r");
+      if (!fp)
+       {
+         perror(filesfile);
+         exit(1);
+       }
+      repo_add_mdk_info(repo, fp, REPO_EXTEND_SOLVABLES | REPO_REUSE_REPODATA | REPO_NO_INTERNALIZE);
+      fclose(fp);
+    }
   repo_internalize(repo);
   tool_write(repo, 0, 0);
   pool_free(pool);