String the offline root path from the file_name in file_hash_get_file_owner().
[oweals/opkg-lede.git] / libopkg / pkg_hash.c
index f5d478221c96d3bbdabded40103c976b41a79c4a..f72ed26e52fc3845e9f29f1c1911605d3dd37cd6 100644 (file)
    General Public License for more details.
 */
 
-#include "includes.h"
-#include <errno.h>
-#include <ctype.h>
-#include <stdlib.h>
-#include <string.h>
+#include <stdio.h>
 
 #include "hash_table.h"
 #include "pkg.h"
@@ -109,10 +105,10 @@ pkg_hash_add_from_file(const char *file_name,
                        continue;
                }
 
-               if (!pkg->architecture) {
+               if (!pkg->architecture || !pkg->arch_priority) {
                        char *version_str = pkg_version_str_alloc(pkg);
-                       opkg_msg(ERROR, "Package %s version %s has no "
-                                       "architecture specified, ignoring.\n",
+                       opkg_msg(NOTICE, "Package %s version %s has no "
+                                       "valid architecture, ignoring.\n",
                                        pkg->name, version_str);
                        free(version_str);
                        continue;
@@ -627,7 +623,14 @@ hash_insert_pkg(pkg_t *pkg, int set_status)
 pkg_t *
 file_hash_get_file_owner(const char *file_name)
 {
-       return hash_table_get(&conf->file_hash, file_name); 
+       if (conf->offline_root) {
+               unsigned int len = strlen(conf->offline_root);
+               if (strncmp(file_name, conf->offline_root, len) == 0) {
+                       file_name += len;
+               }
+       }
+
+       return hash_table_get(&conf->file_hash, file_name);
 }
 
 void