All of lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/1] package/gnupg2: fix build failure when host provides an old gpgrt-config
@ 2023-02-19 15:04 Julien Olivain
  2023-02-19 20:56 ` Thomas Petazzoni via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain @ 2023-02-19 15:04 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain, Bagas Sanjaya

gnupg2 uses the libgpg-error library. The libgpg-error library has a
long plan to be renamed to "gpgrt" (see [1]). For the transition, it
provides two configuration scripts "gpg-error-config" (the old,
original one, kept for compatibility) and "gpgrt-config" (which is
meant to be the replacement). When both are detected, "gpgrt-config"
should be preferred.

gnupg2 configure script searches for "gpg-error-config" in the path
provided to --with-libgpg-error-prefix=PFX (more specifically, in
"PFX/bin").

The logic to find "gpgrt-config" is different: it is searched in
paths "$prefix/bin:$PATH". See [2]. On Buildroot, autotools target
packages are configured with "--prefix=/usr", which makes the
configure script to search in the host "/usr/bin".

In some host environment providing such a "/usr/bin/gpgrt-config"
script of an older version, host compilation flags are incorrectly
added for the target, which leads to compilation failures.

The issue can be reproduced in a Buildroot Docker image from [3] in
which the libgpg-error-dev package is added. When tested, the
libgpg-error-dev package was at version 1.38.

In that configuration, gnupg2 configure will output the message:

    checking for gpgrt-config... /usr/bin/gpgrt-config

and the compilation fails with a message:

    aarch64-buildroot-linux-gnu-gcc: ERROR: unsafe header/library path used in cross-compilation: '-I/usr/include'

Note: it was observed that in some other configurations in which the
host /usr/bin/gpgrt-config was from libgpg-error version 1.46, the
host script was redirecting correctly in the buildroot sysroot.

Since gnupg2 searches for "gpgrt-config" with a
"AC_PATH_PROG(GPGRT_CONFIG, ...)" macro, this patch fixes this
issue by simply forcing the script path in the GPGRT_CONFIG
environment variable.

See also [4] which discussed the "gpgrt-config" search logic.

Fixes:
- http://autobuild.buildroot.net/results/423c3ce7317c181e9f2e4a49b76ee9d26167375c/
(and many others)

[1] https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgpg-error.git;a=blob;f=README;h=e0b9f16445a96942af0839bcdb9a0b0f8cf31380;hb=885a287a57cf060b4c5b441822c09d23b8dee2bd#l29
[2] https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=m4/gpg-error.m4;h=a975e53d07d1b743f51d8aa1767cd8e0d71b4071;hb=c0556edb80518720b0d884251685fe008c8f0429#l68
[3] https://git.buildroot.org/buildroot/tree/support/docker/Dockerfile?id=b6085c00d0feece6f3ba635e7847ea653bc5fac3
[4] https://dev.gnupg.org/T5365

Reported-by: Bagas Sanjaya <bagasdotme@gmail.com>
Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
Patch tested on master branch at commit b6085c0 with commands:

    make check-package
    ...
    0 warnings generated

    support/testing/run-tests \
        -d dl -o output_folder \
        tests.package.test_gnupg2
    ...
    OK

    utils/docker-run support/testing/run-tests \
        -d dl -o output_folder \
        tests.package.test_gnupg2
    ...
    OK

    utils/test-pkg -p gnupg2
                    bootlin-armv5-uclibc [1/6]: OK
                     bootlin-armv7-glibc [2/6]: OK
                   bootlin-armv7m-uclibc [3/6]: SKIPPED
                     bootlin-x86-64-musl [4/6]: OK
                      br-arm-full-static [5/6]: SKIPPED
                            sourcery-arm [6/6]: OK
    6 builds, 2 skipped, 0 build failed, 0 legal-info failed, 0 show-info failed
---
 package/gnupg2/gnupg2.mk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/package/gnupg2/gnupg2.mk b/package/gnupg2/gnupg2.mk
index 5935ce6939..73de185ba7 100644
--- a/package/gnupg2/gnupg2.mk
+++ b/package/gnupg2/gnupg2.mk
@@ -23,6 +23,10 @@ GNUPG2_CONF_OPTS = \
 	--with-ksba-prefix=$(STAGING_DIR)/usr \
 	--with-npth-prefix=$(STAGING_DIR)/usr
 
+# Force the path to "gpgrt-config" (from the libgpg-error package) to
+# avoid using the one on host, if present.
+GNUPG2_CONF_ENV += GPGRT_CONFIG=$(STAGING_DIR)/usr/bin/gpgrt-config
+
 ifneq ($(BR2_PACKAGE_GNUPG2_GPGV),y)
 define GNUPG2_REMOVE_GPGV
 	rm -f $(TARGET_DIR)/usr/bin/gpgv
-- 
2.39.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [PATCH 1/1] package/gnupg2: fix build failure when host provides an old gpgrt-config
  2023-02-19 15:04 [Buildroot] [PATCH 1/1] package/gnupg2: fix build failure when host provides an old gpgrt-config Julien Olivain
@ 2023-02-19 20:56 ` Thomas Petazzoni via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Petazzoni via buildroot @ 2023-02-19 20:56 UTC (permalink / raw)
  To: Julien Olivain; +Cc: Bagas Sanjaya, buildroot

