/** * dnf_package_get_advisories: * @pkg: a #DnfPackage instance. * * Gets the list of advisories for the package. * * Returns: (transfer container) (element-type DnfAdvisory): a list * * Since: 0.7.0 */ GPtrArray * dnf_package_get_advisories(DnfPackage *pkg, int cmp_type) { Dataiterator di; Id evr; int cmp; DnfAdvisory *advisory; Pool *pool = dnf_package_get_pool(pkg); DnfSack *sack = dnf_package_get_sack(pkg); GPtrArray *advisorylist = g_ptr_array_new(); Solvable *s = get_solvable(pkg); dataiterator_init(&di, pool, 0, 0, UPDATE_COLLECTION_NAME, pool_id2str(pool, s->name), SEARCH_STRING); dataiterator_prepend_keyname(&di, UPDATE_COLLECTION); while (dataiterator_step(&di)) { dataiterator_setpos_parent(&di); if (pool_lookup_id(pool, SOLVID_POS, UPDATE_COLLECTION_ARCH) != s->arch) continue; evr = pool_lookup_id(pool, SOLVID_POS, UPDATE_COLLECTION_EVR); if (!evr) continue; cmp = pool_evrcmp(pool, evr, s->evr, EVRCMP_COMPARE); if ((cmp > 0 && (cmp_type & HY_GT)) || (cmp < 0 && (cmp_type & HY_LT)) || (cmp == 0 && (cmp_type & HY_EQ))) { advisory = dnf_advisory_new(sack, di.solvid); g_ptr_array_add(advisorylist, advisory); dataiterator_skip_solvable(&di); } } dataiterator_free(&di); return advisorylist; }
HyAdvisoryList hy_package_get_advisories(HyPackage pkg, int cmp_type) { Dataiterator di; Id evr; int cmp; HyAdvisory advisory; Pool *pool = package_pool(pkg); HyAdvisoryList advisorylist = advisorylist_create(pool); Solvable *s = get_solvable(pkg); dataiterator_init(&di, pool, 0, 0, UPDATE_COLLECTION_NAME, pool_id2str(pool, s->name), SEARCH_STRING); dataiterator_prepend_keyname(&di, UPDATE_COLLECTION); while (dataiterator_step(&di)) { dataiterator_setpos_parent(&di); if (pool_lookup_id(pool, SOLVID_POS, UPDATE_COLLECTION_ARCH) != s->arch) continue; evr = pool_lookup_id(pool, SOLVID_POS, UPDATE_COLLECTION_EVR); if (!evr) continue; cmp = pool_evrcmp(pool, evr, s->evr, EVRCMP_COMPARE); if ((cmp > 0 && (cmp_type & HY_GT)) || (cmp < 0 && (cmp_type & HY_LT)) || (cmp == 0 && (cmp_type & HY_EQ))) { advisory = advisory_create(pool, di.solvid); advisorylist_add(advisorylist, advisory); hy_advisory_free(advisory); dataiterator_skip_solvable(&di); } } dataiterator_free(&di); return advisorylist; }
static int obsq_sortcmp(const void *ap, const void *bp, void *dp) { Id a, b, oa, ob; Pool *pool = dp; Solvable *s, *oas, *obs; int r; a = ((Id *)ap)[0]; oa = ((Id *)ap)[1]; b = ((Id *)bp)[0]; ob = ((Id *)bp)[1]; if (a != b) return a - b; if (oa == ob) return 0; s = pool->solvables + a; oas = pool->solvables + oa; obs = pool->solvables + ob; if (oas->name != obs->name) { /* bring "same name" obsoleters (i.e. upgraders) to front */ if (oas->name == s->name) return -1; if (obs->name == s->name) return 1; return strcmp(pool_id2str(pool, oas->name), pool_id2str(pool, obs->name)); } r = pool_evrcmp(pool, oas->evr, obs->evr, EVRCMP_COMPARE); if (r) return -r; /* highest version first */ if (oas->arch != obs->arch) { /* bring same arch to front */ if (oas->arch == s->arch) return -1; if (obs->arch == s->arch) return 1; } return oa - ob; }
static int classify_cmp_pkgs(const void *ap, const void *bp, void *dp) { Transaction *trans = dp; Pool *pool = trans->pool; Id a = *(Id *)ap; Id b = *(Id *)bp; Solvable *sa, *sb; sa = pool->solvables + a; sb = pool->solvables + b; if (sa->name != sb->name) return strcmp(pool_id2str(pool, sa->name), pool_id2str(pool, sb->name)); if (sa->evr != sb->evr) { int r = pool_evrcmp(pool, sa->evr, sb->evr, EVRCMP_COMPARE); if (r) return r; } return a - b; }
static Id transaction_base_type(Transaction *trans, Id p) { Pool *pool = trans->pool; Solvable *s, *s2; int r; Id p2; if (!MAPTST(&trans->transactsmap, p)) return SOLVER_TRANSACTION_IGNORE; p2 = transaction_obs_pkg(trans, p); if (pool->installed && pool->solvables[p].repo == pool->installed) { /* erase */ if (!p2) return SOLVER_TRANSACTION_ERASE; s = pool->solvables + p; s2 = pool->solvables + p2; if (s->name == s2->name) { if (s->evr == s2->evr && solvable_identical(s, s2)) return SOLVER_TRANSACTION_REINSTALLED; r = pool_evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE); if (r < 0) return SOLVER_TRANSACTION_UPGRADED; else if (r > 0) return SOLVER_TRANSACTION_DOWNGRADED; return SOLVER_TRANSACTION_CHANGED; } return SOLVER_TRANSACTION_OBSOLETED; } else { /* install or multiinstall */ int multi = trans->multiversionmap.size && MAPTST(&trans->multiversionmap, p); if (multi) { if (p2) { s = pool->solvables + p; s2 = pool->solvables + p2; if (s->name == s2->name && s->arch == s2->arch && s->evr == s2->evr) return SOLVER_TRANSACTION_MULTIREINSTALL; } return SOLVER_TRANSACTION_MULTIINSTALL; } if (!p2) return SOLVER_TRANSACTION_INSTALL; s = pool->solvables + p; s2 = pool->solvables + p2; if (s->name == s2->name) { if (s->evr == s2->evr && solvable_identical(s, s2)) return SOLVER_TRANSACTION_REINSTALL; r = pool_evrcmp(pool, s->evr, s2->evr, EVRCMP_COMPARE); if (r > 0) return SOLVER_TRANSACTION_UPGRADE; else if (r < 0) return SOLVER_TRANSACTION_DOWNGRADE; else return SOLVER_TRANSACTION_CHANGE; } return SOLVER_TRANSACTION_OBSOLETES; } }
static void XMLCALL endElement(void *userData, const char *name) { Parsedata *pd = (Parsedata *)userData; Pool *pool = pd->pool; Solvable *s = pd->solvable; Id evr; unsigned int t = 0; const char *flavor; if (pd->depth != pd->statedepth) { pd->depth--; /* printf("back from unknown %d %d %d\n", pd->state, pd->depth, pd->statedepth); */ return; } /* ignore deps element */ if (pd->state == STATE_PACKAGE && !strcmp(name, "deps")) return; pd->depth--; pd->statedepth--; switch (pd->state) { case STATE_PACKAGE: /* package complete */ if (name[0] == 's' && name[1] == 'r' && name[2] == 'c' && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) s->arch = ARCH_SRC; if (!s->arch) /* default to "noarch" */ s->arch = ARCH_NOARCH; if (!s->evr && pd->version) /* set solvable evr */ s->evr = evr2id(pool, pd, pd->epoch ? pd->evrspace + pd->epoch : 0, pd->version ? pd->evrspace + pd->version : 0, pd->release ? pd->evrspace + pd->release : ""); /* ensure self-provides */ if (s->name && s->arch != ARCH_SRC && s->arch != ARCH_NOSRC) s->provides = repo_addid_dep(pd->repo, s->provides, pool_rel2id(pool, s->name, s->evr, REL_EQ, 1), 0); s->supplements = repo_fix_supplements(pd->repo, s->provides, s->supplements, pd->freshens); s->conflicts = repo_fix_conflicts(pd->repo, s->conflicts); pd->freshens = 0; /* see bugzilla bnc#190163 */ flavor = findKernelFlavor(pd, s); if (flavor) { char *cflavor = solv_strdup(flavor); /* make pointer safe */ Id npr; Id pid; /* this is either a kernel package or a kmp */ if (s->provides) { Offset prov = s->provides; npr = 0; while ((pid = pd->repo->idarraydata[prov++]) != 0) { const char *depname = 0; Reldep *prd = 0; if (ISRELDEP(pid)) { prd = GETRELDEP(pool, pid); depname = pool_id2str(pool, prd->name); } else { depname = pool_id2str(pool, pid); } if (!strncmp(depname, "kernel(", 7) && !strchr(depname, ':')) { char newdep[100]; snprintf(newdep, sizeof(newdep), "kernel(%s:%s", cflavor, depname + 7); pid = pool_str2id(pool, newdep, 1); if (prd) pid = pool_rel2id(pool, pid, prd->evr, prd->flags, 1); } npr = repo_addid_dep(pd->repo, npr, pid, 0); } s->provides = npr; } #if 1 if (s->requires) { Offset reqs = s->requires; npr = 0; while ((pid = pd->repo->idarraydata[reqs++]) != 0) { const char *depname = 0; Reldep *prd = 0; if (ISRELDEP(pid)) { prd = GETRELDEP(pool, pid); depname = pool_id2str(pool, prd->name); } else { depname = pool_id2str(pool, pid); } if (!strncmp(depname, "kernel(", 7) && !strchr(depname, ':')) { char newdep[100]; snprintf(newdep, sizeof(newdep), "kernel(%s:%s", cflavor, depname + 7); pid = pool_str2id(pool, newdep, 1); if (prd) pid = pool_rel2id(pool, pid, prd->evr, prd->flags, 1); } npr = repo_addid_dep(pd->repo, npr, pid, 0); } s->requires = npr; } #endif free(cflavor); } break; case STATE_NAME: s->name = pool_str2id(pool, pd->content, 1); break; case STATE_VENDOR: s->vendor = pool_str2id(pool, pd->content, 1); break; case STATE_BUILDTIME: t = atoi (pd->content); if (t) repodata_set_num(pd->data, s - pool->solvables, SOLVABLE_BUILDTIME, t); break; case STATE_UPDATE: /* new version, keeping all other metadata */ evr = evr2id(pool, pd, pd->epoch ? pd->evrspace + pd->epoch : 0, pd->version ? pd->evrspace + pd->version : 0, pd->release ? pd->evrspace + pd->release : 0); pd->levrspace = 1; pd->epoch = 0; pd->version = 0; pd->release = 0; /* use highest evr */ if (!s->evr || pool_evrcmp(pool, s->evr, evr, EVRCMP_COMPARE) <= 0) s->evr = evr; break; case STATE_EPOCH: case STATE_VERSION: case STATE_RELEASE: case STATE_PEPOCH: case STATE_PVERSION: case STATE_PRELEASE: /* ensure buffer space */ if (pd->lcontent + 1 + pd->levrspace > pd->aevrspace) { pd->evrspace = (char *)realloc(pd->evrspace, pd->lcontent + 1 + pd->levrspace + 256); pd->aevrspace = pd->lcontent + 1 + pd->levrspace + 256; } memcpy(pd->evrspace + pd->levrspace, pd->content, pd->lcontent + 1); if (pd->state == STATE_EPOCH || pd->state == STATE_PEPOCH) pd->epoch = pd->levrspace; else if (pd->state == STATE_VERSION || pd->state == STATE_PVERSION) pd->version = pd->levrspace; else pd->release = pd->levrspace; pd->levrspace += pd->lcontent + 1; break; case STATE_ARCH: case STATE_PARCH: s->arch = pool_str2id(pool, pd->content, 1); break; default: break; } pd->state = pd->sbtab[pd->state]; pd->docontent = 0; /* printf("back from known %d %d %d\n", pd->state, pd->depth, pd->statedepth); */ }