aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2021-06-16 22:08:24 +0200
committerFabian Groffen <grobian@gentoo.org>2021-06-16 22:11:11 +0200
commit19211108eb68865b9ba155003f69f073775e3be6 (patch)
tree396120544bd3dd6f5ee7d20e55ad7edeef4af35a /qmerge.c
parentqmerge: Protect against another NULL hash (diff)
downloadportage-utils-19211108eb68865b9ba155003f69f073775e3be6.tar.gz
portage-utils-19211108eb68865b9ba155003f69f073775e3be6.tar.bz2
portage-utils-19211108eb68865b9ba155003f69f073775e3be6.zip
qmerge: slightly re-order tree_pkg_meta_get calls for validity
previous calls to tree_pkg_meta_get might be invalidated on a next call, so try to keep validity of pointers within tree_pkg_meta_get calls Signed-off-by: Fabian Groffen <grobian@gentoo.org>
Diffstat (limited to 'qmerge.c')
-rw-r--r--qmerge.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/qmerge.c b/qmerge.c
index 43f537a4..768877ff 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1108,7 +1108,8 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
}
/* Set up our temp dir to unpack this stuff FIXME p -> builddir */
- xasprintf(&p, "%s/qmerge/%s/%s", port_tmpdir, mpkg->atom->CATEGORY, mpkg->atom->PF);
+ xasprintf(&p, "%s/qmerge/%s/%s", port_tmpdir,
+ mpkg->atom->CATEGORY, mpkg->atom->PF);
mkdir_p(p, 0755);
xchdir(p);
xasprintf(&D, "%s/image", p);
@@ -1457,14 +1458,9 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
if (pretend == 100)
return 0;
- /* First get a handle on the things to clean up */
- buf = tree_pkg_meta_get(pkg_ctx, CONTENTS);
- if (buf == NULL)
- return 1;
-
portroot_fd = cat_ctx->ctx->portroot_fd;
- /* Then execute the pkg_prerm step */
+ /* execute the pkg_prerm step */
if (!pretend) {
phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
if (phases != NULL) {
@@ -1482,6 +1478,11 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
unmerge_config_protected =
strstr(features, "config-protect-if-modified") != NULL;
+ /* get a handle on the things to clean up */
+ buf = tree_pkg_meta_get(pkg_ctx, CONTENTS);
+ if (buf == NULL)
+ return 1;
+
for (; (buf = strtok_r(buf, "\n", &savep)) != NULL; buf = NULL) {
bool del;
contents_entry *e;
@@ -1597,14 +1598,15 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
}
if (!pretend) {
- /* Then execute the pkg_postrm step */
+ phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
+ /* execute the pkg_postrm step */
pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_postrm", T, T);
- /* Finally delete the vdb entry */
+ /* finally delete the vdb entry */
rm_rf_at(pkg_ctx->fd, ".");
unlinkat(cat_ctx->fd, pkg_ctx->name, AT_REMOVEDIR);
- /* And prune the category if it's empty */
+ /* and prune the category if it's empty */
unlinkat(cat_ctx->ctx->tree_fd, cat_ctx->name, AT_REMOVEDIR);
}