Skip to contentSkip to conversation

ccid: fix build with pkgconf 1.5.3

PATCH New Fabrice Fontaine 3 participants 8 messages Dec 11, 2018 – Dec 12, 2018

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ccid: fix build with pkgconf 1.5.3

Do not add DESTDIR before usbdropdir to install pcsc drivers in src/Makefile.am.

Indeed, usbdropdir is retrieved from libpcsc.pc and can be prefixed by
sysroot, so it can can be set for example to:
usbdropdir='/accts/mlweber1/rclinux/rc-buildroot-test/scripts/instance-3/output/host/bin/../microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/pcsc/drivers'

If DESTDIR is added before usbdropdir, files will be installed in a wrong directory and build will fail

Fixes:
- http://autobuild.buildroot.org/results/4d4c1ba7f5d00d1b927ac01ef9851468abfbdff2

---
 ...file.am-don-t-use-DESTDIR-with-usbdropdir.patch | 52 ++++++++++++++++++++++
 package/ccid/ccid.mk                               |  2 +
 2 files changed, 54 insertions(+)
 create mode 100644 package/ccid/0001-src-Makefile.am-don-t-use-DESTDIR-with-usbdropdir.patch
package/ccid/0001-src-Makefile.am-don-t-use-DESTDIR-with-usbdropdir.patch new file +52 -0
new file mode 100644
index 0000000000..c47543fb2d
@@ -0,0 +1,52 @@
+From c4ac2f91c2d078ec0d31295ed81bd350e8e2d5bd Mon Sep 17 00:00:00 2001
+From: Fabrice Fontaine <[email protected]>
+Date: Mon, 10 Dec 2018 19:57:07 +0100
+Subject: [PATCH] src/Makefile.am: don't use DESTDIR with usbdropdir
+
+Do not add DESTDIR before usbdropdir to install pcsc drivers in
+src/Makefile.am.
+
+Indeed, usbdropdir is retrieved from libpcsc.pc and can be prefixed by
+sysroot, so it can can be set for example to:
+usbdropdir='/accts/mlweber1/rclinux/rc-buildroot-test/scripts/instance-3/output/host/bin/../microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/pcsc/drivers'
+
+If DESTDIR is added before usbdropdir, files will be installed in a
+wrong directory and build will fail
+
+Fixes:
+ - http://autobuild.buildroot.org/results/4d4c1ba7f5d00d1b927ac01ef9851468abfbdff2
+
+Signed-off-by: Fabrice Fontaine <[email protected]>
+---
+ src/Makefile.am | 8 ++++----
+ 1 file changed, 4 insertions(+), 4 deletions(-)
+
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 99f3567..d987b33 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -86,9 +86,9 @@ Info.plist: Info.plist.src $(srcdir)/../readers/supported_readers.txt
+ DISTCLEANFILES = tokenparser.c Info.plist
+ 
+ install_ccid: libccid.la Info.plist
+-	$(mkinstalldirs) "$(DESTDIR)$(usbdropdir)/$(CCID_BUNDLE)/Contents/$(BUNDLE_HOST)/"
+-	cp Info.plist "$(DESTDIR)$(usbdropdir)/$(CCID_BUNDLE)/Contents/"
+-	cp .libs/$(CCID_LIB) "$(DESTDIR)$(usbdropdir)/$(CCID_BUNDLE)/Contents/$(BUNDLE_HOST)/$(CCID_LIB)"
++	$(mkinstalldirs) "$(usbdropdir)/$(CCID_BUNDLE)/Contents/$(BUNDLE_HOST)/"
++	cp Info.plist "$(usbdropdir)/$(CCID_BUNDLE)/Contents/"
++	cp .libs/$(CCID_LIB) "$(usbdropdir)/$(CCID_BUNDLE)/Contents/$(BUNDLE_HOST)/$(CCID_LIB)"
+ 	$(INSTALL_UDEV_RULE_FILE)
+ 
+ install_ccidtwin: libccidtwin.la
+@@ -102,7 +102,7 @@ install_ccidtwin: libccidtwin.la
+ uninstall: $(LIBS_TO_UNINSTALL)
+ 
+ uninstall_ccid:
+-	rm -rf "$(DESTDIR)$(usbdropdir)/$(CCID_BUNDLE)"
++	rm -rf "$(usbdropdir)/$(CCID_BUNDLE)"
+ 
+ uninstall_ccidtwin:
+ 	rm -f "$(DESTDIR)$(ccidtwindir)/$(CCIDTWIN_LIB)"
+-- 
+2.14.1
+
package/ccid/ccid.mk +2 -0
index c9b95a6234..7da62e5130 100644
@@ -11,6 +11,8 @@ CCID_LICENSE = LGPL-2.1+
 CCID_LICENSE_FILES = COPYING
 CCID_INSTALL_STAGING = YES
 CCID_DEPENDENCIES = pcsc-lite host-pkgconf libusb
