From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 815E4138335 for ; Mon, 10 Jun 2019 13:31:24 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 872B7E0825; Mon, 10 Jun 2019 13:31:23 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 68AB3E0825 for ; Mon, 10 Jun 2019 13:31:23 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id EC811345B8A for ; Mon, 10 Jun 2019 13:31:21 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 5F5DF57B for ; Mon, 10 Jun 2019 13:31:20 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1560173392.edcb8e142ee18f19f8e9aa9ab7bbccab39fc63c1.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qmerge.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: edcb8e142ee18f19f8e9aa9ab7bbccab39fc63c1 X-VCS-Branch: master Date: Mon, 10 Jun 2019 13:31:20 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: b6b313c0-76e2-4578-a541-14ededf09a22 X-Archives-Hash: 98e90324c449ff65861a845821c9b403 commit: edcb8e142ee18f19f8e9aa9ab7bbccab39fc63c1 Author: Fabian Groffen gentoo org> AuthorDate: Mon Jun 10 13:29:52 2019 +0000 Commit: Fabian Groffen gentoo 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 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 */