lib: with XBPS_FLAG_INSTALL_AUTO only mark new installs as automatic

Closes: https://github.com/void-linux/xbps/issues/556
This commit is contained in:
Duncan Overbruck
2023-05-30 21:16:28 +02:00
parent c1176447f3
commit 825f1f30f9
3 changed files with 123 additions and 13 deletions

View File

@@ -41,7 +41,6 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
const char *pkgver, *pkgname;
char sha256[XBPS_SHA256_SIZE], outstr[64], *buf;
int rv = 0;
bool autoinst = false;
assert(xbps_object_type(pkgrd) == XBPS_TYPE_DICTIONARY);
@@ -53,17 +52,6 @@ xbps_register_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkgrd)
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgver", &pkgver);
xbps_dictionary_get_cstring_nocopy(pkgd, "pkgname", &pkgname);
if (xhp->flags & XBPS_FLAG_INSTALL_AUTO)
autoinst = true;
/*
* Set automatic-install to true, iff it was explicitly set; otherwise
* preserve its value.
*/
if (autoinst && !xbps_dictionary_set_bool(pkgd, "automatic-install", true)) {
xbps_dbg_printf("%s: invalid autoinst for %s\n", __func__, pkgver);
rv = EINVAL;
goto out;
}
if (xhp->flags & XBPS_FLAG_INSTALL_REPRO) {
/*
* Reproducible mode. Some objects must not be recorded:

View File

@@ -62,6 +62,7 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
xbps_trans_type_t ttype;
const char *repoloc, *repopkgver, *instpkgver, *pkgname;
char buf[XBPS_NAME_SIZE] = {0};
bool autoinst = false;
int rv = 0;
assert(pkg != NULL);
@@ -208,7 +209,13 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
return EINVAL;
}
if (!xbps_transaction_store(xhp, pkgs, pkg_repod, false)) {
/*
* Set automatic-install to true if it was requested and this is a new install.
*/
if (ttype == XBPS_TRANS_INSTALL)
autoinst = xhp->flags & XBPS_FLAG_INSTALL_AUTO;
if (!xbps_transaction_store(xhp, pkgs, pkg_repod, autoinst)) {
return EINVAL;
}