+# We're patching src/Makefile.am
+CCID_AUTORECONF = YES
 
 ifeq ($(BR2_PACKAGE_HAS_UDEV),y)
 define CCID_INSTALL_UDEV_RULES
Signature · 1 line
2.14.1
#1 lore raw

PATCH 1/1 ccid: fix build with pkgconf 1.5.3

Quoted 9 lines · Fabrice Fontaine

Do not add DESTDIR before usbdropdir to install pcsc drivers in src/Makefile.am.

Indeed, usbdropdir is retrieved from libpcsc.pc and can be prefixed by
sysroot, so it can can be set for example to:
usbdropdir='/accts/mlweber1/rclinux/rc-buildroot-test/scripts/instance-3/output/host/bin/../microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/pcsc/drivers'

If DESTDIR is added before usbdropdir, files will be installed in a wrong directory and build will fail

I have the feeling this is not the right fix. I think the problem really is
that pkg-config should prefix usbdropdir with sysroot. To me it seems that the right thing to do is to add the sysroot to -L and -I flags, but not to add it to random variables...

Maybe other people who have a better understanding of how pkg-config is
supposed to work can shed some light?

Regards,
Arnout

#2 lore raw

PATCH 1/1 ccid: fix build with pkgconf 1.5.3

Arnout, Fabrice,

On 2018-12-11 19:21 +0100, Arnout Vandecappelle spake thusly:

Quoted 11 lines · Fabrice Fontaine
Quoted 9 lines

Do not add DESTDIR before usbdropdir to install pcsc drivers in src/Makefile.am.

Indeed, usbdropdir is retrieved from libpcsc.pc and can be prefixed by
sysroot, so it can can be set for example to:
usbdropdir='/accts/mlweber1/rclinux/rc-buildroot-test/scripts/instance-3/output/host/bin/../microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/pcsc/drivers'

If DESTDIR is added before usbdropdir, files will be installed in a wrong directory and build will fail

Quoted 7 lines

I have the feeling this is not the right fix. I think the problem really is
that pkg-config should prefix usbdropdir with sysroot. To me it seems that the right thing to do is to add the sysroot to -L and -I flags, but not to add it to random variables...

Maybe other people who have a better understanding of how pkg-config is
supposed to work can shed some light?

Indeed, we must be careful with how we handle pkg-config.

For this specific case, I agree with Arnout: installing a file should always be prefixed by DESTDIR. We should not change that part of a package installation.

There are two conflicting needs: to know where the files are at build time, and to know where they are at runtime.

With pkg-config, there is a mix of both concepts, and they are absolutely not differentiated. That's probably because pkg-config was initially made to be able to provide build-time-only files: headers and libs. But packages (ab)used it to also store and share arbitrary variables, and they expect those locations to be valid both at build time and runtime, which is wrong, as we can see in a lot of cases, such as this one...

Before we bumped pkg-config, we had a patch that would make it prefix a set of carefully selected variables (instead of just -I and -L). But that was probably goign to be an endless whack-a-mole game, and upstream decided to now prefix all variables (again, instead of only -I and -L).

However, I have no good idea on how to solve this situation in a generic way.

Regards,
Yann E. MORIN.

Signature · 6 lines
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 223 225 172 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
#3 lore raw

