Improve xbps_transaction_update_pkg/packages and misc cosmetic changes.
This commit is contained in:
parent
21060384d3
commit
40864bcdce
@ -59,7 +59,7 @@ enum {
|
|||||||
static int
|
static int
|
||||||
transaction_find_pkg(const char *pkg, bool bypattern, bool bestpkg, int action)
|
transaction_find_pkg(const char *pkg, bool bypattern, bool bestpkg, int action)
|
||||||
{
|
{
|
||||||
prop_dictionary_t pkg_pkgdb = NULL, pkg_repod = NULL;
|
prop_dictionary_t pkg_pkgdb, pkg_repod;
|
||||||
prop_array_t unsorted;
|
prop_array_t unsorted;
|
||||||
struct xbps_handle *xhp = xbps_handle_get();
|
struct xbps_handle *xhp = xbps_handle_get();
|
||||||
const char *pkgname, *pkgver, *repoloc, *repover, *instver, *reason;
|
const char *pkgname, *pkgver, *repoloc, *repover, *instver, *reason;
|
||||||
@ -73,28 +73,33 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool bestpkg, int action)
|
|||||||
reason = "install";
|
reason = "install";
|
||||||
} else {
|
} else {
|
||||||
/* update */
|
/* update */
|
||||||
pkg_pkgdb = xbps_find_pkg_dict_installed(pkg, false);
|
if ((pkg_pkgdb = xbps_pkgdb_get_pkgd(pkg, false)) == NULL)
|
||||||
if (pkg_pkgdb == NULL) {
|
return ENODEV;
|
||||||
rv = ENODEV;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
reason = "update";
|
reason = "update";
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find out if the pkg has been found in repository pool.
|
* Find out if the pkg has been found in repository pool.
|
||||||
*/
|
*/
|
||||||
|
if (action == TRANS_INSTALL) {
|
||||||
if (((pkg_repod = xbps_rpool_find_virtualpkg_conf(pkg, bypattern)) == NULL) &&
|
if (((pkg_repod = xbps_rpool_find_virtualpkg_conf(pkg, bypattern)) == NULL) &&
|
||||||
((pkg_repod = xbps_rpool_find_pkg(pkg, bypattern, bestpkg)) == NULL) &&
|
((pkg_repod = xbps_rpool_find_pkg(pkg, bypattern, bestpkg)) == NULL) &&
|
||||||
((pkg_repod = xbps_rpool_find_virtualpkg(pkg, bypattern)) == NULL)) {
|
((pkg_repod = xbps_rpool_find_virtualpkg(pkg, bypattern)) == NULL)) {
|
||||||
/* not found */
|
/* not found */
|
||||||
rv = errno;
|
rv = errno;
|
||||||
errno = 0;
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgver", &pkgver);
|
} else {
|
||||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
|
if ((pkg_repod = xbps_rpool_find_pkg(pkg, false, true)) == NULL) {
|
||||||
|
/* not found */
|
||||||
|
rv = errno;
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
}
|
||||||
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgname", &pkgname);
|
prop_dictionary_get_cstring_nocopy(pkg_repod, "pkgname", &pkgname);
|
||||||
|
prop_dictionary_get_cstring_nocopy(pkg_repod, "version", &repover);
|
||||||
|
prop_dictionary_get_cstring_nocopy(pkg_repod, "repository", &repoloc);
|
||||||
|
|
||||||
if (bestpkg && (action == TRANS_UPDATE)) {
|
if (bestpkg && (action == TRANS_UPDATE)) {
|
||||||
/*
|
/*
|
||||||
@ -102,13 +107,11 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool bestpkg, int action)
|
|||||||
*/
|
*/
|
||||||
prop_dictionary_get_cstring_nocopy(pkg_pkgdb,
|
prop_dictionary_get_cstring_nocopy(pkg_pkgdb,
|
||||||
"version", &instver);
|
"version", &instver);
|
||||||
prop_dictionary_get_cstring_nocopy(pkg_repod,
|
|
||||||
"version", &repover);
|
|
||||||
prop_object_release(pkg_pkgdb);
|
prop_object_release(pkg_pkgdb);
|
||||||
if (xbps_cmpver(repover, instver) <= 0) {
|
if (xbps_cmpver(repover, instver) <= 0) {
|
||||||
xbps_dbg_printf("[rpool] Skipping `%s' "
|
xbps_dbg_printf("[rpool] Skipping `%s-%s' "
|
||||||
"(installed: %s) from repository `%s'\n",
|
"(installed: %s-%s) from repository `%s'\n",
|
||||||
pkgver, instver, repoloc);
|
pkgname, repover, pkgname, instver, repoloc);
|
||||||
rv = EEXIST;
|
rv = EEXIST;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -123,11 +126,9 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool bestpkg, int action)
|
|||||||
* Prepare required package dependencies and add them into the
|
* Prepare required package dependencies and add them into the
|
||||||
* "unsorted" array in transaction dictionary.
|
* "unsorted" array in transaction dictionary.
|
||||||
*/
|
*/
|
||||||
if (xbps_pkg_has_rundeps(pkg_repod)) {
|
if ((xbps_pkg_has_rundeps(pkg_repod)) &&
|
||||||
rv = xbps_repository_find_pkg_deps(xhp, pkg_repod);
|
((rv = xbps_repository_find_pkg_deps(xhp, pkg_repod)) != 0))
|
||||||
if (rv != 0)
|
|
||||||
goto out;
|
goto out;
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Set package state in dictionary with same state than the
|
* Set package state in dictionary with same state than the
|
||||||
* package currently uses, otherwise not-installed.
|
* package currently uses, otherwise not-installed.
|
||||||
@ -172,8 +173,8 @@ transaction_find_pkg(const char *pkg, bool bypattern, bool bestpkg, int action)
|
|||||||
rv = errno;
|
rv = errno;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
xbps_dbg_printf("%s: added into the transaction (%s).\n",
|
xbps_dbg_printf("%s-%s: added into the transaction (%s).\n",
|
||||||
pkgver, repoloc);
|
pkgname, repover, repoloc);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
if (pkg_repod != NULL)
|
if (pkg_repod != NULL)
|
||||||
@ -182,29 +183,33 @@ out:
|
|||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
update_pkgs_cb(prop_object_t obj, void *arg, bool *done)
|
xbps_transaction_update_packages(void)
|
||||||
{
|
{
|
||||||
|
prop_object_t obj;
|
||||||
struct xbps_handle *xhp = xbps_handle_get();
|
struct xbps_handle *xhp = xbps_handle_get();
|
||||||
const char *pkgname, *holdpkgname;
|
const char *pkgname, *holdpkgname;
|
||||||
bool *newpkg_found = arg;
|
bool newpkg_found = false;
|
||||||
int rv = 0;
|
int rv = 0;
|
||||||
size_t i;
|
size_t i, x;
|
||||||
|
|
||||||
(void)done;
|
if ((rv = xbps_pkgdb_init(xhp)) != 0)
|
||||||
|
return rv;
|
||||||
|
|
||||||
|
for (i = 0; i < prop_array_count(xhp->pkgdb); i++) {
|
||||||
|
obj = prop_array_get(xhp->pkgdb, i);
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||||
for (i = 0; i < cfg_size(xhp->cfg, "PackagesOnHold"); i++) {
|
for (x = 0; x < cfg_size(xhp->cfg, "PackagesOnHold"); x++) {
|
||||||
holdpkgname = cfg_getnstr(xhp->cfg, "PackagesOnHold", i);
|
holdpkgname = cfg_getnstr(xhp->cfg, "PackagesOnHold", x);
|
||||||
if (strcmp(pkgname, holdpkgname) == 0) {
|
if (strcmp(pkgname, holdpkgname) == 0) {
|
||||||
xbps_dbg_printf("[rpool] package %s on hold, "
|
xbps_dbg_printf("[rpool] package %s on hold, "
|
||||||
"ignoring updates.\n", pkgname);
|
"ignoring updates.\n", pkgname);
|
||||||
return 0;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
rv = xbps_transaction_update_pkg(pkgname);
|
rv = transaction_find_pkg(pkgname, false, true, TRANS_UPDATE);
|
||||||
if (rv == 0)
|
if (rv == 0)
|
||||||
*newpkg_found = true;
|
newpkg_found = true;
|
||||||
else if (rv == ENOENT || rv == EEXIST || rv == ENODEV) {
|
else if (rv == ENOENT || rv == EEXIST || rv == ENODEV) {
|
||||||
/*
|
/*
|
||||||
* missing pkg or installed version is greater than or
|
* missing pkg or installed version is greater than or
|
||||||
@ -212,21 +217,9 @@ update_pkgs_cb(prop_object_t obj, void *arg, bool *done)
|
|||||||
*/
|
*/
|
||||||
rv = 0;
|
rv = 0;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return rv;
|
return newpkg_found ? rv : EEXIST;
|
||||||
}
|
|
||||||
|
|
||||||
int
|
|
||||||
xbps_transaction_update_packages(void)
|
|
||||||
{
|
|
||||||
bool newpkg_found = false;
|
|
||||||
int rv;
|
|
||||||
|
|
||||||
rv = xbps_pkgdb_foreach_cb(update_pkgs_cb, &newpkg_found);
|
|
||||||
if (!newpkg_found)
|
|
||||||
rv = EEXIST;
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
Loading…
x
Reference in New Issue
Block a user