Added xbps_find_new_packages(): checks if there are new versions.
--HG-- extra : convert_revision : dcd764c96c013f8d299849791110af4f9a4a9401
This commit is contained in:
parent
bd85f1eae5
commit
8cc7f6871d
3 changed files with 50 additions and 34 deletions
|
@ -435,25 +435,18 @@ void
|
|||
xbps_autoupdate_pkgs(bool force)
|
||||
{
|
||||
struct transaction *trans;
|
||||
prop_dictionary_t dict;
|
||||
prop_object_t obj;
|
||||
const char *pkgname;
|
||||
int rv = 0;
|
||||
|
||||
/*
|
||||
* Prepare dictionary with all registered packages.
|
||||
* Find new package versions.
|
||||
*/
|
||||
dict = xbps_prepare_regpkgdb_dict();
|
||||
if (dict == NULL) {
|
||||
printf("No packages currently installed (%s).\n",
|
||||
strerror(errno));
|
||||
cleanup(rv);
|
||||
}
|
||||
/*
|
||||
* Prepare dictionary with all registered repositories.
|
||||
*/
|
||||
if ((rv = xbps_prepare_repolist_data()) != 0)
|
||||
if ((rv = xbps_find_new_packages()) != 0) {
|
||||
if (rv == ENOENT) {
|
||||
printf("No packages currently registered.\n");
|
||||
cleanup(0);
|
||||
}
|
||||
goto out;
|
||||
}
|
||||
|
||||
/*
|
||||
* Prepare transaction data.
|
||||
|
@ -462,26 +455,6 @@ xbps_autoupdate_pkgs(bool force)
|
|||
if (trans == NULL)
|
||||
goto out;
|
||||
|
||||
trans->iter = xbps_get_array_iter_from_dict(dict, "packages");
|
||||
if (trans->iter == NULL) {
|
||||
rv = EINVAL;
|
||||
goto out1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Find out if there is a newer version for all currently
|
||||
* installed packages.
|
||||
*/
|
||||
while ((obj = prop_object_iterator_next(trans->iter)) != NULL) {
|
||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||
rv = xbps_find_new_pkg(pkgname, obj);
|
||||
if (rv != 0) {
|
||||
prop_object_iterator_release(trans->iter);
|
||||
goto out1;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_release(trans->iter);
|
||||
|
||||
/*
|
||||
* Get package transaction dictionary.
|
||||
*/
|
||||
|
|
|
@ -98,6 +98,7 @@ SIMPLEQ_HEAD(, repository_data) repodata_queue;
|
|||
|
||||
int xbps_prepare_pkg(const char *);
|
||||
int xbps_find_new_pkg(const char *, prop_dictionary_t);
|
||||
int xbps_find_new_packages(void);
|
||||
int xbps_prepare_repolist_data(void);
|
||||
void xbps_release_repolist_data(void);
|
||||
prop_dictionary_t xbps_get_pkg_props(void);
|
||||
|
|
|
@ -197,6 +197,48 @@ xbps_release_repolist_data(void)
|
|||
}
|
||||
}
|
||||
|
||||
int
|
||||
xbps_find_new_packages(void)
|
||||
{
|
||||
prop_dictionary_t dict;
|
||||
prop_object_t obj;
|
||||
prop_object_iterator_t iter;
|
||||
const char *pkgname;
|
||||
int rv = 0;
|
||||
|
||||
/*
|
||||
* Prepare dictionary with all registered packages.
|
||||
*/
|
||||
dict = xbps_prepare_regpkgdb_dict();
|
||||
if (dict == NULL)
|
||||
return ENOENT;
|
||||
|
||||
/*
|
||||
* Prepare dictionary with all registered repositories.
|
||||
*/
|
||||
if ((rv = xbps_prepare_repolist_data()) != 0)
|
||||
return rv;
|
||||
|
||||
iter = xbps_get_array_iter_from_dict(dict, "packages");
|
||||
if (iter == NULL)
|
||||
return EINVAL;
|
||||
|
||||
/*
|
||||
* Find out if there is a newer version for all currently
|
||||
* installed packages.
|
||||
*/
|
||||
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) {
|
||||
prop_object_iterator_release(iter);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
prop_object_iterator_reset(iter);
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
int
|
||||
xbps_find_new_pkg(const char *pkgname, prop_dictionary_t instpkg)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue