implement SOLVER_FLAG_BREAK_ORPHANS
[platform/upstream/libsolv.git] / ext / repo_releasefile_products.c
index e7cbc49..a40bc98 100644 (file)
@@ -19,6 +19,7 @@
 #include <assert.h>
 #include <dirent.h>
 #include <ctype.h>
+#include <errno.h>
 
 #include "pool.h"
 #include "repo.h"
@@ -125,9 +126,17 @@ repo_add_releasefile_products(Repo *repo, const char *dirpath, int flags)
   char *fullpath;
   struct parsedata pd;
 
+  if (!dirpath)
+    dirpath = "/etc";
+  if (flags & REPO_USE_ROOTDIR)
+    dirpath = pool_prepend_rootdir(repo->pool, dirpath);
   dir = opendir(dirpath);
   if (!dir)
-    return 0;
+    {
+      if (flags & REPO_USE_ROOTDIR)
+        solv_free((char *)dirpath);
+      return 0;
+    }
 
   memset(&pd, 0, sizeof(pd));
   pd.repo = repo;
@@ -142,7 +151,7 @@ repo_add_releasefile_products(Repo *repo, const char *dirpath, int flags)
          fullpath = join2(&pd.jd, dirpath, "/", entry->d_name);
          if ((fp = fopen(fullpath, "r")) == 0)
            {
-             perror(fullpath);
+             pool_error(repo->pool, 0, "%s: %s", fullpath, strerror(errno));
              continue;
            }
          add_releasefile_product(&pd, fp);
@@ -151,6 +160,8 @@ repo_add_releasefile_products(Repo *repo, const char *dirpath, int flags)
     }
   closedir(dir);
   join_freemem(&pd.jd);
+  if (flags & REPO_USE_ROOTDIR)
+    solv_free((char *)dirpath);
 
   if (!(flags & REPO_NO_INTERNALIZE) && (flags & REPO_REUSE_REPODATA) != 0)
     repodata_internalize(repo_last_repodata(repo));