archive_entry_set_gid(entry, 0);
}
+ // Open the source file
+ f = fopen(sourcepath, "r");
+ if (!f) {
+ ERROR(packager->pakfire, "Could not open %s: %m\n", sourcepath);
+ r = errno;
+ goto ERROR;
+ }
+
// Write the header
r = archive_write_header(packager->payload, entry);
if (r) {
goto ERROR;
}
- // Copy the data of regular files
- if (archive_entry_filetype(entry) == AE_IFREG) {
- f = fopen(sourcepath, "r");
- if (!f) {
- ERROR(packager->pakfire, "Could not open %s: %m\n", sourcepath);
- r = errno;
- goto ERROR;
- }
-
- r = pakfire_packager_copy_data(packager, packager->payload, f);
- if (r)
- goto ERROR;
- }
-
// Write to mtree
r = archive_write_header(packager->mtree, entry);
if (r) {
goto ERROR;
}
+ // Copy the data of regular files
+ if (archive_entry_filetype(entry) == AE_IFREG) {
+ // Copy the payload into the archive
+ r = pakfire_packager_copy_data(packager, packager->payload, f);
+ if (r)
+ goto ERROR;
+
+ // Copy the payload into the mtree for hashing
+ r = pakfire_packager_copy_data(packager, packager->mtree, f);
+ if (r)
+ goto ERROR;
+ }
+
// Increment installsize
packager->installsize += archive_entry_size(entry);