aboutsummaryrefslogtreecommitdiffstats
path: root/URPM.xs
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <peroyvind@mandriva.org>2010-10-13 15:09:12 +0000
committerPer Øyvind Karlsen <peroyvind@mandriva.org>2010-10-13 15:09:12 +0000
commit7d155ef26db49913c17157bd9f0c452abc950178 (patch)
treedb0d4c0f2b0d1b59ff424bb4e0639baacc510e3a /URPM.xs
parent548ee6869603b2f50ecd44cd30d8e4d18fa46e32 (diff)
downloadperl-URPM-7d155ef26db49913c17157bd9f0c452abc950178.tar
perl-URPM-7d155ef26db49913c17157bd9f0c452abc950178.tar.gz
perl-URPM-7d155ef26db49913c17157bd9f0c452abc950178.tar.bz2
perl-URPM-7d155ef26db49913c17157bd9f0c452abc950178.tar.xz
perl-URPM-7d155ef26db49913c17157bd9f0c452abc950178.zip
use do_rpmEVRcmp() Pkg_compare_pkg() as well
Diffstat (limited to 'URPM.xs')
-rw-r--r--URPM.xs88
1 files changed, 37 insertions, 51 deletions
diff --git a/URPM.xs b/URPM.xs
index bae8a19..5ea9c17 100644
--- a/URPM.xs
+++ b/URPM.xs
@@ -1925,66 +1925,52 @@ Pkg_compare_pkg(lpkg, rpkg)
URPM::Package rpkg
PREINIT:
int compare = 0;
- int lepoch;
- char *lversion;
- char *lrelease;
- char *ldistepoch;
+ char *levr;
char *larch;
- char *leos;
- int repoch;
- char *rversion;
- char *rrelease;
- char *rdistepoch;
+ char *revr;
char *rarch;
- char *reos;
CODE:
if (lpkg == rpkg) RETVAL = 0;
else {
- if(get_fullname_parts(lpkg, NULL, &lepoch, &lversion, &lrelease, &ldistepoch, NULL, &larch, &leos) || get_fullname_parts(rpkg, NULL, &repoch, &rversion, &rrelease, &rdistepoch, NULL, &rarch, &reos))
+ levr = (char*)get_evr(lpkg);
+ revr = (char*)get_evr(rpkg);
+ if(levr == NULL || revr == NULL) {
+ restore_chars();
croak("undefined package");
- compare = lepoch - repoch;
+ }
+ compare = do_rpmEVRcmp(levr, revr);
if (!compare) {
- compare = rpmvercmp(lversion, rversion);
- if (!compare) {
- compare = rpmvercmp(lrelease, rrelease);
- if (!compare) {
- int lscore = 0, rscore = 0;
- char *eolarch = strchr(larch, '@');
- char *eorarch = strchr(rarch, '@');
- char *platform = NULL;
-
- read_config_files(0);
- if (eolarch) {
- *eolarch = 0;
- platform = rpmExpand(larch, "-%{_target_vendor}-%{_target_os}%{?_gnu}", NULL);
- lscore = rpmPlatformScore(platform, NULL, 0);
- platform = _free(platform);
- }
- if (eorarch) {
- *eolarch = 0;
- platform = rpmExpand(rarch, "-%{_target_vendor}-%{_target_os}%{?_gnu}", NULL);
- rscore = rpmPlatformScore(platform, NULL, 0);
- platform = _free(platform);
- }
- if (lscore == 0) {
- if (rscore == 0)
+ int lscore, rscore;
+ char *platform = NULL;
+ if(get_fullname_parts(lpkg, NULL, NULL, NULL, NULL, NULL, NULL, &larch, NULL) ||
+ get_fullname_parts(rpkg, NULL, NULL, NULL, NULL, NULL, NULL, &rarch, NULL))
+ croak("undefined package");
+
+ read_config_files(0);
+
+ platform = rpmExpand(larch, "-%{_target_vendor}-%{_target_os}%{?_gnu}", NULL);
+ lscore = rpmPlatformScore(platform, NULL, 0);
+ platform = _free(platform);
+
+ platform = rpmExpand(rarch, "-%{_target_vendor}-%{_target_os}%{?_gnu}", NULL);
+ rscore = rpmPlatformScore(platform, NULL, 0);
+ platform = _free(platform);
+
+ if (lscore == 0) {
+ if (rscore == 0)
#if 0
- /* Nanar: TODO check this
- * hu ?? what is the goal of strcmp, some of arch are equivalent */
- compare = 0
+ /* Nanar: TODO check this
+ * hu ?? what is the goal of strcmp, some of arch are equivalent */
+ compare = 0
#endif
- compare = strcmp(larch, rarch);
- else
- compare = -1;
- } else {
- if (rscore == 0)
- compare = 1;
- else
- compare = rscore - lscore; /* score are lower for better */
- }
- if (eolarch) *eolarch = '@';
- if (eorarch) *eorarch = '@';
- }
+ compare = strcmp(larch, rarch);
+ else
+ compare = -1;
+ } else {
+ if (rscore == 0)
+ compare = 1;
+ else
+ compare = rscore - lscore; /* score are lower for better */
}
}
restore_chars();