++static int check_data_file_clashes_change(ipkg_conf_t *conf, pkg_t *pkg, pkg_t *old_pkg)
++{
++ /* Basically that's the worst hack I could do to be able to change ownership of
++ file list, but, being that we have no way to unwind the mods, due to structure
++ of hash table, probably is the quickest hack too, whishing it would not slow-up thing too much.
++ What we do here is change the ownership of file in hash if a replace ( or similar events
++ happens )
++ Only the action that are needed to change name should be considered.
++ @@@ To change after 1.0 release.
++ */
++ str_list_t *files_list;
++ str_list_elt_t *iter;
++
++ int clashes = 0;
++
++ files_list = pkg_get_installed_files(pkg);
++ for (iter = files_list->head; iter; iter = iter->next) {
++ char *root_filename;
++ char *filename = iter->data;
++ root_filename = root_filename_alloc(conf, filename);
++ if (file_exists(root_filename) && (! file_is_dir(root_filename))) {
++ pkg_t *owner;
++
++ if (conf->force_overwrite) {
++ /* but we need to change who owns this file */
++ file_hash_set_file_owner(conf, filename, pkg);
++ continue;
++ }
++
++ owner = file_hash_get_file_owner(conf, filename);
++
++ /* Pre-existing files are OK if owned by a package replaced by new pkg. */
++ if (owner) {
++ if (pkg_replaces(pkg, owner)) {
++/* It's now time to change the owner of that file.
++ It has been "replaced" from the new "Replaces", then I need to inform lists file about that. */
++ ipkg_message(conf, IPKG_INFO, "Replacing pre-existing file %s owned by package %s\n", filename, owner->name);
++ file_hash_set_file_owner(conf, filename, pkg);
++ continue;
++ }
++ }
++
++ }
++ free(root_filename);
++ }
++ pkg_free_installed_files(pkg);
++
++ return clashes;
++}
++