All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] avoid refs to sysroot in pkgconfig files
@ 2014-12-18 11:04 Enrico Scholz
  2014-12-18 11:04 ` [PATCH 1/3] insane: added 'pkgconfig-nosysroot' check Enrico Scholz
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Enrico Scholz @ 2014-12-18 11:04 UTC (permalink / raw)
  To: openembedded-core; +Cc: Enrico Scholz

Some pkgconfig files like libkmod.pc or fontconfig.pc contain absolute
paths to sysroot dirs in their Cflags: or Libs: section.  This can
break build of dependent packages because wrong paths will be created.

Patchset tries to detect and fix such issues automatically.  It is
conservative by using $PKG_CONFIG_SYSROOT_DIR instead of $TMPDIR.

Enrico Scholz (3):
  insane: added 'pkgconfig-nosysroot' check
  pkgconfig.bblcass: remove PKG_CONFIG_SYSROOT_DIR from installed .pc
    files
  insane: made 'pkgconfig-nosysroot' check critical

 meta/classes/insane.bbclass    | 16 +++++++++++++++-
 meta/classes/pkgconfig.bbclass | 17 +++++++++++++++++
 2 files changed, 32 insertions(+), 1 deletion(-)

-- 
1.9.3



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

* [PATCH 1/3] insane: added 'pkgconfig-nosysroot' check
  2014-12-18 11:04 [PATCH 0/3] avoid refs to sysroot in pkgconfig files Enrico Scholz
@ 2014-12-18 11:04 ` Enrico Scholz
  2014-12-18 11:04 ` [PATCH 2/3] pkgconfig.bblcass: remove PKG_CONFIG_SYSROOT_DIR from installed .pc files Enrico Scholz
  2014-12-18 11:04 ` [PATCH 3/3] insane: made 'pkgconfig-nosysroot' check critical Enrico Scholz
  2 siblings, 0 replies; 6+ messages in thread
From: Enrico Scholz @ 2014-12-18 11:04 UTC (permalink / raw)
  To: openembedded-core; +Cc: Enrico Scholz

pkgconfig files should not contain references to $PKG_CONFIG_SYSROOT_DIR.
E.g. when a .pc file contains

| Cflags: -I/absolute-path-to-sysroot/usr/include/freetype2

pkgconfig will expand this in the next 'pkgconfig --cflags' call as

| -I/absolute-path-to-sysroot/absolute-path-to-sysroot/usr/include/freetype2

(note the duplicate path).

This patch checks therefore whether installed .pc files contain such
absolute paths.

Because some OE core packages trigger this check (fontconfig, libkmod),
it is only a warning for now.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 meta/classes/insane.bbclass | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index b4bffd2..d327294 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -29,7 +29,7 @@ QA_SANE = "True"
 WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \
             textrel already-stripped incompatible-license files-invalid \
             installed-vs-shipped compile-host-path install-host-path \
-            pn-overrides infodir build-deps file-rdeps \
+            pn-overrides infodir build-deps file-rdeps pkgconfig-nosysroot \
             "
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
@@ -606,6 +606,20 @@ def package_qa_check_symlink_to_sysroot(path, name, d, elf, messages):
                 trimmed = path.replace(os.path.join (d.getVar("PKGDEST", True), name), "")
                 messages["symlink-to-sysroot"] = "Symlink %s in %s points to TMPDIR" % (trimmed, name)
 
