Remove stray semicolon.
[oweals/opkg-lede.git] / libopkg / pkg_parse.c
index c35eb1a30d67fef0a555e86db58ace33cd6c0365..2ce696fd586981f90c939de8982f2e3702314089 100644 (file)
@@ -16,6 +16,8 @@
    General Public License for more details.
 */
 
+#include "config.h"
+
 #include <stdio.h>
 #include <ctype.h>
 
@@ -60,7 +62,7 @@ parse_comma_separated(const char *raw, unsigned int *count)
 
        while (*raw) {
                depends = xrealloc(depends, sizeof(char *) * (line_count + 1));
-       
+
                while (isspace(*raw))
                        raw++;
 
@@ -146,6 +148,19 @@ parse_version(pkg_t *pkg, const char *vstr)
        return 0;
 }
 
+static int
+get_arch_priority(const char *arch)
+{
+       nv_pair_list_elt_t *l;
+
+       list_for_each_entry(l , &conf->arch_list.head, node) {
+               nv_pair_t *nv = (nv_pair_t *)l->data;
+               if (strcmp(nv->name, arch) == 0)
+                       return strtol(nv->value, NULL, 0);
+       }
+       return 0;
+}
+
 static int
 pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
 {
@@ -161,9 +176,10 @@ pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
 
        switch (*line) {
        case 'A':
-               if ((mask & PFM_ARCHITECTURE ) && is_field("Architecture", line))
+               if ((mask & PFM_ARCHITECTURE ) && is_field("Architecture", line)) {
                        pkg->architecture = parse_simple("Architecture", line);
-               else if ((mask & PFM_AUTO_INSTALLED) && is_field("Auto-Installed", line)) {
+                       pkg->arch_priority = get_arch_priority(pkg->architecture);
+               } else if ((mask & PFM_AUTO_INSTALLED) && is_field("Auto-Installed", line)) {
                        char *tmp = parse_simple("Auto-Installed", line);
                        if (strcmp(tmp, "yes") == 0)
                            pkg->auto_installed = 1;
@@ -214,7 +230,7 @@ pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
                        char *tmp = parse_simple("Installed-Time", line);
                        pkg->installed_time = strtoul(tmp, NULL, 0);
                        free (tmp);
-               }           
+               }
                break;
 
        case 'M':
@@ -230,7 +246,7 @@ pkg_parse_line(pkg_t *pkg, const char *line, uint mask)
                break;
 
        case 'P':
-               if ((mask & PFM_PACKAGE) && is_field("Package", line)) 
+               if ((mask & PFM_PACKAGE) && is_field("Package", line))
                        pkg->name = parse_simple("Package", line);
                else if ((mask & PFM_PRIORITY) && is_field("Priority", line))
                        pkg->priority = parse_simple("Priority", line);
@@ -382,7 +398,7 @@ pkg_parse_from_stream_nomalloc(pkg_t *pkg, FILE *fp, uint mask,
                buf = *buf0;
                buflen = buf0len;
                buf[0] = '\0';
-       };
+       }
 
        if (pkg->name == NULL) {
                /* probably just a blank line */