Skip to content

Commit c819124

Browse files
committed
lib: fix regression for installing packages by pkgver
Fixes a regression introduces by a634e82, where when installing already installed packages by pkgver only the package would be used to query the repository pool instead of the pkgver. As a result xbps-install would print "package already installed" instead of "package not found" messages. Resolved by only switching to the provider package name when the pkgver refers to an installed virtual package, otherwise the supplied pkgver/pkgname/pkgdep will be used.
1 parent 2900717 commit c819124

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

lib/transaction_ops.c

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2424
*/
2525

26-
#include <stdio.h>
2726
#include <stdbool.h>
2827
#include <stdlib.h>
2928
#include <string.h>
@@ -55,13 +54,13 @@
5554
static int
5655
trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
5756
{
57+
char buf[XBPS_NAME_SIZE];
5858
xbps_dictionary_t pkg_pkgdb = NULL, pkg_repod = NULL, vpkg_pkgdb = NULL;
5959
xbps_object_t obj;
6060
xbps_array_t pkgs;
6161
pkg_state_t state = 0;
6262
xbps_trans_type_t ttype;
6363
const char *repoloc, *repopkgver, *instpkgver, *pkgname;
64-
char buf[XBPS_NAME_SIZE] = {0};
6564
bool autoinst = false;
6665
int rv = 0;
6766

@@ -89,8 +88,16 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
8988
// virtual package installed, if there is no real package in
9089
// the rpool, we are keeping the virtual package.
9190
pkg_repod = xbps_rpool_get_pkg(xhp, pkg);
92-
if (!pkg_repod)
91+
if (!pkg_repod) {
9392
pkg_pkgdb = vpkg_pkgdb;
93+
// if we are using the installed virtual package,
94+
// use the provider to query the repository pool.
95+
if (!xbps_dictionary_get_cstring_nocopy(
96+
pkg_pkgdb, "pkgname", &pkg)) {
97+
xbps_error_printf("missing `pkgname` property\n");
98+
return EINVAL;
99+
}
100+
}
94101
}
95102
if (pkg_pkgdb) {
96103
// package already installed
@@ -99,10 +106,6 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
99106
} else {
100107
ttype = XBPS_TRANS_UPDATE;
101108
}
102-
if (!xbps_dictionary_get_cstring_nocopy(pkg_pkgdb, "pkgname", &pkgname)) {
103-
xbps_error_printf("missing `pkgname` property\n");
104-
return EINVAL;
105-
}
106109
if (xbps_dictionary_get(pkg_pkgdb, "repolock")) {
107110
struct xbps_repo *repo;
108111
/* find update from repo */
@@ -112,10 +115,10 @@ trans_find_pkg(struct xbps_handle *xhp, const char *pkg, bool force)
112115
/* not found */
113116
return ENOENT;
114117
}
115-
pkg_repod = xbps_repo_get_pkg(repo, pkgname);
118+
pkg_repod = xbps_repo_get_pkg(repo, pkg);
116119
} else {
117120
/* find update from rpool */
118-
pkg_repod = xbps_rpool_get_pkg(xhp, pkgname);
121+
pkg_repod = xbps_rpool_get_pkg(xhp, pkg);
119122
}
120123
} else {
121124
ttype = XBPS_TRANS_INSTALL;

0 commit comments

Comments
 (0)