Fix --force-reinstall by removing special case code. Just remove the pkg first.
[oweals/opkg-lede.git] / libopkg / pkg_hash.c
index 5850082d469d553223b0e509eec735b60dbb9acb..67c1781a8228e7443760d5668ac7e3fb9098f12f 100644 (file)
@@ -107,7 +107,7 @@ pkg_hash_add_from_file(const char *file_name,
 
                if (!pkg->architecture || !pkg->arch_priority) {
                        char *version_str = pkg_version_str_alloc(pkg);
-                       opkg_msg(ERROR, "Package %s version %s has no "
+                       opkg_msg(NOTICE, "Package %s version %s has no "
                                        "valid architecture, ignoring.\n",
                                        pkg->name, version_str);
                        free(version_str);
@@ -619,11 +619,32 @@ hash_insert_pkg(pkg_t *pkg, int set_status)
        pkg->parent = ab_pkg;
 }
 
+static const char *
+strip_offline_root(const char *file_name)
+{
+       unsigned int len;
+
+       if (conf->offline_root) {
+               len = strlen(conf->offline_root);
+               if (strncmp(file_name, conf->offline_root, len) == 0)
+                       file_name += len;
+       }
+
+       return file_name;
+}
+
+void
+file_hash_remove(const char *file_name)
+{
+       file_name = strip_offline_root(file_name);
+       hash_table_remove(&conf->file_hash, file_name);
+}
 
 pkg_t *
 file_hash_get_file_owner(const char *file_name)
 {
-       return hash_table_get(&conf->file_hash, file_name); 
+       file_name = strip_offline_root(file_name);
+       return hash_table_get(&conf->file_hash, file_name);
 }
 
 void
@@ -635,12 +656,7 @@ file_hash_set_file_owner(const char *file_name, pkg_t *owning_pkg)
        if (file_name[file_name_len -1] == '/')
                return;
 
-       if (conf->offline_root) {
-               unsigned int len = strlen(conf->offline_root);
-               if (strncmp(file_name, conf->offline_root, len) == 0) {
-                       file_name += len;
-               }
-       }
+       file_name = strip_offline_root(file_name);
 
        hash_table_insert(&conf->file_hash, file_name, owning_pkg);