PATCH 1/1 ccid: fix build with pkgconf 1.5.3

Quoted 19 lines · Yann E. MORIN

Arnout, Fabrice,

On 2018-12-11 19:21 +0100, Arnout Vandecappelle spake thusly:

Quoted 16 lines · Fabrice Fontaine
Quoted 9 lines

Do not add DESTDIR before usbdropdir to install pcsc drivers in src/Makefile.am.

Indeed, usbdropdir is retrieved from libpcsc.pc and can be prefixed by
sysroot, so it can can be set for example to:
usbdropdir='/accts/mlweber1/rclinux/rc-buildroot-test/scripts/instance-3/output/host/bin/../microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/pcsc/drivers'

If DESTDIR is added before usbdropdir, files will be installed in a wrong directory and build will fail

I have the feeling this is not the right fix. I think the problem really is
that pkg-config should prefix usbdropdir with sysroot. To me it seems that the right thing to do is to add the sysroot to -L and -I flags, but not to add it to random variables...

Quoted 8 lines
Quoted 2 lines

Maybe other people who have a better understanding of how pkg-config is
supposed to work can shed some light?

Indeed, we must be careful with how we handle pkg-config.

For this specific case, I agree with Arnout: installing a file should always be prefixed by DESTDIR. We should not change that part of a package installation.

Especially because it is *wrong*, because the files will not be installed in
target...

Quoted 12 lines

There are two conflicting needs: to know where the files are at build time, and to know where they are at runtime.

With pkg-config, there is a mix of both concepts, and they are absolutely not differentiated. That's probably because pkg-config was initially made to be able to provide build-time-only files: headers and libs. But packages (ab)used it to also store and share arbitrary variables, and they expect those locations to be valid both at build time and runtime, which is wrong, as we can see in a lot of cases, such as this one...

Quoted 7 lines

Before we bumped pkg-config, we had a patch that would make it prefix a set of carefully selected variables (instead of just -I and -L). But that was probably goign to be an endless whack-a-mole game, and upstream decided to now prefix all variables (again, instead of only -I and -L).

However, I have no good idea on how to solve this situation in a generic way.

I don't even know how to do it in a specific way :-)

I poked around a bit in pkgconf sources, and this is the fragment that adds the
sysroot:

         if (*value == '/' && client->sysroot_dir != NULL && strncmp(value,
client->sysroot_dir, strlen(client->sysroot_dir)))
                 bptr += pkgconf_strlcpy(buf, client->sysroot_dir, sizeof buf);

This is done unconditionally as far as I can see...

So I see a couple of possibilities...

1. Patch pkgconf to add the sysroot only for a whitelisted set of keys.

2. Mark the not-to-be-prefixed variables in the .pc file in some way, and interpret that mark in pkgconf.

3. Make sure the value in the .pc file doesn't start with / - since there will always be a DESTDIR prefixed to it, we can just make DESTDIR end with /.

4. Do some argument munging in the pkg-config wrapper script and don't set PKG_CONFIG_SYSROOT_DIR if some random variable is requested - probably we capture almost all broken cases by just matching --variable= in the argument list.

I can't say I really like any of these solutions though...

Regards,
Arnout

#4 lore raw

PATCH 1/1 ccid: fix build with pkgconf 1.5.3

Hello,
Le mar. 11 d?c. 2018 ? 22:57, Arnout Vandecappelle <[email protected]> a ?crit :

Quoted 77 lines · Yann E. MORIN
Quoted 19 lines

Arnout, Fabrice,

On 2018-12-11 19:21 +0100, Arnout Vandecappelle spake thusly:

Quoted 16 lines · Fabrice Fontaine
Quoted 9 lines

Do not add DESTDIR before usbdropdir to install pcsc drivers in src/Makefile.am.

Indeed, usbdropdir is retrieved from libpcsc.pc and can be prefixed by
sysroot, so it can can be set for example to:
usbdropdir='/accts/mlweber1/rclinux/rc-buildroot-test/scripts/instance-3/output/host/bin/../microblazeel-buildroot-linux-uclibc/sysroot/usr/lib/pcsc/drivers'

