- expand mergesolv a bit
authorMichael Schroeder <mls@suse.de>
Tue, 13 May 2008 12:41:33 +0000 (12:41 +0000)
committerMichael Schroeder <mls@suse.de>
Tue, 13 May 2008 12:41:33 +0000 (12:41 +0000)
- fix tiny bug in cookie detection

tools/common_write.c
tools/mergesolv.c

index 884b417..e12e82f 100644 (file)
@@ -169,7 +169,10 @@ tool_write(Repo *repo, const char *basename, const char *attrname)
 
   fileinfos = sat_zextend(fileinfos, nfileinfos, 1, sizeof(Repodatafile), REPODATAFILE_BLOCK);
   pool_addfileprovides_ids(repo->pool, 0, &fileinfos[nfileinfos].addedfileprovides);
-  if (repo->rpmdbcookie)
+  for (i = 0; i < 32; i++)
+    if (repo->rpmdbcookie[i])
+      break;
+  if (i < 32)
     fileinfos[nfileinfos].rpmdbcookie = repo->rpmdbcookie;
   if (fileinfos[nfileinfos].addedfileprovides || fileinfos[nfileinfos].rpmdbcookie)
     nfileinfos++;
index f770fbd..5b86161 100644 (file)
@@ -11,6 +11,7 @@
  */
 
 #include <sys/types.h>
+#include <unistd.h>
 #include <limits.h>
 #include <fcntl.h>
 #include <stdio.h>
@@ -32,31 +33,64 @@ usage()
   exit(0);
 }
 
+static FILE *
+loadcallback (Pool *pool, Repodata *data, void *vdata)
+{
+  FILE *fp = 0;
+  if (data->location)
+    {
+      fprintf(stderr, "Loading SOLV file %s\n", data->location);
+      fp = fopen (data->location, "r");
+      if (!fp)
+       perror(data->location);
+    }
+  return fp;
+}
 
 int
 main(int argc, char **argv)
 {
-  Pool *pool = pool_create();
+  Pool *pool;
   Repo *repo;
+  const char *basefile = 0;
+  int with_attr = 0;
+  int c;
 
-  repo = repo_create(pool, "");
-  while (argc-- > 1)
+  pool = pool_create();
+  repo = repo_create(pool, "<mergesolv>");
+  
+  while ((c = getopt(argc, argv, "ahb:")) >= 0)
+    {
+      switch (c)
+      {
+       case 'h':
+         usage();
+         break;
+       case 'a':
+         with_attr = 1;
+         break;
+       case 'b':
+         basefile = optarg;
+         break;
+       default:
+         exit(1);
+      }
+    }
+  if (with_attr)
+    pool_setloadcallback(pool, loadcallback, 0);
+
+  for (; optind < argc; optind++)
     {
       FILE *fp;
-      argv++;
-      if (!strcmp(*argv,"-h"))
-       usage();
-      if ((fp = fopen(*argv, "r")) == NULL)
+      if ((fp = fopen(argv[optind], "r")) == NULL)
        {
-         perror(argv[1]);
+         perror(argv[optind]);
          exit(0);
        }
       repo_add_solv(repo, fp);
       fclose(fp);
     }
-
-  tool_write(repo, 0, 0);
+  tool_write(repo, basefile, 0);
   pool_free(pool);
-
   return 0;
 }