1 |
commit: 7fa57849a692a2900417ed13f67b6c6385a2932e |
2 |
Author: Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com> |
3 |
AuthorDate: Thu Mar 8 21:53:52 2018 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Mar 23 11:18:49 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7fa57849 |
7 |
|
8 |
qmerge: Choose SLOTed packages correctly |
9 |
|
10 |
Ex. packages are readeline, ncurses which can be installed |
11 |
in several SLOTs |
12 |
|
13 |
Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com> |
14 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
15 |
|
16 |
qmerge.c | 22 ++++++++++++++-------- |
17 |
1 file changed, 14 insertions(+), 8 deletions(-) |
18 |
|
19 |
diff --git a/qmerge.c b/qmerge.c |
20 |
index ebd4960..1f75acc 100644 |
21 |
--- a/qmerge.c |
22 |
+++ b/qmerge.c |
23 |
@@ -203,6 +203,7 @@ qmerge_initialize(void) |
24 |
struct qmerge_bv_state { |
25 |
const char *catname; |
26 |
const char *pkgname; |
27 |
+ const char *slot; |
28 |
char buf[4096]; |
29 |
char *retbuf; |
30 |
}; |
31 |
@@ -219,19 +220,20 @@ qmerge_best_version_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv) |
32 |
{ |
33 |
struct qmerge_bv_state *state = priv; |
34 |
if (qlist_match(pkg_ctx, state->buf, NULL, true)) |
35 |
- snprintf(state->retbuf, sizeof(state->buf), "%s/%s", |
36 |
- pkg_ctx->cat_ctx->name, pkg_ctx->name); |
37 |
+ snprintf(state->retbuf, sizeof(state->buf), "%s/%s:%s", |
38 |
+ pkg_ctx->cat_ctx->name, pkg_ctx->name, state->slot); |
39 |
return 0; |
40 |
} |
41 |
|
42 |
static char * |
43 |
-best_version(const char *catname, const char *pkgname) |
44 |
+best_version(const char *catname, const char *pkgname, const char *slot) |
45 |
{ |
46 |
static int vdb_check = 1; |
47 |
static char retbuf[4096]; |
48 |
struct qmerge_bv_state state = { |
49 |
.catname = catname, |
50 |
.pkgname = pkgname, |
51 |
+ .slot = slot, |
52 |
.retbuf = retbuf, |
53 |
}; |
54 |
|
55 |
@@ -252,8 +254,8 @@ best_version(const char *catname, const char *pkgname) |
56 |
} |
57 |
|
58 |
retbuf[0] = '\0'; |
59 |
- snprintf(state.buf, sizeof(state.buf), "%s%s%s", |
60 |
- catname ? : "", catname ? "/" : "", pkgname); |
61 |
+ snprintf(state.buf, sizeof(state.buf), "%s%s%s:%s", |
62 |
+ catname ? : "", catname ? "/" : "", pkgname, slot); |
63 |
q_vdb_foreach_pkg(qmerge_best_version_cb, &state, qmerge_filter_cat); |
64 |
|
65 |
done: |
66 |
@@ -359,7 +361,8 @@ qprint_tree_node(int level, const depend_atom *atom, const struct pkg_t *pkg) |
67 |
if (!pretend) |
68 |
return 0; |
69 |
|
70 |
- p = best_version(pkg->CATEGORY, atom->PN); |
71 |
+ p = best_version(pkg->CATEGORY, atom->PN, pkg->SLOT); |
72 |
+ |
73 |
if (strlen(p) < 1) { |
74 |
c = 'N'; |
75 |
snprintf(buf, sizeof(buf), "%sN%s", GREEN, NORM); |
76 |
@@ -844,7 +847,8 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg) |
77 |
|
78 |
ratom = atom_explode(buf); |
79 |
|
80 |
- p = best_version(subpkg->CATEGORY, subpkg->PF); |
81 |
+ p = best_version(subpkg->CATEGORY, subpkg->PF, subpkg->SLOT); |
82 |
+ |
83 |
/* we dont want to remerge equal versions here */ |
84 |
IF_DEBUG(fprintf(stderr, "+Installed: %s\n", p)); |
85 |
if (strlen(p) < 1) |
86 |
@@ -1373,7 +1377,7 @@ print_Pkg(int full, const depend_atom *atom, const struct pkg_t *pkg) |
87 |
if (strcmp(pkg->REPO, "gentoo") != 0) |
88 |
printf(" %sRepo%s:%s %s\n", DKGREEN, YELLOW, NORM, pkg->REPO); |
89 |
|
90 |
- if ((p = best_version(pkg->CATEGORY, atom->PN)) != NULL) { |
91 |
+ if ((p = best_version(pkg->CATEGORY, atom->PN, pkg->SLOT)) != NULL) { |
92 |
if (*p) { |
93 |
int ret; |
94 |
const char *icolor = RED; |
95 |
@@ -1475,6 +1479,7 @@ grab_binpkg_info(const char *name) |
96 |
static char best_match[sizeof(Pkg.PF)+2+sizeof(Pkg.CATEGORY)]; |
97 |
|
98 |
best_match[0] = 0; |
99 |
+ strcpy(pkg->SLOT,"0"); |
100 |
|
101 |
fp = open_binpkg_index(); |
102 |
|
103 |
@@ -1511,6 +1516,7 @@ grab_binpkg_info(const char *name) |
104 |
atom_implode(atom); |
105 |
} |
106 |
memset(pkg, 0, sizeof(struct pkg_t)); |
107 |
+ strcpy(pkg->SLOT,"0"); |
108 |
} |
109 |
continue; |
110 |
} |