If DESTDIR is added before usbdropdir, files will be installed in a wrong directory and build will fail

I have the feeling this is not the right fix. I think the problem really is
that pkg-config should prefix usbdropdir with sysroot. To me it seems that the right thing to do is to add the sysroot to -L and -I flags, but not to add it to random variables...

Quoted 8 lines
Quoted 2 lines

Maybe other people who have a better understanding of how pkg-config is
supposed to work can shed some light?

Indeed, we must be careful with how we handle pkg-config.

For this specific case, I agree with Arnout: installing a file should always be prefixed by DESTDIR. We should not change that part of a package installation.

Especially because it is *wrong*, because the files will not be installed in
target...

Quoted 12 lines

There are two conflicting needs: to know where the files are at build time, and to know where they are at runtime.

With pkg-config, there is a mix of both concepts, and they are absolutely not differentiated. That's probably because pkg-config was initially made to be able to provide build-time-only files: headers and libs. But packages (ab)used it to also store and share arbitrary variables, and they expect those locations to be valid both at build time and runtime, which is wrong, as we can see in a lot of cases, such as this one...

Quoted 7 lines

Before we bumped pkg-config, we had a patch that would make it prefix a set of carefully selected variables (instead of just -I and -L). But that was probably goign to be an endless whack-a-mole game, and upstream decided to now prefix all variables (again, instead of only -I and -L).

However, I have no good idea on how to solve this situation in a generic way.

I don't even know how to do it in a specific way :-)

I poked around a bit in pkgconf sources, and this is the fragment that adds the
sysroot:

         if (*value == '/' && client->sysroot_dir != NULL && strncmp(value,
client->sysroot_dir, strlen(client->sysroot_dir)))
                 bptr += pkgconf_strlcpy(buf, client->sysroot_dir, sizeof buf);

This is done unconditionally as far as I can see...

So I see a couple of possibilities...

1. Patch pkgconf to add the sysroot only for a whitelisted set of keys.

2. Mark the not-to-be-prefixed variables in the .pc file in some way, and interpret that mark in pkgconf.

3. Make sure the value in the .pc file doesn't start with / - since there will always be a DESTDIR prefixed to it, we can just make DESTDIR end with /.

Quoted 6 lines

4. Do some argument munging in the pkg-config wrapper script and don't set PKG_CONFIG_SYSROOT_DIR if some random variable is requested - probably we capture almost all broken cases by just matching --variable= in the argument list.

I can't say I really like any of these solutions though...

An other option would be to ignore the value provided by pkgconfig. For example, we can pass --enable-usbdropdir=$(TARGET_DIR)/usr/lib/pcsc/drivers to ccid's configure.
Would it be acceptable?

Quoted 3 lines

Regards,
Arnout

Best Regards,

Fabrice

#5 lore raw

PATCH 1/1 ccid: fix build with pkgconf 1.5.3

Quoted 2 lines · Fabrice Fontaine

Hello,
Le mar. 11 d?c. 2018 ? 22:57, Arnout Vandecappelle <[email protected]> a ?crit :

[snip]

Quoted 6 lines
Quoted 1 line

I can't say I really like any of these solutions though...

An other option would be to ignore the value provided by pkgconfig. For example, we can pass --enable-usbdropdir=$(TARGET_DIR)/usr/lib/pcsc/drivers to ccid's configure.
Would it be acceptable?

Since a good fundamental solution will take some time to flesh out, and since
the autobuilders are exploding because of this, it's a great proposal.

However, shouldn't it be --enable-usbdropdir=/usr/lib/pcsc/drivers? DESTDIR is
still prepended to it, no?

Put something like this in the commit message:

Since the bump to 1.5.3, pkgconf prepends the sysroot to all absolute paths found in the .pc file. This is correct when the paths refer to something in STAGING_DIR (e.g. libdir, includedir), but not when it refers to something used for the target.

ccid uses the usbdropdir variable from libpcsclite.pc to decide where to install things. Since DESTDIR is prepended to the install destination, this will end up in the wrong location.

Until a better solution is found in pkgconf, pass the usbdropdir to use explicitly instead of relying on libpcsclite.pc.

