1 |
commit: 19211108eb68865b9ba155003f69f073775e3be6 |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jun 16 20:08:24 2021 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Jun 16 20:11:11 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=19211108 |
7 |
|
8 |
qmerge: slightly re-order tree_pkg_meta_get calls for validity |
9 |
|
10 |
previous calls to tree_pkg_meta_get might be invalidated on a next call, |
11 |
so try to keep validity of pointers within tree_pkg_meta_get calls |
12 |
|
13 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
14 |
|
15 |
qmerge.c | 22 ++++++++++++---------- |
16 |
1 file changed, 12 insertions(+), 10 deletions(-) |
17 |
|
18 |
diff --git a/qmerge.c b/qmerge.c |
19 |
index 43f537a..768877f 100644 |
20 |
--- a/qmerge.c |
21 |
+++ b/qmerge.c |
22 |
@@ -1108,7 +1108,8 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg) |
23 |
} |
24 |
|
25 |
/* Set up our temp dir to unpack this stuff FIXME p -> builddir */ |
26 |
- xasprintf(&p, "%s/qmerge/%s/%s", port_tmpdir, mpkg->atom->CATEGORY, mpkg->atom->PF); |
27 |
+ xasprintf(&p, "%s/qmerge/%s/%s", port_tmpdir, |
28 |
+ mpkg->atom->CATEGORY, mpkg->atom->PF); |
29 |
mkdir_p(p, 0755); |
30 |
xchdir(p); |
31 |
xasprintf(&D, "%s/image", p); |
32 |
@@ -1457,14 +1458,9 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep, |
33 |
if (pretend == 100) |
34 |
return 0; |
35 |
|
36 |
- /* First get a handle on the things to clean up */ |
37 |
- buf = tree_pkg_meta_get(pkg_ctx, CONTENTS); |
38 |
- if (buf == NULL) |
39 |
- return 1; |
40 |
- |
41 |
portroot_fd = cat_ctx->ctx->portroot_fd; |
42 |
|
43 |
- /* Then execute the pkg_prerm step */ |
44 |
+ /* execute the pkg_prerm step */ |
45 |
if (!pretend) { |
46 |
phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES); |
47 |
if (phases != NULL) { |
48 |
@@ -1482,6 +1478,11 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep, |
49 |
unmerge_config_protected = |
50 |
strstr(features, "config-protect-if-modified") != NULL; |
51 |
|
52 |
+ /* get a handle on the things to clean up */ |
53 |
+ buf = tree_pkg_meta_get(pkg_ctx, CONTENTS); |
54 |
+ if (buf == NULL) |
55 |
+ return 1; |
56 |
+ |
57 |
for (; (buf = strtok_r(buf, "\n", &savep)) != NULL; buf = NULL) { |
58 |
bool del; |
59 |
contents_entry *e; |
60 |
@@ -1597,14 +1598,15 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep, |
61 |
} |
62 |
|
63 |
if (!pretend) { |
64 |
- /* Then execute the pkg_postrm step */ |
65 |
+ phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES); |
66 |
+ /* execute the pkg_postrm step */ |
67 |
pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_postrm", T, T); |
68 |
|
69 |
- /* Finally delete the vdb entry */ |
70 |
+ /* finally delete the vdb entry */ |
71 |
rm_rf_at(pkg_ctx->fd, "."); |
72 |
unlinkat(cat_ctx->fd, pkg_ctx->name, AT_REMOVEDIR); |
73 |
|
74 |
- /* And prune the category if it's empty */ |
75 |
+ /* and prune the category if it's empty */ |
76 |
unlinkat(cat_ctx->ctx->tree_fd, cat_ctx->name, AT_REMOVEDIR); |
77 |
} |