static PyObject * evr_cmp(_PackageObject *self, PyObject *other) { DnfPackage *pkg2 = packageFromPyObject(other); if (pkg2 == NULL) return NULL; return PyLong_FromLong(dnf_package_evr_cmp(self->package, pkg2)); }
/** * 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); }