aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFabian Groffen <grobian@gentoo.org>2022-02-06 15:21:38 +0100
committerFabian Groffen <grobian@gentoo.org>2022-02-06 15:21:38 +0100
commitd2c96a1459ce9603e4a538492a43accca376617e (patch)
tree6ffbf33addc55e26fcf9c7432bc0ab2fb0becc2d
parentlibq/xsystem: cleanup/reuse same codepath, allow passing vector (diff)
downloadportage-utils-d2c96a1459ce9603e4a538492a43accca376617e.tar.gz
portage-utils-d2c96a1459ce9603e4a538492a43accca376617e.tar.bz2
portage-utils-d2c96a1459ce9603e4a538492a43accca376617e.zip
qmerge: make use of xsystem instead of DIY
Signed-off-by: Fabian Groffen <grobian@gentoo.org>
-rw-r--r--qmerge.c45
1 files changed, 16 insertions, 29 deletions
diff --git a/qmerge.c b/qmerge.c
index 21f08639..a856aaa4 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2005-2021 Gentoo Authors
+ * Copyright 2005-2022 Gentoo Authors
* Distributed under the terms of the GNU General Public License v2
*
* Copyright 2005-2010 Ned Ludd - <solar@gentoo.org>
@@ -129,45 +129,32 @@ fetch(const char *destdir, const char *src)
char buf[BUFSIZ];
snprintf(buf, sizeof(buf), "(export DISTDIR='%s' URI='%s/%s'; %s)",
destdir, binhost, src, getenv("FETCHCOMMAND"));
- xsystem(buf);
+ xsystem(buf, AT_FDCWD);
} else
#endif
{
- pid_t p;
- int status;
char *path;
- xasprintf(&path, "%s/%s", binhost, src);
-
/* wget -c -q -P <dir> <uri> */
- char prog[] = "wget";
- char *const argv[] = {
- prog,
- (char *)"-c",
- (char *)"-P",
- (char *)destdir,
+ const char *argv[] = {
+ "echo",
+ "wget",
+ "-c",
+ "-P",
+ destdir,
path,
quiet ? (char *)"-q" : NULL,
NULL,
};
- if (!(force_download || install) && pretend)
- strcpy(prog, "echo");
-
- p = vfork();
- switch (p) {
- case 0:
- _exit(execvp(prog, argv));
- case -1:
- errp("vfork failed");
- }
- free(path);
+ xasprintf(&path, "%s/%s", binhost, src);
- waitpid(p, &status, 0);
-#if 0
- if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
- return;
-#endif
+ if (!pretend && (force_download || install))
+ xsystemv(&argv[1], AT_FDCWD); /* skip echo */
+ else
+ xsystemv(argv, AT_FDCWD);
+
+ free(path);
}
fflush(stdout);
@@ -767,7 +754,7 @@ pkg_run_func_at(
/*7*/ phase_replacingvers[phaseidx].varname,
/*8*/ replacing,
/*9*/ debug ? "set -x;" : "");
- xsystembash(script, dirfd);
+ xsystem(script, dirfd);
free(script);
}
#define pkg_run_func(...) pkg_run_func_at(AT_FDCWD, __VA_ARGS__)