}
static int pakfire_packager_write_file_from_buffer(struct pakfire_packager* packager,
- struct archive* a, struct archive* mtree, const char* filename, const char* buffer) {
+ struct archive* a, struct archive* mtree, const char* filename, mode_t mode, const char* buffer) {
size_t size = strlen(buffer);
// Create a new file
- struct archive_entry* entry = pakfire_packager_create_file(packager, filename, size);
- if (!entry)
+ struct archive_entry* entry = pakfire_packager_create_file(packager, filename, size, mode);
+ if (!entry) {
+ ERROR(packager->pakfire, "Could not create file '%s'\n", filename);
return 1;
+ }
// This is the end of the header
int r = archive_write_header(a, entry);
struct archive* a) {
const char buffer[] = TO_STRING(PACKAGE_FORMAT) "\n";
+ DEBUG(packager->pakfire, "Writing package format\n");
+
int r = pakfire_packager_write_file_from_buffer(packager, a, NULL,
PAKFIRE_ARCHIVE_FN_FORMAT, 0444, buffer);
if (r)
struct archive** payload, FILE* f) {
struct stat st;
+ DEBUG(packager->pakfire, "Writing '%s' to package\n", filename);
+
// Close the payload
if (*payload) {
archive_write_free(*payload);
// Copy data
r = pakfire_packager_copy_data(packager, a, f);
- if (r)
+ if (r) {
+ const char* error = archive_error_string(a);
+ if (!error)
+ error = strerror(errno);
+
+ ERROR(packager->pakfire, "Could not copy payload: %s\n", error);
goto ERROR;
+ }
// Add this file to the mtree
if (mtree) {
if (!entry)
return ENOMEM;
+ DEBUG(packager->pakfire, "Adding '%s' to archive (from %s)\n", path, sourcepath);
+
// Set the source path
archive_entry_copy_sourcepath(entry, sourcepath);