Commit Graph

11 Commits

Author SHA1 Message Date
Nicolas Iooss 07629c0a9f
libselinux,libsemanage: Replace PYSITEDIR with PYTHONLIBDIR
libselinux and libsemanage Makefiles invoke site.getsitepackages() in
order to get the path to the directory /usr/lib/pythonX.Y/site-packages
that matches the Python interpreter chosen with $(PYTHON). This method
is incompatible with Python virtual environments, as described in
https://github.com/pypa/virtualenv/issues/355#issuecomment-10250452 .
This issue has been opened for more than 5 years.

On the contrary python/semanage/ and python/sepolgen/ Makefiles use
distutils.sysconfig.get_python_lib() in order to get the site-packages
path into a variable named PYTHONLIBDIR. This way of computing
PYTHONLIBDIR is compatible with virtual environments and gives the same
result as PYSITEDIR.

As PYTHONLIBDIR works in more cases than PYSITEDIR, make libselinux and
libsemanage Makefiles use it. And as native code is installed (as part
of the SWIG wrapper), use "plat_specific=1" in order to use /usr/lib64
on systems which distinguish /usr/lib64 from /usr/lib.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
Acked-by: Petr Lautrbach <plautrba@redhat.com>
2018-03-17 09:03:33 +01:00
Nicolas Iooss fdd306711a
Travis-CI: do not duplicate $DESTDIR in $PYSITEDIR
Recent commits removed $DESTDIR from $PYSITEDIR in libselinux and
libsemanage:

    -PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site;
    print(site.getsitepackages()[0])')
    +PYSITEDIR ?= $(shell $(PYTHON) -c 'import site;
    print(site.getsitepackages()[0])')

As "site.getsitepackages()" does not work within virtualenvs,
.travis.yml defines PYSITEDIR's value in it and this definition needs to
be updated too.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2018-02-21 22:42:47 +01:00
Nicolas Iooss 1b7073c700 Travis-CI: try working around network issues by retrying downloads
Some Travis-CI builds failed because of issues when downloading
refpolicy files for sepolgen tests. Use curl's option --retry to make
the downloads work when the networking issues are only transient.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-10-26 12:51:33 -07:00
Nicolas Iooss 6d9258e5a0 Travis-CI: fix configuration after September's update
The latest update to Travis-CI build environment splitted sugilite
environment into amethyst and garnet and deprecated sugilite. As garnet
provides tools for languages C and Python, and as it is automatically
selected according to
https://travis-ci.org/fishilico/selinux/jobs/278927391 , remove "group:
sugilite" from Travis-CI configuration file.

This update introduced two issues:

- Ruby 2.1 is no longer provided. As it has reached End Of Life
  according to https://www.ruby-lang.org/en/downloads/, remove it from
  the tested versions

- Python 3.3, 3.4 and 3.5 are no longer installed by default. When
  Travis-CI builds Python projects using these versions, it
  automatically download and extract an archive from
  https://s3.amazonaws.com/travis-python-archives/binaries/ubuntu/14.04/x86_64/.
  Implement this process in .travis.yml directly (because Travis-CI does
  not support multi-language projects which use several versions of C
  compilers and Python and Ruby interpreters).

Last but not least, it is now possible to build with PyPy3. Enable this
interpreter in the build environment matrix.

More information about the Travis-CI update is available at
https://docs.travis-ci.com/user/build-environment-updates/2017-09-06/

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-09-25 12:56:02 -04:00
Nicolas Iooss ff2e36831d Travis-CI: do not test gold linkers with clang
clang does not know -fuse-ld=gold. It only needs -flto, which
automatically adds -plugin=LLVMgold.so to the linker command line, but
this does not work on Travis-CI because the gold linker plugin is not
installed:

    /usr/bin/ld: /usr/local/clang-3.9.0/bin/../lib/LLVMgold.so: error
    loading plugin: /usr/local/clang-3.9.0/bin/../lib/LLVMgold.so:
    cannot open shared object file: No such file or directory

Disable in the build matrix the combination of linking with special
linkers with using clang.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-08-07 10:44:17 -04:00
Nicolas Iooss b1ea812083 Travis-CI: use sugulite environment
Travis-CI provides several environments for Ubuntu 14.04 Trusty. It
chooses the one that best matches the needs defined in .travis.yml
depending on a complex algorithm.

In order to test several C compilers, Python versions and Ruby versions,
we need the full image, which is named "sugulite".

For future reference, there are some notes about using the full image
on https://github.com/travis-ci/packer-templates/pull/454 and
https://github.com/travis-ci/docs-travis-ci-com/issues/1267#issuecomment-316016312
and https://blog.travis-ci.com/2017-06-21-trusty-updates-2017-Q2-launch

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-08-07 10:44:17 -04:00
Nicolas Iooss 1edb93c0ba Travis-CI: test defining CFLAGS, LDFLAGS, etc. on make command line
Some Makefiles rely on adding values to variables like CFLAGS,
LDFLAGS, etc. For example doing "LDFLAGS += -L../src" does not work fine
when LDFLAGS is defined on the command line of "make".

Commits 297877ab88 ("libselinux utils: override LD{FLAGS, LIBS} for
libselinux.so in Makefile") and 15f2740733 ("Makefiles: override
*FLAGS and *LIBS") recently fixed such issues, by introducing keyword
"override" in the relevant Makefile statements.

In order to prevent the fixed issues from appearing again, add a test
case in Travis-CI configuration file. This case adds on make's command
line minimal definitions for CFLAGS and LDFLAGS and empty definitions
for CPPFLAGS and LDLIBS.

An example of build failure due to a missing override in a required
CPPFLAGS addition is provided on
https://travis-ci.org/fishilico/selinux/builds/245107609

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-06-30 08:56:43 -04:00
Nicolas Iooss 9a0279e9e9 Travis-CI: update the list of Ruby's and Python's versions
Travis-CI no longer provides Ruby 2.0 in its Trusty environment (it has
been updated according to
https://blog.travis-ci.com/2017-06-21-trusty-updates-2017-Q2-launch).
Remove this version from .travis.yml.

Moreover Python 3.6 and Ruby 3.4 are available. Test building with them.

Last by not least, pypy virtual environment directory has been renamed
pypy2 (/home/travis/virtualenv/pypy2 is a symbolic link to pypy2-5.6.0).

The updated .travis.yml file has been tested on
https://travis-ci.org/fishilico/selinux/builds/248126824

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-06-30 08:56:43 -04:00
Nicolas Iooss ccfbd9aa17 libsemanage/tests: include libsepol headers from $DESTDIR
When building and running tests on a system without SELinux with a
command similar to "make DESTDIR=/tmp/destdir install test", libsemanage
tests fail to build with the following error:

    In file included from utilities.h:20:0,
                     from utilities.c:24:
    ../src/handle.h:29:26: fatal error: sepol/handle.h: No such file or
    directory
     #include <sepol/handle.h>
                              ^

Fix this by adding the newly-installed directory under $DESTDIR (using
variable $PREFIX) in the search paths of the compiler.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-03-01 10:42:34 -05:00
Nicolas Iooss 1cd3e1a40a libselinux, libsemanage: make PYPREFIX computation more robust
On systems where $PYTHON is python3.5 (instead of python2 or python3),
pkg-config fails to find the Python package because it is named with a
dash (e.g. python-3.5).

Moreover the build system may have been using the pkg-config
configuration files for the wrong Python version when several Python
with the same major version number are installed (e.g. using python-3.5
on a system with both python-3.4 and python-3.5 and where
/usr/lib/pkgconfig/python3.pc is a symlink to python-3.5.pc).

In order to fix these two issues, compute $PYPREFIX from $PYTHON by
using the full major.minor version.

Moreover update Travis-Ci configuration to grab the relevant
configuration files for pkg-config from /opt/python (for example
/opt/python/3.5.2/lib/pkgconfig/python-3.5.pc) instead of using
system-provided files (/usr/lib/x86_64-linux-gnu/pkgconfig/python3.pc
and /usr/lib/x86_64-linux-gnu/pkgconfig/python2.pc).

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-02-21 13:42:52 -05:00
Nicolas Iooss c9adfe2d26 Introduce Travis-CI tests
Add a configuration file for https://travis-ci.org/. This continuous
integration platform can build the project for several configurations on
Linux, using different compilers, linkers, Python versions and Ruby
versions. An example of build results is available on
https://travis-ci.org/fishilico/selinux/builds/185912863

Even if the SELinux userland libraries and tools project does not enable
Travis-CI integration, the .travis.yml file may be helpful for
contributors who wish to run tests in several configurations.

Current limitations:

- It does not run an OS X build. Travis-CI provides free OS X
  environments but it is quite difficult to configure a single
  .travis.yml file which defines many Linux environments and some OS X
  ones.
- It only runs Ubuntu 14.04 with an x86-64 CPU. This does not test
  Android, ARM nor 32-bit x86 configurations.
- It only builds with glibc, not musl or other light C library.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
2017-02-08 10:48:53 -05:00