Return appropiate value in xbps_check_is_installed_pkg().

Return -1 if package is not installed or dependency not satisfied.
Return 0 if same version required is already installed.
Return 1 if installed version is greater than required.

--HG--
extra : convert_revision : 359b79cbe809e1818fe999dc1d55da7e635dbe44
This commit is contained in:
Juan RP 2009-03-17 04:32:03 +01:00
parent f7ef4ccf5c
commit 40b62ee70d
5 changed files with 6 additions and 6 deletions

View file

@ -292,7 +292,7 @@ xbps_cmpver_packages(const char *pkg1, const char *pkg2)
result = (r1 < r2 ? -1 : 1); result = (r1 < r2 ? -1 : 1);
} }
return result == -1 ? 1 : 0; return result;
} }
int int
@ -300,5 +300,5 @@ xbps_cmpver_versions(const char *inst, const char *req)
{ {
int res = xbps_cmpver_packages(inst, req); int res = xbps_cmpver_packages(inst, req);
return res == -1 ? 1 : 0; return res;
} }

View file

@ -527,7 +527,7 @@ find_pkg_deps_from_repo(prop_dictionary_t repo, prop_dictionary_t pkg,
/* /*
* Check if required dep is satisfied and installed. * Check if required dep is satisfied and installed.
*/ */
if (xbps_check_is_installed_pkg(reqpkg) == 0) { if (xbps_check_is_installed_pkg(reqpkg) >= 0) {
free(pkgname); free(pkgname);
continue; continue;
} }

View file

@ -210,7 +210,7 @@ xbps_sort_pkg_deps(prop_dictionary_t chaindeps)
/* /*
* If package is installed, pass to the next one. * If package is installed, pass to the next one.
*/ */
if (xbps_check_is_installed_pkg(rundep) == 0) { if (xbps_check_is_installed_pkg(rundep) >= 0) {
free(pkgname); free(pkgname);
continue; continue;
} }

View file

@ -125,7 +125,7 @@ xbps_check_is_installed_pkg(const char *pkg)
dict = xbps_find_pkg_installed_from_plist(pkgname); dict = xbps_find_pkg_installed_from_plist(pkgname);
if (dict == NULL) { if (dict == NULL) {
free(pkgname); free(pkgname);
return 1; /* not installed */ return -1; /* not installed */
} }
/* Get version from installed package */ /* Get version from installed package */

View file

@ -166,7 +166,7 @@ check_installed_pkg()
iver="$($XBPS_REGPKGDB_CMD version $pkgname)" iver="$($XBPS_REGPKGDB_CMD version $pkgname)"
if [ -n "$iver" ]; then if [ -n "$iver" ]; then
xbps-cmpver $pkgname-$iver $pkgname-$reqver xbps-cmpver $pkgname-$iver $pkgname-$reqver
[ $? -eq 0 ] && return 0 [ $? -ge 0 ] && return 0
fi fi
return 1 return 1