commit: edcb8e142ee18f19f8e9aa9ab7bbccab39fc63c1 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Mon Jun 10 13:29:52 2019 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Mon Jun 10 13:29:52 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=edcb8e14
qmerge: avoid nested vdb entries while writing a new vdb dir, ensure we removed any existing one, for rename will only overwrite an empty directory. This also means the `mv` fallback is pointless, because rename now no longer will fail, and mv no longer will put the vdb dir inside the target dir. Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> qmerge.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/qmerge.c b/qmerge.c index ce45628..8644ddc 100644 --- a/qmerge.c +++ b/qmerge.c @@ -1342,6 +1342,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg) if ((contents = fopen("vdb/CONTENTS", "w")) == NULL) errf("come on wtf?"); + objs = NULL; { char *cpath; @@ -1415,6 +1416,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg) free(T); /* Update the magic counter */ + /* FIXME: check Portage's get_counter_tick_core */ if ((fp = fopen("vdb/COUNTER", "w")) != NULL) { fputs("0", fp); fclose(fp); @@ -1426,11 +1428,9 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg) portroot, portvdb, pkg->CATEGORY); mkdir_p(buf, 0755); strcat(buf, pkg->PF); - if (rename("vdb", buf)) { - xasprintf(&p, "mv vdb '%s'", buf); - xsystem(p); - free(p); - } + rm_rf(buf); /* get rid of existing dir, empty dir is fine */ + if (rename("vdb", buf) != 0) + warn("failed to move 'vdb' to '%s': %s", buf, strerror(errno)); } /* clean up our local temp dir */