summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgraham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-20 22:49:21 (EST)
committer graham.gower <graham.gower@e8e0d7a0-c8d9-11dd-a880-a1081c7ac358>2009-12-20 22:49:21 (EST)
commitcdeb4ec7a68b9a9f240d19b525849c77118c0ff0 (patch)
treede473039908c2da11b2d632818464861451be556
parentec5a26e8047307658a0b78ffaa65f9d2daedd7b0 (diff)
Set the arch_priority when parsing the Architecture.
git-svn-id: http://opkg.googlecode.com/svn/trunk@507 e8e0d7a0-c8d9-11dd-a880-a1081c7ac358
-rw-r--r--libopkg/pkg.c42
-rw-r--r--libopkg/pkg_hash.c4
-rw-r--r--libopkg/pkg_parse.c18
3 files changed, 18 insertions, 46 deletions
diff --git a/libopkg/pkg.c b/libopkg/pkg.c
index bd7e9f8..c5a3336 100644
--- a/libopkg/pkg.c
+++ b/libopkg/pkg.c
@@ -1315,54 +1315,12 @@ pkg_arch_supported(pkg_t *pkg)
return 0;
}
-static int
-pkg_get_arch_priority(const char *archname)
-{
- 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, archname) == 0) {
- int priority = strtol(nv->value, NULL, 0);
- return priority;
- }
- }
- return 0;
-}
-
void
pkg_info_preinstall_check(void)
{
int i;
- pkg_vec_t *available_pkgs = pkg_vec_alloc();
pkg_vec_t *installed_pkgs = pkg_vec_alloc();
- opkg_msg(INFO, "Updating arch priority for each package.\n");
- pkg_hash_fetch_available(available_pkgs);
- /* update arch_priority for each package */
- for (i = 0; i < available_pkgs->len; i++) {
- pkg_t *pkg = available_pkgs->pkgs[i];
- int arch_priority = 1;
- if (!pkg)
- continue;
- arch_priority = pkg_get_arch_priority(pkg->architecture);
- pkg->arch_priority = arch_priority;
- }
-
- for (i = 0; i < available_pkgs->len; i++) {
- pkg_t *pkg = available_pkgs->pkgs[i];
- if (!pkg->arch_priority && (pkg->state_flag || (pkg->state_want != SW_UNKNOWN))) {
- /* clear flags and want for any uninstallable package */
- opkg_msg(DEBUG, "Clearing state_want and state_flag for pkg=%s "
- "(arch_priority=%d flag=%d want=%d)\n",
- pkg->name, pkg->arch_priority,
- pkg->state_flag, pkg->state_want);
- pkg->state_want = SW_UNKNOWN;
- pkg->state_flag = 0;
- }
- }
- pkg_vec_free(available_pkgs);
-
/* update the file owner data structure */
opkg_msg(INFO, "Updating file owner list.\n");
pkg_hash_fetch_all_installed(installed_pkgs);
diff --git a/libopkg/pkg_hash.c b/libopkg/pkg_hash.c
index 2fc539e..5850082 100644
--- a/libopkg/pkg_hash.c
+++ b/libopkg/pkg_hash.c
@@ -105,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",
+ "valid architecture, ignoring.\n",
pkg->name, version_str);
free(version_str);
continue;
diff --git a/libopkg/pkg_parse.c b/libopkg/pkg_parse.c
index 6c9c7ee..f1725de 100644
--- a/libopkg/pkg_parse.c
+++ b/libopkg/pkg_parse.c
@@ -149,6 +149,19 @@ parse_version(pkg_t *pkg, const char *vstr)
}
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)
{
/* these flags are a bit hackish... */
@@ -163,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;