1 |
commit: 40d634fe925bda6b3c95067cb7d23f2bce32ce36 |
2 |
Author: Sam James <sam <AT> gentoo <DOT> org> |
3 |
AuthorDate: Thu Sep 29 06:37:19 2022 +0000 |
4 |
Commit: Sam James <sam <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Sep 29 20:45:40 2022 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=40d634fe |
7 |
|
8 |
bin: isolated-functions.sh: make ___makeopts_jobs return CPUs as default, not 1 |
9 |
|
10 |
Both Portage and pkgcore interpret no MAKEOPTS as "-jN" where N is the number |
11 |
of available CPUs but we weren't doing this on the bash side in ___makeopts_jobs. |
12 |
|
13 |
Switch it to use nproc for consistency (it's also, really, the behaviour |
14 |
we're expecting). |
15 |
|
16 |
Signed-off-by: Sam James <sam <AT> gentoo.org> |
17 |
|
18 |
NEWS | 3 +++ |
19 |
bin/isolated-functions.sh | 9 ++++++++- |
20 |
2 files changed, 11 insertions(+), 1 deletion(-) |
21 |
|
22 |
diff --git a/NEWS b/NEWS |
23 |
index 21296d5ff..31927c819 100644 |
24 |
--- a/NEWS |
25 |
+++ b/NEWS |
26 |
@@ -29,6 +29,9 @@ Bug fixes: |
27 |
|
28 |
* data: Fix PORTAGE_USERNAME default (bug #873088). |
29 |
|
30 |
+* bin: isolated-functions.sh: return number of CPUs in ___makeopts_jobs as default |
31 |
+ instead of 1 to match Portage's behavior on the Python side. |
32 |
+ |
33 |
* bin: ecompress: zstd: Recognize .zst as a compressed file suffix for the purposes |
34 |
of the internal compressed file collision check. |
35 |
|
36 |
|
37 |
diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh |
38 |
index 0efcd5a7d..882789132 100644 |
39 |
--- a/bin/isolated-functions.sh |
40 |
+++ b/bin/isolated-functions.sh |
41 |
@@ -475,7 +475,14 @@ ___makeopts_jobs() { |
42 |
# since POSIX doesn't specify a non-greedy match (i.e. ".*?"). |
43 |
local jobs=$(echo " ${MAKEOPTS} " | sed -r -n \ |
44 |
-e 's:.*[[:space:]](-[a-z]*j|--jobs[=[:space:]])[[:space:]]*([0-9]+).*:\2:p' || die) |
45 |
- echo ${jobs:-1} |
46 |
+ |
47 |
+ # Fallbacks for if MAKEOPTS parsing failed |
48 |
+ [[ -n ${jobs} ]] || \ |
49 |
+ jobs=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \ |
50 |
+ jobs=$(sysctl -n hw.ncpu 2>/dev/null) || \ |
51 |
+ jobs=1 |
52 |
+ |
53 |
+ echo ${jobs} |
54 |
} |
55 |
|
56 |
# Run ${XARGS} in parallel for detected number of CPUs, if supported. |