struct archive* a) {
const char buffer[] = TO_STRING(PACKAGE_FORMAT) "\n";
- // Create a new file entry
- struct archive_entry* entry = archive_entry_new();
- if (!entry)
- return 1;
-
- // Set filename
- archive_entry_set_pathname(entry, PAKFIRE_ARCHIVE_FN_FORMAT);
-
- // This is a regular file
- archive_entry_set_filetype(entry, AE_IFREG);
- archive_entry_set_perm(entry, 0644);
-
- // Set length
- archive_entry_set_size(entry, strlen(buffer));
-
- // This is the end of the header
- int r = archive_write_header(a, entry);
- if (r) {
- ERROR(packager->pakfire, "Error writing header: %s\n", archive_error_string(a));
- archive_entry_free(entry);
- return r;
- }
-
- // Write content
- r = archive_write_data(a, buffer, strlen(buffer));
- if (r < 0) {
- ERROR(packager->pakfire, "Error writing data: %s\n", archive_error_string(a));
- archive_entry_free(entry);
- return r;
- }
-
- archive_entry_free(entry);
-
- return 0;
+ return pakfire_packager_write_file_from_buffer(packager, a,
+ PAKFIRE_ARCHIVE_FN_FORMAT, buffer);
}
static char* pakfire_package_make_metadata(struct pakfire_packager* packager) {