[lttng-dev] lttng-tools build failure with uClibc due to dlmopen()

2017-02-28 Thread Thomas Petazzoni
Hello,

First of all, thanks for having fixed the dlmopen issue with musl in
lttng-ust. Now, there is another dlmopen issue, this time in
lttng-tools, and this time with uClibc:

  CC   prog.o
prog.c: In function 'main':
prog.c:24:7: warning: implicit declaration of function 'dlmopen' 
[-Wimplicit-function-declaration]
  h1 = dlmopen(LM_ID_BASE, "libfoo.so", RTLD_LAZY);
   ^
prog.c:24:15: error: 'LM_ID_BASE' undeclared (first use in this function)
  h1 = dlmopen(LM_ID_BASE, "libfoo.so", RTLD_LAZY);
   ^
prog.c:24:15: note: each undeclared identifier is reported only once for each 
function it appears in

See
http://autobuild.buildroot.net/results/c07/c07b5bac6146d83c3224de147da3798d3e7b527f/build-end.log
for the full build log.

So, the ust regression test case in lttng-tools doesn't test if
dlmopen() is provided by the C library before using it.

I guess some additional autoconf/automake conditional is needed here.

Thanks,

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
___
lttng-dev mailing list
lttng-dev@lists.lttng.org
https://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev


[lttng-dev] [PATCH lttng-ust] Fix: (un)install targets of Python agent

2017-02-28 Thread Francis Deslauriers
This Makefile was using Distutils' setup.py to install the Python agent
but was using the Autoconf's $pkgpythondir variable for the uninstall
process. The two folders can be different on some distributions which
made the uninstall attempting to delete a non-existant folder and
effectively not uninstalling.

We now save the paths of the installed files and use this information
during the uninstallation.

Also, we print a warning if the install directory is not included in the
PYTHONPATH variable.

Signed-off-by: Francis Deslauriers 
---
 .gitignore  |  1 +
 python-lttngust/Makefile.am | 22 
 python-lttngust/setup.py.in | 62 +
 3 files changed, 59 insertions(+), 26 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0d322b1..fe43230 100644
--- a/.gitignore
+++ b/.gitignore
@@ -86,3 +86,4 @@ python-lttngust/lttngust/__init__.py
 python-lttngust/**/*.pyc
 python-lttngust/build
 python-lttngust/setup.py
+python-lttngust/installed_files.txt
diff --git a/python-lttngust/Makefile.am b/python-lttngust/Makefile.am
index cc28989..d7c2071 100644
--- a/python-lttngust/Makefile.am
+++ b/python-lttngust/Makefile.am
@@ -1,25 +1,27 @@
 # Use setup.py for the installation instead of Autoconf.
 # This ease the installation process and assure a *pythonic*
 # installation.
-agent_path=lttngust
+INSTALLED_FILES=$(builddir)/installed_files.txt
 all-local:
$(PYTHON) setup.py build --verbose
 
+# This target installs the Python package and saves the path of all the
+# installed files in the INSTALLED_FILES text file to be used during this
+# uninstallation
 install-exec-local:
-   @opts="--prefix=$(prefix) --verbose --no-compile $(DISTSETUPOPTS)"; \
+   @opts="--prefix=$(prefix) --verbose --record $(INSTALLED_FILES) 
--no-compile $(DISTSETUPOPTS)"; \
if [ "$(DESTDIR)" != "" ]; then \
opts="$$opts --root=$(DESTDIR)"; \
fi; \
$(PYTHON) setup.py install $$opts;
 
 clean-local:
-   rm -rf build
+   rm -rf $(builddir)/build
 
+# Distutils' setup.py does not include an uninstall target, we thus need to do
+# it manually. We use the INSTALLED_FILES file produced during the install to
+# clean up the install folder and delete the folder it self.
 uninstall-local:
-   rm -rf $(DESTDIR)$(pkgpythondir)
-
-EXTRA_DIST=$(agent_path)
-
-# Remove automake generated file before dist
-dist-hook:
-   rm -rf $(distdir)/$(agent_path)/__init__.py
+   cat $(INSTALLED_FILES) | xargs rm -rf
+   cat $(INSTALLED_FILES) | $(GREP) "__init__.py" | xargs dirname | xargs 
rmdir
+   rm -f $(INSTALLED_FILES)
diff --git a/python-lttngust/setup.py.in b/python-lttngust/setup.py.in
index 370fd61..89cd5f0 100644
--- a/python-lttngust/setup.py.in
+++ b/python-lttngust/setup.py.in
@@ -15,22 +15,52 @@
 # along with this library; if not, write to the Free Software Foundation, Inc.,
 # 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA
 
+import sys
+
 from distutils.core import setup, Extension
 
+PY_PATH_WARN_MSG = """
+-WARNING
+The install directory used:\n ({})\nis not included in your PYTHONPATH.
+
+To add this directory to your Python search path permanently you can add the
+following command to your .bashrc/.zshrc:
+export PYTHONPATH="${{PYTHONPATH}}:{}"
+
+"""
+
+def main():
+dist = setup(name='lttngust',
+version='@PACKAGE_VERSION@',
+description='LTTng-UST Python agent',
+packages=['lttngust'],
+package_dir={'lttngust': 'lttngust'},
+options={'build': {'build_base': 'build'}},
+url='http://lttng.org',
+license='LGPL-2.1',
+classifiers=[
+'Development Status :: 5 - Production/Stable',
+'Intended Audience :: Developers',
+'License :: OSI Approved :: GNU Lesser General Public License 
v2 (LGPLv2)',
+'Programming Language :: Python :: 2.7',
+'Programming Language :: Python :: 3'
+'Topic :: System :: Logging',
+])
+
+# After the installation, we check that the install directory is included in
+# the Python search path and we print a warning message when it's not. We need
+# to do this because Python search path differs depending on the distro and
+# some distros don't include any `/usr/local/` (the default install prefix) in
+# the search path. This is also useful for out-of-tree installs and tests. It's
+# only relevant to make this check on the `install` command.
+
+if 'install' in dist.command_obj:
+install_dir = dist.command_obj['install'].install_libbase
+if install_dir not in sys.path:
+# We can't consider this an error because if affects every
+#