diff options
author | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-09-11 11:01:42 +0200 |
---|---|---|
committer | Michael Olbrich <m.olbrich@pengutronix.de> | 2020-09-11 11:51:08 +0200 |
commit | ee2867017402a411c279095a0bd7669693c98352 (patch) | |
tree | e60b5e2d6b62a8790d558e6fc53f4b9af47b7b48 /scripts | |
parent | 2ac42d72ee7fac6582a4a2fb2e33923ddebc734b (diff) | |
download | ptxdist-ee2867017402a411c279095a0bd7669693c98352.tar.gz ptxdist-ee2867017402a411c279095a0bd7669693c98352.tar.xz |
pkg-config-wrapper: fix a race condition
Currently, pkg-config-wrapper assumes, that if a pkg-config call fails
once, then it will fail again. So if pkg-config fails during the whitelist
check, it just continues and lets the next call to pkg-config produce the
error.
However, this is racy when packages are built in parallel: It can happen,
that the pkg-config whitelist call fails, because the package is not yet
available, and the following 'real' pkg-config call succeeds because the
.pc was installed in between the two calls.
As a result the whitelist check is bypassed. This usually leads to build
errors because followup pkg-config calls to query cflags or libs will be
blocked.
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/pkg-config-wrapper | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/scripts/pkg-config-wrapper b/scripts/pkg-config-wrapper index 79018c63c..53be1a987 100755 --- a/scripts/pkg-config-wrapper +++ b/scripts/pkg-config-wrapper @@ -78,8 +78,15 @@ check_pipe_status() { done } -if [ -n "${PKGCONFIG_WHITELIST_SRC}" ]; then - pkgs="$(pkg-config.real --print-provides "${@}" 2>/dev/null | awk '{print $1}' && check_pipe_status)" && +if [ -n "${PKGCONFIG_WHITELIST_SRC}" -a "${1}" != "--version" -a "${1}" != "--help" ]; then + error="$(mktemp "${PTXDIST_TEMPDIR}/pkg-config.XXXXXX")" + pkgs="$(pkg-config.real --print-provides "${@}" 2> "${error}" | awk '{print $1}' && check_pipe_status)" + if [ $? -ne 0 ]; then + cat "${error}" >&2 + rm "${error}" + exit 1 + fi + rm "${error}" for pkg in ${pkgs}; do if [[ ! " ${whitelist} " =~ " ${pkg} " && ! "${pkg}" =~ '-uninstalled' ]]; then echo "$(basename ${0}): warning: blocking '${pkg}': not selected by '${PKGCONFIG_WHITELIST_SRC}'" >&2 |