Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 0 additions & 12 deletions lib/package_register.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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:
Expand Down
9 changes: 8 additions & 1 deletion lib/transaction_ops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}

Expand Down
36 changes: 23 additions & 13 deletions lib/transaction_pkg_deps.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ repo_deps(struct xbps_handle *xhp,
unsigned short *depth) /* max recursion depth */
{
xbps_array_t pkg_rdeps = NULL, pkg_provides = NULL;
xbps_dictionary_t curpkgd = NULL;
xbps_dictionary_t curpkgd = NULL, repopkgd = NULL;
xbps_trans_type_t ttype;
pkg_state_t state;
xbps_object_t obj;
Expand Down Expand Up @@ -146,6 +146,7 @@ repo_deps(struct xbps_handle *xhp,

while ((obj = xbps_object_iterator_next(iter))) {
bool error = false, foundvpkg = false;
bool autoinst = true;

ttype = XBPS_TRANS_UNKNOWN;
reqpkg = xbps_string_cstring_nocopy(obj);
Expand Down Expand Up @@ -328,17 +329,17 @@ repo_deps(struct xbps_handle *xhp,
xbps_dbg_printf("`%s' is repolocked, looking at single repository.\n", reqpkg);
xbps_dictionary_get_cstring_nocopy(curpkgd, "repository", &repourl);
if (repourl && (repo = xbps_regget_repo(xhp, repourl))) {
curpkgd = xbps_repo_get_pkg(repo, reqpkg);
repopkgd = xbps_repo_get_pkg(repo, reqpkg);
} else {
curpkg = NULL;
repopkgd = NULL;
}
} else {
curpkgd = xbps_rpool_get_pkg(xhp, reqpkg);
if (!curpkgd) {
curpkgd = xbps_rpool_get_virtualpkg(xhp, reqpkg);
repopkgd = xbps_rpool_get_pkg(xhp, reqpkg);
if (!repopkgd) {
repopkgd = xbps_rpool_get_virtualpkg(xhp, reqpkg);
}
}
if (curpkgd == NULL) {
if (repopkgd == NULL) {
/* pkg not found, there was some error */
if (errno && errno != ENOENT) {
xbps_dbg_printf("failed to find pkg for `%s' in rpool: %s\n", reqpkg, strerror(errno));
Expand All @@ -360,7 +361,7 @@ repo_deps(struct xbps_handle *xhp,
}


xbps_dictionary_get_cstring_nocopy(curpkgd, "pkgver", &pkgver_q);
xbps_dictionary_get_cstring_nocopy(repopkgd, "pkgver", &pkgver_q);
if (!xbps_pkg_name(reqpkgname, sizeof(reqpkgname), pkgver_q)) {
rv = EINVAL;
break;
Expand Down Expand Up @@ -408,7 +409,7 @@ repo_deps(struct xbps_handle *xhp,
if (error)
break;
}
pkg_rdeps = xbps_dictionary_get(curpkgd, "run_depends");
pkg_rdeps = xbps_dictionary_get(repopkgd, "run_depends");
if (xbps_array_count(pkg_rdeps)) {
/*
* Process rundeps for current pkg found in rpool.
Expand All @@ -421,7 +422,7 @@ repo_deps(struct xbps_handle *xhp,
xbps_dbg_printf_append("%s: finding dependencies:\n", pkgver_q);
}
(*depth)++;
rv = repo_deps(xhp, pkgs, curpkgd, depth);
rv = repo_deps(xhp, pkgs, repopkgd, depth);
if (rv != 0) {
xbps_dbg_printf("Error checking %s for rundeps: %s\n", reqpkg, strerror(rv));
break;
Expand All @@ -432,15 +433,24 @@ repo_deps(struct xbps_handle *xhp,
} else if (xbps_dictionary_get(curpkgd, "hold")) {
ttype = XBPS_TRANS_HOLD;
}
if (ttype == XBPS_TRANS_UPDATE || ttype == XBPS_TRANS_CONFIGURE) {
/*
* If the package is already installed preserve the installation mode,
* which is not automatic if automatic-install is not set.
*/
bool pkgd_auto = false;
xbps_dictionary_get_bool(curpkgd, "automatic-install", &pkgd_auto);
autoinst = pkgd_auto;
}
/*
* All deps were processed, store pkg in transaction.
*/
if (!xbps_transaction_pkg_type_set(curpkgd, ttype)) {
if (!xbps_transaction_pkg_type_set(repopkgd, ttype)) {
rv = EINVAL;
xbps_dbg_printf("xbps_transaction_store failed for `%s': %s\n", reqpkg, strerror(rv));
xbps_dbg_printf("xbps_transaction_pkg_type_set failed for `%s': %s\n", reqpkg, strerror(rv));
break;
}
if (!xbps_transaction_store(xhp, pkgs, curpkgd, true)) {
if (!xbps_transaction_store(xhp, pkgs, repopkgd, autoinst)) {
rv = EINVAL;
xbps_dbg_printf("xbps_transaction_store failed for `%s': %s\n", reqpkg, strerror(rv));
break;
Expand Down
3 changes: 2 additions & 1 deletion lib/transaction_store.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@ xbps_transaction_store(struct xbps_handle *xhp, xbps_array_t pkgs,
xbps_set_cb_state(xhp, XBPS_STATE_TRANS_ADDPKG, 0, pkgver,
"Found %s in repository %s", pkgver, repo);

xbps_dbg_printf("[trans] `%s' stored (%s)\n", pkgver, repo);
xbps_dbg_printf("[trans] `%s' stored%s (%s)\n", pkgver,
autoinst ? " as automatic install" : "", repo);
xbps_object_release(pkgd);

return true;
Expand Down
Loading