All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] libselinux,libsemanage: use Ruby to define RUBYINC
@ 2016-11-14 21:28 Nicolas Iooss
  2016-11-14 21:28 ` [PATCH 2/4] libselinux,libsemanage: link Ruby wrapper with -lruby Nicolas Iooss
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Nicolas Iooss @ 2016-11-14 21:28 UTC (permalink / raw)
  To: selinux

This makes building libselinux and libsemanage  more robust on systems
with several versions of Ruby installed: when building, only RUBY needs
to be set, without wondering about PKG_CONFIG_PATH or other environment
variables.

Using RbConfig::CONFIG["rubyarchhdrdir"] only works with Ruby >= 2.0 but
since previous Ruby versions are retired since 2015-02-23 this should
not have any impact
(https://www.ruby-lang.org/en/news/2015/02/23/support-for-ruby-1-9-3-has-ended/).

While at it, in libsemanage, use RbConfig::CONFIG["vendorarchdir"] to
install the Ruby extension, like commit 1cd80faa53b6 ("libselinux:
versioned ruby pkg-config and query vendorarchdir properly") did for
libselinux.

My main motivation with this patch is to make the build configuration
easier to define on Travis-CI or other continuous integration platforms.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libselinux/src/Makefile  | 3 +--
 libsemanage/src/Makefile | 6 ++----
 2 files changed, 3 insertions(+), 6 deletions(-)

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 76efe49586c0..4fe1f7002181 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -14,8 +14,7 @@ SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
 PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
-RUBYLIBVER ?= $(shell $(RUBY) -e 'print RUBY_VERSION.split(".")[0..1].join(".")')
-RUBYINC ?= $(shell $(PKG_CONFIG) --exists ruby-$(RUBYLIBVER) && $(PKG_CONFIG) --cflags ruby-$(RUBYLIBVER) || $(PKG_CONFIG) --cflags ruby)
+RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
 RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
 LIBBASE ?= $(shell basename $(LIBDIR))
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
index cd29a8abf5ab..c646f274cbc1 100644
--- a/libsemanage/src/Makefile
+++ b/libsemanage/src/Makefile
@@ -15,10 +15,8 @@ INCLUDEDIR ?= $(PREFIX)/include
 PYLIBVER ?= $(shell $(PYTHON) -c 'import sys;print("python%d.%d" % sys.version_info[0:2])')
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
 PYLIBDIR ?= $(LIBDIR)/$(PYLIBVER)
-RUBYLIBVER ?= $(shell $(RUBY) -e 'print RUBY_VERSION.split(".")[0..1].join(".")')
-RUBYPLATFORM ?= $(shell $(RUBY) -e 'print RUBY_PLATFORM')
-RUBYINC ?= $(shell $(PKG_CONFIG) --cflags ruby-$(RUBYLIBVER))
-RUBYINSTALL ?= $(LIBDIR)/ruby/site_ruby/$(RUBYLIBVER)/$(RUBYPLATFORM)
+RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
+RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
 
 LIBBASE=$(shell basename $(LIBDIR))
 
-- 
2.10.2

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

* [PATCH 2/4] libselinux,libsemanage: link Ruby wrapper with -lruby
  2016-11-14 21:28 [PATCH 1/4] libselinux,libsemanage: use Ruby to define RUBYINC Nicolas Iooss
@ 2016-11-14 21:28 ` Nicolas Iooss
  2017-06-21  9:38   ` [PATCH 2/4] libselinux, libsemanage: " Laurent Bigonville
  2016-11-14 21:28 ` [PATCH 3/4] libsemanage: query for python site-packages dir directly Nicolas Iooss
  2016-11-14 21:28 ` [PATCH 4/4] libselinux,libsemanage: link Python wrapper with Python Nicolas Iooss
  2 siblings, 1 reply; 11+ messages in thread
From: Nicolas Iooss @ 2016-11-14 21:28 UTC (permalink / raw)
  To: selinux

When linking with -Wl,-no-undefined in LDFLAGS (in order to find
possible link-time errors), the Ruby wrapper module needs to be linked
with the libruby.so which is used by $(RUBY). Introduce a new RUBYLIBS
variable to find this library.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libselinux/src/Makefile  | 3 ++-
 libsemanage/src/Makefile | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 4fe1f7002181..82a1010af2d8 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -15,6 +15,7 @@ INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
 PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
 RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
+RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -lruby"')
 RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
 LIBBASE ?= $(shell basename $(LIBDIR))
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a
@@ -133,7 +134,7 @@ $(SWIGSO): $(SWIGLOBJ)
 	$(CC) $(CFLAGS) -shared -o $@ $< -L. -lselinux $(LDFLAGS) -L$(LIBDIR)
 
 $(SWIGRUBYSO): $(SWIGRUBYLOBJ)
-	$(CC) $(CFLAGS) -shared -o $@ $^ -L. -lselinux $(LDFLAGS) -L$(LIBDIR)
+	$(CC) $(CFLAGS) -shared -o $@ $^ -L. -lselinux $(LDFLAGS) $(RUBYLIBS) -L$(LIBDIR)
 
 $(LIBA): $(OBJS)
 	$(AR) rcs $@ $^
diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
index c646f274cbc1..37d6eabbdae8 100644
--- a/libsemanage/src/Makefile
+++ b/libsemanage/src/Makefile
@@ -16,6 +16,7 @@ PYLIBVER ?= $(shell $(PYTHON) -c 'import sys;print("python%d.%d" % sys.version_i
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
 PYLIBDIR ?= $(LIBDIR)/$(PYLIBVER)
 RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
+RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -lruby"')
 RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
 
 LIBBASE=$(shell basename $(LIBDIR))
@@ -82,7 +83,7 @@ $(SWIGSO): $(SWIGLOBJ)
 	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lsemanage -L$(LIBDIR)
 
 $(SWIGRUBYSO): $(SWIGRUBYLOBJ)
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L. -lsemanage -L$(LIBDIR)
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L. -lsemanage $(RUBYLIBS) -L$(LIBDIR)
 
 $(LIBA): $(OBJS)
 	$(AR) rcs $@ $^
-- 
2.10.2

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

* [PATCH 3/4] libsemanage: query for python site-packages dir directly
  2016-11-14 21:28 [PATCH 1/4] libselinux,libsemanage: use Ruby to define RUBYINC Nicolas Iooss
  2016-11-14 21:28 ` [PATCH 2/4] libselinux,libsemanage: link Ruby wrapper with -lruby Nicolas Iooss
