Make xbps_configure_pkg/packages accept a flush bool arg for frontends.
This commit is contained in:
parent
812005a7d9
commit
a31c20e52a
@ -329,9 +329,9 @@ main(int argc, char **argv)
|
|||||||
usage(xhp);
|
usage(xhp);
|
||||||
|
|
||||||
if (strcasecmp(argv[1], "all") == 0)
|
if (strcasecmp(argv[1], "all") == 0)
|
||||||
rv = xbps_configure_packages();
|
rv = xbps_configure_packages(true);
|
||||||
else
|
else
|
||||||
rv = xbps_configure_pkg(argv[1], NULL, true, false);
|
rv = xbps_configure_pkg(argv[1], NULL, true, false, true);
|
||||||
|
|
||||||
} else if (strcasecmp(argv[0], "show-deps") == 0) {
|
} else if (strcasecmp(argv[0], "show-deps") == 0) {
|
||||||
/*
|
/*
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2008-2011 Juan Romero Pardines.
|
* Copyright (c) 2008-2012 Juan Romero Pardines.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -56,7 +56,7 @@
|
|||||||
*/
|
*/
|
||||||
#define XBPS_PKGINDEX_VERSION "1.3"
|
#define XBPS_PKGINDEX_VERSION "1.3"
|
||||||
|
|
||||||
#define XBPS_API_VERSION "20111229"
|
#define XBPS_API_VERSION "20120104"
|
||||||
#define XBPS_VERSION "0.12"
|
#define XBPS_VERSION "0.12"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -608,20 +608,23 @@ struct xbps_handle *xbps_handle_get(void);
|
|||||||
* @param[in] check_state Set it to true to check that package is
|
* @param[in] check_state Set it to true to check that package is
|
||||||
* in unpacked state.
|
* in unpacked state.
|
||||||
* @param[in] update Set it to true if this package is being updated.
|
* @param[in] update Set it to true if this package is being updated.
|
||||||
|
* @param[in] flush Set it to true to flush state to regpkgdb.
|
||||||
*
|
*
|
||||||
* @return 0 on success, otherwise an errno value.
|
* @return 0 on success, otherwise an errno value.
|
||||||
*/
|
*/
|
||||||
int xbps_configure_pkg(const char *pkgname,
|
int xbps_configure_pkg(const char *pkgname,
|
||||||
const char *version,
|
const char *version,
|
||||||
bool check_state,
|
bool check_state,
|
||||||
bool update);
|
bool update,
|
||||||
|
bool flush);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure (or force reconfiguration of) all packages.
|
* Configure (or force reconfiguration of) all packages.
|
||||||
|
* @param[in] flush Set it to true to flush state to regpkgdb.
|
||||||
*
|
*
|
||||||
* @return 0 on success, otherwise an errno value.
|
* @return 0 on success, otherwise an errno value.
|
||||||
*/
|
*/
|
||||||
int xbps_configure_packages(void);
|
int xbps_configure_packages(bool flush);
|
||||||
|
|
||||||
/*@}*/
|
/*@}*/
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2009-2011 Juan Romero Pardines.
|
* Copyright (c) 2009-2012 Juan Romero Pardines.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -57,20 +57,28 @@ configure_pkgs_cb(prop_object_t obj, void *arg, bool *done)
|
|||||||
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
prop_dictionary_get_cstring_nocopy(obj, "pkgname", &pkgname);
|
||||||
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
prop_dictionary_get_cstring_nocopy(obj, "version", &version);
|
||||||
|
|
||||||
return xbps_configure_pkg(pkgname, version, true, false);
|
return xbps_configure_pkg(pkgname, version, true, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xbps_configure_packages(void)
|
xbps_configure_packages(bool flush)
|
||||||
{
|
{
|
||||||
return xbps_regpkgdb_foreach_pkg_cb(configure_pkgs_cb, NULL);
|
struct xbps_handle *xhp = xbps_handle_get();
|
||||||
|
int rv;
|
||||||
|
|
||||||
|
rv = xbps_regpkgdb_foreach_pkg_cb(configure_pkgs_cb, &flush);
|
||||||
|
if (rv == 0)
|
||||||
|
rv = xbps_regpkgdb_update(xhp, true);
|
||||||
|
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
xbps_configure_pkg(const char *pkgname,
|
xbps_configure_pkg(const char *pkgname,
|
||||||
const char *version,
|
const char *version,
|
||||||
bool check_state,
|
bool check_state,
|
||||||
bool update)
|
bool update,
|
||||||
|
bool flush)
|
||||||
{
|
{
|
||||||
struct xbps_handle *xhp;
|
struct xbps_handle *xhp;
|
||||||
prop_dictionary_t pkgd;
|
prop_dictionary_t pkgd;
|
||||||
@ -160,6 +168,8 @@ xbps_configure_pkg(const char *pkgname,
|
|||||||
pkgver, strerror(rv));
|
pkgver, strerror(rv));
|
||||||
}
|
}
|
||||||
free(pkgver);
|
free(pkgver);
|
||||||
|
if (flush)
|
||||||
|
rv = xbps_regpkgdb_update(xhp, true);
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*-
|
/*-
|
||||||
* Copyright (c) 2008-2011 Juan Romero Pardines.
|
* Copyright (c) 2008-2012 Juan Romero Pardines.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@ -76,24 +76,24 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush)
|
|||||||
}
|
}
|
||||||
if (!prop_dictionary_set_cstring_nocopy(pkgd,
|
if (!prop_dictionary_set_cstring_nocopy(pkgd,
|
||||||
"version", version)) {
|
"version", version)) {
|
||||||
prop_object_release(pkgd);
|
xbps_dbg_printf("%s: invalid version for %s\n", __func__, pkgname);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!prop_dictionary_set_cstring_nocopy(pkgd,
|
if (!prop_dictionary_set_cstring_nocopy(pkgd,
|
||||||
"pkgver", pkgver)) {
|
"pkgver", pkgver)) {
|
||||||
prop_object_release(pkgd);
|
xbps_dbg_printf("%s: invalid pkgver for %s\n", __func__, pkgname);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (!prop_dictionary_set_cstring_nocopy(pkgd,
|
if (!prop_dictionary_set_cstring_nocopy(pkgd,
|
||||||
"short_desc", desc)) {
|
"short_desc", desc)) {
|
||||||
prop_object_release(pkgd);
|
xbps_dbg_printf("%s: invalid short_desc for %s\n", __func__, pkgname);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (reqby && !prop_dictionary_set(pkgd, "requiredby", reqby)) {
|
if (reqby && !prop_dictionary_set(pkgd, "requiredby", reqby)) {
|
||||||
prop_object_release(pkgd);
|
xbps_dbg_printf("%s: invalid requiredby for %s\n", __func__, pkgname);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -105,13 +105,14 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush)
|
|||||||
|
|
||||||
if (!prop_dictionary_set_bool(pkgd,
|
if (!prop_dictionary_set_bool(pkgd,
|
||||||
"automatic-install", autoinst)) {
|
"automatic-install", autoinst)) {
|
||||||
prop_object_release(pkgd);
|
xbps_dbg_printf("%s: invalid autoinst for %s\n", __func__, pkgname);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
if (provides) {
|
if (provides) {
|
||||||
if (!prop_dictionary_set(pkgd, "provides", provides)) {
|
if (!prop_dictionary_set(pkgd, "provides", provides)) {
|
||||||
prop_object_release(pkgd);
|
xbps_dbg_printf("%s: invalid provides for %s\n",
|
||||||
|
__func__, pkgname);
|
||||||
rv = EINVAL;
|
rv = EINVAL;
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
@ -121,14 +122,18 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool flush)
|
|||||||
*/
|
*/
|
||||||
if (pkgrd && xbps_pkg_has_rundeps(pkgrd)) {
|
if (pkgrd && xbps_pkg_has_rundeps(pkgrd)) {
|
||||||
if ((rv = xbps_requiredby_pkg_add(xhp, pkgrd)) != 0) {
|
if ((rv = xbps_requiredby_pkg_add(xhp, pkgrd)) != 0) {
|
||||||
prop_object_release(pkgd);
|
xbps_dbg_printf("%s: requiredby add failed for %s\n",
|
||||||
|
__func__, pkgname);
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
array = prop_dictionary_get(xhp->regpkgdb, "packages");
|
array = prop_dictionary_get(xhp->regpkgdb, "packages");
|
||||||
rv = xbps_array_replace_dict_by_name(array, pkgd, pkgname);
|
rv = xbps_array_replace_dict_by_name(array, pkgd, pkgname);
|
||||||
if (rv != 0)
|
if (rv != 0) {
|
||||||
|
xbps_dbg_printf("%s: failed to replace pkgd dict for %s\n",
|
||||||
|
__func__, pkgname);
|
||||||
goto out;
|
goto out;
|
||||||
|
}
|
||||||
if (flush)
|
if (flush)
|
||||||
rv = xbps_regpkgdb_update(xhp, true);
|
rv = xbps_regpkgdb_update(xhp, true);
|
||||||
|
|
||||||
|
@ -224,7 +224,8 @@ xbps_transaction_commit(prop_dictionary_t transd)
|
|||||||
/*
|
/*
|
||||||
* Reconfigure pending package.
|
* Reconfigure pending package.
|
||||||
*/
|
*/
|
||||||
rv = xbps_configure_pkg(pkgname, version, false, false);
|
rv = xbps_configure_pkg(pkgname, version,
|
||||||
|
false, false, false);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
goto out;
|
goto out;
|
||||||
} else {
|
} else {
|
||||||
@ -305,7 +306,7 @@ xbps_transaction_commit(prop_dictionary_t transd)
|
|||||||
if (strcmp(tract, "update") == 0)
|
if (strcmp(tract, "update") == 0)
|
||||||
update = true;
|
update = true;
|
||||||
|
|
||||||
rv = xbps_configure_pkg(pkgname, version, false, update);
|
rv = xbps_configure_pkg(pkgname, version, false, update, false);
|
||||||
if (rv != 0)
|
if (rv != 0)
|
||||||
goto out;
|
goto out;
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user