// Generate a file object
r = pakfire_file_create_from_archive_entry(&file, archive->pakfire, entry);
- if (r)
+ if (r < 0)
goto ERROR;
- // Add entry to filelist (if requested)
- if (archive->filelist) {
- // Append the file to the list
- r = pakfire_filelist_add(archive->filelist, file);
- if (r)
- goto ERROR;
- }
-
const int configfile = pakfire_file_has_flag(file, PAKFIRE_FILE_CONFIG);
// Prepend the prefix
}
// Write the file...
- if (state->writer) {
- // Fetch path again since we changed it
- path = archive_entry_pathname(entry);
- DEBUG(archive->ctx, "Extracting %s\n", path);
+ // Fetch path again since we changed it
+ path = archive_entry_pathname(entry);
- // Remove any extended attributes which we never write to disk
- archive_entry_xattr_clear(entry);
+ DEBUG(archive->ctx, "Extracting %s\n", path);
- // Set capabilities
- if (pakfire_file_has_caps(file)) {
- r = pakfire_file_write_fcaps(file, &cap_data);
- if (r)
- goto ERROR;
+ // Remove any extended attributes which we never write to disk
+ archive_entry_xattr_clear(entry);
- // Store capabilities in archive entry
- archive_entry_xattr_add_entry(entry,
- "security.capability", &cap_data, sizeof(cap_data));
- }
+ // Set capabilities
+ if (pakfire_file_has_caps(file)) {
+ r = pakfire_file_write_fcaps(file, &cap_data);
+ if (r)
+ goto ERROR;
- // Write payload
- r = archive_read_extract2(state->a, entry, state->writer);
- switch (r) {
- case ARCHIVE_OK:
- r = 0;
- break;
+ // Store capabilities in archive entry
+ archive_entry_xattr_add_entry(entry,
+ "security.capability", &cap_data, sizeof(cap_data));
+ }
- case ARCHIVE_WARN:
- ERROR(archive->ctx, "%s\n", archive_error_string(state->writer));
+ // Write payload
+ r = archive_read_extract2(state->a, entry, state->writer);
+ switch (r) {
+ case ARCHIVE_OK:
+ r = 0;
+ break;
- // Pretend everything has been okay
- r = 0;
- break;
+ case ARCHIVE_WARN:
+ ERROR(archive->ctx, "%s\n", archive_error_string(state->writer));
- case ARCHIVE_FATAL:
- ERROR(archive->ctx, "%s\n", archive_error_string(state->writer));
- r = 1;
- break;
- }
+ // Pretend everything has been okay
+ r = 0;
+ break;
+
+ case ARCHIVE_FATAL:
+ ERROR(archive->ctx, "%s\n", archive_error_string(state->writer));
+ r = 1;
+ break;
}
ERROR:
DEBUG(archive->ctx, "Extracting %s\n", archive->path);
- int progress_flags = PAKFIRE_PROGRESS_SHOW_PERCENTAGE;
-
- // Should we show any progress?
- if (flags & PAKFIRE_EXTRACT_NO_PROGRESS)
- progress_flags |= PAKFIRE_PROGRESS_NO_PROGRESS;
-
- // Show throughput?
- if (flags & PAKFIRE_EXTRACT_SHOW_THROUGHPUT)
- progress_flags |= PAKFIRE_PROGRESS_SHOW_TRANSFER_SPEED;
-
// Fetch package
pkg = pakfire_archive_get_package(archive);
if (!pkg) {
if (r < 0)
goto ERROR;
- // Setup the writer if we are not running in dry mode
- if (!(flags & PAKFIRE_EXTRACT_DRY_RUN)) {
- writer = pakfire_get_disk_writer(archive->pakfire);
- if (!writer) {
- r = -errno;
- goto ERROR;
- }
+ // Setup the writer
+ writer = pakfire_get_disk_writer(archive->pakfire);
+ if (!writer) {
+ r = -errno;
+ goto ERROR;
}
// Fetch NEVRA
const char* nevra = pakfire_package_get_string(pkg, PAKFIRE_PKG_NEVRA);
// Create the progress indicator
- r = pakfire_progress_create(&archive->progress, archive->ctx, progress_flags, NULL);
+ r = pakfire_progress_create(&archive->progress,
+ archive->ctx, PAKFIRE_PROGRESS_SHOW_PERCENTAGE, NULL);
if (r < 0)
goto ERROR;
goto ERROR;
}
- // Load the filelist (if not done already)
- if (!archive->filelist) {
- r = pakfire_filelist_create(&archive->filelist, archive->pakfire);
- if (r < 0)
- goto ERROR;
- }
-
// Create state
struct pakfire_extract_state state = {
.archive = archive,
// Walk through the entire archive and extract everything
r = pakfire_archive_walk(archive, a,
pakfire_archive_extract_one, pakfire_archive_filter_payload, &state);
- if (r)
+ if (r < 0)
goto ERROR;
ERROR:
return archive->format;
}
-static int pakfire_archive_load_filelist(struct pakfire_archive* archive) {
- // Perform a dry-run extraction
- return __pakfire_archive_extract(archive, NULL,
- PAKFIRE_EXTRACT_DRY_RUN|PAKFIRE_EXTRACT_NO_PROGRESS);
+static int __pakfire_archive_load_filelist(struct pakfire_archive* archive,
+ struct archive* a, struct archive_entry* entry, void* data) {
+ struct pakfire_filelist* filelist = data;
+ struct pakfire_file* file = NULL;
+ int r;
+
+ // Generate a file object
+ r = pakfire_file_create_from_archive_entry(&file, archive->pakfire, entry);
+ if (r < 0)
+ goto ERROR;
+
+ // Add entry to filelist
+ r = pakfire_filelist_add(filelist, file);
+ if (r < 0)
+ goto ERROR;
+
+ERROR:
+ if (file)
+ pakfire_file_unref(file);
+
+ return r;
+}
+
+static int pakfire_archive_load_filelist(struct pakfire_archive* self) {
+ struct pakfire_filelist* filelist = NULL;
+ int r;
+
+ // Create a new filelist
+ r = pakfire_filelist_create(&filelist, self->pakfire);
+ if (r < 0)
+ goto ERROR;
+
+ // Walk through the entire archive and extract everything
+ r = pakfire_archive_open_and_walk(self,
+ __pakfire_archive_load_filelist, pakfire_archive_filter_payload, filelist);
+ if (r < 0)
+ goto ERROR;
+
+ // Free any previous data
+ if (self->filelist)
+ pakfire_filelist_unref(self->filelist);
+
+ // Store the filelist
+ self->filelist = pakfire_filelist_ref(filelist);
+
+ERROR:
+ if (filelist)
+ pakfire_filelist_unref(filelist);
+
+ return r;
}
int pakfire_archive_get_filelist(struct pakfire_archive* self, struct pakfire_filelist** filelist) {