From 7d155ef26db49913c17157bd9f0c452abc950178 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Per=20=C3=98yvind=20Karlsen?= Date: Wed, 13 Oct 2010 15:09:12 +0000 Subject: use do_rpmEVRcmp() Pkg_compare_pkg() as well --- URPM.xs | 88 +++++++++++++++++++++++++++-------------------------------------- 1 file 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(); -- cgit v1.2.1