xbps-bin: multiple fixes to update packages.
* Fix 'autoupdate' target to look for new packages in ALL repos, not just the first one that has the package. * Fix 'update' target to work correctly. --HG-- extra : convert_revision : xtraeme%40gmail.com-20091016133157-asvkv5jb6i9q2ibe
This commit is contained in:
parent
d771383442
commit
e1f2a8b7bd
@ -220,10 +220,19 @@ xbps_install_pkg(const char *pkg, bool force, bool update)
|
||||
pkgd = xbps_find_pkg_installed_from_plist(pkg);
|
||||
if (update) {
|
||||
if (pkgd) {
|
||||
if ((rv = xbps_find_new_pkg(pkg, pkgd)) == 0) {
|
||||
rv = xbps_find_new_pkg(pkg, pkgd);
|
||||
if (rv == EEXIST) {
|
||||
printf("Package '%s' is up to date.\n", pkg);
|
||||
prop_object_release(pkgd);
|
||||
cleanup(rv);
|
||||
} else if (rv == ENOENT) {
|
||||
printf("Package '%s' not found in "
|
||||
"repository pool.\n", pkg);
|
||||
prop_object_release(pkgd);
|
||||
cleanup(rv);
|
||||
} else if (rv != 0) {
|
||||
prop_object_release(pkgd);
|
||||
cleanup(rv);
|
||||
}
|
||||
prop_object_release(pkgd);
|
||||
} else {
|
||||
@ -238,7 +247,8 @@ xbps_install_pkg(const char *pkg, bool force, bool update)
|
||||
}
|
||||
rv = xbps_prepare_pkg(pkg);
|
||||
if (rv != 0 && rv == EAGAIN) {
|
||||
printf("Unable to locate '%s' in repository pool.\n", pkg);
|
||||
printf("Unable to locate '%s' in repository pool.\n",
|
||||
pkg);
|
||||
cleanup(rv);
|
||||
} else if (rv != 0 && rv != ENOENT) {
|
||||
printf("Unexpected error: %s", strerror(rv));
|
||||
@ -268,12 +278,21 @@ xbps_install_pkg(const char *pkg, bool force, bool update)
|
||||
prop_dictionary_get_cstring_nocopy(trans->dict,
|
||||
"origin", &trans->originpkgname);
|
||||
|
||||
/*
|
||||
* Sort the package transaction dictionary.
|
||||
*/
|
||||
if ((rv = xbps_sort_pkg_deps(trans->dict)) != 0) {
|
||||
printf("Error while sorting packages: %s\n",
|
||||
strerror(rv));
|
||||
goto out2;
|
||||
}
|
||||
|
||||
/*
|
||||
* It's time to run the transaction!
|
||||
*/
|
||||
trans->iter = xbps_get_array_iter_from_dict(trans->dict, "packages");
|
||||
if (trans->iter == NULL) {
|
||||
printf("error: allocating array mem! (%s)",
|
||||
printf("error: allocating array mem! (%s)\n",
|
||||
strerror(errno));
|
||||
goto out2;
|
||||
}
|
||||
|
@ -130,6 +130,11 @@ main(int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
}
|
||||
if ((rv = xbps_prepare_repolist_data()) != 0) {
|
||||
printf("Couldn't initialized repository pool data (%s)\n",
|
||||
strerror(rv));
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (strcasecmp(argv[0], "list") == 0) {
|
||||
/* Lists packages currently registered in database. */
|
||||
@ -267,6 +272,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
|
||||
out:
|
||||
xbps_release_repolist_data();
|
||||
xbps_release_regpkgdb_dict();
|
||||
if (rv != 0)
|
||||
exit(EXIT_FAILURE);
|
||||
|
@ -228,7 +228,10 @@ xbps_find_new_packages(void)
|
||||
*/
|
||||
while ((obj = prop_object_iterator_next(iter)) != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
if ((rv = xbps_find_new_pkg(pkgname, obj)) != 0) {
|
||||
rv = xbps_find_new_pkg(pkgname, obj);
|
||||
if (rv == ENOENT || rv == EEXIST)
|
||||
continue;
|
||||
else if (rv != 0) {
|
||||
prop_object_iterator_release(iter);
|
||||
return rv;
|
||||
}
|
||||
@ -246,6 +249,7 @@ xbps_find_new_pkg(const char *pkgname, prop_dictionary_t instpkg)
|
||||
struct repository_data *rdata;
|
||||
const char *repoloc, *repover, *instver;
|
||||
int rv = 0;
|
||||
bool newpkg_found = false;
|
||||
|
||||
assert(pkgname != NULL);
|
||||
assert(instpkg != NULL);
|
||||
@ -259,22 +263,24 @@ xbps_find_new_pkg(const char *pkgname, prop_dictionary_t instpkg)
|
||||
"packages", pkgname);
|
||||
if (pkgrd != NULL) {
|
||||
/*
|
||||
* Check if installed version is >= than the
|
||||
* one available in current repository.
|
||||
* Check if version in repository is greater than
|
||||
* the version currently installed.
|
||||
*/
|
||||
prop_dictionary_get_cstring_nocopy(instpkg,
|
||||
"version", &instver);
|
||||
prop_dictionary_get_cstring_nocopy(pkgrd,
|
||||
"version", &repover);
|
||||
if (xbps_cmpver(instver, repover) >= 0)
|
||||
goto out;
|
||||
|
||||
break;
|
||||
if (xbps_cmpver(repover, instver) > 0) {
|
||||
newpkg_found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (pkgrd == NULL)
|
||||
return 0;
|
||||
if (!newpkg_found)
|
||||
return EEXIST;
|
||||
|
||||
if (pkgrd == NULL)
|
||||
return ENOENT;
|
||||
/*
|
||||
* Create master pkg dictionary.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user