@ 2016-11-14 21:28 ` Nicolas Iooss
  2016-11-14 21:28 ` [PATCH 4/4] libselinux,libsemanage: link Python wrapper with Python Nicolas Iooss
  2 siblings, 0 replies; 11+ messages in thread
From: Nicolas Iooss @ 2016-11-14 21:28 UTC (permalink / raw)
  To: selinux

Use the python interpreter to find the install directory, like commit
8162f10e670d ("libselinux: query for python site-packages dir directly")
did for libselinux.

While at it, do not install semanage.py (generated by SWIG) with
executable permission bits.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libsemanage/src/Makefile | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
index 37d6eabbdae8..5c7bc6c6ea65 100644
--- a/libsemanage/src/Makefile
+++ b/libsemanage/src/Makefile
@@ -12,9 +12,8 @@ PREFIX ?= $(DESTDIR)/usr
 LIBDIR ?= $(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
-PYLIBVER ?= $(shell $(PYTHON) -c 'import sys;print("python%d.%d" % sys.version_info[0:2])')
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
-PYLIBDIR ?= $(LIBDIR)/$(PYLIBVER)
+PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
 RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
 RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -lruby"')
 RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts RbConfig::CONFIG["vendorarchdir"]')
@@ -144,9 +143,9 @@ install: all
 	cd $(LIBDIR) && ln -sf $(LIBSO) $(TARGET)
 
 install-pywrap: pywrap 
-	test -d $(PYLIBDIR)/site-packages || install -m 755 -d $(PYLIBDIR)/site-packages
-	install -m 755 $(SWIGSO) $(PYLIBDIR)/site-packages/_semanage.so
-	install -m 755 semanage.py $(PYLIBDIR)/site-packages
+	test -d $(PYSITEDIR) || install -m 755 -d $(PYSITEDIR)
+	install -m 755 $(SWIGSO) $(PYSITEDIR)/_semanage.so
+	install -m 644 semanage.py $(PYSITEDIR)
 
 
 install-rubywrap: rubywrap
-- 
2.10.2

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

* [PATCH 4/4] libselinux,libsemanage: link Python wrapper with Python
  2016-11-14 21:28 [PATCH 1/4] libselinux,libsemanage: use Ruby to define RUBYINC Nicolas Iooss
  2016-11-14 21:28 ` [PATCH 2/4] libselinux,libsemanage: link Ruby wrapper with -lruby Nicolas Iooss
  2016-11-14 21:28 ` [PATCH 3/4] libsemanage: query for python site-packages dir directly Nicolas Iooss
@ 2016-11-14 21:28 ` Nicolas Iooss
  2016-11-15 16:08   ` Stephen Smalley
  2 siblings, 1 reply; 11+ messages in thread
From: Nicolas Iooss @ 2016-11-14 21:28 UTC (permalink / raw)
  To: selinux

When linking with -Wl,-no-undefined in LDFLAGS (in order to find
possible link-time errors), the Python wrapper module needs to be
linked with the right libpython.so. This library is found using
pkg-config in a new PYLIBS variable.

Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
---
 libselinux/src/Makefile  | 5 +++--
 libsemanage/src/Makefile | 3 ++-
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
index 82a1010af2d8..928cc049cedb 100644
--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -13,6 +13,7 @@ LIBDIR ?= $(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
+PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
 PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
 RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
 RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -lruby"')
@@ -131,7 +132,7 @@ $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
 	$(CC) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(SWIGSO): $(SWIGLOBJ)
-	$(CC) $(CFLAGS) -shared -o $@ $< -L. -lselinux $(LDFLAGS) -L$(LIBDIR)
+	$(CC) $(CFLAGS) -shared -o $@ $< -L. -lselinux $(LDFLAGS) $(PYLIBS) -L$(LIBDIR)
 
 $(SWIGRUBYSO): $(SWIGRUBYLOBJ)
 	$(CC) $(CFLAGS) -shared -o $@ $^ -L. -lselinux $(LDFLAGS) $(RUBYLIBS) -L$(LIBDIR)
@@ -154,7 +155,7 @@ $(AUDIT2WHYLOBJ): audit2why.c
 	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
-	$(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBSEPOLA) -L$(LIBDIR)
+	$(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBSEPOLA) $(PYLIBS) -L$(LIBDIR)
 
 %.o:  %.c policy.h
 	$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
index 5c7bc6c6ea65..5176582f654d 100644
--- a/libsemanage/src/Makefile
+++ b/libsemanage/src/Makefile
@@ -13,6 +13,7 @@ LIBDIR ?= $(PREFIX)/lib
 SHLIBDIR ?= $(DESTDIR)/lib
 INCLUDEDIR ?= $(PREFIX)/include
 PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
+PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
 PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
 RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
 RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -lruby"')
@@ -79,7 +80,7 @@ $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
 	$(CC) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<
 
 $(SWIGSO): $(SWIGLOBJ)
-	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lsemanage -L$(LIBDIR)
+	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lsemanage $(PYLIBS) -L$(LIBDIR)
 
 $(SWIGRUBYSO): $(SWIGRUBYLOBJ)
 	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L. -lsemanage $(RUBYLIBS) -L$(LIBDIR)
-- 
2.10.2

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

* Re: [PATCH 4/4] libselinux,libsemanage: link Python wrapper with Python
  2016-11-14 21:28 ` [PATCH 4/4] libselinux,libsemanage: link Python wrapper with Python Nicolas Iooss
@ 2016-11-15 16:08   ` Stephen Smalley
  0 siblings, 0 replies; 11+ messages in thread
From: Stephen Smalley @ 2016-11-15 16:08 UTC (permalink / raw)
  To: Nicolas Iooss, selinux

On 11/14/2016 04:28 PM, Nicolas Iooss wrote:
> When linking with -Wl,-no-undefined in LDFLAGS (in order to find
> possible link-time errors), the Python wrapper module needs to be
> linked with the right libpython.so. This library is found using
> pkg-config in a new PYLIBS variable.
> 
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

Thanks, applied all four.

> ---
>  libselinux/src/Makefile  | 5 +++--
>  libsemanage/src/Makefile | 3 ++-
>  2 files changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> index 82a1010af2d8..928cc049cedb 100644
> --- a/libselinux/src/Makefile
> +++ b/libselinux/src/Makefile
> @@ -13,6 +13,7 @@ LIBDIR ?= $(PREFIX)/lib
>  SHLIBDIR ?= $(DESTDIR)/lib
>  INCLUDEDIR ?= $(PREFIX)/include
>  PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
> +PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
>  PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
>  RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
>  RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -lruby"')
> @@ -131,7 +132,7 @@ $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
>  	$(CC) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<
>  
>  $(SWIGSO): $(SWIGLOBJ)
> -	$(CC) $(CFLAGS) -shared -o $@ $< -L. -lselinux $(LDFLAGS) -L$(LIBDIR)
> +	$(CC) $(CFLAGS) -shared -o $@ $< -L. -lselinux $(LDFLAGS) $(PYLIBS) -L$(LIBDIR)
>  
>  $(SWIGRUBYSO): $(SWIGRUBYLOBJ)
>  	$(CC) $(CFLAGS) -shared -o $@ $^ -L. -lselinux $(LDFLAGS) $(RUBYLIBS) -L$(LIBDIR)
> @@ -154,7 +155,7 @@ $(AUDIT2WHYLOBJ): audit2why.c
>  	$(CC) $(filter-out -Werror, $(CFLAGS)) $(PYINC) -fPIC -DSHARED -c -o $@ $<
>  
>  $(AUDIT2WHYSO): $(AUDIT2WHYLOBJ)
> -	$(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBSEPOLA) -L$(LIBDIR)
> +	$(CC) $(CFLAGS) -shared -o $@ $^ -L. $(LDFLAGS) -lselinux $(LIBSEPOLA) $(PYLIBS) -L$(LIBDIR)
>  
>  %.o:  %.c policy.h
>  	$(CC) $(CFLAGS) $(TLSFLAGS) -c -o $@ $<
> diff --git a/libsemanage/src/Makefile b/libsemanage/src/Makefile
> index 5c7bc6c6ea65..5176582f654d 100644
> --- a/libsemanage/src/Makefile
> +++ b/libsemanage/src/Makefile
> @@ -13,6 +13,7 @@ LIBDIR ?= $(PREFIX)/lib
>  SHLIBDIR ?= $(DESTDIR)/lib
>  INCLUDEDIR ?= $(PREFIX)/include
>  PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
> +PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
>  PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
>  RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
>  RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -lruby"')
> @@ -79,7 +80,7 @@ $(SWIGRUBYLOBJ): $(SWIGRUBYCOUT)
>  	$(CC) $(CFLAGS) $(SWIG_CFLAGS) $(RUBYINC) -fPIC -DSHARED -c -o $@ $<
>  
>  $(SWIGSO): $(SWIGLOBJ)
> -	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lsemanage -L$(LIBDIR)
> +	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $< -L. -lsemanage $(PYLIBS) -L$(LIBDIR)
>  
>  $(SWIGRUBYSO): $(SWIGRUBYLOBJ)
>  	$(CC) $(CFLAGS) $(LDFLAGS) -shared -o $@ $^ -L. -lsemanage $(RUBYLIBS) -L$(LIBDIR)
> 

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

* Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
  2016-11-14 21:28 ` [PATCH 2/4] libselinux,libsemanage: link Ruby wrapper with -lruby Nicolas Iooss
@ 2017-06-21  9:38   ` Laurent Bigonville
  2017-06-21 13:42     ` Stephen Smalley
  0 siblings, 1 reply; 11+ messages in thread
From: Laurent Bigonville @ 2017-06-21  9:38 UTC (permalink / raw)
  To: Nicolas Iooss, selinux

Hello,

Le 14/11/16 à 22:28, Nicolas Iooss a écrit :
> When linking with -Wl,-no-undefined in LDFLAGS (in order to find
> possible link-time errors), the Ruby wrapper module needs to be linked
> with the libruby.so which is used by $(RUBY). Introduce a new RUBYLIBS
> variable to find this library.
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> ---
>   libselinux/src/Makefile  | 3 ++-
>   libsemanage/src/Makefile | 3 ++-
>   2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> index 4fe1f7002181..82a1010af2d8 100644
> --- a/libselinux/src/Makefile
> +++ b/libselinux/src/Makefile
> @@ -15,6 +15,7 @@ INCLUDEDIR ?= $(PREFIX)/include
>   PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
>   PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')
>   RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" + RbConfig::CONFIG["rubyarchhdrdir"] + " -I" + RbConfig::CONFIG["rubyhdrdir"]')
> +RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" + RbConfig::CONFIG["libdir"] + " -lruby"')

I'm trying to package 2.7-rc2 in debian and unfortunately this is not 
working out of the box for me. The library is not installed as -lruby 
but as -lruby-2.3 (for ruby 2.3). In addition the lib is not installed 
in /usr/lib.

I can see in the RbConfig::CONFIG hash a key called LIBRUBYARG_SHARED or 
LIBRUBYARG which contains "-lruby-2.3". Also I see a "archlibdir" or 
"sitearchlibdir" key which contains the correct path to the lib (the 
multiarch path)

RUBYLIBS ?= $(shell $@ -e 'puts "-L" + RbConfig::CONFIG["archlibdir"] + 
" " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')

Could this be a possible alternatives for the other distributions?

Regards,

Laurent Bigonville

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

* Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
  2017-06-21  9:38   ` [PATCH 2/4] libselinux, libsemanage: " Laurent Bigonville
@ 2017-06-21 13:42     ` Stephen Smalley
  2017-06-21 14:02       ` Nicolas Iooss
  0 siblings, 1 reply; 11+ messages in thread
From: Stephen Smalley @ 2017-06-21 13:42 UTC (permalink / raw)
  To: Laurent Bigonville, Nicolas Iooss, selinux

On Wed, 2017-06-21 at 11:38 +0200, Laurent Bigonville wrote:
> Hello,
> 
> Le 14/11/16 à 22:28, Nicolas Iooss a écrit :
> > When linking with -Wl,-no-undefined in LDFLAGS (in order to find
> > possible link-time errors), the Ruby wrapper module needs to be
> > linked
> > with the libruby.so which is used by $(RUBY). Introduce a new
> > RUBYLIBS
> > variable to find this library.
> > 
> > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> > ---
> >   libselinux/src/Makefile  | 3 ++-
> >   libsemanage/src/Makefile | 3 ++-
> >   2 files changed, 4 insertions(+), 2 deletions(-)
> > 
> > diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> > index 4fe1f7002181..82a1010af2d8 100644
> > --- a/libselinux/src/Makefile
> > +++ b/libselinux/src/Makefile
> > @@ -15,6 +15,7 @@ INCLUDEDIR ?= $(PREFIX)/include
> >   PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
> >   PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site;
> > print(site.getsitepackages()[0])')
> >   RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" +
> > RbConfig::CONFIG["rubyarchhdrdir"] + " -I" +
> > RbConfig::CONFIG["rubyhdrdir"]')
> > +RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" +
> > RbConfig::CONFIG["libdir"] + " -lruby"')
> 
> I'm trying to package 2.7-rc2 in debian and unfortunately this is
> not 
> working out of the box for me. The library is not installed as
> -lruby 
> but as -lruby-2.3 (for ruby 2.3). In addition the lib is not
> installed 
> in /usr/lib.
> 
> I can see in the RbConfig::CONFIG hash a key called LIBRUBYARG_SHARED
> or 
> LIBRUBYARG which contains "-lruby-2.3". Also I see a "archlibdir" or 
> "sitearchlibdir" key which contains the correct path to the lib (the 
> multiarch path)
> 
> RUBYLIBS ?= $(shell $@ -e 'puts "-L" + RbConfig::CONFIG["archlibdir"]
> + 
> " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
> 
> Could this be a possible alternatives for the other distributions?

Assuming you mean $(RUBY) rather than $@ above, that works for me on
Fedora:
$ ruby -e 'puts "-L" + RbConfig::CONFIG["archlibdir"] + " " +
RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
-L/usr/lib64 -lruby

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

* Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
  2017-06-21 13:42     ` Stephen Smalley
@ 2017-06-21 14:02       ` Nicolas Iooss
  2017-06-21 14:27         ` Jason Zaman
  0 siblings, 1 reply; 11+ messages in thread
From: Nicolas Iooss @ 2017-06-21 14:02 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: Laurent Bigonville, selinux

On Wed, Jun 21, 2017 at 3:42 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> On Wed, 2017-06-21 at 11:38 +0200, Laurent Bigonville wrote:
>> Hello,
>>
>> Le 14/11/16 à 22:28, Nicolas Iooss a écrit :
>> > When linking with -Wl,-no-undefined in LDFLAGS (in order to find
>> > possible link-time errors), the Ruby wrapper module needs to be
>> > linked
>> > with the libruby.so which is used by $(RUBY). Introduce a new
>> > RUBYLIBS
>> > variable to find this library.
>> >
>> > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>> > ---
>> >   libselinux/src/Makefile  | 3 ++-
>> >   libsemanage/src/Makefile | 3 ++-
>> >   2 files changed, 4 insertions(+), 2 deletions(-)
>> >
>> > diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
>> > index 4fe1f7002181..82a1010af2d8 100644
>> > --- a/libselinux/src/Makefile
>> > +++ b/libselinux/src/Makefile
>> > @@ -15,6 +15,7 @@ INCLUDEDIR ?= $(PREFIX)/include
>> >   PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
>> >   PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site;
>> > print(site.getsitepackages()[0])')
>> >   RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" +
>> > RbConfig::CONFIG["rubyarchhdrdir"] + " -I" +
>> > RbConfig::CONFIG["rubyhdrdir"]')
>> > +RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" +
>> > RbConfig::CONFIG["libdir"] + " -lruby"')
>>
>> I'm trying to package 2.7-rc2 in debian and unfortunately this is
>> not
>> working out of the box for me. The library is not installed as
>> -lruby
>> but as -lruby-2.3 (for ruby 2.3). In addition the lib is not
>> installed
>> in /usr/lib.
>>
>> I can see in the RbConfig::CONFIG hash a key called LIBRUBYARG_SHARED
>> or
>> LIBRUBYARG which contains "-lruby-2.3". Also I see a "archlibdir" or
>> "sitearchlibdir" key which contains the correct path to the lib (the
>> multiarch path)
>>
>> RUBYLIBS ?= $(shell $@ -e 'puts "-L" + RbConfig::CONFIG["archlibdir"]
>> +
>> " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
>>
>> Could this be a possible alternatives for the other distributions?
>
> Assuming you mean $(RUBY) rather than $@ above, that works for me on
> Fedora:
> $ ruby -e 'puts "-L" + RbConfig::CONFIG["archlibdir"] + " " +
> RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
> -L/usr/lib64 -lruby

On Arch Linux:

$ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG"]'
-lruby
$ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
-lruby
$ ruby -e 'puts RbConfig::CONFIG["archlibdir"]'
/usr/lib/x86_64-linux
$ ls -l /usr/lib/x86_64-linux/libruby.so
ls: cannot access '/usr/lib/x86_64-linux/libruby.so': No such file or directory
$ ruby -e 'puts RbConfig::CONFIG["libdir"]'
/usr/lib
$ ls -l /usr/lib/libruby.so
lrwxrwxrwx 1 root root 16 2017-04-22 15:40 /usr/lib/libruby.so ->
libruby.so.2.4.1*

So replacing -lruby with RbConfig::CONFIG["LIBRUBYARG_SHARED"] and
adding "-L" + RbConfig::CONFIG["archlibdir"] in RUBYLIBS definition
seem to work fine.

Nicolas

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

* Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
  2017-06-21 14:02       ` Nicolas Iooss
@ 2017-06-21 14:27         ` Jason Zaman
  2017-06-23 14:14           ` Stephen Smalley
  0 siblings, 1 reply; 11+ messages in thread
From: Jason Zaman @ 2017-06-21 14:27 UTC (permalink / raw)
  To: Nicolas Iooss; +Cc: Stephen Smalley, selinux

On Wed, Jun 21, 2017 at 04:02:29PM +0200, Nicolas Iooss wrote:
> On Wed, Jun 21, 2017 at 3:42 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> > On Wed, 2017-06-21 at 11:38 +0200, Laurent Bigonville wrote:
> >> Hello,
> >>
> >> Le 14/11/16 à 22:28, Nicolas Iooss a écrit :
> >> > When linking with -Wl,-no-undefined in LDFLAGS (in order to find
> >> > possible link-time errors), the Ruby wrapper module needs to be
> >> > linked
> >> > with the libruby.so which is used by $(RUBY). Introduce a new
> >> > RUBYLIBS
> >> > variable to find this library.
> >> >
> >> > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> >> > ---
> >> >   libselinux/src/Makefile  | 3 ++-
> >> >   libsemanage/src/Makefile | 3 ++-
> >> >   2 files changed, 4 insertions(+), 2 deletions(-)
> >> >
> >> > diff --git a/libselinux/src/Makefile b/libselinux/src/Makefile
> >> > index 4fe1f7002181..82a1010af2d8 100644
> >> > --- a/libselinux/src/Makefile
> >> > +++ b/libselinux/src/Makefile
> >> > @@ -15,6 +15,7 @@ INCLUDEDIR ?= $(PREFIX)/include
> >> >   PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
> >> >   PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site;
> >> > print(site.getsitepackages()[0])')
> >> >   RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" +
> >> > RbConfig::CONFIG["rubyarchhdrdir"] + " -I" +
> >> > RbConfig::CONFIG["rubyhdrdir"]')
> >> > +RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" +
> >> > RbConfig::CONFIG["libdir"] + " -lruby"')
> >>
> >> I'm trying to package 2.7-rc2 in debian and unfortunately this is
> >> not
> >> working out of the box for me. The library is not installed as
> >> -lruby
> >> but as -lruby-2.3 (for ruby 2.3). In addition the lib is not
> >> installed
> >> in /usr/lib.
> >>
> >> I can see in the RbConfig::CONFIG hash a key called LIBRUBYARG_SHARED
> >> or
> >> LIBRUBYARG which contains "-lruby-2.3". Also I see a "archlibdir" or
> >> "sitearchlibdir" key which contains the correct path to the lib (the
> >> multiarch path)
> >>
> >> RUBYLIBS ?= $(shell $@ -e 'puts "-L" + RbConfig::CONFIG["archlibdir"]
> >> +
> >> " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
> >>
> >> Could this be a possible alternatives for the other distributions?
> >
> > Assuming you mean $(RUBY) rather than $@ above, that works for me on
> > Fedora:
> > $ ruby -e 'puts "-L" + RbConfig::CONFIG["archlibdir"] + " " +
> > RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
> > -L/usr/lib64 -lruby
> 
> On Arch Linux:
> 
> $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG"]'
> -lruby
> $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
> -lruby
> $ ruby -e 'puts RbConfig::CONFIG["archlibdir"]'
> /usr/lib/x86_64-linux
> $ ls -l /usr/lib/x86_64-linux/libruby.so
> ls: cannot access '/usr/lib/x86_64-linux/libruby.so': No such file or directory
> $ ruby -e 'puts RbConfig::CONFIG["libdir"]'
> /usr/lib
> $ ls -l /usr/lib/libruby.so
> lrwxrwxrwx 1 root root 16 2017-04-22 15:40 /usr/lib/libruby.so ->
> libruby.so.2.4.1*
> 
> So replacing -lruby with RbConfig::CONFIG["LIBRUBYARG_SHARED"] and
> adding "-L" + RbConfig::CONFIG["archlibdir"] in RUBYLIBS definition
> seem to work fine.
> 
> Nicolas

Heres gentoo:
$ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG"]'
-lruby21
$ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
-lruby21
$ ruby -e 'puts RbConfig::CONFIG["archlibdir"]'
/usr/lib64/x86_64-linux
$ stat /usr/lib64/x86_64-linux
stat: cannot stat '/usr/lib64/x86_64-linux': No such file or directory
$ ruby -e 'puts RbConfig::CONFIG["libdir"]'
/usr/lib64
$ ls -l /usr/lib64/libruby2*
-rw-r--r--. 1 root root 4078832 May  8 16:27 /usr/lib64/libruby21-static.a
lrwxrwxrwx. 1 root root      18 May  8 16:27 /usr/lib64/libruby21.so -> libruby21.so.2.1.0*
lrwxrwxrwx. 1 root root      18 May  8 16:27 /usr/lib64/libruby21.so.2.1 -> libruby21.so.2.1.0*
-rwxr-xr-x. 1 root root 2506160 May  8 16:27 /usr/lib64/libruby21.so.2.1.0*
-rw-r--r--. 1 root root 4588894 May  6 12:28 /usr/lib64/libruby22-static.a
lrwxrwxrwx. 1 root root      18 May  6 12:28 /usr/lib64/libruby22.so -> libruby22.so.2.2.0*
lrwxrwxrwx. 1 root root      18 May  6 12:28 /usr/lib64/libruby22.so.2.2 -> libruby22.so.2.2.0*
-rwxr-xr-x. 1 root root 2622488 May  6 12:28 /usr/lib64/libruby22.so.2.2.0*

$ qlist -Iv ruby
...
dev-lang/ruby-2.1.9
dev-lang/ruby-2.2.6

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

* Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
  2017-06-21 14:27         ` Jason Zaman
@ 2017-06-23 14:14           ` Stephen Smalley
  2017-06-26 21:08             ` Nicolas Iooss
  0 siblings, 1 reply; 11+ messages in thread
From: Stephen Smalley @ 2017-06-23 14:14 UTC (permalink / raw)
  To: Jason Zaman, Nicolas Iooss; +Cc: selinux

On Wed, 2017-06-21 at 22:27 +0800, Jason Zaman wrote:
> On Wed, Jun 21, 2017 at 04:02:29PM +0200, Nicolas Iooss wrote:
> > On Wed, Jun 21, 2017 at 3:42 PM, Stephen Smalley <sds@tycho.nsa.gov
> > > wrote:
> > > On Wed, 2017-06-21 at 11:38 +0200, Laurent Bigonville wrote:
> > > > Hello,
> > > > 
> > > > Le 14/11/16 à 22:28, Nicolas Iooss a écrit :
> > > > > When linking with -Wl,-no-undefined in LDFLAGS (in order to
> > > > > find
> > > > > possible link-time errors), the Ruby wrapper module needs to
> > > > > be
> > > > > linked
> > > > > with the libruby.so which is used by $(RUBY). Introduce a new
> > > > > RUBYLIBS
> > > > > variable to find this library.
> > > > > 
> > > > > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
> > > > > ---
> > > > >   libselinux/src/Makefile  | 3 ++-
> > > > >   libsemanage/src/Makefile | 3 ++-
> > > > >   2 files changed, 4 insertions(+), 2 deletions(-)
> > > > > 
> > > > > diff --git a/libselinux/src/Makefile
> > > > > b/libselinux/src/Makefile
> > > > > index 4fe1f7002181..82a1010af2d8 100644
> > > > > --- a/libselinux/src/Makefile
> > > > > +++ b/libselinux/src/Makefile
> > > > > @@ -15,6 +15,7 @@ INCLUDEDIR ?= $(PREFIX)/include
> > > > >   PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
> > > > >   PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site;
> > > > > print(site.getsitepackages()[0])')
> > > > >   RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" +
> > > > > RbConfig::CONFIG["rubyarchhdrdir"] + " -I" +
> > > > > RbConfig::CONFIG["rubyhdrdir"]')
> > > > > +RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" +
> > > > > RbConfig::CONFIG["libdir"] + " -lruby"')
> > > > 
> > > > I'm trying to package 2.7-rc2 in debian and unfortunately this
> > > > is
> > > > not
> > > > working out of the box for me. The library is not installed as
> > > > -lruby
> > > > but as -lruby-2.3 (for ruby 2.3). In addition the lib is not
> > > > installed
> > > > in /usr/lib.
> > > > 
> > > > I can see in the RbConfig::CONFIG hash a key called
> > > > LIBRUBYARG_SHARED
> > > > or
> > > > LIBRUBYARG which contains "-lruby-2.3". Also I see a
> > > > "archlibdir" or
> > > > "sitearchlibdir" key which contains the correct path to the lib
> > > > (the
> > > > multiarch path)
> > > > 
> > > > RUBYLIBS ?= $(shell $@ -e 'puts "-L" +
> > > > RbConfig::CONFIG["archlibdir"]
> > > > +
> > > > " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
> > > > 
> > > > Could this be a possible alternatives for the other
> > > > distributions?
> > > 
> > > Assuming you mean $(RUBY) rather than $@ above, that works for me
> > > on
> > > Fedora:
> > > $ ruby -e 'puts "-L" + RbConfig::CONFIG["archlibdir"] + " " +
> > > RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
> > > -L/usr/lib64 -lruby
> > 
> > On Arch Linux:
> > 
> > $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG"]'
> > -lruby
> > $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
> > -lruby
> > $ ruby -e 'puts RbConfig::CONFIG["archlibdir"]'
> > /usr/lib/x86_64-linux
> > $ ls -l /usr/lib/x86_64-linux/libruby.so
> > ls: cannot access '/usr/lib/x86_64-linux/libruby.so': No such file
> > or directory
> > $ ruby -e 'puts RbConfig::CONFIG["libdir"]'
> > /usr/lib
> > $ ls -l /usr/lib/libruby.so
> > lrwxrwxrwx 1 root root 16 2017-04-22 15:40 /usr/lib/libruby.so ->
> > libruby.so.2.4.1*
> > 
> > So replacing -lruby with RbConfig::CONFIG["LIBRUBYARG_SHARED"] and
> > adding "-L" + RbConfig::CONFIG["archlibdir"] in RUBYLIBS definition
> > seem to work fine.
> > 
> > Nicolas
> 
> Heres gentoo:
> $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG"]'
> -lruby21
> $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
> -lruby21
> $ ruby -e 'puts RbConfig::CONFIG["archlibdir"]'
> /usr/lib64/x86_64-linux
> $ stat /usr/lib64/x86_64-linux
> stat: cannot stat '/usr/lib64/x86_64-linux': No such file or
> directory
> $ ruby -e 'puts RbConfig::CONFIG["libdir"]'
> /usr/lib64
> $ ls -l /usr/lib64/libruby2*
> -rw-r--r--. 1 root root 4078832 May  8 16:27 /usr/lib64/libruby21-
> static.a
> lrwxrwxrwx. 1 root root      18 May  8 16:27 /usr/lib64/libruby21.so
> -> libruby21.so.2.1.0*
> lrwxrwxrwx. 1 root root      18 May  8 16:27
> /usr/lib64/libruby21.so.2.1 -> libruby21.so.2.1.0*
> -rwxr-xr-x. 1 root root 2506160 May  8 16:27
> /usr/lib64/libruby21.so.2.1.0*
> -rw-r--r--. 1 root root 4588894 May  6 12:28 /usr/lib64/libruby22-
> static.a
> lrwxrwxrwx. 1 root root      18 May  6 12:28 /usr/lib64/libruby22.so
> -> libruby22.so.2.2.0*
> lrwxrwxrwx. 1 root root      18 May  6 12:28
> /usr/lib64/libruby22.so.2.2 -> libruby22.so.2.2.0*
> -rwxr-xr-x. 1 root root 2622488 May  6 12:28
> /usr/lib64/libruby22.so.2.2.0*
> 
> $ qlist -Iv ruby
> ...
> dev-lang/ruby-2.1.9
> dev-lang/ruby-2.2.6

So, what's the conclusion?  Do we have a consensus on replacing it as
proposed?  Looks like from the output above that archlibdir doesn't
actually work on gentoo or arch since the file doesn't exist there?

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

* Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
  2017-06-23 14:14           ` Stephen Smalley
@ 2017-06-26 21:08             ` Nicolas Iooss
  0 siblings, 0 replies; 11+ messages in thread
From: Nicolas Iooss @ 2017-06-26 21:08 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: Jason Zaman, selinux

On Fri, Jun 23, 2017 at 4:14 PM, Stephen Smalley <sds@tycho.nsa.gov> wrote:
> On Wed, 2017-06-21 at 22:27 +0800, Jason Zaman wrote:
>> On Wed, Jun 21, 2017 at 04:02:29PM +0200, Nicolas Iooss wrote:
>> > On Wed, Jun 21, 2017 at 3:42 PM, Stephen Smalley <sds@tycho.nsa.gov
>> > > wrote:
>> > > On Wed, 2017-06-21 at 11:38 +0200, Laurent Bigonville wrote:
>> > > > Hello,
>> > > >
>> > > > Le 14/11/16 à 22:28, Nicolas Iooss a écrit :
>> > > > > When linking with -Wl,-no-undefined in LDFLAGS (in order to
>> > > > > find
>> > > > > possible link-time errors), the Ruby wrapper module needs to
>> > > > > be
>> > > > > linked
>> > > > > with the libruby.so which is used by $(RUBY). Introduce a new
>> > > > > RUBYLIBS
>> > > > > variable to find this library.
>> > > > >
>> > > > > Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>
>> > > > > ---
>> > > > >   libselinux/src/Makefile  | 3 ++-
>> > > > >   libsemanage/src/Makefile | 3 ++-
>> > > > >   2 files changed, 4 insertions(+), 2 deletions(-)
>> > > > >
>> > > > > diff --git a/libselinux/src/Makefile
>> > > > > b/libselinux/src/Makefile
>> > > > > index 4fe1f7002181..82a1010af2d8 100644
>> > > > > --- a/libselinux/src/Makefile
>> > > > > +++ b/libselinux/src/Makefile
>> > > > > @@ -15,6 +15,7 @@ INCLUDEDIR ?= $(PREFIX)/include
>> > > > >   PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX))
>> > > > >   PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site;
>> > > > > print(site.getsitepackages()[0])')
>> > > > >   RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" +
>> > > > > RbConfig::CONFIG["rubyarchhdrdir"] + " -I" +
>> > > > > RbConfig::CONFIG["rubyhdrdir"]')
>> > > > > +RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" +
>> > > > > RbConfig::CONFIG["libdir"] + " -lruby"')
>> > > >
>> > > > I'm trying to package 2.7-rc2 in debian and unfortunately this
>> > > > is
>> > > > not
>> > > > working out of the box for me. The library is not installed as
>> > > > -lruby
>> > > > but as -lruby-2.3 (for ruby 2.3). In addition the lib is not
>> > > > installed
>> > > > in /usr/lib.
>> > > >
>> > > > I can see in the RbConfig::CONFIG hash a key called
>> > > > LIBRUBYARG_SHARED
>> > > > or
>> > > > LIBRUBYARG which contains "-lruby-2.3". Also I see a
>> > > > "archlibdir" or
>> > > > "sitearchlibdir" key which contains the correct path to the lib
>> > > > (the
>> > > > multiarch path)
>> > > >
>> > > > RUBYLIBS ?= $(shell $@ -e 'puts "-L" +
>> > > > RbConfig::CONFIG["archlibdir"]
>> > > > +
>> > > > " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
>> > > >
>> > > > Could this be a possible alternatives for the other
>> > > > distributions?
>> > >
>> > > Assuming you mean $(RUBY) rather than $@ above, that works for me
>> > > on
>> > > Fedora:
>> > > $ ruby -e 'puts "-L" + RbConfig::CONFIG["archlibdir"] + " " +
>> > > RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
>> > > -L/usr/lib64 -lruby
>> >
>> > On Arch Linux:
>> >
>> > $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG"]'
>> > -lruby
>> > $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
>> > -lruby
>> > $ ruby -e 'puts RbConfig::CONFIG["archlibdir"]'
>> > /usr/lib/x86_64-linux
>> > $ ls -l /usr/lib/x86_64-linux/libruby.so
>> > ls: cannot access '/usr/lib/x86_64-linux/libruby.so': No such file
>> > or directory
>> > $ ruby -e 'puts RbConfig::CONFIG["libdir"]'
>> > /usr/lib
>> > $ ls -l /usr/lib/libruby.so
>> > lrwxrwxrwx 1 root root 16 2017-04-22 15:40 /usr/lib/libruby.so ->
>> > libruby.so.2.4.1*
>> >
>> > So replacing -lruby with RbConfig::CONFIG["LIBRUBYARG_SHARED"] and
>> > adding "-L" + RbConfig::CONFIG["archlibdir"] in RUBYLIBS definition
>> > seem to work fine.
>> >
>> > Nicolas
>>
>> Heres gentoo:
>> $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG"]'
>> -lruby21
>> $ ruby -e 'puts RbConfig::CONFIG["LIBRUBYARG_SHARED"]'
>> -lruby21
>> $ ruby -e 'puts RbConfig::CONFIG["archlibdir"]'
>> /usr/lib64/x86_64-linux
>> $ stat /usr/lib64/x86_64-linux
>> stat: cannot stat '/usr/lib64/x86_64-linux': No such file or
>> directory
>> $ ruby -e 'puts RbConfig::CONFIG["libdir"]'
>> /usr/lib64
>> $ ls -l /usr/lib64/libruby2*
>> -rw-r--r--. 1 root root 4078832 May  8 16:27 /usr/lib64/libruby21-
>> static.a
>> lrwxrwxrwx. 1 root root      18 May  8 16:27 /usr/lib64/libruby21.so
>> -> libruby21.so.2.1.0*
>> lrwxrwxrwx. 1 root root      18 May  8 16:27
>> /usr/lib64/libruby21.so.2.1 -> libruby21.so.2.1.0*
>> -rwxr-xr-x. 1 root root 2506160 May  8 16:27
>> /usr/lib64/libruby21.so.2.1.0*
>> -rw-r--r--. 1 root root 4588894 May  6 12:28 /usr/lib64/libruby22-
>> static.a
>> lrwxrwxrwx. 1 root root      18 May  6 12:28 /usr/lib64/libruby22.so
>> -> libruby22.so.2.2.0*
>> lrwxrwxrwx. 1 root root      18 May  6 12:28
>> /usr/lib64/libruby22.so.2.2 -> libruby22.so.2.2.0*
>> -rwxr-xr-x. 1 root root 2622488 May  6 12:28
>> /usr/lib64/libruby22.so.2.2.0*
>>
>> $ qlist -Iv ruby
>> ...
>> dev-lang/ruby-2.1.9
>> dev-lang/ruby-2.2.6
>
> So, what's the conclusion?  Do we have a consensus on replacing it as
> proposed?  Looks like from the output above that archlibdir doesn't
> actually work on gentoo or arch since the file doesn't exist there?

>From the previous messages, I conclude that both "libdir" and
"archlibdir" are needed and that "LIBRUBYARG" and "LIBRUBYARG_SHARED"
share the same value. As the linker does not issue any error when
using -L with a non-existent path, a possible solution would be to use
both directories. For example for libselinux:

--- a/libselinux/src/Makefile
+++ b/libselinux/src/Makefile
@@ -17,7 +17,7 @@ PYLIBS ?= $(shell $(PKG_CONFIG) --libs $(PYPREFIX))
 PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site;
print(site.getsitepackages()[0])')
 PYCEXT ?= $(shell $(PYTHON) -c 'import imp;print([s for s,m,t in
imp.get_suffixes() if t == imp.C_EXTENSION][0])')
 RUBYINC ?= $(shell $(RUBY) -e 'puts "-I" +
RbConfig::CONFIG["rubyarchhdrdir"] + " -I" +
RbConfig::CONFIG["rubyhdrdir"]')
-RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" +
RbConfig::CONFIG["libdir"] + " -lruby"')
+RUBYLIBS ?= $(shell $(RUBY) -e 'puts "-L" +
RbConfig::CONFIG["libdir"] + " -L" + RbConfig::CONFIG["archlibdir"] +
" " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]')
 RUBYINSTALL ?= $(DESTDIR)$(shell $(RUBY) -e 'puts
RbConfig::CONFIG["vendorarchdir"]')
 LIBBASE ?= $(shell basename $(LIBDIR))
 LIBSEPOLA ?= $(LIBDIR)/libsepol.a

With this, "make install-rubywrap" works fine on my system and should
work on other ones.

Nicolas

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

end of thread, other threads:[~2017-06-26 21:08 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-14 21:28 [PATCH 1/4] libselinux,libsemanage: use Ruby to define RUBYINC Nicolas Iooss
2016-11-14 21:28 ` [PATCH 2/4] libselinux,libsemanage: link Ruby wrapper with -lruby Nicolas Iooss
2017-06-21  9:38   ` [PATCH 2/4] libselinux, libsemanage: " Laurent Bigonville
2017-06-21 13:42     ` Stephen Smalley
2017-06-21 14:02       ` Nicolas Iooss
2017-06-21 14:27         ` Jason Zaman
2017-06-23 14:14           ` Stephen Smalley
2017-06-26 21:08             ` Nicolas Iooss
2016-11-14 21:28 ` [PATCH 3/4] libsemanage: query for python site-packages dir directly Nicolas Iooss
2016-11-14 21:28 ` [PATCH 4/4] libselinux,libsemanage: link Python wrapper with Python Nicolas Iooss
2016-11-15 16:08   ` Stephen Smalley

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.