From 8191a1511c15d8121904fce90ea191966a2e6277 Mon Sep 17 00:00:00 2001 From: Juan RP Date: Sat, 26 Feb 2011 11:11:45 +0100 Subject: [PATCH] Make it possible to overwrite the "automatic-install" pkg object via xbps_init(). Two new booleans were added to struct xbps_handle: install_reason_{auto,manual}. The backend is able to force auto or manual installation for a package (and dependencies that were installed/updated) by setting to true any of those booleans. Bump XBPS_RELVER. --- include/xbps_api.h | 19 ++++++++++++++++++- lib/package_register.c | 18 +++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/include/xbps_api.h b/include/xbps_api.h index 0f4f36ee..cc96849f 100644 --- a/include/xbps_api.h +++ b/include/xbps_api.h @@ -53,7 +53,7 @@ * @def XBPS_RELVER * Current library release date. */ -#define XBPS_RELVER "20110224" +#define XBPS_RELVER "20110225" /** * @def XBPS_META_PATH @@ -193,6 +193,23 @@ struct xbps_handle { * Set to true to enable debugging messages to stderr. */ bool with_debug; + /** + * @var install_reason_auto + * + * Set to true to make installed or updated target package + * (and its dependencies) marked with automatic installation, + * thus it will be found as orphan if no packages are depending + * on it. + */ + bool install_reason_auto; + /** + * @var install_reason_manual + * + * Set to true to make installed or updated target package + * (and its dependencies) marked with manual installation, thus + * it will never will be found as orphan. + */ + bool install_reason_manual; }; /** diff --git a/lib/package_register.c b/lib/package_register.c index 9a2a1548..e5f06a44 100644 --- a/lib/package_register.c +++ b/lib/package_register.c @@ -49,7 +49,6 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic) const char *pkgname, *version, *desc, *pkgver; char *plist; int rv = 0; - bool autoinst = false; xhp = xbps_handle_get(); plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir, @@ -93,14 +92,15 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic) rv = EINVAL; goto out; } - if (!prop_dictionary_get_bool(pkgd, - "automatic-install", &autoinst)) { - if (!prop_dictionary_set_bool(pkgd, - "automatic-install", automatic)) { - prop_object_release(pkgd); - rv = EINVAL; - goto out; - } + if (xhp->install_reason_auto) + automatic = true; + else if (xhp->install_reason_manual) + automatic = false; + if (!prop_dictionary_set_bool(pkgd, "automatic-install", + automatic)) { + prop_object_release(pkgd); + rv = EINVAL; + goto out; } if (provides) { if (!prop_dictionary_set(pkgd, "provides", provides)) {