Don't continue installing a binpkg if newest version in repos is already installed.

--HG--
extra : convert_revision : b73376d091fd95f4cfd92cbdba21f4bc93781504
This commit is contained in:
Juan RP 2009-03-17 05:10:21 +01:00
parent 40b62ee70d
commit 0ed055c4eb
3 changed files with 26 additions and 5 deletions

View File

@ -214,7 +214,6 @@ main(int argc, char **argv)
if (argc != 2)
usage();
/* Install into root directory by default. */
rv = xbps_install_binary_pkg(argv[1]);
if (rv != 0) {
if (rv == EAGAIN) {
@ -224,6 +223,10 @@ main(int argc, char **argv)
dict = xbps_get_pkg_deps_dictionary();
if (dict)
show_missing_deps(dict, argv[1]);
} else if (rv == EEXIST) {
printf("Package '%s' is already up to date.\n",
argv[1]);
exit(EXIT_SUCCESS);
}
exit(EXIT_FAILURE);

View File

@ -19,8 +19,6 @@ xbps-bin:
* Show binpkg size and installed size for all packages that are going
to be installed before installation happens.
* Add support to update packages. [IN PROGRESS]
* While installing a package, check if version that is going to be
installed is already installed. [IN PROGRESS]
* Add a flag to reinstall a package version that is already installed,
overwritting files on disk and updating required_by if required.
Perhaps change the automatic-install object to false, like pkg_install

View File

@ -90,8 +90,9 @@ static int
install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done)
{
prop_dictionary_t repod, pkgrd;
const char *repoloc, *pkgname = arg;
char *plist;
size_t len = 0;
const char *repoloc, *instver, *pkgname = arg;
char *plist, *pkg;
int rv = 0;
plist = xbps_get_pkg_index_plist(prop_string_cstring_nocopy(obj));
@ -116,6 +117,25 @@ install_binpkg_repo_cb(prop_object_t obj, void *arg, bool *cbloop_done)
return 0;
}
/*
* Check if available version in repository is already installed,
* and return immediately in that case.
*/
prop_dictionary_get_cstring_nocopy(pkgrd, "version", &instver);
len = strlen(pkgname) + strlen(instver) + 2;
pkg = malloc(len);
if (pkg == NULL) {
rv = EINVAL;
goto out;
}
(void)snprintf(pkg, len, "%s-%s", pkgname, instver);
if (xbps_check_is_installed_pkg(pkg) == 0) {
free(pkg);
rv = EEXIST;
goto out;
}
free(pkg);
/*
* Check SHA256 hash for binary package before anything else.
*/