+QAPATHTEST[pkgconfig-nosysroot] = "package_qa_check_pkgconfig_nosysroot"
+def package_qa_check_pkgconfig_nosysroot(file, pkgname, d, elf, messages):
+    if not file.endswith('.pc') or os.path.islink(file):
+	return
+
+    sysroot = d.getVar("PKG_CONFIG_SYSROOT_DIR", True)
+    if not sysroot:
+        return
+
+    with open(file) as f:
+        content = f.read()
+        if sysroot in content:
+            messages["pkgconfig-nosysroot"] = "pkgconfig file %s contains absolute reference to sysroot" % package_qa_clean_path(file,d)
+
 def package_qa_check_license(workdir, d):
     """
     Check for changes in the license files 
-- 
1.9.3



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

* [PATCH 2/3] pkgconfig.bblcass: remove PKG_CONFIG_SYSROOT_DIR from installed .pc files
  2014-12-18 11:04 [PATCH 0/3] avoid refs to sysroot in pkgconfig files Enrico Scholz
  2014-12-18 11:04 ` [PATCH 1/3] insane: added 'pkgconfig-nosysroot' check Enrico Scholz
@ 2014-12-18 11:04 ` Enrico Scholz
  2014-12-18 12:03   ` Richard Purdie
  2014-12-18 11:04 ` [PATCH 3/3] insane: made 'pkgconfig-nosysroot' check critical Enrico Scholz
  2 siblings, 1 reply; 6+ messages in thread
From: Enrico Scholz @ 2014-12-18 11:04 UTC (permalink / raw)
  To: openembedded-core; +Cc: Enrico Scholz

Having ${PKG_CONFIG_SYSROOT_DIR} in installed .pc files is nearly
everytime an error because it next 'pkgconfig' call will prepend
${PKG_CONFIG_SYSROOT_DIR} environment variable again resulting into a
duplication and invalidation of paths.

Patch removes this string from installed .pc files.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 meta/classes/pkgconfig.bbclass | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/meta/classes/pkgconfig.bbclass b/meta/classes/pkgconfig.bbclass
index ad1f84f..459a871 100644
--- a/meta/classes/pkgconfig.bbclass
+++ b/meta/classes/pkgconfig.bbclass
@@ -1,2 +1,19 @@
 DEPENDS_prepend = "pkgconfig-native "
 
+PKGCONFIG_FILE_PATTERN ?= "-path '*/pkgconfig/*' -name '*.pc' -type f"
+PKGCONFIG_FILE_PATTERN[doc] = "Options given to the 'find' utility to \
+ iterate over pkgconfig files"
+
+pkgconfig_mangle_pc() {
+    if test -n '${PKG_CONFIG_SYSROOT_DIR}'; then
+	# find .pc files, check and give out whether they contain
+	# the sysroot dir and remove this string
+	find '${D}' ${PKGCONFIG_FILE_PATTERN} \
+	     -exec grep '${PKG_CONFIG_SYSROOT_DIR}' '{}' \; \
+	     -printf "NOTE: removing PKG_CONFIG_SYSROOT_DIR from %P\n" \
+	     -exec sed -i \
+	               -e 's!${PKG_CONFIG_SYSROOT_DIR}!!g' \
+	           '{}' \;
+    fi
+}
+do_install[postfuncs] += "pkgconfig_mangle_pc"
-- 
1.9.3



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

* [PATCH 3/3] insane: made 'pkgconfig-nosysroot' check critical
  2014-12-18 11:04 [PATCH 0/3] avoid refs to sysroot in pkgconfig files Enrico Scholz
  2014-12-18 11:04 ` [PATCH 1/3] insane: added 'pkgconfig-nosysroot' check Enrico Scholz
  2014-12-18 11:04 ` [PATCH 2/3] pkgconfig.bblcass: remove PKG_CONFIG_SYSROOT_DIR from installed .pc files Enrico Scholz
@ 2014-12-18 11:04 ` Enrico Scholz
  2 siblings, 0 replies; 6+ messages in thread
From: Enrico Scholz @ 2014-12-18 11:04 UTC (permalink / raw)
  To: openembedded-core; +Cc: Enrico Scholz

Now, as pkgconfig.bbclass fixes .pc files, this check can be turned
from a warning into an error.

Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 meta/classes/insane.bbclass | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index d327294..c69f1d9 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -29,12 +29,12 @@ QA_SANE = "True"
 WARN_QA ?= "ldflags useless-rpaths rpaths staticdev libdir xorg-driver-abi \
             textrel already-stripped incompatible-license files-invalid \
             installed-vs-shipped compile-host-path install-host-path \
-            pn-overrides infodir build-deps file-rdeps pkgconfig-nosysroot \
+            pn-overrides infodir build-deps file-rdeps \
             "
 ERROR_QA ?= "dev-so debug-deps dev-deps debug-files arch pkgconfig la \
             perms dep-cmp pkgvarcheck perm-config perm-line perm-link \
             split-strip packages-list pkgv-undefined var-undefined \
-            version-going-backwards \
+            version-going-backwards pkgconfig-nosysroot \
             "
 
 ALL_QA = "${WARN_QA} ${ERROR_QA}"
-- 
1.9.3



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

* Re: [PATCH 2/3] pkgconfig.bblcass: remove PKG_CONFIG_SYSROOT_DIR from installed .pc files
  2014-12-18 11:04 ` [PATCH 2/3] pkgconfig.bblcass: remove PKG_CONFIG_SYSROOT_DIR from installed .pc files Enrico Scholz
@ 2014-12-18 12:03   ` Richard Purdie
  2014-12-18 12:47     ` Enrico Scholz
  0 siblings, 1 reply; 6+ messages in thread
From: Richard Purdie @ 2014-12-18 12:03 UTC (permalink / raw)
  To: Enrico Scholz; +Cc: openembedded-core

On Thu, 2014-12-18 at 12:04 +0100, Enrico Scholz wrote:
> Having ${PKG_CONFIG_SYSROOT_DIR} in installed .pc files is nearly
> everytime an error because it next 'pkgconfig' call will prepend
> ${PKG_CONFIG_SYSROOT_DIR} environment variable again resulting into a
> duplication and invalidation of paths.
> 
> Patch removes this string from installed .pc files.
> 
> Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
> ---
>  meta/classes/pkgconfig.bbclass | 17 +++++++++++++++++
>  1 file changed, 17 insertions(+)
> 
> diff --git a/meta/classes/pkgconfig.bbclass b/meta/classes/pkgconfig.bbclass
> index ad1f84f..459a871 100644
> --- a/meta/classes/pkgconfig.bbclass
> +++ b/meta/classes/pkgconfig.bbclass
> @@ -1,2 +1,19 @@
>  DEPENDS_prepend = "pkgconfig-native "
>  
> +PKGCONFIG_FILE_PATTERN ?= "-path '*/pkgconfig/*' -name '*.pc' -type f"
> +PKGCONFIG_FILE_PATTERN[doc] = "Options given to the 'find' utility to \
> + iterate over pkgconfig files"
> +
> +pkgconfig_mangle_pc() {
> +    if test -n '${PKG_CONFIG_SYSROOT_DIR}'; then
> +	# find .pc files, check and give out whether they contain
> +	# the sysroot dir and remove this string
> +	find '${D}' ${PKGCONFIG_FILE_PATTERN} \
> +	     -exec grep '${PKG_CONFIG_SYSROOT_DIR}' '{}' \; \
> +	     -printf "NOTE: removing PKG_CONFIG_SYSROOT_DIR from %P\n" \
> +	     -exec sed -i \
> +	               -e 's!${PKG_CONFIG_SYSROOT_DIR}!!g' \
> +	           '{}' \;
> +    fi
> +}
> +do_install[postfuncs] += "pkgconfig_mangle_pc"

We are *not* going down this route. We should fix the problematic .pc
files which are by definition broken if they're doing this, not start
mangling the .pc files.

The binconfig class is near unmaintainable due to these kinds of
problems, we have no idea which things we need to map and so on. With
pkgconfig, we used to have this madness, we got rid of most of it with
the inclusion of sysroot support in pkgconfig itself.

Cheers,

Richard




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

* Re: [PATCH 2/3] pkgconfig.bblcass: remove PKG_CONFIG_SYSROOT_DIR from installed .pc files
  2014-12-18 12:03   ` Richard Purdie
@ 2014-12-18 12:47     ` Enrico Scholz
  0 siblings, 0 replies; 6+ messages in thread
From: Enrico Scholz @ 2014-12-18 12:47 UTC (permalink / raw)
  To: Richard Purdie; +Cc: openembedded-core

Richard Purdie <richard.purdie@linuxfoundation.org> writes:

>> Patch removes this string from installed .pc files.
>> ...
>> +do_install[postfuncs] += "pkgconfig_mangle_pc"
>
> We are *not* going down this route.

Ok; then just apply the first patch and perhaps the last one.


Enrico


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

end of thread, other threads:[~2014-12-18 12:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-18 11:04 [PATCH 0/3] avoid refs to sysroot in pkgconfig files Enrico Scholz
2014-12-18 11:04 ` [PATCH 1/3] insane: added 'pkgconfig-nosysroot' check Enrico Scholz
2014-12-18 11:04 ` [PATCH 2/3] pkgconfig.bblcass: remove PKG_CONFIG_SYSROOT_DIR from installed .pc files Enrico Scholz
2014-12-18 12:03   ` Richard Purdie
2014-12-18 12:47     ` Enrico Scholz
2014-12-18 11:04 ` [PATCH 3/3] insane: made 'pkgconfig-nosysroot' check critical Enrico Scholz

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.