diff --git a/lib/package_unpack.c b/lib/package_unpack.c index d935ef59..3fa90a15 100644 --- a/lib/package_unpack.c +++ b/lib/package_unpack.c @@ -658,24 +658,6 @@ xbps_unpack_binary_pkg(struct xbps_handle *xhp, xbps_dictionary_t pkg_repod) /* * Extract archive files. */ - if (access(xhp->rootdir, R_OK) == -1) { - if (errno != ENOENT) { - rv = errno; - goto out; - } - if (xbps_mkpath(xhp->rootdir, 0750) == -1) { - rv = errno; - goto out; - } - } - if (chdir(xhp->rootdir) == -1) { - xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, - errno, pkgver, - "%s: [unpack] failed to chdir to rootdir `%s': %s", - pkgver, xhp->rootdir, strerror(errno)); - rv = errno; - goto out; - } if ((rv = unpack_archive(xhp, pkg_repod, pkgver, bpkg, ar)) != 0) { xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, rv, pkgver, "%s: [unpack] failed to unpack files from archive: %s", diff --git a/lib/transaction_commit.c b/lib/transaction_commit.c index 4d67676c..976a6610 100644 --- a/lib/transaction_commit.c +++ b/lib/transaction_commit.c @@ -249,6 +249,32 @@ xbps_transaction_commit(struct xbps_handle *xhp) */ xbps_set_cb_state(xhp, XBPS_STATE_TRANS_RUN, 0, NULL, NULL); + /* + * Create rootdir if necessary. + */ + if (access(xhp->rootdir, R_OK) == -1) { + if (errno != ENOENT) { + rv = errno; + xbps_set_cb_state(xhp, XBPS_STATE_TRANS_FAIL, errno, xhp->rootdir, + "[trans] failed to access rootdir `%s': %s", + xhp->rootdir, strerror(rv)); + goto out; + } + if (xbps_mkpath(xhp->rootdir, 0750) == -1) { + rv = errno; + xbps_set_cb_state(xhp, XBPS_STATE_TRANS_FAIL, errno, xhp->rootdir, + "[trans] failed to create rootdir `%s': %s", + xhp->rootdir, strerror(rv)); + goto out; + } + } + if (chdir(xhp->rootdir) == -1) { + rv = errno; + xbps_set_cb_state(xhp, XBPS_STATE_UNPACK_FAIL, rv, xhp->rootdir, + "[trans] failed to chdir to rootdir `%s': %s", + xhp->rootdir, strerror(errno)); + goto out; + } while ((obj = xbps_object_iterator_next(iter)) != NULL) { xbps_dictionary_get_cstring_nocopy(obj, "transaction", &tract); xbps_dictionary_get_cstring_nocopy(obj, "pkgver", &pkgver);