int repo_add_products(Repo *repo, const char *proddir, int flags) { const char *fullpath; DIR *dir; if (proddir) { dir = opendir(flags & REPO_USE_ROOTDIR ? pool_prepend_rootdir_tmp(repo->pool, proddir) : proddir); if (dir) { /* assume code11 stype products */ closedir(dir); return repo_add_code11_products(repo, proddir, flags); } } /* code11 didn't work, try old code10 zyppdb */ fullpath = "/var/lib/zypp/db/products"; if (flags & REPO_USE_ROOTDIR) fullpath = pool_prepend_rootdir_tmp(repo->pool, fullpath); dir = opendir(fullpath); if (dir) { closedir(dir); /* assume code10 style products */ return repo_add_zyppdb_products(repo, "/var/lib/zypp/db/products", flags); } /* code10/11 didn't work, try -release files parsing */ fullpath = "/etc"; if (flags & REPO_USE_ROOTDIR) fullpath = pool_prepend_rootdir_tmp(repo->pool, fullpath); dir = opendir(fullpath); if (dir) { closedir(dir); return repo_add_releasefile_products(repo, "/etc", flags); } /* no luck. check if the rootdir exists */ fullpath = pool_get_rootdir(repo->pool); if (fullpath && *fullpath) { dir = opendir(fullpath); if (!dir) return pool_error(repo->pool, -1, "%s: %s", fullpath, strerror(errno)); closedir(dir); } /* the least we can do... */ if (!(flags & REPO_NO_INTERNALIZE) && (flags & REPO_REUSE_REPODATA) != 0) repodata_internalize(repo_last_repodata(repo)); return 0; }
void repo_add_products(Repo *repo, const char *proddir, const char *root, int flags) { const char *fullpath; DIR *dir; dir = opendir(proddir); if (dir) { /* assume code11 stype products */ closedir(dir); repo_add_code11_products(repo, proddir, flags); return; } /* code11 didn't work, try old zyppdb */ fullpath = root ? join2(root, "", "/var/lib/zypp/db/products") : "/var/lib/zypp/db/products"; dir = opendir(fullpath); if (dir) { closedir(dir); /* assume code10 style products */ repo_add_zyppdb_products(repo, fullpath, flags); join_freemem(); return; } /* code11 didn't work, try -release files parsing */ fullpath = root ? join2(root, "", "/etc") : "/etc"; dir = opendir(fullpath); if (dir) { closedir(dir); repo_add_releasefile_products(repo, fullpath, flags); join_freemem(); return; } /* no luck. print an error message in case the root argument is wrong */ perror(fullpath); join_freemem(); /* the least we can do... */ if (!(flags & REPO_NO_INTERNALIZE) && (flags & REPO_REUSE_REPODATA) != 0) repodata_internalize(repo_last_repodata(repo)); }