refactor testcase_str2dep
[platform/upstream/libsolv.git] / tools / common_write.c
index 3ea6a5b..6de8a69 100644 (file)
@@ -27,6 +27,8 @@ static Id verticals[] = {
   SOLVABLE_EULA,
   SOLVABLE_DISKUSAGE,
   SOLVABLE_FILELIST,
+  SOLVABLE_CHANGELOG_AUTHOR,
+  SOLVABLE_CHANGELOG_TEXT,
   0
 };
 
@@ -180,7 +182,11 @@ write_info(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void
   Queue keyq;
 
   queue_init(&keyq);
-  repo_write_filtered(repo, fp, keyfilter, kfdata, &keyq);
+  if (repo_write_filtered(repo, fp, keyfilter, kfdata, &keyq) != 0)
+    {
+      fprintf(stderr, "repo_write failed\n");
+      exit(1);
+    }
   h = repodata_new_handle(info);
   if (keyq.count)
     repodata_set_idarray(info, h, REPOSITORY_KEYS, &keyq);
@@ -189,7 +195,7 @@ write_info(Repo *repo, FILE *fp, int (*keyfilter)(Repo *repo, Repokey *key, void
   repodata_add_flexarray(info, SOLVID_META, REPOSITORY_EXTERNAL, h);
 }
 
-int
+void
 tool_write(Repo *repo, const char *basename, const char *attrname)
 {
   Repodata *data;
@@ -205,7 +211,7 @@ tool_write(Repo *repo, const char *basename, const char *attrname)
   info = repo_add_repodata(repo, 0);
   repodata_set_str(info, SOLVID_META, REPOSITORY_TOOLVERSION, LIBSOLV_TOOLVERSION);
   queue_init(&addedfileprovides);
-  pool_addfileprovides_queue(repo->pool, &addedfileprovides);
+  pool_addfileprovides_queue(repo->pool, &addedfileprovides, 0);
   if (addedfileprovides.count)
     {
       kd.haveaddedfileprovides = 1;
@@ -298,13 +304,20 @@ tool_write(Repo *repo, const char *basename, const char *attrname)
       kd.languages = languages;
       kd.nlanguages = nlanguages;
       repodata_internalize(info);
-      repo_write_filtered(repo, fp, keyfilter_other, &kd, 0);
-      fclose(fp);
+      if (repo_write_filtered(repo, fp, keyfilter_other, &kd, 0) != 0)
+       {
+         fprintf(stderr, "repo_write failed\n");
+         exit(1);
+       }
+      if (fclose(fp) != 0)
+       {
+         perror("fclose");
+         exit(1);
+       }
       for (i = 0; i < nlanguages; i++)
        free(languages[i]);
       solv_free(languages);
       repodata_free(info);
-      return 0;
     }
   if (attrname)
     {
@@ -316,7 +329,10 @@ tool_write(Repo *repo, const char *basename, const char *attrname)
       kd.haveexternal = 1;
     }
   repodata_internalize(info);
-  repo_write_filtered(repo, stdout, keyfilter_solv, &kd, 0);
+  if (repo_write_filtered(repo, stdout, keyfilter_solv, &kd, 0) != 0)
+    {
+      fprintf(stderr, "repo_write failed\n");
+      exit(1);
+    }
   repodata_free(info);
-  return 0;
 }