#include <time.h>
+struct pakfire_package;
+
#include <pakfire/filelist.h>
#include <pakfire/packagelist.h>
#include <pakfire/pakfire.h>
#include <pakfire/repo.h>
-struct pakfire_package;
-
struct pakfire_package* pakfire_package_create(struct pakfire* pakfire, struct pakfire_repo* repo,
const char* name, const char* evr, const char* arch);
int pakfire_repo_read_solv(struct pakfire_repo* repo, FILE *f, int flags);
int pakfire_repo_write_solv(struct pakfire_repo* repo, FILE *f, int flags);
-struct pakfire_package* pakfire_repo_add_archive(struct pakfire_repo* repo, struct pakfire_archive* archive);
+int pakfire_repo_add_archive(struct pakfire_repo* repo,
+ struct pakfire_archive* archive, struct pakfire_package** package);
// Cache
PAKFIRE_EXPORT int pakfire_repo_write_solv(struct pakfire_repo* repo, FILE *f, int flags) {
pakfire_repo_internalize(repo);
- return repo_write(repo->repo, f);
+ // Export repository data
+ int r = repo_write(repo->repo, f);
+ if (r)
+ return r;
+
+ // Flush buffers
+ r = fflush(f);
+ if (r) {
+ ERROR(repo->pakfire, "Could not flush after writing repository: %m\n");
+ return r;
+ }
+
+ return r;
}
-PAKFIRE_EXPORT struct pakfire_package* pakfire_repo_add_archive(struct pakfire_repo* repo, struct pakfire_archive* archive) {
- return pakfire_archive_make_package(archive, repo);
+PAKFIRE_EXPORT int pakfire_repo_add_archive(struct pakfire_repo* repo,
+ struct pakfire_archive* archive, struct pakfire_package** package) {
+ struct pakfire_package* p = pakfire_archive_make_package(archive, repo);
+
+ if (package)
+ *package = p;
+
+ if (p)
+ return 0;
+
+ return 1;
}
PAKFIRE_EXPORT int pakfire_repo_clean(struct pakfire_repo* repo, int flags) {
static int pakfire_request_add_archive(struct pakfire_request* request, int action,
struct pakfire_archive* archive, int extra_flags) {
struct pakfire_repo* repo = NULL;
+ struct pakfire_package* package = NULL;
int r;
r = pakfire_repo_create(&repo, request->pakfire, "@commandline");
return r;
// Add it to the repository
- struct pakfire_package* pkg = pakfire_repo_add_archive(repo, archive);
- if (!pkg)
+ r = pakfire_repo_add_archive(repo, archive, &package);
+ if (r)
goto ERROR;
- r = pakfire_request_add_package(request, action, pkg, extra_flags);
+ r = pakfire_request_add_package(request, action, package, extra_flags);
if (r)
goto ERROR;
r = 0;
ERROR:
- if (pkg)
- pakfire_package_unref(pkg);
+ if (package)
+ pakfire_package_unref(package);
pakfire_repo_unref(repo);
return r;