xbps_register_pkg: remove 'automatic' boolean argument.

It should be provided in the proplib dictionary with key 'automatic-install'.
This fixes a regression not respecting the 'automatic-install' value stored
in regpkgdb.
This commit is contained in:
Juan RP 2011-04-11 14:42:06 +02:00
parent ad66fa2e3d
commit ef28101203
4 changed files with 19 additions and 15 deletions

View File

@ -387,7 +387,7 @@ exec_transaction(struct transaction *trans)
prop_object_t obj; prop_object_t obj;
const char *pkgname, *version, *pkgver, *instver, *filen, *tract; const char *pkgname, *version, *pkgver, *instver, *filen, *tract;
int rv = 0; int rv = 0;
bool update, preserve, autoinst; bool update, preserve;
pkg_state_t state; pkg_state_t state;
/* /*
@ -484,12 +484,11 @@ exec_transaction(struct transaction *trans)
if ((strcmp(tract, "remove") == 0) || if ((strcmp(tract, "remove") == 0) ||
(strcmp(tract, "configure") == 0)) (strcmp(tract, "configure") == 0))
continue; continue;
autoinst = preserve = false; preserve = false;
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);
prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver); prop_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);
prop_dictionary_get_cstring_nocopy(obj, "filename", &filen); prop_dictionary_get_cstring_nocopy(obj, "filename", &filen);
prop_dictionary_get_bool(obj, "automatic-install", &autoinst);
prop_dictionary_get_bool(obj, "preserve", &preserve); prop_dictionary_get_bool(obj, "preserve", &preserve);
/* /*
* If dependency is already unpacked skip this phase. * If dependency is already unpacked skip this phase.
@ -537,7 +536,7 @@ exec_transaction(struct transaction *trans)
/* /*
* Register binary package. * Register binary package.
*/ */
if ((rv = xbps_register_pkg(obj, autoinst)) != 0) { if ((rv = xbps_register_pkg(obj)) != 0) {
xbps_error_printf("xbps-bin: error registering %s " xbps_error_printf("xbps-bin: error registering %s "
"(%s)\n", pkgver, strerror(rv)); "(%s)\n", pkgver, strerror(rv));
return rv; return rv;

View File

@ -184,7 +184,7 @@ main(int argc, char **argv)
if (rv != 0) if (rv != 0)
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
rv = xbps_register_pkg(dict, false); rv = xbps_register_pkg(dict);
if (rv == EEXIST) { if (rv == EEXIST) {
printf("%s%s=> %s-%s already registered.%s\n", MSG_WARN, printf("%s%s=> %s-%s already registered.%s\n", MSG_WARN,
in_chroot ? "[chroot] " : "", argv[1], argv[2], in_chroot ? "[chroot] " : "", argv[1], argv[2],

View File

@ -776,14 +776,12 @@ int xbps_purge_all_pkgs(void);
* Register a package into the installed packages database. * Register a package into the installed packages database.
* *
* @param[in] pkg_dict A dictionary with the following objects: * @param[in] pkg_dict A dictionary with the following objects:
* \a pkgname, \a version, \a pkgver, \a short_desc (string) * \a pkgname, \a version, \a pkgver, \a short_desc (string),
* and optionally \a provides (array of strings). * \a automatic-install (bool) and optionally \a provides (array of strings).
* @param[in] automatic Set it to true to mark package that has been
* installed by another package, and not explicitly.
* *
* @return 0 on success, otherwise an errno value. * @return 0 on success, otherwise an errno value.
*/ */
int xbps_register_pkg(prop_dictionary_t pkg_dict, bool automatic); int xbps_register_pkg(prop_dictionary_t pkg_dict);
/** /**
* Unregister a package from the package database. * Unregister a package from the package database.

View File

@ -41,7 +41,7 @@
*/ */
int int
xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic) xbps_register_pkg(prop_dictionary_t pkgrd)
{ {
const struct xbps_handle *xhp; const struct xbps_handle *xhp;
prop_dictionary_t dict, pkgd; prop_dictionary_t dict, pkgd;
@ -49,6 +49,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
const char *pkgname, *version, *desc, *pkgver; const char *pkgname, *version, *desc, *pkgver;
char *plist; char *plist;
int rv = 0; int rv = 0;
bool autoinst;
xhp = xbps_handle_get(); xhp = xbps_handle_get();
plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir, plist = xbps_xasprintf("%s/%s/%s", xhp->rootdir,
@ -60,6 +61,7 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
prop_dictionary_get_cstring_nocopy(pkgrd, "version", &version); prop_dictionary_get_cstring_nocopy(pkgrd, "version", &version);
prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc); prop_dictionary_get_cstring_nocopy(pkgrd, "short_desc", &desc);
prop_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver); prop_dictionary_get_cstring_nocopy(pkgrd, "pkgver", &pkgver);
prop_dictionary_get_bool(pkgrd, "automatic-install", &autoinst);
provides = prop_dictionary_get(pkgrd, "provides"); provides = prop_dictionary_get(pkgrd, "provides");
assert(pkgname != NULL); assert(pkgname != NULL);
@ -92,12 +94,17 @@ xbps_register_pkg(prop_dictionary_t pkgrd, bool automatic)
rv = EINVAL; rv = EINVAL;
goto out; goto out;
} }
prop_dictionary_get_bool(pkgd, "automatic-install", &autoinst);
if (xhp->install_reason_auto) if (xhp->install_reason_auto)
automatic = true; autoinst = true;
else if (xhp->install_reason_manual) else if (xhp->install_reason_manual)
automatic = false; autoinst = false;
if (!prop_dictionary_set_bool(pkgd, "automatic-install",
automatic)) { xbps_dbg_printf("%s: autoinst %d reason_auto %d reason_manual %d\n",
pkgver, autoinst, xhp->install_reason_auto, xhp->install_reason_manual);
if (!prop_dictionary_set_bool(pkgd,
"automatic-install", autoinst)) {
prop_object_release(pkgd); prop_object_release(pkgd);
rv = EINVAL; rv = EINVAL;
goto out; goto out;