From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id AB211138A87 for ; Tue, 24 Feb 2015 01:26:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 18055E08D2; Tue, 24 Feb 2015 01:26:09 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 51D4CE08CD for ; Tue, 24 Feb 2015 01:26:08 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 646D134095F for ; Tue, 24 Feb 2015 01:26:07 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 6D1C3126B3 for ; Tue, 24 Feb 2015 01:26:04 +0000 (UTC) From: "Mike Frysinger" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Mike Frysinger" Message-ID: <1424595774.657234dd353ffc2ee1f464634aa8950260317404.vapier@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: /, libq/ X-VCS-Repository: proj/portage-utils X-VCS-Files: libq/xsystem.c qmerge.c X-VCS-Directories: / libq/ X-VCS-Committer: vapier X-VCS-Committer-Name: Mike Frysinger X-VCS-Revision: 657234dd353ffc2ee1f464634aa8950260317404 X-VCS-Branch: master Date: Tue, 24 Feb 2015 01:26:04 +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-Archives-Salt: 8b5955bf-a340-4147-b63d-171ddfba5864 X-Archives-Hash: cbd4e3fab8ddaf85a3802185e29fd710 commit: 657234dd353ffc2ee1f464634aa8950260317404 Author: Mike Frysinger gentoo org> AuthorDate: Sun Feb 22 09:02:54 2015 +0000 Commit: Mike Frysinger gentoo org> CommitDate: Sun Feb 22 09:02:54 2015 +0000 URL: http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=657234dd qmerge: support running pkg funcs in a dir via fd --- libq/xsystem.c | 5 ++++- qmerge.c | 5 +++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/libq/xsystem.c b/libq/xsystem.c index 199a1d2..d8a551a 100644 --- a/libq/xsystem.c +++ b/libq/xsystem.c @@ -14,13 +14,16 @@ static void xsystem(const char *command) errp("system(%s) failed", command); } -static void xsystembash(const char *command) +static void xsystembash(const char *command, int cwd) { pid_t p = vfork(); int status; switch (p) { case 0: /* child */ + if (cwd != AT_FDCWD) + if (fchdir(cwd)) + errp("fchdir failed"); execl("/bin/bash", "bash", "--norc", "--noprofile", "-c", command, NULL); /* Hrm, still here ? Maybe no bash ... */ _exit(execl("/bin/sh", "sh", "-c", command, NULL)); diff --git a/qmerge.c b/qmerge.c index c58e4f2..980a5b6 100644 --- a/qmerge.c +++ b/qmerge.c @@ -417,7 +417,7 @@ qprint_tree_node(int level, const depend_atom *atom, const struct pkg_t *pkg) } _q_static void -pkg_run_func(const char *vdb_path, const char *phases, const char *func, const char *D, const char *T) +pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char *func, const char *D, const char *T) { const char *phase; char *script; @@ -484,9 +484,10 @@ pkg_run_func(const char *vdb_path, const char *phases, const char *func, const c /*5*/ D, /*6*/ T, /*7*/ debug ? "set -x;" : ""); - xsystembash(script); + xsystembash(script, dirfd); free(script); } +#define pkg_run_func(...) pkg_run_func_at(AT_FDCWD, __VA_ARGS__) /* Copy one tree (the single package) to another tree (ROOT) */ _q_static int