1 |
commit: f3fe974732b9dc08f07545b713e5a78922af955e |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Jun 24 06:44:20 2021 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Jun 24 06:44:20 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f3fe9747 |
7 |
|
8 |
qmerge: add support for REPLACING_VERSIONS and REPLACED_BY_VERSION |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
qmerge.c | 57 +++++++++++++++++++++++++++++++++++++++++---------------- |
13 |
1 file changed, 41 insertions(+), 16 deletions(-) |
14 |
|
15 |
diff --git a/qmerge.c b/qmerge.c |
16 |
index e3be6a2..d6532eb 100644 |
17 |
--- a/qmerge.c |
18 |
+++ b/qmerge.c |
19 |
@@ -98,7 +98,7 @@ typedef struct llist_char_t llist_char; |
20 |
|
21 |
static void pkg_fetch(int, const depend_atom *, const tree_match_ctx *); |
22 |
static void pkg_merge(int, const depend_atom *, const tree_match_ctx *); |
23 |
-static int pkg_unmerge(tree_pkg_ctx *, set *, int, char **, int, char **); |
24 |
+static int pkg_unmerge(tree_pkg_ctx *, depend_atom *, set *, int, char **, int, char **); |
25 |
|
26 |
static bool |
27 |
qmerge_prompt(const char *p) |
28 |
@@ -652,6 +652,19 @@ static struct { |
29 |
{ PKG_PRERM, "pkg_prerm", {1,1,1,1,1,1,1,1,1} }, |
30 |
{ PKG_POSTRM, "pkg_postrm", {1,1,1,1,1,1,1,1,1} } |
31 |
}; |
32 |
+static struct { |
33 |
+ enum pkg_phases phase; |
34 |
+ const char *varname; |
35 |
+} phase_replacingvers[] = { |
36 |
+ { 0, NULL }, /* align */ |
37 |
+ /* phase varname PMS 11.1.2 */ |
38 |
+ { PKG_PRETEND, "REPLACING_VERSIONS" }, |
39 |
+ { PKG_SETUP, "REPLACING_VERSIONS" }, |
40 |
+ { PKG_PREINST, "REPLACING_VERSIONS" }, |
41 |
+ { PKG_POSTINST, "REPLACING_VERSIONS" }, |
42 |
+ { PKG_PRERM, "REPLACED_BY_VERSION" }, |
43 |
+ { PKG_POSTRM, "REPLACED_BY_VERSION" } |
44 |
+}; |
45 |
|
46 |
static void |
47 |
pkg_run_func_at( |
48 |
@@ -661,7 +674,8 @@ pkg_run_func_at( |
49 |
enum pkg_phases phaseidx, |
50 |
const char *D, |
51 |
const char *T, |
52 |
- const char *EAPI) |
53 |
+ const char *EAPI, |
54 |
+ const char *replacing) |
55 |
{ |
56 |
const char *func; |
57 |
const char *phase; |
58 |
@@ -743,8 +757,11 @@ pkg_run_func_at( |
59 |
/* we do not support preserve-libs yet, so force |
60 |
* preserve_old_lib instead */ |
61 |
"export FEATURES=\"${FEATURES/preserve-libs/}\"\n" |
62 |
+ /* replacing versions: we ignore EAPI availability, for it will |
63 |
+ * never hurt */ |
64 |
+ "export %7$s=\"%8$s\"\n" |
65 |
/* Finally run the func */ |
66 |
- "%7$s%2$s\n" |
67 |
+ "%9$s%2$s\n" |
68 |
/* Ignore func return values (not exit values) */ |
69 |
":", |
70 |
/*1*/ vdb_path, |
71 |
@@ -753,7 +770,9 @@ pkg_run_func_at( |
72 |
/*4*/ portroot, |
73 |
/*5*/ D, |
74 |
/*6*/ T, |
75 |
- /*7*/ debug ? "set -x;" : ""); |
76 |
+ /*7*/ phase_replacingvers[phaseidx].varname, |
77 |
+ /*8*/ replacing, |
78 |
+ /*9*/ debug ? "set -x;" : ""); |
79 |
xsystembash(script, dirfd); |
80 |
free(script); |
81 |
} |
82 |
@@ -1052,7 +1071,8 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg) |
83 |
char **cp_argv; |
84 |
char **cpm_argv; |
85 |
int tbz2size; |
86 |
- int replacing = 0; |
87 |
+ const char *replver = ""; |
88 |
+ int replacing = NOT_EQUAL; |
89 |
char *eprefix = NULL; |
90 |
size_t eprefix_len = 0; |
91 |
char *pm_phases = NULL; |
92 |
@@ -1072,8 +1092,10 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg) |
93 |
slotatom = atom_explode(buf); |
94 |
|
95 |
previnst = best_version(slotatom, BV_INSTALLED); |
96 |
- if (previnst != NULL) |
97 |
- replacing = atom_compare(mpkg->atom, slotatom); |
98 |
+ if (previnst != NULL) { |
99 |
+ replacing = atom_compare(mpkg->atom, previnst->atom); |
100 |
+ replver = previnst->atom->PVR; |
101 |
+ } |
102 |
|
103 |
(void)qprint_tree_node(level, mpkg, previnst, replacing); |
104 |
|
105 |
@@ -1349,9 +1371,9 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg) |
106 |
eat_file("vdb/DEFINED_PHASES", &pm_phases, &pm_phases_len); |
107 |
|
108 |
if (!pretend) { |
109 |
- pkg_run_func("vdb", pm_phases, PKG_PRETEND, D, T, eapi); |
110 |
- pkg_run_func("vdb", pm_phases, PKG_SETUP, D, T, eapi); |
111 |
- pkg_run_func("vdb", pm_phases, PKG_PREINST, D, T, eapi); |
112 |
+ pkg_run_func("vdb", pm_phases, PKG_PRETEND, D, T, eapi, replver); |
113 |
+ pkg_run_func("vdb", pm_phases, PKG_SETUP, D, T, eapi, replver); |
114 |
+ pkg_run_func("vdb", pm_phases, PKG_PREINST, D, T, eapi, replver); |
115 |
} |
116 |
|
117 |
{ |
118 |
@@ -1429,7 +1451,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg) |
119 |
case EQUAL: |
120 |
/* We need to really set this unmerge pending after we |
121 |
* look at contents of the new pkg */ |
122 |
- pkg_unmerge(previnst->pkg, objs, |
123 |
+ pkg_unmerge(previnst->pkg, mpkg->atom, objs, |
124 |
cp_argc, cp_argv, cpm_argc, cpm_argv); |
125 |
break; |
126 |
default: |
127 |
@@ -1441,7 +1463,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg) |
128 |
|
129 |
/* run postinst */ |
130 |
if (!pretend) |
131 |
- pkg_run_func("vdb", pm_phases, PKG_POSTINST, D, T, eapi); |
132 |
+ pkg_run_func("vdb", pm_phases, PKG_POSTINST, D, T, eapi, replver); |
133 |
|
134 |
if (eprefix != NULL) |
135 |
free(eprefix); |
136 |
@@ -1492,7 +1514,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg) |
137 |
} |
138 |
|
139 |
static int |
140 |
-pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep, |
141 |
+pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep, |
142 |
int cp_argc, char **cp_argv, int cpm_argc, char **cpm_argv) |
143 |
{ |
144 |
tree_cat_ctx *cat_ctx = pkg_ctx->cat_ctx; |
145 |
@@ -1524,7 +1546,8 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep, |
146 |
buf = tree_pkg_meta_get(pkg_ctx, EAPI); /* when phases caused ralloc */ |
147 |
if (phases != NULL) { |
148 |
mkdirat(pkg_ctx->fd, "temp", 0755); |
149 |
- pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_PRERM, T, T, buf); |
150 |
+ pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_PRERM, |
151 |
+ T, T, buf, rpkg == NULL ? "" : rpkg->PVR); |
152 |
} |
153 |
} |
154 |
|
155 |
@@ -1660,7 +1683,8 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep, |
156 |
buf = tree_pkg_meta_get(pkg_ctx, EAPI); |
157 |
phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES); |
158 |
/* execute the pkg_postrm step */ |
159 |
- pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_POSTRM, T, T, buf); |
160 |
+ pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_POSTRM, |
161 |
+ T, T, buf, rpkg == NULL ? "" : rpkg->PVR); |
162 |
|
163 |
/* finally delete the vdb entry */ |
164 |
rm_rf_at(pkg_ctx->fd, "."); |
165 |
@@ -1837,7 +1861,8 @@ qmerge_unmerge_cb(tree_pkg_ctx *pkg_ctx, void *priv) |
166 |
(void)list_set(priv, &todo); |
167 |
for (p = todo; *p != NULL; p++) { |
168 |
if (qlist_match(pkg_ctx, *p, NULL, true, false)) |
169 |
- pkg_unmerge(pkg_ctx, NULL, cp_argc, cp_argv, cpm_argc, cpm_argv); |
170 |
+ pkg_unmerge(pkg_ctx, NULL, NULL, |
171 |
+ cp_argc, cp_argv, cpm_argc, cpm_argv); |
172 |
} |
173 |
|
174 |
free(todo); |