BTW, is the libva issue similar?

Regards,
Arnout

#6 lore raw

PATCH 1/1 ccid: fix build with pkgconf 1.5.3

Quoted 13 lines · Arnout Vandecappelle
Quoted 2 lines · Fabrice Fontaine

Hello,
Le mar. 11 d?c. 2018 ? 22:57, Arnout Vandecappelle <[email protected]> a ?crit :

[snip]

Quoted 6 lines
Quoted 1 line

I can't say I really like any of these solutions though...

An other option would be to ignore the value provided by pkgconfig. For example, we can pass --enable-usbdropdir=$(TARGET_DIR)/usr/lib/pcsc/drivers to ccid's configure.
Would it be acceptable?

Quoted 5 lines

Since a good fundamental solution will take some time to flesh out, and since
the autobuilders are exploding because of this, it's a great proposal.

However, shouldn't it be --enable-usbdropdir=/usr/lib/pcsc/drivers? DESTDIR is
still prepended to it, no?

BTW, asccid [1] seems to have a similar issue.

Thanks!

Regards,
Arnout

[1]
http://autobuild.buildroot.net/results/d7f1f368f11da302d8fa2b9268d5ea7bd737b5f2/build-end.log

Quoted 21 lines

Put something like this in the commit message:

Since the bump to 1.5.3, pkgconf prepends the sysroot to all absolute paths found in the .pc file. This is correct when the paths refer to something in STAGING_DIR (e.g. libdir, includedir), but not when it refers to something used for the target.

ccid uses the usbdropdir variable from libpcsclite.pc to decide where to install things. Since DESTDIR is prepended to the install destination, this will end up in the wrong location.

Until a better solution is found in pkgconf, pass the usbdropdir to use explicitly instead of relying on libpcsclite.pc.

BTW, is the libva issue similar?

Regards,
Arnout

#7 lore raw

PATCH 1/1 ccid: fix build with pkgconf 1.5.3

In reply to Arnout Vandecappelle

Dear Arnout,
Le mer. 12 d?c. 2018 ? 09:50, Arnout Vandecappelle <[email protected]> a ?crit :

Quoted 14 lines · Fabrice Fontaine
Quoted 2 lines

Hello,
Le mar. 11 d?c. 2018 ? 22:57, Arnout Vandecappelle <[email protected]> a ?crit :

[snip]

Quoted 6 lines
Quoted 1 line

I can't say I really like any of these solutions though...

An other option would be to ignore the value provided by pkgconfig. For example, we can pass --enable-usbdropdir=$(TARGET_DIR)/usr/lib/pcsc/drivers to ccid's configure.
Would it be acceptable?

Quoted 5 lines

Since a good fundamental solution will take some time to flesh out, and since
the autobuilders are exploding because of this, it's a great proposal.

However, shouldn't it be --enable-usbdropdir=/usr/lib/pcsc/drivers? DESTDIR is
still prepended to it, no?

Yes, you're right.

Quoted 8 lines

Put something like this in the commit message:

Since the bump to 1.5.3, pkgconf prepends the sysroot to all absolute paths found in the .pc file. This is correct when the paths refer to something in STAGING_DIR (e.g. libdir, includedir), but not when it refers to something used for the target.

Quoted 6 lines

ccid uses the usbdropdir variable from libpcsclite.pc to decide where to install things. Since DESTDIR is prepended to the install destination, this will end up in the wrong location.

Until a better solution is found in pkgconf, pass the usbdropdir to use explicitly instead of relying on libpcsclite.pc.

OK, I will do.

Quoted 3 lines

BTW, is the libva issue similar?

It is somewhat similar, the difference is that build won't fail on
install step but in build step because pkgconfig is used to find
wayland-scanner which is built for the target not the host:
/accts/mlweber1/rclinux/rc-buildroot-test/scripts/instance-3/output/host/bin/../arm-buildroot-linux-uclibcgnueabi/sysroot/usr/bin/wayland-scanner

I will also try to fix the other packages: acsccid, iwd, ...

Quoted 3 lines

Regards,
Arnout

Best Regards,

Fabrice