static int do_dist(struct pakfire* pakfire, const char* makefile, const char* resultdir) {
struct pakfire_archive* archive = NULL;
- char* filename = NULL;
+ const char* filename = NULL;
char path[PATH_MAX];
int r;
// Create the archive
- r = pakfire_dist(pakfire, makefile, &archive, &filename);
+ r = pakfire_dist(pakfire, makefile, &archive);
if (r < 0)
goto ERROR;
+ // Fetch the filename
+ filename = pakfire_archive_get_filename(archive);
+
// Make the final path
r = pakfire_path_append(path, resultdir, filename);
if (r < 0)
ERROR:
if (archive)
pakfire_archive_unref(archive);
- if (filename)
- free(filename);
return r;
}
return r;
}
-int pakfire_dist(struct pakfire* pakfire, const char* path,
- struct pakfire_archive** archive, char** filename) {
+int pakfire_dist(struct pakfire* pakfire,
+ const char* path, struct pakfire_archive** archive) {
struct pakfire_packager* packager = NULL;
struct pakfire_package* pkg = NULL;
struct pakfire_parser* makefile = NULL;
if (r < 0)
goto ERROR;
- // Return the filename
- if (filename)
- *filename = pakfire_packager_filename(packager);
-
// Return a reference to the archive
*archive = pakfire_archive_ref(a);
#include <pakfire/pakfire.h>
#include <pakfire/parser.h>
-int pakfire_dist(struct pakfire* pakfire, const char* path,
- struct pakfire_archive** archive, char** filename);
+int pakfire_dist(struct pakfire* pakfire,
+ const char* path, struct pakfire_archive** archive);
int pakfire_read_makefile(struct pakfire_parser** parser, struct pakfire* pakfire,
const char* path, struct pakfire_parser_error** error);
return NULL;
}
-char* pakfire_packager_filename(struct pakfire_packager* packager) {
- const char* filename = NULL;
-
- // Fetch the filename from the package
- filename = pakfire_package_get_string(packager->pkg, PAKFIRE_PKG_FILENAME);
- if (!filename)
- return NULL;
-
- // Copy the string
- return strdup(filename);
-}
-
static int pakfire_packager_write_format(struct pakfire_packager* packager,
struct pakfire_archive_writer* writer) {
const char format[] = TO_STRING(PACKAGE_FORMAT) "\n";
struct pakfire_packager* pakfire_packager_ref(struct pakfire_packager* packager);
struct pakfire_packager* pakfire_packager_unref(struct pakfire_packager* packager);
-char* pakfire_packager_filename(struct pakfire_packager* packager);
-
int pakfire_packager_write_archive(struct pakfire_packager* self,
struct pakfire_archive** archive);
int r;
// Run dist()
- r = pakfire_dist(pakfire, path, &archive, NULL);
+ r = pakfire_dist(pakfire, path, &archive);
if (r < 0)
goto ERROR;
Py_BEGIN_ALLOW_THREADS
- r = pakfire_dist(self->pakfire, path, &archive, NULL);
+ r = pakfire_dist(self->pakfire, path, &archive);
if (r) {
Py_BLOCK_THREADS
PyErr_SetFromErrno(PyExc_OSError);
char* tmp = test_mkdtemp();
ASSERT(tmp);
- char* filename = NULL;
-
// Attempt to dist the dummy package
ASSERT_SUCCESS(pakfire_dist(t->pakfire,
- TEST_SRC_PATH "data/packages/dummy/dummy.nm", &archive, &filename));
-
- // Check if filename is set
- ASSERT(filename);
+ TEST_SRC_PATH "data/packages/dummy/dummy.nm", &archive));
// Extract all package metadata
ASSERT_SUCCESS(pakfire_archive_make_package(archive, NULL, &package));