diff mbox series

[v2] buildtools-tarball: handle missing host pkg-config gracefully

Message ID 20250909074229.1249725-1-dwagenknecht@emlix.com
State New
Headers show
Series [v2] buildtools-tarball: handle missing host pkg-config gracefully | expand

Commit Message

Daniel Wagenknecht Sept. 9, 2025, 7:42 a.m. UTC
The host might not have pkg-config installed, which is OK when using the
buildtools-extended-tarball, since that contains pkg-config. So the command in
the generated environment-setup-* script for setting HOST_PKG_PATH is expected
to fail in some cases without this being an error.

The generated environment-setup-* script might be sourced in a shell with
activated `errexit` option. Prevent the expected failure of this command from
being treated as an error.

The only usage of the HOST_PKG_PATH variable is in this script and already
handles the case of the variable being empty. The variable is not exposed to
anywhere outside this script so the effects of this change are limited to this
script.

Signed-off-by: Daniel Wagenknecht <dwagenknecht@emlix.com>
---

v2:
 - extend commit message to address review comments on unclear impact of the
   change

 meta/recipes-core/meta/buildtools-tarball.bb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Alexander Kanavin Sept. 9, 2025, 7:50 a.m. UTC | #1
Thanks, lgtm.

Alex

On Tue, 9 Sept 2025 at 09:42, Daniel Wagenknecht via
lists.openembedded.org <dwagenknecht=emlix.com@lists.openembedded.org>
wrote:
>
> The host might not have pkg-config installed, which is OK when using the
> buildtools-extended-tarball, since that contains pkg-config. So the command in
> the generated environment-setup-* script for setting HOST_PKG_PATH is expected
> to fail in some cases without this being an error.
>
> The generated environment-setup-* script might be sourced in a shell with
> activated `errexit` option. Prevent the expected failure of this command from
> being treated as an error.
>
> The only usage of the HOST_PKG_PATH variable is in this script and already
> handles the case of the variable being empty. The variable is not exposed to
> anywhere outside this script so the effects of this change are limited to this
> script.
>
> Signed-off-by: Daniel Wagenknecht <dwagenknecht@emlix.com>
> ---
>
> v2:
>  - extend commit message to address review comments on unclear impact of the
>    change
>
>  meta/recipes-core/meta/buildtools-tarball.bb | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/meta/recipes-core/meta/buildtools-tarball.bb b/meta/recipes-core/meta/buildtools-tarball.bb
> index 02117ab84d..61b98c7387 100644
> --- a/meta/recipes-core/meta/buildtools-tarball.bb
> +++ b/meta/recipes-core/meta/buildtools-tarball.bb
> @@ -73,7 +73,7 @@ create_sdk_files:append () {
>         touch $script
>         echo 'export PATH="${SDKPATHNATIVE}${bindir_nativesdk}:${SDKPATHNATIVE}${sbindir_nativesdk}:${SDKPATHNATIVE}${base_bindir_nativesdk}:${SDKPATHNATIVE}${base_sbindir_nativesdk}:$PATH"' >> $script
>         echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script
> -       echo 'HOST_PKG_PATH=$(command -p pkg-config --variable=pc_path pkg-config 2>/dev/null)' >>$script
> +       echo 'HOST_PKG_PATH=$(command -p pkg-config --variable=pc_path pkg-config 2>/dev/null || true)' >>$script
>         echo 'export PKG_CONFIG_LIBDIR=${SDKPATHNATIVE}/${libdir}/pkgconfig:${SDKPATHNATIVE}/${datadir}/pkgconfig:${HOST_PKG_PATH:-/usr/lib/pkgconfig:/usr/share/pkgconfig}' >>$script
>         echo 'unset HOST_PKG_PATH'
>
> --
> 2.49.0
>
>
> -=-=-=-=-=-=-=-=-=-=-=-
> Links: You receive all messages sent to this group.
> View/Reply Online (#223091): https://lists.openembedded.org/g/openembedded-core/message/223091
> Mute This Topic: https://lists.openembedded.org/mt/115146660/1686489
> Group Owner: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [alex.kanavin@gmail.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
diff mbox series

Patch

diff --git a/meta/recipes-core/meta/buildtools-tarball.bb b/meta/recipes-core/meta/buildtools-tarball.bb
index 02117ab84d..61b98c7387 100644
--- a/meta/recipes-core/meta/buildtools-tarball.bb
+++ b/meta/recipes-core/meta/buildtools-tarball.bb
@@ -73,7 +73,7 @@  create_sdk_files:append () {
 	touch $script
 	echo 'export PATH="${SDKPATHNATIVE}${bindir_nativesdk}:${SDKPATHNATIVE}${sbindir_nativesdk}:${SDKPATHNATIVE}${base_bindir_nativesdk}:${SDKPATHNATIVE}${base_sbindir_nativesdk}:$PATH"' >> $script
 	echo 'export OECORE_NATIVE_SYSROOT="${SDKPATHNATIVE}"' >> $script
-	echo 'HOST_PKG_PATH=$(command -p pkg-config --variable=pc_path pkg-config 2>/dev/null)' >>$script
+	echo 'HOST_PKG_PATH=$(command -p pkg-config --variable=pc_path pkg-config 2>/dev/null || true)' >>$script
 	echo 'export PKG_CONFIG_LIBDIR=${SDKPATHNATIVE}/${libdir}/pkgconfig:${SDKPATHNATIVE}/${datadir}/pkgconfig:${HOST_PKG_PATH:-/usr/lib/pkgconfig:/usr/share/pkgconfig}' >>$script
 	echo 'unset HOST_PKG_PATH'