On Sun, 19 Feb 2023 16:04:26 +0100
Julien Olivain <ju.o@free.fr> wrote:

> gnupg2 uses the libgpg-error library. The libgpg-error library has a
> long plan to be renamed to "gpgrt" (see [1]). For the transition, it
> provides two configuration scripts "gpg-error-config" (the old,
> original one, kept for compatibility) and "gpgrt-config" (which is
> meant to be the replacement). When both are detected, "gpgrt-config"
> should be preferred.
> 
> gnupg2 configure script searches for "gpg-error-config" in the path
> provided to --with-libgpg-error-prefix=PFX (more specifically, in
> "PFX/bin").
> 
> The logic to find "gpgrt-config" is different: it is searched in
> paths "$prefix/bin:$PATH". See [2]. On Buildroot, autotools target
> packages are configured with "--prefix=/usr", which makes the
> configure script to search in the host "/usr/bin".
> 
> In some host environment providing such a "/usr/bin/gpgrt-config"
> script of an older version, host compilation flags are incorrectly
> added for the target, which leads to compilation failures.
> 
> The issue can be reproduced in a Buildroot Docker image from [3] in
> which the libgpg-error-dev package is added. When tested, the
> libgpg-error-dev package was at version 1.38.
> 
> In that configuration, gnupg2 configure will output the message:
> 
>     checking for gpgrt-config... /usr/bin/gpgrt-config
> 
> and the compilation fails with a message:
> 
>     aarch64-buildroot-linux-gnu-gcc: ERROR: unsafe header/library path used in cross-compilation: '-I/usr/include'
> 
> Note: it was observed that in some other configurations in which the
> host /usr/bin/gpgrt-config was from libgpg-error version 1.46, the
> host script was redirecting correctly in the buildroot sysroot.
> 
> Since gnupg2 searches for "gpgrt-config" with a
> "AC_PATH_PROG(GPGRT_CONFIG, ...)" macro, this patch fixes this
> issue by simply forcing the script path in the GPGRT_CONFIG
> environment variable.
> 
> See also [4] which discussed the "gpgrt-config" search logic.
> 
> Fixes:
> - http://autobuild.buildroot.net/results/423c3ce7317c181e9f2e4a49b76ee9d26167375c/
> (and many others)
> 
> [1] https://git.gnupg.org/cgi-bin/gitweb.cgi?p=libgpg-error.git;a=blob;f=README;h=e0b9f16445a96942af0839bcdb9a0b0f8cf31380;hb=885a287a57cf060b4c5b441822c09d23b8dee2bd#l29
> [2] https://git.gnupg.org/cgi-bin/gitweb.cgi?p=gnupg.git;a=blob;f=m4/gpg-error.m4;h=a975e53d07d1b743f51d8aa1767cd8e0d71b4071;hb=c0556edb80518720b0d884251685fe008c8f0429#l68
> [3] https://git.buildroot.org/buildroot/tree/support/docker/Dockerfile?id=b6085c00d0feece6f3ba635e7847ea653bc5fac3
> [4] https://dev.gnupg.org/T5365
> 
> Reported-by: Bagas Sanjaya <bagasdotme@gmail.com>
> Tested-by: Bagas Sanjaya <bagasdotme@gmail.com>
> Signed-off-by: Julien Olivain <ju.o@free.fr>
> ---
> Patch tested on master branch at commit b6085c0 with commands:

Applied to master, thanks.

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-02-19 20:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-19 15:04 [Buildroot] [PATCH 1/1] package/gnupg2: fix build failure when host provides an old gpgrt-config Julien Olivain
2023-02-19 20:56 ` Thomas Petazzoni via buildroot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.