libselinux,libsemanage: use Ruby to define RUBYINC
PATCH 1/4 libselinux,libsemanage: use Ruby to define RUBYINC
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.
--- libselinux/src/Makefile | 3 +-- libsemanage/src/Makefile | 6 ++---- 2 files changed, 3 insertions(+), 6 deletions(-)
libselinux/src/Makefile +1 -2
@@ -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
libsemanage/src/Makefile +2 -4
@@ -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))
Signature · 1 line
2.10.2
PATCH 2/4 libselinux,libsemanage: link Ruby wrapper with -lruby
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.
--- libselinux/src/Makefile | 3 ++- libsemanage/src/Makefile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)
libselinux/src/Makefile +2 -1
@@ -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 $@ $^
libsemanage/src/Makefile +2 -1
@@ -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 $@ $^
Signature · 1 line
2.10.2
Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
Hello,
Quoted 16 lines · Nicolas Iooss
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 <[email protected]>--- libselinux/src/Makefile | 3 ++- libsemanage/src/Makefile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)libselinux/src/Makefile +0
-0
libselinux/src/Makefile INCLUDEDIR ?= $(PREFIX)/include · line 18
Quoted 4 lines
libselinux/src/Makefile +1
-0@@ -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
Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
Quoted 44 lines · Laurent Bigonville
Hello,
Quoted 21 lines · Nicolas Iooss
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 <[email protected]>---
libselinux/src/Makefile | 3 ++-
libsemanage/src/Makefile | 3 ++-2 files changed, 4 insertions(+), 2 deletions(-)libselinux/src/Makefile +0
-0@@ -15,6 +15,7 @@ INCLUDEDIR ?= $(PREFIX)/include PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX)) PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')Quoted 5 lines
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::CONFIGhash a key calledLIBRUBYARG_SHAREDor
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)
Quoted 5 lines
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
Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
Quoted 49 lines · Stephen Smalley
Quoted 48 lines · Laurent Bigonville
Hello,
Quoted 22 lines · Nicolas Iooss
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 <[email protected]>--- libselinux/src/Makefile | 3 ++- libsemanage/src/Makefile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)libselinux/src/Makefile +0
-0@@ -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" +Quoted 4 lines
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::CONFIGhash a key calledLIBRUBYARG_SHAREDor
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"]')
Quoted 7 lines
Quoted 1 line
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
Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
Quoted 74 lines · Nicolas Iooss
Quoted 49 lines · Stephen Smalley
Quoted 48 lines · Laurent Bigonville
Hello,
Quoted 22 lines · Nicolas Iooss
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 <[email protected]>--- libselinux/src/Makefile | 3 ++- libsemanage/src/Makefile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)libselinux/src/Makefile +0
-0@@ -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" +Quoted 4 lines
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::CONFIGhash a key calledLIBRUBYARG_SHAREDor
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"]')Quoted 7 lines
Quoted 1 line
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 -lrubyOn 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*
Quoted 5 lines
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
Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
Quoted 123 lines · Jason Zaman
Quoted 86 lines · Nicolas Iooss
On Wed, Jun 21, 2017 at 3:42 PM, Stephen Smalley <[email protected]
Quoted 64 lines
wrote:
Quoted 51 lines · Laurent Bigonville
Hello,
Quoted 24 lines · Nicolas Iooss
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 <[email protected]>---
libselinux/src/Makefile | 3 ++-
libsemanage/src/Makefile | 3 ++-2 files changed, 4 insertions(+), 2 deletions(-)libselinux/src/Makefile +0
-0@@ -15,6 +15,7 @@ INCLUDEDIR ?= $(PREFIX)/include PYINC ?= $(shell $(PKG_CONFIG) --cflags $(PYPREFIX)) PYSITEDIR ?= $(DESTDIR)$(shell $(PYTHON) -c 'import site; print(site.getsitepackages()[0])')Quoted 5 lines
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::CONFIGhash a key calledLIBRUBYARG_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)Quoted 7 lines
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:Quoted 3 lines
$ ruby -e 'puts "-L" + RbConfig::CONFIG["archlibdir"] + " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]' -L/usr/lib64 -lrubyOn 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*Quoted 5 lines
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*
Quoted 4 lines
$ 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?
Re: [PATCH 2/4] libselinux, libsemanage: link Ruby wrapper with -lruby
Quoted 133 lines · Stephen Smalley
Quoted 123 lines · Jason Zaman
Quoted 86 lines · Nicolas Iooss
On Wed, Jun 21, 2017 at 3:42 PM, Stephen Smalley <[email protected]
Quoted 64 lines
wrote:
Quoted 51 lines · Laurent Bigonville
Hello,
Quoted 25 lines · Nicolas Iooss
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 <[email protected]>--- libselinux/src/Makefile | 3 ++- libsemanage/src/Makefile | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-)libselinux/src/Makefile +0
-0@@ -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" +Quoted 4 lines
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::CONFIGhash a key calledLIBRUBYARG_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)Quoted 7 lines
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:Quoted 3 lines
$ ruby -e 'puts "-L" + RbConfig::CONFIG["archlibdir"] + " " + RbConfig::CONFIG["LIBRUBYARG_SHARED"]' -L/usr/lib64 -lrubyOn 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*Quoted 5 lines
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*Quoted 4 lines
$ qlist -Iv ruby ... dev-lang/ruby-2.1.9 dev-lang/ruby-2.2.6So, 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?
Quoted 1 line
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:
libselinux/src/Makefile +0 -0
@@ -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 inimp.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
PATCH 3/4 libsemanage: query for python site-packages dir directly
In reply to Nicolas IoossUse 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.
--- libsemanage/src/Makefile | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
libsemanage/src/Makefile +4 -5
@@ -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
Signature · 1 line
2.10.2
PATCH 4/4 libselinux,libsemanage: link Python wrapper with Python
In reply to Nicolas IoossWhen 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.
--- libselinux/src/Makefile | 5 +++-- libsemanage/src/Makefile | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-)
libselinux/src/Makefile +3 -2
@@ -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 $@ $<
libsemanage/src/Makefile +2 -1
@@ -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)
Signature · 1 line
2.10.2
Stephen Smalley
AppliedRe: [PATCH 4/4] libselinux,libsemanage: link Python wrapper with Python
Quoted 6 lines · Nicolas Iooss
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 <[email protected]>
Thanks, applied all four.
Quoted 57 lines
--- libselinux/src/Makefile | 5 +++-- libsemanage/src/Makefile | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-)libselinux/src/Makefile +3
-2@@ -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 $@ $<libsemanage/src/Makefile +2
-1@@ -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)