1 |
commit: d2c96a1459ce9603e4a538492a43accca376617e |
2 |
Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sun Feb 6 14:21:38 2022 +0000 |
4 |
Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> |
5 |
CommitDate: Sun Feb 6 14:21:38 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d2c96a14 |
7 |
|
8 |
qmerge: make use of xsystem instead of DIY |
9 |
|
10 |
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> |
11 |
|
12 |
qmerge.c | 45 ++++++++++++++++----------------------------- |
13 |
1 file changed, 16 insertions(+), 29 deletions(-) |
14 |
|
15 |
diff --git a/qmerge.c b/qmerge.c |
16 |
index 21f0863..a856aaa 100644 |
17 |
--- a/qmerge.c |
18 |
+++ b/qmerge.c |
19 |
@@ -1,5 +1,5 @@ |
20 |
/* |
21 |
- * Copyright 2005-2021 Gentoo Authors |
22 |
+ * Copyright 2005-2022 Gentoo Authors |
23 |
* Distributed under the terms of the GNU General Public License v2 |
24 |
* |
25 |
* Copyright 2005-2010 Ned Ludd - <solar@g.o> |
26 |
@@ -129,45 +129,32 @@ fetch(const char *destdir, const char *src) |
27 |
char buf[BUFSIZ]; |
28 |
snprintf(buf, sizeof(buf), "(export DISTDIR='%s' URI='%s/%s'; %s)", |
29 |
destdir, binhost, src, getenv("FETCHCOMMAND")); |
30 |
- xsystem(buf); |
31 |
+ xsystem(buf, AT_FDCWD); |
32 |
} else |
33 |
#endif |
34 |
{ |
35 |
- pid_t p; |
36 |
- int status; |
37 |
char *path; |
38 |
|
39 |
- xasprintf(&path, "%s/%s", binhost, src); |
40 |
- |
41 |
/* wget -c -q -P <dir> <uri> */ |
42 |
- char prog[] = "wget"; |
43 |
- char *const argv[] = { |
44 |
- prog, |
45 |
- (char *)"-c", |
46 |
- (char *)"-P", |
47 |
- (char *)destdir, |
48 |
+ const char *argv[] = { |
49 |
+ "echo", |
50 |
+ "wget", |
51 |
+ "-c", |
52 |
+ "-P", |
53 |
+ destdir, |
54 |
path, |
55 |
quiet ? (char *)"-q" : NULL, |
56 |
NULL, |
57 |
}; |
58 |
- if (!(force_download || install) && pretend) |
59 |
- strcpy(prog, "echo"); |
60 |
- |
61 |
- p = vfork(); |
62 |
- switch (p) { |
63 |
- case 0: |
64 |
- _exit(execvp(prog, argv)); |
65 |
- case -1: |
66 |
- errp("vfork failed"); |
67 |
- } |
68 |
|
69 |
- free(path); |
70 |
+ xasprintf(&path, "%s/%s", binhost, src); |
71 |
|
72 |
- waitpid(p, &status, 0); |
73 |
-#if 0 |
74 |
- if (WIFEXITED(status) && WEXITSTATUS(status) == 0) |
75 |
- return; |
76 |
-#endif |
77 |
+ if (!pretend && (force_download || install)) |
78 |
+ xsystemv(&argv[1], AT_FDCWD); /* skip echo */ |
79 |
+ else |
80 |
+ xsystemv(argv, AT_FDCWD); |
81 |
+ |
82 |
+ free(path); |
83 |
} |
84 |
|
85 |
fflush(stdout); |
86 |
@@ -767,7 +754,7 @@ pkg_run_func_at( |
87 |
/*7*/ phase_replacingvers[phaseidx].varname, |
88 |
/*8*/ replacing, |
89 |
/*9*/ debug ? "set -x;" : ""); |
90 |
- xsystembash(script, dirfd); |
91 |
+ xsystem(script, dirfd); |
92 |
free(script); |
93 |
} |
94 |
#define pkg_run_func(...) pkg_run_func_at(AT_FDCWD, __VA_ARGS__) |