#include <pakfire/filelist.h>
#include <pakfire/logging.h>
#include <pakfire/progressbar.h>
+#include <pakfire/string.h>
#include <pakfire/util.h>
// Read up to N bytes for analyze the magic
// Fetch path
const char* path = archive_entry_pathname(entry);
+ // Generate a file object
+ r = pakfire_file_create_from_archive_entry(&file, pakfire, entry);
+ if (r)
+ goto ERROR;
+
// Add entry to filelist (if requested)
if (data->filelist) {
- r = pakfire_file_create_from_archive_entry(&file, pakfire, entry);
- if (r)
- goto ERROR;
-
// Append the file to the list
r = pakfire_filelist_add(data->filelist, file);
if (r)
goto ERROR;
}
+ const int configfile = pakfire_file_has_flag(file, PAKFIRE_FILE_CONFIG);
+
// Prepend the prefix
if (*data->prefix) {
// Compose file path
r = pakfire_path_join(buffer, data->prefix, path);
if (r) {
ERROR(pakfire, "Could not compose file path: %m\n");
- return r;
+ goto ERROR;
}
// Set file path
r = pakfire_path_join(buffer, data->prefix, link);
if (r) {
ERROR(pakfire, "Could not compose hardlink path: %m\n");
- return r;
+ goto ERROR;
}
// Set hardlink path
}
}
+ if (configfile) {
+ // Fetch path again since we changed it
+ path = archive_entry_pathname(entry);
+
+ if (pakfire_path_exists(path)) {
+ DEBUG(pakfire, "The configuration file %s exists\n",
+ pakfire_file_get_path(file));
+
+ r = pakfire_string_format(buffer, "%s.paknew", path);
+ if (r) {
+ ERROR(pakfire, "Could not compose path for configuration file: %m\n");
+ goto ERROR;
+ }
+
+ // Set the path again
+ archive_entry_set_pathname(entry, buffer);
+ }
+ }
+
// Create file & extract payload
if (data->writer) {
// Fetch path again since we changed it