const char * pool_solvable2str(Pool *pool, Solvable *s) { const char *n, *e, *a; int nl, el, al; char *p; n = pool_id2str(pool, s->name); e = pool_id2str(pool, s->evr); /* XXX: may want to skip the epoch here */ a = pool_id2str(pool, s->arch); nl = strlen(n); el = strlen(e); al = strlen(a); if (pool->havedistepoch) { /* strip the distepoch from the evr */ const char *de = strrchr(e, '-'); if (de && (de = strchr(de, ':')) != 0) el = de - e; } p = pool_alloctmpspace(pool, nl + el + al + 3); strcpy(p, n); if (el) { p[nl++] = '-'; strncpy(p + nl, e, el); p[nl + el] = 0; } if (al) { p[nl + el] = pool->disttype == DISTTYPE_HAIKU ? '-' : '.'; strcpy(p + nl + el + 1, a); } return p; }
void commit_transactionelement_rpm(Pool *pool, Id type, Id p, FILE *fp) { Solvable *s = pool_id2solvable(pool, p); const char *rootdir = pool_get_rootdir(pool); const char *evr, *evrp, *nvra; switch(type) { case SOLVER_TRANSACTION_ERASE: if (!s->repo->rpmdbid || !s->repo->rpmdbid[p - s->repo->start]) break; /* strip epoch from evr */ evr = evrp = pool_id2str(pool, s->evr); while (*evrp >= '0' && *evrp <= '9') evrp++; if (evrp > evr && evrp[0] == ':' && evrp[1]) evr = evrp + 1; nvra = pool_tmpjoin(pool, pool_id2str(pool, s->name), "-", evr); nvra = pool_tmpappend(pool, nvra, ".", pool_id2str(pool, s->arch)); runrpm("-e", nvra, -1, rootdir); /* too bad that --querybynumber doesn't work */ break; case SOLVER_TRANSACTION_INSTALL: case SOLVER_TRANSACTION_MULTIINSTALL: rewind(fp); lseek(fileno(fp), 0, SEEK_SET); runrpm(type == SOLVER_TRANSACTION_MULTIINSTALL ? "-i" : "-U", "/dev/fd/3", fileno(fp), rootdir); break; default: break; } }
int pool_evrcmp(const Pool *pool, Id evr1id, Id evr2id, int mode) { const char *evr1, *evr2; if (evr1id == evr2id) return 0; evr1 = pool_id2str(pool, evr1id); evr2 = pool_id2str(pool, evr2id); return pool_evrcmp_str(pool, evr1, evr2, mode); }
/** * dnf_package_evr_cmp: * @pkg1: a #DnfPackage instance. * @pkg2: another #DnfPackage instance. * * Compares two packages, only using the EVR values. * * Returns: %TRUE for success * * Since: 0.7.0 */ int dnf_package_evr_cmp(DnfPackage *pkg1, DnfPackage *pkg2) { Pool *pool1 = dnf_package_get_pool(pkg1); Pool *pool2 = dnf_package_get_pool(pkg2); Solvable *s1 = get_solvable(pkg1); Solvable *s2 = get_solvable(pkg2); const char *str1 = pool_id2str(pool1, s1->evr); const char *str2 = pool_id2str(pool2, s2->evr); return pool_evrcmp_str(dnf_package_get_pool(pkg1), str1, str2, EVRCMP_COMPARE); }
int hy_package_evr_cmp(HyPackage pkg1, HyPackage pkg2) { Pool *pool1 = package_pool(pkg1); Pool *pool2 = package_pool(pkg2); Solvable *s1 = get_solvable(pkg1); Solvable *s2 = get_solvable(pkg2); const char *str1 = pool_id2str(pool1, s1->evr); const char *str2 = pool_id2str(pool2, s2->evr); return pool_evrcmp_str(package_pool(pkg1), str1, str2, EVRCMP_COMPARE); }
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; }
/** * dnf_package_get_delta_from_evr: * @pkg: a #DnfPackage instance. * @from_evr: the EVR string of what's installed * * Gets the package delta for the package given an existing EVR. * * Returns: a #DnfPackageDelta, or %NULL * * Since: 0.7.0 */ DnfPackageDelta * dnf_package_get_delta_from_evr(DnfPackage *pkg, const char *from_evr) { Pool *pool = dnf_package_get_pool(pkg); Solvable *s = get_solvable(pkg); DnfPackageDelta *delta = NULL; Dataiterator di; const char *name = dnf_package_get_name(pkg); dataiterator_init(&di, pool, s->repo, SOLVID_META, DELTA_PACKAGE_NAME, name, SEARCH_STRING); dataiterator_prepend_keyname(&di, REPOSITORY_DELTAINFO); while (dataiterator_step(&di)) { dataiterator_setpos_parent(&di); if (pool_lookup_id(pool, SOLVID_POS, DELTA_PACKAGE_EVR) != s->evr || pool_lookup_id(pool, SOLVID_POS, DELTA_PACKAGE_ARCH) != s->arch) continue; const char * base_evr = pool_id2str(pool, pool_lookup_id(pool, SOLVID_POS, DELTA_BASE_EVR)); if (strcmp(base_evr, from_evr)) continue; // we have the right delta info, set up DnfPackageDelta *and break out: delta = dnf_packagedelta_new(pool); break; } dataiterator_free(&di); return delta; }
Offset repo_fix_conflicts(Repo *repo, Offset conflicts) { char buf[1024], *p, *dep; Pool *pool = repo->pool; Id id; int i; if (!conflicts) return conflicts; for (i = conflicts; repo->idarraydata[i]; i++) { id = repo->idarraydata[i]; if (ISRELDEP(id)) continue; dep = (char *)pool_id2str(pool, id); if (!strncmp(dep, "otherproviders(", 15) && strlen(dep) < sizeof(buf) - 2) { strcpy(buf, dep + 15); if ((p = strchr(buf, ')')) != 0) *p = 0; id = pool_str2id(pool, buf, 1); id = pool_rel2id(pool, NAMESPACE_OTHERPROVIDERS, id, REL_NAMESPACE, 1); repo->idarraydata[i] = id; } } return conflicts; }
static int conflicts_cmp(const void *ap, const void *bp, void *dp) { Pool *pool = dp; const Id *a = ap; const Id *b = bp; if (a[0] != b[0]) /* filename1 */ return strcmp(pool_id2str(pool, a[0]), pool_id2str(pool, b[0])); if (a[3] != b[3]) /* filename2 */ return strcmp(pool_id2str(pool, a[3]), pool_id2str(pool, b[3])); if (a[1] != b[1]) /* pkgid1 */ return a[1] - b[1]; if (a[4] != b[4]) /* pkgid2 */ return a[4] - b[4]; return 0; }
/** * 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; }
static int keyfilter_other(Repo *repo, Repokey *key, void *kfdata) { const char *name, *p; struct keyfilter_data *kd = kfdata; int i; if (!kd->haveaddedfileprovides && key->name == REPOSITORY_ADDEDFILEPROVIDES) return KEY_STORAGE_DROPPED; if (!kd->haveexternal && key->name == REPOSITORY_EXTERNAL) return KEY_STORAGE_DROPPED; if (key->name == SOLVABLE_FILELIST || key->name == SOLVABLE_DISKUSAGE) return KEY_STORAGE_DROPPED; name = pool_id2str(repo->pool, key->name); p = strrchr(name, ':'); if (p) { for (i = 0; i < kd->nlanguages; i++) if (!strcmp(p + 1, kd->languages[i])) return KEY_STORAGE_DROPPED; } for (i = 0; verticals[i]; i++) if (key->name == verticals[i]) return KEY_STORAGE_VERTICAL_OFFSET; return KEY_STORAGE_INCORE; }
static const char *findKernelFlavor(Parsedata *pd, Solvable *s) { Pool *pool = pd->pool; Id pid, *pidp; if (s->provides) { pidp = pd->repo->idarraydata + s->provides; while ((pid = *pidp++) != 0) { Reldep *prd; const char *depname; if (!ISRELDEP(pid)) continue; /* wrong provides name */ prd = GETRELDEP(pool, pid); depname = pool_id2str(pool, prd->name); if (!strncmp(depname, "kernel-", 7)) return depname + 7; } } if (s->requires) { pidp = pd->repo->idarraydata + s->requires; while ((pid = *pidp++) != 0) { const char *depname; if (!ISRELDEP(pid)) { depname = pool_id2str(pool, pid); } else { Reldep *prd = GETRELDEP(pool, pid); depname = pool_id2str(pool, prd->name); } if (!strncmp(depname, "kernel-", 7)) return depname + 7; } } return 0; }
const char * pool_solvable2str(Pool *pool, Solvable *s) { const char *n, *e, *a; int nl, el, al; char *p; n = pool_id2str(pool, s->name); e = s->evr ? pool_id2str(pool, s->evr) : ""; /* XXX: may want to skip the epoch here */ a = s->arch ? pool_id2str(pool, s->arch) : ""; nl = strlen(n); el = strlen(e); al = strlen(a); if (pool->havedistepoch) { /* strip the distepoch from the evr */ const char *de = strrchr(e, '-'); if (de && (de = strchr(de, ':')) != 0) el = de - e; } p = pool_alloctmpspace(pool, nl + el + al + 3); strcpy(p, n); if (el) { p[nl++] = '-'; strncpy(p + nl, e, el); p[nl + el] = 0; } if (al) { p[nl + el] = pool->disttype == DISTTYPE_HAIKU ? '-' : '.'; strcpy(p + nl + el + 1, a); } if (pool->disttype == DISTTYPE_CONDA && solvable_lookup_type(s, SOLVABLE_BUILDFLAVOR)) { Queue flavorq; int i; queue_init(&flavorq); solvable_lookup_idarray(s, SOLVABLE_BUILDFLAVOR, &flavorq); for (i = 0; i < flavorq.count; i++) p = pool_tmpappend(pool, p, "-", pool_id2str(pool, flavorq.elements[i])); queue_free(&flavorq); } return p; }
static Id nscallback(Pool *pool, void *data, Id name, Id evr) { #if 0 if (name == NAMESPACE_LANGUAGE) { if (!strcmp(pool_id2str(pool, evr), "ja")) return 1; if (!strcmp(pool_id2str(pool, evr), "de")) return 1; if (!strcmp(pool_id2str(pool, evr), "en")) return 1; if (!strcmp(pool_id2str(pool, evr), "en_US")) return 1; } #endif return 0; }
int main(int argc, char **argv) { Pool *pool; Repo *installed; Solvable *s; Id p; int i; Queue todo, conflicts; void *state = 0; pool = pool_create(); pool_setdebuglevel(pool, 1); installed = repo_create(pool, "@System"); pool_set_installed(pool, installed); if (repo_add_rpmdb(installed, 0, 0)) { fprintf(stderr, "findfileconflicts: %s\n", pool_errstr(pool)); exit(1); } queue_init(&todo); queue_init(&conflicts); FOR_REPO_SOLVABLES(installed, p, s) queue_push(&todo, p); pool_findfileconflicts(pool, &todo, 0, &conflicts, &iterate_handle, (void *)&state); queue_free(&todo); for (i = 0; i < conflicts.count; i += 5) printf("%s: %s[%s] %s[%s]\n", pool_id2str(pool, conflicts.elements[i]), pool_solvid2str(pool, conflicts.elements[i + 1]), pool_id2str(pool, conflicts.elements[i + 2]), pool_solvid2str(pool, conflicts.elements[i + 3]), pool_id2str(pool, conflicts.elements[i + 4])); if (conflicts.count) { Queue job; int problemcnt; queue_init(&job); pool_add_fileconflicts_deps(pool, &conflicts); pool_addfileprovides(pool); pool_createwhatprovides(pool); pool_setdebuglevel(pool, 0); Solver *solv = solver_create(pool); queue_push2(&job, SOLVER_VERIFY|SOLVER_SOLVABLE_ALL, 0); #if 0 solver_set_flag(solv, SOLVER_FLAG_ALLOW_UNINSTALL, 1); #endif problemcnt = solver_solve(solv, &job); if (problemcnt) solver_printallsolutions(solv); else { Transaction *trans = solver_create_transaction(solv); transaction_print(trans); transaction_free(trans); } queue_free(&job); solver_free(solv); } queue_free(&conflicts); exit(0); }
static void set_sourcerpm(Repodata *data, Solvable *s, Id handle, char *sourcerpm) { const char *p, *sevr, *sarch, *name, *evr; Pool *pool; p = strrchr(sourcerpm, '.'); if (!p || strcmp(p, ".rpm") != 0) return; p--; while (p > sourcerpm && *p != '.') p--; if (*p != '.' || p == sourcerpm) return; sarch = p-- + 1; while (p > sourcerpm && *p != '-') p--; if (*p != '-' || p == sourcerpm) return; p--; while (p > sourcerpm && *p != '-') p--; if (*p != '-' || p == sourcerpm) return; sevr = p + 1; pool = s->repo->pool; if (!strcmp(sarch, "src.rpm")) repodata_set_constantid(data, handle, SOLVABLE_SOURCEARCH, ARCH_SRC); else if (!strcmp(sarch, "nosrc.rpm")) repodata_set_constantid(data, handle, SOLVABLE_SOURCEARCH, ARCH_NOSRC); else repodata_set_constantid(data, handle, SOLVABLE_SOURCEARCH, pool_strn2id(pool, sarch, strlen(sarch) - 4, 1)); evr = pool_id2str(pool, s->evr); if (evr && !strncmp(sevr, evr, sarch - sevr - 1) && evr[sarch - sevr - 1] == 0) repodata_set_void(data, handle, SOLVABLE_SOURCEEVR); else repodata_set_id(data, handle, SOLVABLE_SOURCEEVR, pool_strn2id(pool, sevr, sarch - sevr - 1, 1)); name = pool_id2str(pool, s->name); if (name && !strncmp(sourcerpm, name, sevr - sourcerpm - 1) && name[sevr - sourcerpm - 1] == 0) repodata_set_void(data, handle, SOLVABLE_SOURCENAME); else repodata_set_id(data, handle, SOLVABLE_SOURCENAME, pool_strn2id(pool, sourcerpm, sevr - sourcerpm - 1, 1)); }
static const char * solvable_lookup_str_joinarray(Solvable *s, Id keyname, const char *joinstr) { Queue q; Id qbuf[10]; char *str = 0; queue_init_buffer(&q, qbuf, sizeof(qbuf)/sizeof(*qbuf)); if (solvable_lookup_idarray(s, keyname, &q) && q.count) { Pool *pool = s->repo->pool; int i; str = pool_tmpjoin(pool, pool_id2str(pool, q.elements[0]), 0, 0); for (i = 1; i < q.count; i++) str = pool_tmpappend(pool, str, joinstr, pool_id2str(pool, q.elements[i])); } queue_free(&q); return str; }
static const char * solvable_lookup_str_base(Solvable *s, Id keyname, Id basekeyname, int usebase) { Pool *pool; const char *str, *basestr; Id p, pp, name; Solvable *s2; int pass; if (!s->repo) return 0; pool = s->repo->pool; str = solvable_lookup_str(s, keyname); if (str || keyname == basekeyname) return str; basestr = solvable_lookup_str(s, basekeyname); if (!basestr) return 0; /* search for a solvable with same name and same base that has the * translation */ if (!pool->whatprovides) return usebase ? basestr : 0; name = s->name; /* we do this in two passes, first same vendor, then all other vendors */ for (pass = 0; pass < 2; pass++) { FOR_PROVIDES(p, pp, name) { s2 = pool->solvables + p; if (s2->name != name) continue; if ((s->vendor == s2->vendor) != (pass == 0)) continue; str = solvable_lookup_str(s2, basekeyname); if (!str || strcmp(str, basestr)) continue; str = solvable_lookup_str(s2, keyname); if (str) return str; } #ifdef ENABLE_LINKED_PKGS /* autopattern/product translation magic */ if (pass) { const char *n = pool_id2str(pool, name); if (*n == 'p') { if (!strncmp("pattern:", n, 8) && (name = find_autopattern_name(pool, s)) != 0) pass = -1; if (!strncmp("product:", n, 8) && (name = find_autoproduct_name(pool, s)) != 0) pass = -1; } } #endif }
static int classify_cmp(const void *ap, const void *bp, void *dp) { Transaction *trans = dp; Pool *pool = trans->pool; const Id *a = ap; const Id *b = bp; int r; r = a[0] - b[0]; if (r) return r; r = a[2] - b[2]; if (r) return a[2] && b[2] ? strcmp(pool_id2str(pool, a[2]), pool_id2str(pool, b[2])) : r; r = a[3] - b[3]; if (r) return a[3] && b[3] ? strcmp(pool_id2str(pool, a[3]), pool_id2str(pool, b[3])) : r; return 0; }
static int keyfilter_language(Repo *repo, Repokey *key, void *kfdata) { Pool *pool = repo->pool; const char *name, *p; char *lang = kfdata; int i; name = pool_id2str(repo->pool, key->name); p = strrchr(name, ':'); if (!p || strcmp(p + 1, lang) != 0) return KEY_STORAGE_DROPPED; for (i = 0; verticals[i]; i++) { const char *vname = pool_id2str(pool, verticals[i]); if (!strncmp(name, vname, p - name) && vname[p - name] == 0) return KEY_STORAGE_VERTICAL_OFFSET; } return KEY_STORAGE_INCORE; }
static unsigned int adddep(Pool *pool, struct parsedata *pd, unsigned int olddeps, const char **atts, int isreq) { Id id, name, marker; const char *n, *f, *k; const char **a; n = f = k = 0; marker = isreq ? -SOLVABLE_PREREQMARKER : 0; for (a = atts; *a; a += 2) { if (!strcmp(*a, "name")) n = a[1]; else if (!strcmp(*a, "flags")) f = a[1]; else if (!strcmp(*a, "kind")) k = a[1]; else if (isreq && !strcmp(*a, "pre") && a[1][0] == '1') marker = SOLVABLE_PREREQMARKER; } if (!n) return olddeps; if (k && !strcmp(k, "package")) k = 0; if (k) { int l = strlen(k) + 1 + strlen(n) + 1; if (l > pd->acontent) { pd->content = solv_realloc(pd->content, l + 256); pd->acontent = l + 256; } sprintf(pd->content, "%s:%s", k, n); name = pool_str2id(pool, pd->content, 1); } else name = pool_str2id(pool, (char *)n, 1); if (f) { Id evr = makeevr_atts(pool, pd, atts); int flags; for (flags = 0; flags < 6; flags++) if (!strcmp(f, flagtab[flags])) break; flags = flags < 6 ? flags + 1 : 0; id = pool_rel2id(pool, name, evr, flags, 1); } else id = name; #if 0 fprintf(stderr, "new dep %s%s%s\n", pool_id2str(pool, d), id2rel(pool, d), id2evr(pool, d)); #endif return repo_addid_dep(pd->common.repo, olddeps, id, marker); }
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; }
/** * dnf_package_cmp: * @pkg1: a #DnfPackage instance. * @pkg2: another #DnfPackage instance. * * Compares two packages. * * Returns: %TRUE for success * * Since: 0.7.0 */ int dnf_package_cmp(DnfPackage *pkg1, DnfPackage *pkg2) { Pool *pool1 = dnf_package_get_pool(pkg1); Pool *pool2 = dnf_package_get_pool(pkg2); Solvable *s1 = pool_id2solvable(pool1, dnf_package_get_id(pkg1)); Solvable *s2 = pool_id2solvable(pool2, dnf_package_get_id(pkg2)); const char *str1 = pool_id2str(pool1, s1->name); const char *str2 = pool_id2str(pool2, s2->name); int ret = strcmp(str1, str2); if (ret) return ret; ret = dnf_package_evr_cmp(pkg1, pkg2); if (ret) return ret; str1 = pool_id2str(pool1, s1->arch); str2 = pool_id2str(pool2, s2->arch); return strcmp(str1, str2); }
int hy_package_cmp(HyPackage pkg1, HyPackage pkg2) { Pool *pool1 = package_pool(pkg1); Pool *pool2 = package_pool(pkg2); Solvable *s1 = pool_id2solvable(pool1, pkg1->id); Solvable *s2 = pool_id2solvable(pool2, pkg2->id); const char *str1 = pool_id2str(pool1, s1->name); const char *str2 = pool_id2str(pool2, s2->name); int ret = strcmp(str1, str2); if (ret) return ret; ret = hy_package_evr_cmp(pkg1, pkg2); if (ret) return ret; str1 = pool_id2str(pool1, s1->arch); str2 = pool_id2str(pool2, s2->arch); return strcmp(str1, str2); }
int pool_evrmatch(const Pool *pool, Id evrid, const char *epoch, const char *version, const char *release) { const char *evr1; const char *s1; const char *r1; int r; evr1 = pool_id2str(pool, evrid); for (s1 = evr1; *s1 >= '0' && *s1 <= '9'; s1++) ; if (s1 != evr1 && *s1 == ':') { if (epoch) { r = solv_vercmp(evr1, s1, epoch, epoch + strlen(epoch)); if (r) return r; } evr1 = s1 + 1; } else if (epoch) { while (*epoch == '0') epoch++; if (*epoch) return -1; } for (s1 = evr1, r1 = 0; *s1; s1++) if (*s1 == '-') r1 = s1; if (pool->disttype == DISTTYPE_HAIKU) { /* make sure it's really a release, releases always are numeric */ if (r1 && (r1[1] < '0' || r1[1] > '9')) r1 = 0; } if (version) { r = solv_vercmp(evr1, r1 ? r1 : s1, version, version + strlen(version)); if (r) return r; } if (release) { if (!r1) return -1; r = solv_vercmp(r1 + 1, s1, release, release + strlen(release)); if (r) return r; } return 0; }
static int prune_to_best_version_sortcmp(const void *ap, const void *bp, void *dp) { Pool *pool = dp; int r; Id a = *(Id *)ap; Id b = *(Id *)bp; Solvable *sa, *sb; sa = pool->solvables + a; sb = pool->solvables + b; r = sa->name - sb->name; if (r) { const char *na, *nb; /* different names. We use real strcmp here so that the result * is not depending on some random solvable order */ na = pool_id2str(pool, sa->name); nb = pool_id2str(pool, sb->name); return strcmp(na, nb); } /* the same name, bring installed solvables to the front */ if (pool->installed) { if (sa->repo == pool->installed) { if (sb->repo != pool->installed) return -1; } else if (sb->repo == pool->installed) return 1; } /* sort by repository sub-prio (installed repo handled above) */ r = (sb->repo ? sb->repo->subpriority : 0) - (sa->repo ? sa->repo->subpriority : 0); if (r) return r; /* no idea about the order, sort by id */ return a - b; }
/* these packages do not get installed by the package manager */ static inline int is_pseudo_package(Pool *pool, Solvable *s) { const char *n = pool_id2str(pool, s->name); if (*n == 'p' && !strncmp(n, "patch:", 6)) return 1; if (*n == 'p' && !strncmp(n, "pattern:", 8)) return 1; if (*n == 'p' && !strncmp(n, "product:", 8)) return 1; if (*n == 'a' && !strncmp(n, "application:", 12)) return 1; return 0; }
/* these packages will never show up installed */ static inline int is_noinst_pseudo_package(Pool *pool, Solvable *s) { const char *n = pool_id2str(pool, s->name); if (!strncmp(n, "patch:", 6)) return 1; if (!strncmp(n, "pattern:", 8)) { #if defined(SUSE) && defined(ENABLE_LINKED_PKGS) /* unlike normal patterns, autopatterns *can* be installed (via the package link), so do not filter them */ if (s->provides) { Id prv, *prvp = s->repo->idarraydata + s->provides; while ((prv = *prvp++) != 0) if (ISRELDEP(prv) && !strcmp(pool_id2str(pool, prv), "autopattern()")) return 0; } #endif return 1; } return 0; }
/* split filelist dep into basename and dirname */ static void create_dirs_names_array(struct addfileprovides_cbdata *cbd, Pool *pool) { int i; cbd->dirs = solv_malloc2(cbd->nfiles, sizeof(char *)); cbd->names = solv_malloc2(cbd->nfiles, sizeof(char *)); for (i = 0; i < cbd->nfiles; i++) { char *s = solv_strdup(pool_id2str(pool, cbd->ids[i])); cbd->dirs[i] = s; s = strrchr(s, '/'); *s = 0; cbd->names[i] = s + 1; } }